mirror of https://github.com/arendst/Tasmota.git
Implement deepsleep(0)
Implement deepsleep(0) as command ``restart 9`` (#19024)
This commit is contained in:
parent
cc55cf0bb1
commit
522e6cf234
|
@ -305,6 +305,7 @@ struct TasmotaGlobal_t {
|
|||
bool ntp_force_sync; // Force NTP sync
|
||||
bool skip_light_fade; // Temporarily skip light fading
|
||||
bool restart_halt; // Do not restart but stay in wait loop
|
||||
bool restart_deepsleep; // Do not restart but do deepsleep
|
||||
bool module_changed; // Indicate module changed since last restart
|
||||
bool wifi_stay_asleep; // Allow sleep only incase of ESP32 BLE
|
||||
bool no_autoexec; // Disable autoexec
|
||||
|
|
|
@ -1151,6 +1151,11 @@ void CmndRestart(void)
|
|||
}
|
||||
break;
|
||||
#endif // ESP32
|
||||
case 9:
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
TasmotaGlobal.restart_deepsleep = true;
|
||||
ResponseCmndChar(PSTR("Go to sleep"));
|
||||
break;
|
||||
case -1:
|
||||
CmndCrash(); // force a crash
|
||||
break;
|
||||
|
|
|
@ -1560,7 +1560,7 @@ void Every250mSeconds(void)
|
|||
|
||||
TasmotaGlobal.restart_flag--;
|
||||
if (TasmotaGlobal.restart_flag <= 0) {
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "%s"), (TasmotaGlobal.restart_halt) ? PSTR("Halted") : PSTR(D_RESTARTING));
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "%s"), (TasmotaGlobal.restart_halt) ? PSTR("Halted") : (TasmotaGlobal.restart_deepsleep) ? PSTR("Sleeping") : PSTR(D_RESTARTING));
|
||||
EspRestart();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1161,7 +1161,7 @@ void EspRestart(void)
|
|||
WifiShutdown(true);
|
||||
CrashDumpClear(); // Clear the stack dump in RTC
|
||||
|
||||
if (TasmotaGlobal.restart_halt) {
|
||||
if (TasmotaGlobal.restart_halt) { // Restart 2
|
||||
while (1) {
|
||||
OsWatchLoop(); // Feed OsWatch timer to prevent restart
|
||||
SetLedLink(1); // Wifi led on
|
||||
|
@ -1169,7 +1169,11 @@ void EspRestart(void)
|
|||
SetLedLink(0); // Wifi led off
|
||||
delay(800); // Satisfy SDK
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else if (TasmotaGlobal.restart_deepsleep) { // Restart 9
|
||||
ESP.deepSleep(0); // Deep sleep mode with only hardware triggered wake up
|
||||
}
|
||||
else {
|
||||
ESP_Restart();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue