From cbeacbb7eeee9157cb1353289e67d1eedd2b2f15 Mon Sep 17 00:00:00 2001 From: KlausMu Date: Sun, 9 Jun 2024 08:38:34 +0200 Subject: [PATCH] Fallback in case of sleepTimeout is set to 0 --- Platformio/hardware/ESP32/sleep_hal_esp32.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp b/Platformio/hardware/ESP32/sleep_hal_esp32.cpp index 1e44e24..0b69e9d 100644 --- a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp +++ b/Platformio/hardware/ESP32/sleep_hal_esp32.cpp @@ -238,6 +238,10 @@ uint32_t get_sleepTimeout_HAL() { } void set_sleepTimeout_HAL(uint32_t aSleepTimeout) { sleepTimeout = aSleepTimeout; + // For reason unknown, some users reported sleepTimeout was set to 0. In this case device would immediately go to sleep. Prevent this. + if (sleepTimeout == 0) { + sleepTimeout = DEFAULT_SLEEP_TIMEOUT; + } } bool get_wakeupByIMUEnabled_HAL() { return wakeupByIMUEnabled;