Some webserver code saving

This commit is contained in:
Theo Arends 2020-06-05 11:53:53 +02:00
parent f95a0d13d1
commit 9d86c15685
1 changed files with 7 additions and 11 deletions

View File

@ -34,8 +34,8 @@
const uint16_t CHUNKED_BUFFER_SIZE = (MESSZ / 2) - 100; // Chunk buffer size (should be smaller than half mqtt_data size = MESSZ)
const uint16_t HTTP_REFRESH_TIME = 2345; // milliseconds
#define HTTP_RESTART_RECONNECT_TIME 9000 // milliseconds
#define HTTP_OTA_RESTART_RECONNECT_TIME 20000 // milliseconds
const uint16_t HTTP_RESTART_RECONNECT_TIME = 9000; // milliseconds - Allow time for restart and wifi reconnect
const uint16_t HTTP_OTA_RESTART_RECONNECT_TIME = 28000; // milliseconds - Allow time for uploading binary, unzip/write to final destination and wifi reconnect
#include <ESP8266WebServer.h>
#include <DNSServer.h>
@ -170,12 +170,8 @@ const char HTTP_SCRIPT_WIFI[] PROGMEM =
"eb('p1').focus();"
"}";
const char HTTP_SCRIPT_RELOAD[] PROGMEM =
"setTimeout(function(){location.href='.';}," STR(HTTP_RESTART_RECONNECT_TIME) ");";
// 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='.';}," STR(HTTP_OTA_RESTART_RECONNECT_TIME) ");";
const char HTTP_SCRIPT_RELOAD_TIME[] PROGMEM =
"setTimeout(function(){location.href='.';},%d);";
const char HTTP_SCRIPT_CONSOL[] PROGMEM =
"var sn=0,id=0;" // Scroll position, Get most of weblog initially
@ -980,7 +976,7 @@ void WebRestart(uint32_t type)
bool reset_only = (HTTP_MANAGER_RESET_ONLY == Web.state);
WSContentStart_P((type) ? S_SAVE_CONFIGURATION : S_RESTART, !reset_only);
WSContentSend_P(HTTP_SCRIPT_RELOAD);
WSContentSend_P(HTTP_SCRIPT_RELOAD_TIME, HTTP_RESTART_RECONNECT_TIME);
WSContentSendStyle();
if (type) {
WSContentSend_P(PSTR("<div style='text-align:center;'><b>" D_CONFIGURATION_SAVED "</b><br>"));
@ -2346,7 +2342,7 @@ void HandleUpgradeFirmwareStart(void)
}
WSContentStart_P(S_INFORMATION);
WSContentSend_P(HTTP_SCRIPT_RELOAD_OTA);
WSContentSend_P(HTTP_SCRIPT_RELOAD_TIME, HTTP_OTA_RESTART_RECONNECT_TIME);
WSContentSendStyle();
WSContentSend_P(PSTR("<div style='text-align:center;'><b>" D_UPGRADE_STARTED " ...</b></div>"));
WSContentSend_P(HTTP_MSG_RSTRT);
@ -2371,7 +2367,7 @@ void HandleUploadDone(void)
WSContentStart_P(S_INFORMATION);
if (!Web.upload_error) {
WSContentSend_P(HTTP_SCRIPT_RELOAD_OTA); // Refesh main web ui after OTA upgrade
WSContentSend_P(HTTP_SCRIPT_RELOAD_TIME, HTTP_OTA_RESTART_RECONNECT_TIME); // Refesh main web ui after OTA upgrade
}
WSContentSendStyle();
WSContentSend_P(PSTR("<div style='text-align:center;'><b>" D_UPLOAD " <font color='#"));