Skip to content

Commit

Permalink
WIP: working retry of uart pm2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Jan 17, 2025
1 parent 1fe51a7 commit 30565af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Wippersnapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
} \
Expand Down
12 changes: 6 additions & 6 deletions src/components/uart/drivers/ws_uart_drv_pm25aqi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 30565af

Please sign in to comment.