From ccf24f50f9c2b10dd62d6a3301e7798c35780213 Mon Sep 17 00:00:00 2001 From: Timm Bogner <64260873+timmbogner@users.noreply.github.com> Date: Fri, 9 Sep 2022 12:27:58 -0500 Subject: [PATCH] added delay(0) --- examples/ESPNOW_Sensor/ESPNOW_Sensor.ino | 9 +++++++-- src/fdrs_node.h | 16 +++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/examples/ESPNOW_Sensor/ESPNOW_Sensor.ino b/examples/ESPNOW_Sensor/ESPNOW_Sensor.ino index 1cd48be..d56722d 100644 --- a/examples/ESPNOW_Sensor/ESPNOW_Sensor.ino +++ b/examples/ESPNOW_Sensor/ESPNOW_Sensor.ino @@ -20,7 +20,12 @@ void loop() { loadFDRS(data1, HUMIDITY_T); data2 = readTemp(); loadFDRS(data2, TEMP_T); - sendFDRS(); +// DBG(sendFDRS()); + if(sendFDRS()){ + DBG("Big Success!"); + } else { + DBG("Nope, not so much."); + } sleepFDRS(10); //Sleep time in seconds } @@ -29,5 +34,5 @@ float readTemp() { } float readHum() { - return random(0,100); + return random(0, 100); } diff --git a/src/fdrs_node.h b/src/fdrs_node.h index 5039ca3..2ac857d 100644 --- a/src/fdrs_node.h +++ b/src/fdrs_node.h @@ -121,8 +121,7 @@ void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { esp_now_ack_flag = CRC_OK; } else { esp_now_ack_flag = CRC_BAD; - } - + } } void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) { #endif @@ -408,12 +407,15 @@ bool sendFDRS() { #ifdef USE_ESPNOW esp_now_send(gatewayAddress, (uint8_t *) &fdrsData, data_count * sizeof(DataReading)); esp_now_ack_flag = CRC_NULL; - while(esp_now_ack_flag == CRC_NULL){} - if (esp_now_ack_flag = CRC_OK){ - return true; - } else { - return false; + while(esp_now_ack_flag == CRC_NULL){ + delay(0); } + if (esp_now_ack_flag == CRC_OK){ + return true; + } else { + return false; + } + #endif #ifdef USE_LORA if(transmitLoRa(>wyAddress, fdrsData, data_count)){