Skip to content

Commit

Permalink
add restart device button
Browse files Browse the repository at this point in the history
  • Loading branch information
technyon committed Jul 3, 2022
1 parent 50def5c commit a2e1999
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions WebCfgServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ void WebCfgServer::initialize()
_network->reconfigureDevice();
}
});
_server.on("/restart", [&]() {
String response = "";
buildConfirmHtml(response, "Restarting device, please wait.", 5);
_server.send(200, "text/html", response);
Serial.println(F("Restarting"));

waitAndProcess(true, 1000);
ESP.restart();
});

_server.on("/method=get", [&]() {
if (_hasCredentials && !_server.authenticate(_credUser, _credPassword)) {
return _server.requestAuthentication();
Expand Down Expand Up @@ -300,6 +310,9 @@ void WebCfgServer::buildHtml(String& response)
buildNavigationButton(response, "Restart and configure wifi", "/wifi");
}

response.concat("<BR><BR><h3>Restart device</h3>");
buildNavigationButton(response, "Restart", "/restart");

response.concat("</BODY></HTML>");
}

Expand Down

0 comments on commit a2e1999

Please sign in to comment.