Skip to content

Commit

Permalink
[deepsleep] Make sure the 'shortcut' of running all services when sle…
Browse files Browse the repository at this point in the history
…ep enabled

As pointed out on [the forum by arion_p](https://www.letscontrolit.com/forum/viewtopic.php?p=25771#p25771)
  • Loading branch information
TD-er committed Mar 10, 2018
1 parent bb9f8fc commit bcca051
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ESPEasy.ino
Expand Up @@ -1167,7 +1167,7 @@ void setup()
String event = F("System#Initialized");
rulesProcessing(event);
}

WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
WifiAPconfig();

Expand Down Expand Up @@ -1315,7 +1315,7 @@ void loop()

backgroundtasks();

if (isDeepSleepEnabled()){
if (readyForSleep()){
deepSleep(Settings.Delay);
//deepsleep will never return, its a special kind of reboot
}
Expand Down
9 changes: 7 additions & 2 deletions src/Misc.ino
Expand Up @@ -27,8 +27,6 @@ bool isDeepSleepEnabled()
{
if (!Settings.deepSleep)
return false;
if (!timeOutReached(timerAwakeFromDeepSleep + 1000 * Settings.deepSleep))
return false;

//cancel deep sleep loop by pulling the pin GPIO16(D0) to GND
//recommended wiring: 3-pin-header with 1=RST, 2=D0, 3=GND
Expand All @@ -42,6 +40,13 @@ bool isDeepSleepEnabled()
return true;
}

bool readyForSleep()
{
if (!isDeepSleepEnabled())
return false;
return timeOutReached(timerAwakeFromDeepSleep + 1000 * Settings.deepSleep);
}

void deepSleep(int delay)
{

Expand Down

0 comments on commit bcca051

Please sign in to comment.