Add time to flush all clients when restarting

by using a light page without css to load
This commit is contained in:
luc 2015-08-06 12:19:14 +08:00
parent 8dd8ec207d
commit a18f924153
3 changed files with 32 additions and 16 deletions

View File

@ -167,4 +167,9 @@ uint8_t i,data;
COMMAND::read_buffer_serial(sbuf, len); COMMAND::read_buffer_serial(sbuf, len);
} }
} }
if (web_interface->restartmodule)
{
ESP.restart();
while (1){delay(1);};
}
} }

View File

@ -314,6 +314,8 @@ const char POLLING_TITLE[]PROGMEM ="Refresh Web page (s):";
const char POLLING_NAME[]PROGMEM ="Refresh printer status every :"; const char POLLING_NAME[]PROGMEM ="Refresh printer status every :";
const char POLLING_ID[]PROGMEM ="POLLING"; const char POLLING_ID[]PROGMEM ="POLLING";
const char TEXT_HTML[]PROGMEM ="text/html"; const char TEXT_HTML[]PROGMEM ="text/html";
const char RESTARTCMD [] PROGMEM ="<script>setTimeout(function(){window.location.href='/RESTART'},10000);</script>";
const char RESTARTINGMSG [] PROGMEM = "<CENTER>Restarting, please wait.... </CENTER><script>setTimeout(function(){window.location.href='/'},20000);</script>";
@ -774,12 +776,12 @@ void handle_web_interface_configSys()
buffer2send+=(PROGMEM2CHAR(FORM_END)); buffer2send+=(PROGMEM2CHAR(FORM_END));
buffer2send+=(PROGMEM2CHAR(PANEL_END)); buffer2send+=(PROGMEM2CHAR(PANEL_END));
buffer2send+=(PROGMEM2CHAR(PAGE_BOTTOM));
web_interface->WebServer.send(200, "text/html", buffer2send);
if (msg_alert_success && !msg_alert_error) if (msg_alert_success && !msg_alert_error)
{ {
system_restart(); buffer2send+= PROGMEM2CHAR(RESTARTCMD);
} }
buffer2send+=(PROGMEM2CHAR(PAGE_BOTTOM));
web_interface->WebServer.send(200, "text/html", buffer2send);
} }
void handle_web_interface_configAP() void handle_web_interface_configAP()
@ -1138,12 +1140,12 @@ void handle_web_interface_configAP()
buffer2send+=(PROGMEM2CHAR(FORM_END)); buffer2send+=(PROGMEM2CHAR(FORM_END));
buffer2send+=(PROGMEM2CHAR(PANEL_END)); buffer2send+=(PROGMEM2CHAR(PANEL_END));
buffer2send+=(PROGMEM2CHAR(PAGE_BOTTOM));
web_interface->WebServer.send(200, "text/html", buffer2send);
if (msg_alert_success && !msg_alert_error) if (msg_alert_success && !msg_alert_error)
{ {
system_restart(); buffer2send+=PROGMEM2CHAR(RESTARTCMD);
} }
buffer2send+=(PROGMEM2CHAR(PAGE_BOTTOM));
web_interface->WebServer.send(200, "text/html", buffer2send);
} }
@ -1479,12 +1481,12 @@ void handle_web_interface_configSTA()
buffer2send+=(PROGMEM2CHAR(FORM_END)); buffer2send+=(PROGMEM2CHAR(FORM_END));
buffer2send+=(PROGMEM2CHAR(PANEL_END)); buffer2send+=(PROGMEM2CHAR(PANEL_END));
buffer2send+=(PROGMEM2CHAR(PAGE_BOTTOM));
web_interface->WebServer.send(200, "text/html", buffer2send);
if (msg_alert_success && !msg_alert_error) if (msg_alert_success && !msg_alert_error)
{ {
system_restart(); buffer2send+= PROGMEM2CHAR(RESTARTCMD);
} }
buffer2send+=(PROGMEM2CHAR(PAGE_BOTTOM));
web_interface->WebServer.send(200, "text/html", buffer2send);
} }
@ -1713,6 +1715,12 @@ void handle_web_interface_status()
} }
void handle_restart()
{
web_interface->WebServer.send(200,"text/html",PROGMEM2CHAR(RESTARTINGMSG));
web_interface->restartmodule=true;
}
void handle_web_command() void handle_web_command()
{ {
if (web_interface->WebServer.hasArg(PROGMEM2CHAR(COMMAND_ID))) if (web_interface->WebServer.hasArg(PROGMEM2CHAR(COMMAND_ID)))
@ -1784,6 +1792,7 @@ WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port):WebServer(port)
WebServer.on("/PRINTER",HTTP_ANY, handle_web_interface_printer); WebServer.on("/PRINTER",HTTP_ANY, handle_web_interface_printer);
WebServer.on("/CMD",HTTP_ANY, handle_web_command); WebServer.on("/CMD",HTTP_ANY, handle_web_command);
WebServer.on("/mincss.css",HTTP_GET, handle_css); WebServer.on("/mincss.css",HTTP_GET, handle_css);
WebServer.on("/RESTART",HTTP_GET, handle_restart);
#ifdef SSDP_FEATURE #ifdef SSDP_FEATURE
WebServer.on("/description.xml", HTTP_GET, handle_SSDP); WebServer.on("/description.xml", HTTP_GET, handle_SSDP);
#endif #endif
@ -1793,6 +1802,7 @@ WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port):WebServer(port)
answer4M220="100"; answer4M220="100";
answer4M221="100"; answer4M221="100";
last_temp=system_get_time(); last_temp=system_get_time();
restartmodule=false;
} }
WEBINTERFACE_CLASS * web_interface; WEBINTERFACE_CLASS * web_interface;

View File

@ -45,6 +45,7 @@ class WEBINTERFACE_CLASS
STORESTRINGS_CLASS error_msg; STORESTRINGS_CLASS error_msg;
STORESTRINGS_CLASS info_msg; STORESTRINGS_CLASS info_msg;
STORESTRINGS_CLASS status_msg; STORESTRINGS_CLASS status_msg;
bool restartmodule;
private: private:
}; };