diff --git a/platformio.ini b/platformio.ini
index 5939e5929..a0d33d6b0 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -284,7 +284,7 @@ lib_deps = ${esp8266.lib_deps}
board = esp32dev
platform = espressif32@2.0
build_unflags = ${common.build_unflags}
-build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32 #-D WLED_DISABLE_BROWNOUT_DET
+build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32 -D WLED_DEBUG_NET #-D WLED_DISABLE_BROWNOUT_DET
lib_deps = ${esp32.lib_deps}
[env:esp32_eth]
diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp
index 6d86b6ea3..6ee85ea3d 100644
--- a/wled00/cfg.cpp
+++ b/wled00/cfg.cpp
@@ -404,6 +404,13 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
}
#endif
+ #ifdef WLED_DEBUG_NET
+ JsonObject netDebugPrint = doc["netdebug"];
+ CJSON(netDebugPrintEnabled, netDebugPrint[F("enabled")]);
+ getStringFromJson(netDebugPrintHost, netDebugPrint[F("host")], 33);
+ CJSON(netDebugPrintPort, netDebugPrint[F("port")]);
+ #endif
+
DEBUG_PRINTLN(F("Starting usermod config."));
JsonObject usermods_settings = doc["um"];
if (!usermods_settings.isNull()) {
diff --git a/wled00/data/settings_sec.htm b/wled00/data/settings_sec.htm
index 27f36f12c..212e71fb0 100644
--- a/wled00/data/settings_sec.htm
+++ b/wled00/data/settings_sec.htm
@@ -81,6 +81,10 @@
⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.
Incorrect configuration may require a factory reset or re-flashing of your ESP.
For security reasons, passwords are not backed up.
+ Network Debug Logging
+ Log to network:
+ Network logging host:
+ Network logging port:
About
WLED version ##VERSION##
Contributors, dependencies and special thanks
diff --git a/wled00/html_settings.h b/wled00/html_settings.h
index 51e331d9d..e4a343e84 100644
--- a/wled00/html_settings.h
+++ b/wled00/html_settings.h
@@ -404,7 +404,10 @@ onclick='uploadFile(d.Sf.data2,"/cfg.json")'>
⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.
Incorrect configuration may require a factory reset or re-flashing of your ESP.
-
For security reasons, passwords are not backed up.About For security reasons, passwords are not backed up.
+Network Debug Logging Log to network:
+Network logging host: Network logging port:
+About WLED
version 0.13.0-b2(s), strlen(s));
+ debugUdp.endPacket();
+}
+
+void NetworkDebugPrinter::print(const __FlashStringHelper* s) {
+ print(reinterpret_cast(s));
+}
+
+void NetworkDebugPrinter::print(String s) {
+ print(s.c_str());
+}
+
+void NetworkDebugPrinter::print(unsigned int n) {
+ char s[10];
+ snprintf(s, sizeof(s), "%d", n);
+ s[9] = '\0';
+ print(s);
+}
+
+void NetworkDebugPrinter::println() {
+ print("\n");
+}
+
+void NetworkDebugPrinter::println(const char *s) {
+ print(s);
+ print("\n");
+}
+
+void NetworkDebugPrinter::println(const __FlashStringHelper* s) {
+ print(s);
+ print("\n");
+}
+
+void NetworkDebugPrinter::println(String s) {
+ print(s);
+ print("\n");
+}
+
+void NetworkDebugPrinter::println(unsigned int n) {
+ print(n);
+ print("\n");
+}
+
+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
diff --git a/wled00/net_debug.h b/wled00/net_debug.h
new file mode 100644
index 000000000..19dad41a1
--- /dev/null
+++ b/wled00/net_debug.h
@@ -0,0 +1,25 @@
+#ifndef WLED_NET_DEBUG_H
+#define WLED_NET_DEBUG_H
+
+#include
+#include
+
+class NetworkDebugPrinter {
+private:
+ WiFiUDP debugUdp;
+public:
+ void print(const char *s);
+ void print(const __FlashStringHelper* s);
+ void print(String s);
+ void print(unsigned int n);
+ 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;
+
+#endif
\ No newline at end of file
diff --git a/wled00/set.cpp b/wled00/set.cpp
index 37004dd05..495f9c897 100644
--- a/wled00/set.cpp
+++ b/wled00/set.cpp
@@ -387,6 +387,18 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
wifiLock = request->hasArg(F("OW"));
aOtaEnabled = request->hasArg(F("AO"));
}
+
+ #ifdef WLED_DEBUG_NET
+ netDebugPrintEnabled = request->hasArg(F("NDE"));
+ if (request->hasArg(F("NDH")))
+ {
+ strlcpy(netDebugPrintHost, request->arg(F("NDH")).c_str(), 33);
+ }
+ if (request->hasArg(F("NDP")))
+ {
+ netDebugPrintPort = request->arg(F("NDP")).toInt();
+ }
+ #endif
}
#ifdef WLED_ENABLE_DMX // include only if DMX is enabled
if (subPage == 7)
diff --git a/wled00/wled.h b/wled00/wled.h
index fc390ae2a..864cd9367 100644
--- a/wled00/wled.h
+++ b/wled00/wled.h
@@ -80,6 +80,10 @@
#include "my_config.h"
#endif
+#ifdef WLED_DEBUG_NET
+#include "net_debug.h"
+#endif
+
#include
#include
#include
@@ -599,17 +603,21 @@ WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
#endif
// enable additional debug output
+
+#define DEBUG_PRINT(x)
+#define DEBUG_PRINTLN(x)
+#define DEBUG_PRINTF(x...)
+
#ifdef WLED_DEBUG
#ifndef ESP8266
#include
#endif
+ #undef DEBUG_PRINT
+ #undef DEBUG_PRINTLN
+ #undef DEBUG_PRINTF
#define DEBUG_PRINT(x) Serial.print(x)
#define DEBUG_PRINTLN(x) Serial.println(x)
#define DEBUG_PRINTF(x...) Serial.printf(x)
-#else
- #define DEBUG_PRINT(x)
- #define DEBUG_PRINTLN(x)
- #define DEBUG_PRINTF(x...)
#endif
#ifdef WLED_DEBUG_FS
@@ -622,6 +630,18 @@ WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
#define DEBUGFS_PRINTF(x...)
#endif
+#ifdef WLED_DEBUG_NET
+ #undef DEBUG_PRINT
+ #undef DEBUG_PRINTLN
+ #undef DEBUG_PRINTF
+ #define DEBUG_PRINT(x) NetDebug.print(x)
+ #define DEBUG_PRINTLN(x) NetDebug.println(x)
+ #define DEBUG_PRINTF(x...) NetDebug.printf(x)
+ WLED_GLOBAL bool netDebugPrintEnabled _INIT(false);
+ WLED_GLOBAL char netDebugPrintHost[33] _INIT("");
+ WLED_GLOBAL int netDebugPrintPort _INIT(7868);
+#endif
+
// debug macro variable definitions
#ifdef WLED_DEBUG
WLED_GLOBAL unsigned long debugTime _INIT(0);
diff --git a/wled00/wled00.vcxproj b/wled00/wled00.vcxproj
index e095b8f76..e372a4e84 100644
--- a/wled00/wled00.vcxproj
+++ b/wled00/wled00.vcxproj
@@ -227,6 +227,7 @@
+
VisualMicroDebugger
diff --git a/wled00/xml.cpp b/wled00/xml.cpp
index 453206067..0e6e5298d 100644
--- a/wled00/xml.cpp
+++ b/wled00/xml.cpp
@@ -544,6 +544,11 @@ void getSettingsJS(byte subPage, char* dest)
oappend(SET_F(" (build "));
oappendi(VERSION);
oappend(SET_F(")\";"));
+#ifdef WLED_DEBUG_NET
+ sappend('c',SET_F("NDE"),netDebugPrintEnabled);
+ sappends('s',SET_F("NDH"),netDebugPrintHost);
+ sappend('v',SET_F("NDP"),netDebugPrintPort);
+#endif
}
#ifdef WLED_ENABLE_DMX // include only if DMX is enabled