Skip to content

Commit

Permalink
Replaced delay() with light sleep for ESP32 (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-bs authored Aug 20, 2024
1 parent 4962a3b commit b9ddcac
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions BresserWeatherSensorLWCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
//
// 20240723 Extracted from BresserWeatherSensorLW.ino
// 20240729 Added PowerFeather specific status information
// 20240818 Replaced delay() with light sleep for ESP32
//
// ToDo:
// -
Expand Down Expand Up @@ -300,7 +301,12 @@ void sendCfgUplink(uint8_t uplinkReq, uint32_t uplinkInterval)
uint32_t delayMs = max(interval, minimumDelay); // cannot send faster than duty cycle allows

log_d("Sending configuration uplink in %u s", delayMs / 1000);
#if defined(ESP32)
esp_sleep_enable_timer_wakeup(delayMs * 1000);
esp_light_sleep_start();
#else
delay(delayMs);
#endif
log_d("Sending configuration uplink now.");
int16_t state = node.sendReceive(uplinkPayload, encoder.getLength(), port);
debug((state != RADIOLIB_LORAWAN_NO_DOWNLINK) && (state != RADIOLIB_ERR_NONE), "Error in sendReceive", state, false);
Expand Down

0 comments on commit b9ddcac

Please sign in to comment.