diff --git a/examples/Wippersnapper_demo/Wippersnapper_demo.ino b/examples/Wippersnapper_demo/Wippersnapper_demo.ino index 489a3d96c..78335334f 100644 --- a/examples/Wippersnapper_demo/Wippersnapper_demo.ino +++ b/examples/Wippersnapper_demo/Wippersnapper_demo.ino @@ -1,17 +1,5 @@ -// Adafruit IO WipperSnapper Beta -// -// -// NOTE: This software is a BETA release and in active development. -// Please report bugs or errors to https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/issues -// -// -// Adafruit invests time and resources providing this open source code. -// Please support Adafruit and open source hardware by purchasing -// products from Adafruit! -// -// Brent Rubell for Adafruit Industries, 2021-2022 -// -// All text above must be included in any redistribution. +// Adafruit IO WipperSnapper Beta (DEBUG BUILD ONLY!) +// Brent Rubell for Adafruit Industries, 2021 - 2023 #include "Wippersnapper_Networking.h" Wippersnapper_WiFi wipper; @@ -23,11 +11,12 @@ void setup() { // Provisioning must occur prior to serial init. wipper.provision(); - Serial.begin(115200); + Serial.begin(115200); // wippersnapper serial + // Serial1.begin(115200); // ESP-IDF messages serial + // Serial1.setDebugOutput(true); // Enable ESP-IDF messages over Serial1 //while (!Serial) delay(10); wipper.connect(); - } void loop() { diff --git a/src/components/uart/drivers/ws_uart_drv_pm25aqi.h b/src/components/uart/drivers/ws_uart_drv_pm25aqi.h index c38772ca9..3c8282b0a 100644 --- a/src/components/uart/drivers/ws_uart_drv_pm25aqi.h +++ b/src/components/uart/drivers/ws_uart_drv_pm25aqi.h @@ -106,7 +106,38 @@ class ws_uart_drv_pm25aqi : public ws_uart_drv { // Attempt to read the PM2.5 Sensor if (!_aqi->read(&_data)) { Serial.println("[UART, PM25] Data not available."); - delay(500); +#ifdef USE_SW_UART + if (_swSerial->available()) { + WS_DEBUG_PRINTLN("[UART, PM25] Flushing Software Serial.."); + _swSerial->flush(); + WS_DEBUG_PRINTLN("[UART, PM25] Uart Available. Attempting to clear write errors"); + _swSerial->clearWriteError(); + } else { + WS_DEBUG_PRINTLN("[UART, PM25] Uart Unavailable. Attempting to clear write errors"); + _swSerial->clearWriteError(); + if (!_swSerial->isListening()) { + WS_DEBUG_PRINTLN("[UART, PM25] Re-listening on Software Serial.."); + _swSerial->listen(); + } + // delay(500); + } +#else + WS_DEBUG_PRINTLN("[UART, PM25] Setting Hardware Serial to debug mode.."); + _hwSerial->setDebugOutput(true); + if (_hwSerial->available()) { + WS_DEBUG_PRINTLN("[UART, PM25] Uart available, flushing Hardware Serial.."); + _hwSerial->flush(); + WS_DEBUG_PRINTLN("[UART, PM25] Uart available, clearing write errors.."); + _hwSerial->clearWriteError(); + WS_DEBUG_PRINTLN("[UART, PM25] Uart available, resetting event queue.."); + _hwSerial->eventQueueReset(); + } else { + WS_DEBUG_PRINTLN("[UART, PM25] Uart Unavailable. Attempting to reset event queue..."); + _hwSerial->eventQueueReset(); + WS_DEBUG_PRINTLN("[UART, PM25] Uart Unavailable. Attempting to clear write errors"); + _hwSerial->clearWriteError(); + } +#endif return false; } Serial.println("[UART, PM25] Read data OK");