diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index eec4ac701..0cd2d3093 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,4 +1,8 @@ -/* 6.2.1.14 20181010 +/* 6.2.1.15 20181012 + * Fix Color Temperature slider functionality regression from 20180726 (#4037) + * Add auto reload of main web page to some web restarts + * + * 6.2.1.14 20181010 * Rewrite Webserver page handler for easier extension (thx to Adrian Scillato) * Add support for DS3231 Real Time Clock * Add support for HX711 Load Cell diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index 080c76fa4..d283e0476 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,7 +20,7 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -#define VERSION 0x0602010E +#define VERSION 0x0602010F #define D_PROGRAMNAME "Sonoff-Tasmota" #define D_AUTHOR "Theo Arends" diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index b035c0020..894806919 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -80,9 +80,12 @@ const char HTTP_HEAD[] PROGMEM = "la('?d='+p);" "}" "function lc(p){" - "la('?t='+p);" + "la('?t='+p);" // ?t related to WebGetArg("t", tmp, sizeof(tmp)); "}"; +const char HTTP_HEAD_RELOAD[] PROGMEM = + "setTimeout(function(){location.href='.';},4000);"; + const char HTTP_HEAD_STYLE[] PROGMEM = "" @@ -191,7 +194,7 @@ const char HTTP_BTN_MENU1[] PROGMEM = "
" "
"; const char HTTP_BTN_RSTRT[] PROGMEM = - "
"; + "
"; const char HTTP_BTN_MENU_MODULE[] PROGMEM = "
" "
"; @@ -353,8 +356,6 @@ void StartWebserver(int type, IPAddress ipweb) WebServer->on("/ax", HandleAjaxConsoleRefresh); WebServer->on("/ay", HandleAjaxStatusRefresh); WebServer->on("/cm", HandleHttpCommand); - WebServer->on("/rb", HandleRestart); -// WebServer->on("/fwlink", HandleRoot); // Microsoft captive portal. Maybe not needed. Might be handled by notFound handler. WebServer->onNotFound(HandleNotFound); #ifndef BE_MINIMAL WebServer->on("/cn", HandleConfiguration); @@ -471,6 +472,43 @@ void ShowPage(String &page) ShowPage(page, true); } +/*-------------------------------------------------------------------------------------------*/ + +void WebRestart(uint8_t type) +{ + // type 0 = restart + // type 1 = restart after config change + // type 2 = restart after config change with possible ip address change too + AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTART); + + String page = FPSTR(HTTP_HEAD); + page += FPSTR(HTTP_HEAD_RELOAD); + page += FPSTR(HTTP_HEAD_STYLE); + + if (type) { + page.replace(F("{v}"), FPSTR(S_SAVE_CONFIGURATION)); + page += F("
" D_CONFIGURATION_SAVED "
"); + if (2 == type) { + page += F("
" D_TRYING_TO_CONNECT "
"); + } + page += F("
"); + } + else { + page.replace(F("{v}"), FPSTR(S_RESTART)); + } + + page += FPSTR(HTTP_MSG_RSTRT); + if (HTTP_MANAGER == webserver_state) { + webserver_state = HTTP_ADMIN; + } else { + page += FPSTR(HTTP_BTN_MAIN); + } + ShowPage(page); + + ShowWebSource(SRC_WEBGUI); + restart_flag = 2; +} + /*********************************************************************************************/ void HandleWifiLogin() @@ -488,6 +526,11 @@ void HandleRoot() if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the page. + if ( WebServer->hasArg("rstrt") ) { + WebRestart(0); + return; + } + if (HTTP_MANAGER == webserver_state) { #ifndef BE_MINIMAL if ((Settings.web_password[0] != 0) && !(WebServer->hasArg("USER1")) && !(WebServer->hasArg("PASS1"))) { @@ -601,7 +644,7 @@ void HandleAjaxStatusRefresh() snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_DIMMER " %s"), tmp); ExecuteWebCommand(svalue, SRC_WEBGUI); } - WebGetArg("c", tmp, sizeof(tmp)); + WebGetArg("t", tmp, sizeof(tmp)); if (strlen(tmp)) { snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_COLORTEMPERATURE " %s"), tmp); ExecuteWebCommand(svalue, SRC_WEBGUI); @@ -653,28 +696,6 @@ boolean HttpUser() /*-------------------------------------------------------------------------------------------*/ -void WaitForRestart(String result) -{ - String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), FPSTR(S_SAVE_CONFIGURATION)); - page += FPSTR(HTTP_HEAD_STYLE); - page += F("
" D_CONFIGURATION_SAVED "
"); - page += result; - page += F("
"); - page += FPSTR(HTTP_MSG_RSTRT); - if (HTTP_MANAGER == webserver_state) { - webserver_state = HTTP_ADMIN; - } else { - page += FPSTR(HTTP_BTN_MAIN); - } - ShowPage(page); - - ShowWebSource(SRC_WEBGUI); - restart_flag = 2; -} - -/*-------------------------------------------------------------------------------------------*/ - #ifndef BE_MINIMAL void HandleConfiguration() @@ -708,7 +729,7 @@ void HandleModuleConfiguration() if (WebServer->hasArg("save")) { ModuleSaveSettings(); - WaitForRestart(""); + WebRestart(1); return; } @@ -818,8 +839,7 @@ void HandleWifiConfiguration() if (WebServer->hasArg("save")) { WifiSaveSettings(); - String result = F("
" D_TRYING_TO_CONNECT "
"); - WaitForRestart(result); + WebRestart(2); return; } @@ -1028,7 +1048,7 @@ void HandleOtherConfiguration() if (WebServer->hasArg("save")) { OtherSaveSettings(); - WaitForRestart(""); + WebRestart(1); return; } @@ -1734,29 +1754,6 @@ void HandleAjaxConsoleRefresh() WebServer->send(200, FPSTR(HDR_CTYPE_XML), message); } -/*-------------------------------------------------------------------------------------------*/ - -void HandleRestart() -{ - if (HttpUser()) { return; } - if (!WebAuthenticate()) { return WebServer->requestAuthentication(); } - AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTART); - - String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), FPSTR(S_RESTART)); - page += FPSTR(HTTP_HEAD_STYLE); - page += FPSTR(HTTP_MSG_RSTRT); - if (HTTP_MANAGER == webserver_state) { - webserver_state = HTTP_ADMIN; - } else { - page += FPSTR(HTTP_BTN_MAIN); - } - ShowPage(page); - - ShowWebSource(SRC_WEBGUI); - restart_flag = 2; -} - /********************************************************************************************/ void HandleNotFound() diff --git a/sonoff/xdrv_02_mqtt.ino b/sonoff/xdrv_02_mqtt.ino index 1cd6d9aff..89cddbd6c 100644 --- a/sonoff/xdrv_02_mqtt.ino +++ b/sonoff/xdrv_02_mqtt.ino @@ -813,7 +813,7 @@ void HandleMqttConfiguration() if (WebServer->hasArg("save")) { MqttSaveSettings(); - WaitForRestart(""); + WebRestart(1); return; } diff --git a/sonoff/xdrv_07_domoticz.ino b/sonoff/xdrv_07_domoticz.ino index d40bae88f..060301323 100644 --- a/sonoff/xdrv_07_domoticz.ino +++ b/sonoff/xdrv_07_domoticz.ino @@ -399,7 +399,7 @@ void HandleDomoticzConfiguration() if (WebServer->hasArg("save")) { DomoticzSaveSettings(); - WaitForRestart(""); + WebRestart(1); return; }