|
|
@ -21,18 +21,20 @@ extern "C" { |
|
|
|
WiFiUDP _udp_debug; |
|
|
|
#endif
|
|
|
|
|
|
|
|
void debugSend(const char * format, ...) { |
|
|
|
void _debugSend(char * message) { |
|
|
|
|
|
|
|
va_list args; |
|
|
|
va_start(args, format); |
|
|
|
char test[1]; |
|
|
|
int len = ets_vsnprintf(test, 1, format, args) + 1; |
|
|
|
char * buffer = new char[len]; |
|
|
|
ets_vsnprintf(buffer, len, format, args); |
|
|
|
va_end(args); |
|
|
|
#if DEBUG_ADD_TIMESTAMP
|
|
|
|
static bool add_timestamp = true; |
|
|
|
char timestamp[10] = {0}; |
|
|
|
if (add_timestamp) snprintf_P(timestamp, sizeof(timestamp), PSTR("[%06lu] "), millis() % 1000000); |
|
|
|
add_timestamp = (message[strlen(message)-1] == 10); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_SERIAL_SUPPORT
|
|
|
|
DEBUG_PORT.printf(buffer); |
|
|
|
#if DEBUG_ADD_TIMESTAMP
|
|
|
|
DEBUG_PORT.printf(timestamp); |
|
|
|
#endif
|
|
|
|
DEBUG_PORT.printf(message); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_UDP_SUPPORT
|
|
|
@ -40,7 +42,10 @@ void debugSend(const char * format, ...) { |
|
|
|
if (systemCheck()) { |
|
|
|
#endif
|
|
|
|
_udp_debug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT); |
|
|
|
_udp_debug.write(buffer); |
|
|
|
#if DEBUG_ADD_TIMESTAMP
|
|
|
|
_udp_debug.write(timestamp); |
|
|
|
#endif
|
|
|
|
_udp_debug.write(message); |
|
|
|
_udp_debug.endPacket(); |
|
|
|
#if SYSTEM_CHECK_ENABLED
|
|
|
|
} |
|
|
@ -48,9 +53,27 @@ void debugSend(const char * format, ...) { |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_TELNET_SUPPORT
|
|
|
|
_telnetWrite(buffer, strlen(buffer)); |
|
|
|
#if DEBUG_ADD_TIMESTAMP
|
|
|
|
_telnetWrite(timestamp, strlen(timestamp)); |
|
|
|
#endif
|
|
|
|
_telnetWrite(message, strlen(message)); |
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void debugSend(const char * format, ...) { |
|
|
|
|
|
|
|
va_list args; |
|
|
|
va_start(args, format); |
|
|
|
char test[1]; |
|
|
|
int len = ets_vsnprintf(test, 1, format, args) + 1; |
|
|
|
char * buffer = new char[len]; |
|
|
|
ets_vsnprintf(buffer, len, format, args); |
|
|
|
va_end(args); |
|
|
|
|
|
|
|
_debugSend(buffer); |
|
|
|
|
|
|
|
delete[] buffer; |
|
|
|
|
|
|
|
} |
|
|
@ -68,25 +91,7 @@ void debugSend_P(PGM_P format_P, ...) { |
|
|
|
ets_vsnprintf(buffer, len, format, args); |
|
|
|
va_end(args); |
|
|
|
|
|
|
|
#if DEBUG_SERIAL_SUPPORT
|
|
|
|
DEBUG_PORT.printf(buffer); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_UDP_SUPPORT
|
|
|
|
#if SYSTEM_CHECK_ENABLED
|
|
|
|
if (systemCheck()) { |
|
|
|
#endif
|
|
|
|
_udp_debug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT); |
|
|
|
_udp_debug.write(buffer); |
|
|
|
_udp_debug.endPacket(); |
|
|
|
#if SYSTEM_CHECK_ENABLED
|
|
|
|
} |
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG_TELNET_SUPPORT
|
|
|
|
_telnetWrite(buffer, strlen(buffer)); |
|
|
|
#endif
|
|
|
|
_debugSend(buffer); |
|
|
|
|
|
|
|
delete[] buffer; |
|
|
|
|
|
|
|