Optimization & bugfix for net debug.
- Inherited from Print class. - Added UI option to disable net debug output.
This commit is contained in:
parent
5f4199183c
commit
d370f67f60
@ -657,12 +657,13 @@ function populateInfo(i)
|
|||||||
}
|
}
|
||||||
var vcn = "Kuuhaku";
|
var vcn = "Kuuhaku";
|
||||||
if (i.ver.startsWith("0.14.")) vcn = "Hoshi";
|
if (i.ver.startsWith("0.14.")) vcn = "Hoshi";
|
||||||
if (i.ver.includes("-bl")) vcn = "Supāku";
|
// if (i.ver.includes("-bl")) vcn = "Supāku";
|
||||||
if (i.cn) vcn = i.cn;
|
if (i.cn) vcn = i.cn;
|
||||||
|
|
||||||
cn += `v${i.ver} "${vcn}"<br><br><table>
|
cn += `v${i.ver} "${vcn}"<br><br><table>
|
||||||
${urows}
|
${urows}
|
||||||
${urows===""?'':'<tr><td colspan=2><hr style="height:1px;border-width:0;color:gray;background-color:gray"></td></tr>'}
|
${urows===""?'':'<tr><td colspan=2><hr style="height:1px;border-width:0;color:gray;background-color:gray"></td></tr>'}
|
||||||
|
${i.opt&0x100?inforow("Debug","<button class=\"btn btn-xs\" onclick=\"requestJson({'debug':"+(i.opt&0x0080?"false":"true")+"});\"><i class=\"icons "+(i.opt&0x0080?"on":"off")+"\"></i></button>"):''}
|
||||||
${inforow("Build",i.vid)}
|
${inforow("Build",i.vid)}
|
||||||
${inforow("Signal strength",i.wifi.signal +"% ("+ i.wifi.rssi, " dBm)")}
|
${inforow("Signal strength",i.wifi.signal +"% ("+ i.wifi.rssi, " dBm)")}
|
||||||
${inforow("Uptime",getRuntimeStr(i.uptime))}
|
${inforow("Uptime",getRuntimeStr(i.uptime))}
|
||||||
|
3778
wled00/html_ui.h
3778
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -255,6 +255,10 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
|||||||
{
|
{
|
||||||
bool stateResponse = root[F("v")] | false;
|
bool stateResponse = root[F("v")] | false;
|
||||||
|
|
||||||
|
#if defined(WLED_DEBUG) && defined(WLED_DEBUG_HOST)
|
||||||
|
netDebugEnabled = root[F("debug")] | netDebugEnabled;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool onBefore = bri;
|
bool onBefore = bri;
|
||||||
getVal(root["bri"], &bri);
|
getVal(root["bri"], &bri);
|
||||||
|
|
||||||
@ -679,9 +683,13 @@ void serializeInfo(JsonObject root)
|
|||||||
|
|
||||||
usermods.addToJsonInfo(root);
|
usermods.addToJsonInfo(root);
|
||||||
|
|
||||||
byte os = 0;
|
uint16_t os = 0;
|
||||||
#ifdef WLED_DEBUG
|
#ifdef WLED_DEBUG
|
||||||
os = 0x80;
|
os = 0x80;
|
||||||
|
#ifdef WLED_DEBUG_HOST
|
||||||
|
os |= 0x0100;
|
||||||
|
if (!netDebugEnabled) os &= ~0x0080;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef WLED_DISABLE_ALEXA
|
#ifndef WLED_DISABLE_ALEXA
|
||||||
os += 0x40;
|
os += 0x40;
|
||||||
|
@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
#ifdef WLED_DEBUG_HOST
|
#ifdef WLED_DEBUG_HOST
|
||||||
|
|
||||||
NetworkDebugPrinter NetDebug;
|
size_t NetworkDebugPrinter::write(uint8_t c) {
|
||||||
|
if (!WLED_CONNECTED || !udpConnected) return 0;
|
||||||
void NetworkDebugPrinter::print(const char *s, bool newline) {
|
|
||||||
if (!WLED_CONNECTED || !udpConnected || s == nullptr) return;
|
|
||||||
|
|
||||||
if (!debugPrintHostIP && !debugPrintHostIP.fromString(netDebugPrintHost)) {
|
if (!debugPrintHostIP && !debugPrintHostIP.fromString(netDebugPrintHost)) {
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
@ -19,57 +17,33 @@ void NetworkDebugPrinter::print(const char *s, bool newline) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
WiFiUDP debugUdp;
|
|
||||||
debugUdp.beginPacket(debugPrintHostIP, netDebugPrintPort);
|
debugUdp.beginPacket(debugPrintHostIP, netDebugPrintPort);
|
||||||
debugUdp.write(reinterpret_cast<const uint8_t *>(s), strlen(s));
|
debugUdp.write(c);
|
||||||
if (newline) debugUdp.write('\n');
|
|
||||||
debugUdp.endPacket();
|
debugUdp.endPacket();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkDebugPrinter::print(const __FlashStringHelper* s, bool newline) {
|
size_t NetworkDebugPrinter::write(const uint8_t *buf, size_t size) {
|
||||||
char buf[512];
|
if (!WLED_CONNECTED || !udpConnected || buf == nullptr) return 0;
|
||||||
strncpy_P(buf, (PGM_P)s, 512);
|
|
||||||
print(buf, newline);
|
if (!debugPrintHostIP && !debugPrintHostIP.fromString(netDebugPrintHost)) {
|
||||||
|
#ifdef ESP8266
|
||||||
|
WiFi.hostByName(netDebugPrintHost, debugPrintHostIP, 750);
|
||||||
|
#else
|
||||||
|
#ifdef WLED_USE_ETHERNET
|
||||||
|
ETH.hostByName(netDebugPrintHost, debugPrintHostIP);
|
||||||
|
#else
|
||||||
|
WiFi.hostByName(netDebugPrintHost, debugPrintHostIP);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
debugUdp.beginPacket(debugPrintHostIP, netDebugPrintPort);
|
||||||
|
debugUdp.write(buf, size);
|
||||||
|
debugUdp.endPacket();
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkDebugPrinter::print(String s) {
|
NetworkDebugPrinter NetDebug;
|
||||||
print(s.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkDebugPrinter::print(unsigned int n, bool newline) {
|
|
||||||
char s[10];
|
|
||||||
snprintf_P(s, sizeof(s), PSTR("%d"), n);
|
|
||||||
s[9] = '\0';
|
|
||||||
print(s, newline);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkDebugPrinter::println() {
|
|
||||||
print("", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkDebugPrinter::println(const char *s) {
|
|
||||||
print(s, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkDebugPrinter::println(const __FlashStringHelper* s) {
|
|
||||||
print(s, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkDebugPrinter::println(String s) {
|
|
||||||
print(s.c_str(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkDebugPrinter::println(unsigned int n) {
|
|
||||||
print(n, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkDebugPrinter::printf(const char *fmt...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, fmt);
|
|
||||||
char s[1024];
|
|
||||||
vsnprintf(s, sizeof(s), fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
print(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,20 +4,13 @@
|
|||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
|
|
||||||
class NetworkDebugPrinter {
|
class NetworkDebugPrinter : public Print {
|
||||||
private:
|
private:
|
||||||
|
WiFiUDP debugUdp; // needs to be here otherwise UDP messages get truncated upon destruction
|
||||||
IPAddress debugPrintHostIP;
|
IPAddress debugPrintHostIP;
|
||||||
public:
|
public:
|
||||||
void print(const char *s, bool newline = false);
|
virtual size_t write(uint8_t c);
|
||||||
void print(const __FlashStringHelper* s, bool newline = false);
|
virtual size_t write(const uint8_t *buf, size_t s);
|
||||||
void print(String s);
|
|
||||||
void print(unsigned int n, bool newline = false);
|
|
||||||
void println();
|
|
||||||
void println(const char *s);
|
|
||||||
void println(const __FlashStringHelper* s);
|
|
||||||
void println(String s);
|
|
||||||
void println(unsigned int n);
|
|
||||||
void printf(const char *fmt, ...);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NetworkDebugPrinter NetDebug;
|
extern NetworkDebugPrinter NetDebug;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2211050
|
#define VERSION 2211100
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
@ -677,6 +677,7 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0);
|
|||||||
// On the host side, use netcat to receive the log statements: nc -l 7868 -u
|
// On the host side, use netcat to receive the log statements: nc -l 7868 -u
|
||||||
// use -D WLED_DEBUG_HOST='"192.168.xxx.xxx"' or FQDN within quotes
|
// use -D WLED_DEBUG_HOST='"192.168.xxx.xxx"' or FQDN within quotes
|
||||||
#define DEBUGOUT NetDebug
|
#define DEBUGOUT NetDebug
|
||||||
|
WLED_GLOBAL bool netDebugEnabled _INIT(true);
|
||||||
WLED_GLOBAL char netDebugPrintHost[33] _INIT(WLED_DEBUG_HOST);
|
WLED_GLOBAL char netDebugPrintHost[33] _INIT(WLED_DEBUG_HOST);
|
||||||
#if defined(WLED_DEBUG_NET_PORT)
|
#if defined(WLED_DEBUG_NET_PORT)
|
||||||
WLED_GLOBAL int netDebugPrintPort _INIT(WLED_DEBUG_PORT);
|
WLED_GLOBAL int netDebugPrintPort _INIT(WLED_DEBUG_PORT);
|
||||||
|
Loading…
Reference in New Issue
Block a user