From 30565af8c72efca4a559c78e20d0f7b2347fc154 Mon Sep 17 00:00:00 2001 From: tyeth Date: Fri, 17 Jan 2025 02:25:24 +0000 Subject: [PATCH] WIP: working retry of uart pm2.5 --- src/Wippersnapper.h | 2 +- src/components/uart/drivers/ws_uart_drv_pm25aqi.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Wippersnapper.h b/src/Wippersnapper.h index e58353b5b..3527c5302 100644 --- a/src/Wippersnapper.h +++ b/src/Wippersnapper.h @@ -95,7 +95,7 @@ { \ unsigned long startTime = millis(); \ while (millis() - startTime < timeout) { \ - result_type result_var = func(__VA_ARGS__); \ + result_var = func(__VA_ARGS__); \ if (condition(result_var)) { \ break; \ } \ diff --git a/src/components/uart/drivers/ws_uart_drv_pm25aqi.h b/src/components/uart/drivers/ws_uart_drv_pm25aqi.h index 100104bde..2cdaa9eeb 100644 --- a/src/components/uart/drivers/ws_uart_drv_pm25aqi.h +++ b/src/components/uart/drivers/ws_uart_drv_pm25aqi.h @@ -104,13 +104,13 @@ class ws_uart_drv_pm25aqi : public ws_uart_drv { bool read_data() override { WS_DEBUG_PRINTLN("[UART, PM25] Reading data..."); // Attempt to read the PM2.5 Sensor - bool result; - RETRY_FUNCTION_UNTIL_TIMEOUT(_aqi->read, bool, result, - // lambda function to check if data is available - [](bool res) { + bool result = false; + RETRY_FUNCTION_UNTIL_TIMEOUT(_aqi->read, bool, result, + [](bool res) -> bool { WS_DEBUG_PRINT("UART IN TIMED CHECK, RES: "); WS_DEBUG_PRINTLN(res); - return res==true; } - , 5000, 250, &_data); + return res==true; + }, + 500, 100, &_data); WS_DEBUG_PRINT("RESULT VAR: "); WS_DEBUG_PRINTLN(result); if (!result) {