Add http request to reboot ESP

GPIO0 should be at 3.3v to boot correctly
This commit is contained in:
Mathieu Maret 2016-03-16 01:09:25 +01:00
parent ff178ce940
commit b66769f9d6

View File

@ -70,7 +70,7 @@ void handleSave() {
} }
server.send(200, "text/html", "<h1>Configuration Saved</h1><br/>" server.send(200, "text/html", "<h1>Configuration Saved</h1><br/>"
"You can reboot now"); "<a href=\"/reboot\">Reboot</a><br/>");
} }
void handleOTA() { void handleOTA() {
@ -95,12 +95,19 @@ void handleNotFound() {
server.send(404, "text/plain", message); server.send(404, "text/plain", message);
} }
void handleReboot() {
Serial.println("HTTP request to reboot");
server.send(200, "text/html", "<h1>Device Reboot</h1><br/>");
ESP.restart();
}
void setupWebServer(int bootmode) { void setupWebServer(int bootmode) {
server.on("/", handleRoot); server.on("/", handleRoot);
server.on("/setup", handleSetup); server.on("/setup", handleSetup);
server.on("/save", handleSave); server.on("/save", handleSave);
server.on("/gpio", handleGpio); server.on("/gpio", handleGpio);
server.on("/otamode", handleOTA); server.on("/otamode", handleOTA);
server.on("/reboot", handleReboot);
server.onNotFound(handleNotFound); server.onNotFound(handleNotFound);
server.begin(); server.begin();