Add network debug printer
This commit is contained in:
parent
bd13336256
commit
15055fa509
@ -284,7 +284,7 @@ lib_deps = ${esp8266.lib_deps}
|
|||||||
board = esp32dev
|
board = esp32dev
|
||||||
platform = espressif32@2.0
|
platform = espressif32@2.0
|
||||||
build_unflags = ${common.build_unflags}
|
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}
|
lib_deps = ${esp32.lib_deps}
|
||||||
|
|
||||||
[env:esp32_eth]
|
[env:esp32_eth]
|
||||||
|
@ -404,6 +404,13 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
}
|
}
|
||||||
#endif
|
#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."));
|
DEBUG_PRINTLN(F("Starting usermod config."));
|
||||||
JsonObject usermods_settings = doc["um"];
|
JsonObject usermods_settings = doc["um"];
|
||||||
if (!usermods_settings.isNull()) {
|
if (!usermods_settings.isNull()) {
|
||||||
|
@ -81,6 +81,10 @@
|
|||||||
<div style="color: #fa0;">⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.<br>
|
<div style="color: #fa0;">⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.<br>
|
||||||
Incorrect configuration may require a factory reset or re-flashing of your ESP.</div>
|
Incorrect configuration may require a factory reset or re-flashing of your ESP.</div>
|
||||||
For security reasons, passwords are not backed up.
|
For security reasons, passwords are not backed up.
|
||||||
|
<h3>Network Debug Logging</h3>
|
||||||
|
Log to network: <input type="checkbox" name="NDE"><br>
|
||||||
|
Network logging host: <input type="text" name="NDH"><br>
|
||||||
|
Network logging port: <input type="number" name="NDP"><br>
|
||||||
<h3>About</h3>
|
<h3>About</h3>
|
||||||
<a href="https://github.com/Aircoookie/WLED/" target="_blank">WLED</a> version ##VERSION##<!-- Autoreplaced from package.json --><br><br>
|
<a href="https://github.com/Aircoookie/WLED/" target="_blank">WLED</a> version ##VERSION##<!-- Autoreplaced from package.json --><br><br>
|
||||||
<a href="https://github.com/Aircoookie/WLED/wiki/Contributors-and-credits" target="_blank">Contributors, dependencies and special thanks</a><br>
|
<a href="https://github.com/Aircoookie/WLED/wiki/Contributors-and-credits" target="_blank">Contributors, dependencies and special thanks</a><br>
|
||||||
|
@ -404,7 +404,10 @@ onclick='uploadFile(d.Sf.data2,"/cfg.json")'><br></div><div style="color:#fa0">
|
|||||||
⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.
|
⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.
|
||||||
<br>
|
<br>
|
||||||
Incorrect configuration may require a factory reset or re-flashing of your ESP.
|
Incorrect configuration may require a factory reset or re-flashing of your ESP.
|
||||||
</div>For security reasons, passwords are not backed up.<h3>About</h3><a
|
</div>For security reasons, passwords are not backed up.<h3>
|
||||||
|
Network Debug Logging</h3>Log to network: <input type="checkbox" name="NDE"><br>
|
||||||
|
Network logging host: <input type="text" name="NDH"><br>Network logging port:
|
||||||
|
<input type="number" name="NDP"><br><h3>About</h3><a
|
||||||
href="https://github.com/Aircoookie/WLED/" target="_blank">WLED</a>
|
href="https://github.com/Aircoookie/WLED/" target="_blank">WLED</a>
|
||||||
version 0.13.0-b2<br><br><a
|
version 0.13.0-b2<br><br><a
|
||||||
href="https://github.com/Aircoookie/WLED/wiki/Contributors-and-credits"
|
href="https://github.com/Aircoookie/WLED/wiki/Contributors-and-credits"
|
||||||
|
1576
wled00/html_ui.h
1576
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
75
wled00/net_debug.cpp
Normal file
75
wled00/net_debug.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include "wled.h"
|
||||||
|
|
||||||
|
#ifdef WLED_DEBUG_NET
|
||||||
|
|
||||||
|
NetworkDebugPrinter NetDebug;
|
||||||
|
|
||||||
|
void NetworkDebugPrinter::print(const char *s) {
|
||||||
|
#ifdef WLED_DEBUG
|
||||||
|
Serial.print(s);
|
||||||
|
#endif
|
||||||
|
if (!WLED_CONNECTED || !netDebugPrintEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IPAddress debugPrintHostIP;
|
||||||
|
if (!debugPrintHostIP.fromString(netDebugPrintHost)) {
|
||||||
|
#ifdef ESP8266
|
||||||
|
WiFi.hostByName(netDebugPrintHost, debugPrintHostIP, 750);
|
||||||
|
#else
|
||||||
|
WiFi.hostByName(netDebugPrintHost, debugPrintHostIP);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
debugUdp.beginPacket(debugPrintHostIP, netDebugPrintPort);
|
||||||
|
debugUdp.write(reinterpret_cast<const uint8_t *>(s), strlen(s));
|
||||||
|
debugUdp.endPacket();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkDebugPrinter::print(const __FlashStringHelper* s) {
|
||||||
|
print(reinterpret_cast<const char *>(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
|
25
wled00/net_debug.h
Normal file
25
wled00/net_debug.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef WLED_NET_DEBUG_H
|
||||||
|
#define WLED_NET_DEBUG_H
|
||||||
|
|
||||||
|
#include <WString.h>
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
|
||||||
|
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
|
@ -387,6 +387,18 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
wifiLock = request->hasArg(F("OW"));
|
wifiLock = request->hasArg(F("OW"));
|
||||||
aOtaEnabled = request->hasArg(F("AO"));
|
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
|
#ifdef WLED_ENABLE_DMX // include only if DMX is enabled
|
||||||
if (subPage == 7)
|
if (subPage == 7)
|
||||||
|
@ -80,6 +80,10 @@
|
|||||||
#include "my_config.h"
|
#include "my_config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WLED_DEBUG_NET
|
||||||
|
#include "net_debug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
@ -599,17 +603,21 @@ WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// enable additional debug output
|
// enable additional debug output
|
||||||
|
|
||||||
|
#define DEBUG_PRINT(x)
|
||||||
|
#define DEBUG_PRINTLN(x)
|
||||||
|
#define DEBUG_PRINTF(x...)
|
||||||
|
|
||||||
#ifdef WLED_DEBUG
|
#ifdef WLED_DEBUG
|
||||||
#ifndef ESP8266
|
#ifndef ESP8266
|
||||||
#include <rom/rtc.h>
|
#include <rom/rtc.h>
|
||||||
#endif
|
#endif
|
||||||
|
#undef DEBUG_PRINT
|
||||||
|
#undef DEBUG_PRINTLN
|
||||||
|
#undef DEBUG_PRINTF
|
||||||
#define DEBUG_PRINT(x) Serial.print(x)
|
#define DEBUG_PRINT(x) Serial.print(x)
|
||||||
#define DEBUG_PRINTLN(x) Serial.println(x)
|
#define DEBUG_PRINTLN(x) Serial.println(x)
|
||||||
#define DEBUG_PRINTF(x...) Serial.printf(x)
|
#define DEBUG_PRINTF(x...) Serial.printf(x)
|
||||||
#else
|
|
||||||
#define DEBUG_PRINT(x)
|
|
||||||
#define DEBUG_PRINTLN(x)
|
|
||||||
#define DEBUG_PRINTF(x...)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WLED_DEBUG_FS
|
#ifdef WLED_DEBUG_FS
|
||||||
@ -622,6 +630,18 @@ WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
|||||||
#define DEBUGFS_PRINTF(x...)
|
#define DEBUGFS_PRINTF(x...)
|
||||||
#endif
|
#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
|
// debug macro variable definitions
|
||||||
#ifdef WLED_DEBUG
|
#ifdef WLED_DEBUG
|
||||||
WLED_GLOBAL unsigned long debugTime _INIT(0);
|
WLED_GLOBAL unsigned long debugTime _INIT(0);
|
||||||
|
@ -227,6 +227,7 @@
|
|||||||
<ClCompile Include="wled_eeprom.cpp" />
|
<ClCompile Include="wled_eeprom.cpp" />
|
||||||
<ClCompile Include="wled_server.cpp" />
|
<ClCompile Include="wled_server.cpp" />
|
||||||
<ClCompile Include="xml.cpp" />
|
<ClCompile Include="xml.cpp" />
|
||||||
|
<ClCompile Include="net_debug.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DebuggerFlavor>VisualMicroDebugger</DebuggerFlavor>
|
<DebuggerFlavor>VisualMicroDebugger</DebuggerFlavor>
|
||||||
|
@ -544,6 +544,11 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
oappend(SET_F(" (build "));
|
oappend(SET_F(" (build "));
|
||||||
oappendi(VERSION);
|
oappendi(VERSION);
|
||||||
oappend(SET_F(")\";"));
|
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
|
#ifdef WLED_ENABLE_DMX // include only if DMX is enabled
|
||||||
|
Loading…
Reference in New Issue
Block a user