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
This commit is contained in:
stefanbode 2022-01-28 08:39:41 +01:00 committed by GitHub
parent 295cfca805
commit 13280c985d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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();