From 13280c985d0d580088b75a9a29551562e2805784 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Fri, 28 Jan 2022 08:39:41 +0100 Subject: [PATCH] Added WIFI check to avoid extensive battery usage The device is send to an additional deepsleep cycle if there could not establish a WIFI connection with IP in the first 15 seconds after startup. Normal connection time is 6-7 seconds. Address #14483 --- tasmota/xdrv_29_deepsleep.ino | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_29_deepsleep.ino b/tasmota/xdrv_29_deepsleep.ino index f93506410..ac78357bd 100644 --- a/tasmota/xdrv_29_deepsleep.ino +++ b/tasmota/xdrv_29_deepsleep.ino @@ -154,9 +154,13 @@ 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()) { + 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();