2021-08-25 07:12:03 +02:00
|
|
|
#include "wled.h"
|
|
|
|
|
2022-11-06 10:58:19 +01:00
|
|
|
#ifdef WLED_DEBUG_HOST
|
2021-08-25 07:12:03 +02:00
|
|
|
|
2022-11-10 21:50:21 +01:00
|
|
|
size_t NetworkDebugPrinter::write(uint8_t c) {
|
2023-02-08 10:18:41 +01:00
|
|
|
if (!WLED_CONNECTED || !netDebugEnabled) return 0;
|
2021-08-25 07:12:03 +02:00
|
|
|
|
2022-11-10 21:50:21 +01:00
|
|
|
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
|
|
|
|
}
|
2021-08-25 07:12:03 +02:00
|
|
|
|
2022-11-11 18:17:12 +01:00
|
|
|
debugUdp.beginPacket(debugPrintHostIP, netDebugPrintPort);
|
|
|
|
debugUdp.write(c);
|
|
|
|
debugUdp.endPacket();
|
|
|
|
return 1;
|
2022-11-11 14:39:47 +01:00
|
|
|
}
|
|
|
|
|
2022-11-11 18:17:12 +01:00
|
|
|
size_t NetworkDebugPrinter::write(const uint8_t *buf, size_t size) {
|
2023-02-08 10:18:41 +01:00
|
|
|
if (!WLED_CONNECTED || buf == nullptr || !netDebugEnabled) return 0;
|
2022-11-11 18:17:12 +01:00
|
|
|
|
|
|
|
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
|
2022-11-11 14:39:47 +01:00
|
|
|
}
|
2022-11-11 18:17:12 +01:00
|
|
|
|
|
|
|
debugUdp.beginPacket(debugPrintHostIP, netDebugPrintPort);
|
|
|
|
size = debugUdp.write(buf, size);
|
|
|
|
debugUdp.endPacket();
|
|
|
|
return size;
|
2021-08-25 07:12:03 +02:00
|
|
|
}
|
|
|
|
|
2022-11-10 21:50:21 +01:00
|
|
|
NetworkDebugPrinter NetDebug;
|
2021-08-25 07:12:03 +02:00
|
|
|
|
|
|
|
#endif
|