forked from Aircoookie/WLED
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnet_debug.cpp
49 lines (40 loc) · 1.29 KB
/
net_debug.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "wled.h"
#ifdef WLED_DEBUG_HOST
size_t NetworkDebugPrinter::write(uint8_t c) {
if (!WLED_CONNECTED || !netDebugEnabled) return 0;
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(c);
debugUdp.endPacket();
return 1;
}
size_t NetworkDebugPrinter::write(const uint8_t *buf, size_t size) {
if (!WLED_CONNECTED || buf == nullptr || !netDebugEnabled) return 0;
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);
size = debugUdp.write(buf, size);
debugUdp.endPacket();
return size;
}
NetworkDebugPrinter NetDebug;
#endif