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)){