diff --git a/src/hasp_debug.cpp b/src/hasp_debug.cpp index f056db21..befc10ca 100644 --- a/src/hasp_debug.cpp +++ b/src/hasp_debug.cpp @@ -87,7 +87,7 @@ static void debugPrintTimestamp(int level, Print* _logOutput) static inline void debug_flush() { #if defined(ARDUINO) - Serial.flush(); + HASP_SERIAL.flush(); #endif #if defined(WINDOWS) || defined(POSIX) diff --git a/src/hasp_debug.h b/src/hasp_debug.h index 9a9e04ee..fbe058a7 100644 --- a/src/hasp_debug.h +++ b/src/hasp_debug.h @@ -202,6 +202,8 @@ enum { TAG_CUSTOM = 99 }; +#define HASP_SERIAL Serial + //#define TERM_COLOR_Black "\u001b[30m" #define TERM_COLOR_GRAY "\e[37m" #define TERM_COLOR_RED "\e[91m" diff --git a/src/log/hasp_debug.cpp b/src/log/hasp_debug.cpp index 4fb3c8b9..fde3675e 100644 --- a/src/log/hasp_debug.cpp +++ b/src/log/hasp_debug.cpp @@ -253,13 +253,13 @@ size_t debugHistoryIndex(size_t num) void debugShowHistory() { size_t num = debugHistorycount(); - Serial.println(); + HASP_SERIAL.println(); for(int i = 0; i <= num; i++) { - Serial.print("["); - Serial.print(i); - Serial.print("] "); + HASP_SERIAL.print("["); + HASP_SERIAL.print(i); + HASP_SERIAL.print("] "); size_t pos = debugHistoryIndex(i); - if(pos < sizeof(serialInputBuffer)) Serial.println((char *)(serialInputBuffer + pos)); + if(pos < sizeof(serialInputBuffer)) HASP_SERIAL.println((char *)(serialInputBuffer + pos)); } } @@ -375,18 +375,18 @@ void debugStartSerial() #if defined(STM32F4xx) || defined(STM32F7xx) #ifndef STM32_SERIAL1 // Define what Serial port to use for log output - Serial.setRx(PA3); // User Serial2 - Serial.setTx(PA2); + HASP_SERIAL.setRx(PA3); // User Serial2 + HASP_SERIAL.setTx(PA2); #endif #endif - Serial.begin(baudrate); /* prepare for possible serial debug */ + HASP_SERIAL.begin(baudrate); /* prepare for possible serial debug */ delay(10); Log.registerOutput(0, &Serial, HASP_LOG_LEVEL, true); // LOG_LEVEL_VERBOSE - Serial.println(); + HASP_SERIAL.println(); debugPrintHaspHeader(&Serial); - Serial.flush(); + HASP_SERIAL.flush(); LOG_INFO(TAG_DEBG, F(D_SERVICE_STARTED " @ %u bps"), debugSerialBaud); LOG_INFO(TAG_DEBG, F(D_INFO_ENVIRONMENT ": " PIOENV)); @@ -424,12 +424,12 @@ void printLocalTime() timeinfo = localtime(&rawtime); strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S.", timeinfo); - Serial.println(buffer); + HASP_SERIAL.println(buffer); // struct tm timeinfo; // time_t now = time(nullptr); // Serial-.print(ctime(&now)); - // Serial.print(&timeinfo, " %d %B %Y %H:%M:%S "); + // HASP_SERIAL.print(&timeinfo, " %d %B %Y %H:%M:%S "); #if LWIP_VERSION_MAJOR > 1 @@ -438,13 +438,13 @@ void printLocalTime() IPAddress sntp = *sntp_getserver(i); const char* name = sntp_getservername(i); if(sntp.isSet()) { - Serial.printf("sntp%d: ", i); + HASP_SERIAL.printf("sntp%d: ", i); if(name) { - Serial.printf("%s (%s) ", name, sntp.toString().c_str()); + HASP_SERIAL.printf("%s (%s) ", name, sntp.toString().c_str()); } else { - Serial.printf("%s ", sntp.toString().c_str()); + HASP_SERIAL.printf("%s ", sntp.toString().c_str()); } - Serial.printf("IPv6: %s Reachability: %o\n", sntp.isV6() ? D_YES : D_NO, sntp_getreachability(i)); + HASP_SERIAL.printf("IPv6: %s Reachability: %o\n", sntp.isV6() ? D_YES : D_NO, sntp_getreachability(i)); } } #endif diff --git a/src/sys/svc/hasp_console.cpp b/src/sys/svc/hasp_console.cpp index 95c43a90..9cb04527 100644 --- a/src/sys/svc/hasp_console.cpp +++ b/src/sys/svc/hasp_console.cpp @@ -19,7 +19,7 @@ extern hasp_http_config_t http_config; #endif // Create a new Stream that buffers all writes to serialClient -HardwareSerial* bufferedSerialClient = &Serial; +HardwareSerial* bufferedSerialClient = (HardwareSerial*)&Serial; uint8_t consoleLoginState = CONSOLE_UNAUTHENTICATED; uint16_t serialPort = 0; @@ -129,7 +129,7 @@ void consoleStop() { console_logoff(); Log.unregisterOutput(0); // serialClient - Serial.end(); + HASP_SERIAL.end(); delete console; console = NULL;