Add reset and restart functionality
This commit is contained in:
parent
07b8a3aacf
commit
64ef26117f
25
src/main.cpp
25
src/main.cpp
|
@ -151,6 +151,8 @@ span:empty {content: 'nicht verbunden';}\
|
|||
void reload_home();
|
||||
void reload_settings();
|
||||
void handleToggle();
|
||||
void handleReset();
|
||||
void handleRestart();
|
||||
|
||||
void load_EEPROM() {
|
||||
unsigned int EEPROM_Addr = 0;
|
||||
|
@ -179,6 +181,27 @@ void handleSettings() {
|
|||
debugln(ESP.getFreeHeap(), DEC);
|
||||
}
|
||||
|
||||
void handleReset() {
|
||||
for (int i = 0; i < 264; i++) {
|
||||
EEPROM.put(i, 0);
|
||||
EEPROM.commit();
|
||||
}
|
||||
server.send(200, "text/html",
|
||||
"<html><head><meta http-equiv=\"refresh\" "
|
||||
"content=\"2;url=/restart\"/></head><body><p>EEPROM has been "
|
||||
"reset.</p></body></html>");
|
||||
}
|
||||
|
||||
void handleRestart() {
|
||||
server.send(200, "text/html",
|
||||
"<html><head><meta http-equiv=\"refresh\" "
|
||||
"content=\"10;url=/\"/></head><body><p>Restarting...</p></"
|
||||
"body></html>");
|
||||
server.close();
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
void handleTime() {
|
||||
if (server.arg("rule") != "") {
|
||||
debugln("write main");
|
||||
|
@ -346,6 +369,8 @@ void setup() {
|
|||
server.on("/settings", HTTP_GET, handleSettings);
|
||||
server.on("/settings", HTTP_POST, handleTime);
|
||||
server.on("/toggle", HTTP_GET, handleToggle);
|
||||
server.on("/reset", HTTP_GET, handleReset);
|
||||
server.on("/restart", HTTP_GET, handleRestart);
|
||||
server.on("/version", HTTP_GET, [] {
|
||||
server.send(200, "text/html",
|
||||
BUILD_VERSION + BUILD_DEBUG ? "-debug" : "");
|
||||
|
|
Loading…
Reference in New Issue