From 14473cb7c7de2cbd991b77ebc1d7c6d153c40cf4 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Thu, 24 Apr 2025 16:17:29 -0400 Subject: [PATCH] Sleep fix when saving Config --- src/configuration.cpp | 4 ++++ src/sleep_utils.cpp | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/configuration.cpp b/src/configuration.cpp index 3daa2ea..d507a3a 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -4,6 +4,9 @@ #include "display.h" +bool shouldSleepStop = true; + + void Configuration::writeFile() { Serial.println("Saving config..."); @@ -166,6 +169,7 @@ bool Configuration::readFile() { digi.mode = data["digi"]["mode"] | 0; digi.ecoMode = data["digi"]["ecoMode"] | 0; + if (digi.ecoMode == 1) shouldSleepStop = false; loramodule.txFreq = data["lora"]["txFreq"] | 433775000; loramodule.rxFreq = data["lora"]["rxFreq"] | 433775000; diff --git a/src/sleep_utils.cpp b/src/sleep_utils.cpp index aa2f97f..5081958 100644 --- a/src/sleep_utils.cpp +++ b/src/sleep_utils.cpp @@ -6,6 +6,7 @@ extern Configuration Config; +extern bool shouldSleepStop; extern uint32_t lastBeaconTx; bool wakeUpFlag = false; @@ -48,15 +49,15 @@ namespace SLEEP_Utils { } void startSleeping() { - uint32_t timeToSleep = getSecondsToSleep(); - esp_sleep_enable_timer_wakeup(timeToSleep * 1000000); // 1 min = 60sec - Serial.print("(Sleeping : "); Serial.print(timeToSleep); Serial.println("seconds)"); - - //esp_sleep_enable_timer_wakeup(getSecondsToSleep() * 1000000); // 1 min = 60sec - - delay(100); - LoRa_Utils::wakeRadio(); - esp_light_sleep_start(); + if (!shouldSleepStop) { + uint32_t timeToSleep = getSecondsToSleep(); + esp_sleep_enable_timer_wakeup(timeToSleep * 1000000); // 1 min = 60sec + Serial.print("(Sleeping : "); Serial.print(timeToSleep); Serial.println("seconds)"); + delay(100); + LoRa_Utils::wakeRadio(); + esp_light_sleep_start(); + } + } } \ No newline at end of file