From a6983d52f7a877e5b5c286796dd060f01235557a Mon Sep 17 00:00:00 2001 From: andrethomas Date: Sat, 24 Nov 2018 12:46:32 +0200 Subject: [PATCH] Increase delays before web ui is refreshed The current 5-second delay before refreshing web ui after settings were changed is not always sufficient as wifi can take up to 10 seconds to re-connect and be available on some wireless networks, depending on the device's RSSI. This change increases the delay from 5 seconds to 10 seconds which have been tested down to RSSI levels of 25 to be sufficient. This change also increases the refresh delay when a local OTA is uploaded to 20 seconds which allows enough time for the cp: process to complete and the device to reconnected to wifi under >= 25 RSSI conditions. --- sonoff/xdrv_01_webserver.ino | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 09df2dd7d..7c7f60718 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -95,7 +95,12 @@ const char HTTP_SCRIPT_WIFI[] PROGMEM = "}"; const char HTTP_SCRIPT_RELOAD[] PROGMEM = - "setTimeout(function(){location.href='.';},5000);" + "setTimeout(function(){location.href='.';},10000);" + ""; + +// Local OTA upgrade requires more time to complete cp: before web ui should be reloaded +const char HTTP_SCRIPT_RELOAD_OTA[] PROGMEM = + "setTimeout(function(){location.href='.';},20000);" ""; const char HTTP_SCRIPT_CONSOL[] PROGMEM = @@ -1463,7 +1468,7 @@ void HandleUploadDone(void) } else { page += F("green'>" D_SUCCESSFUL "
"); page += FPSTR(HTTP_MSG_RSTRT); - page.replace(F(""), FPSTR(HTTP_SCRIPT_RELOAD)); + page.replace(F(""), FPSTR(HTTP_SCRIPT_RELOAD_OTA)); // Refesh main web ui after OTA upgrade ShowWebSource(SRC_WEBGUI); restart_flag = 2; // Always restart to re-enable disabled features during update }