From 11284bbd4930b6f60dc850a6e8669d0ea64614d3 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Fri, 28 Jan 2022 12:06:59 +0100 Subject: [PATCH] Introduce DEEPSLEEP_NETWORK_TIMEOUT = 15 Network timeout can be configured in seconds or totally disabled by = 0 --- tasmota/xdrv_29_deepsleep.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_29_deepsleep.ino b/tasmota/xdrv_29_deepsleep.ino index ac78357bd..17ef2d896 100644 --- a/tasmota/xdrv_29_deepsleep.ino +++ b/tasmota/xdrv_29_deepsleep.ino @@ -32,6 +32,7 @@ #define D_PRFX_DEEPSLEEP "DeepSleep" #define D_CMND_DEEPSLEEP_TIME "Time" +#define DEEPSLEEP_NETWORK_TIMEOUT 15 const uint32_t DEEPSLEEP_MAX = 10 * 366 * 24 * 60 * 60; // Allow max 10 years sleep const uint32_t DEEPSLEEP_MAX_CYCLE = 60 * 60; // Maximum time for a deepsleep as defined by chip hardware @@ -137,8 +138,6 @@ void DeepSleepPrepare(void) void DeepSleepStart(void) { - AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Sleeping")); // Won't show in GUI - WifiShutdown(); RtcSettings.ultradeepsleep = RtcSettings.nextwakeup - LocalTime(); RtcSettingsSave(); @@ -154,13 +153,14 @@ void DeepSleepStart(void) } void DeepSleepEverySecond(void) -{ +{ //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("Wifi Info: up %d, wifidown %d, wifistatus %d, flag %d"),TasmotaGlobal.uptime, TasmotaGlobal.global_state.wifi_down, Wifi.status , deepsleep_flag); - if (TasmotaGlobal.uptime > 15 && Wifi.status != WL_CONNECTED && !deepsleep_flag && DeepSleepEnabled()) { + if (DEEPSLEEP_NETWORK_TIMEOUT && TasmotaGlobal.uptime > DEEPSLEEP_NETWORK_TIMEOUT && Wifi.status != WL_CONNECTED && !deepsleep_flag && DeepSleepEnabled()) { AddLog(LOG_LEVEL_ERROR, PSTR("Error Wifi could not connect 15 seconds. Deepsleep") ); deepsleep_flag = DEEPSLEEP_START_COUNTDOWN; // Start deepsleep in 4 seconds } if (!deepsleep_flag) { return; } + if (DeepSleepEnabled()) { if (DEEPSLEEP_START_COUNTDOWN == deepsleep_flag) { // Allow 4 seconds to update web console before deepsleep SettingsSaveAll();