From a2e199955334300a0e018b72dfe228df4cc35fa4 Mon Sep 17 00:00:00 2001 From: technyon Date: Sun, 3 Jul 2022 23:22:09 +0200 Subject: [PATCH] add restart device button --- WebCfgServer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index 9d40879..f804886 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -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(); @@ -300,6 +310,9 @@ void WebCfgServer::buildHtml(String& response) buildNavigationButton(response, "Restart and configure wifi", "/wifi"); } + response.concat("

Restart device

"); + buildNavigationButton(response, "Restart", "/restart"); + response.concat(""); }