Add http request to reboot ESP
GPIO0 should be at 3.3v to boot correctly
This commit is contained in:
parent
ff178ce940
commit
b66769f9d6
@ -2,7 +2,7 @@ void handleRoot() {
|
||||
server.send(200, "text/html", "<h1>You are connected</h1><br/>"
|
||||
"Current temperature " + String(temp, 2) + "C<br/>"
|
||||
"Current pressure " + String(pressure, 2) + "mB<br/>"
|
||||
"MQTT Status :" + (MQTT_isConnected()? "Connected":"Disconnected") +"<br/>"
|
||||
"MQTT Status :" + (MQTT_isConnected() ? "Connected" : "Disconnected") + "<br/>"
|
||||
"<a href=\"/setup\">Setup</a><br/>"
|
||||
"<a href=\"/otamode\">OTA mode</a><br/>"
|
||||
"<a href=\"/gpio?gpio=2&value=1\">ON</a><br/>"
|
||||
@ -27,14 +27,14 @@ void handleSetup() {
|
||||
"<legend>Wifi configuration:</legend>"
|
||||
"<div><label for=\"ssid\">Wifi SSID :</label> <input type=\"text\" name=\"ssid\" value=\"" + String(confSsid) + "\" /></div>"
|
||||
"<div><label for=\"password\">Wifi Password :</label><input type=\"password\" name=\"password\" /> </div>"
|
||||
"<div><label for=\"host\">Hostname :</label><input type=\"text\" name=\"host\" value=\"" + String(confHost) +"\" /> </div>"
|
||||
"<div><label for=\"host\">Hostname :</label><input type=\"text\" name=\"host\" value=\"" + String(confHost) + "\" /> </div>"
|
||||
"</fieldset>"
|
||||
"<fieldset>"
|
||||
"<legend>MQTT:</legend>"
|
||||
"<div><label for=\"mqttServer\">MQTTServer :</label><input type=\"text\" name=\"mqttServer\" value=\""+ String(mqttServer) +"\" /> </div>"
|
||||
"<div><label for=\"mqttUser\">MQTTUsername :</label><input type=\"text\" name=\"mqttUser\" value=\""+ String(mqttUser) +"\" /> </div>"
|
||||
"<div><label for=\"mqttServer\">MQTTServer :</label><input type=\"text\" name=\"mqttServer\" value=\"" + String(mqttServer) + "\" /> </div>"
|
||||
"<div><label for=\"mqttUser\">MQTTUsername :</label><input type=\"text\" name=\"mqttUser\" value=\"" + String(mqttUser) + "\" /> </div>"
|
||||
"<div><label for=\"mqttPasswd\">MQTTPassword :</label><input type=\"password\" name=\"mqttPasswd\" /> </div>"
|
||||
"<div><label for=\"mqttPort\">MQTTPort :</label><input type=\"text\" name=\"mqttPort\" value=\""+ String(mqttPort) +"\" /> </div>"
|
||||
"<div><label for=\"mqttPort\">MQTTPort :</label><input type=\"text\" name=\"mqttPort\" value=\"" + String(mqttPort) + "\" /> </div>"
|
||||
"</fieldset>"
|
||||
"<div class=\"button\"> <button type=\"submit\">Save</button></div>"
|
||||
"</form>");
|
||||
@ -70,7 +70,7 @@ void handleSave() {
|
||||
}
|
||||
|
||||
server.send(200, "text/html", "<h1>Configuration Saved</h1><br/>"
|
||||
"You can reboot now");
|
||||
"<a href=\"/reboot\">Reboot</a><br/>");
|
||||
}
|
||||
|
||||
void handleOTA() {
|
||||
@ -95,12 +95,19 @@ void handleNotFound() {
|
||||
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) {
|
||||
server.on("/", handleRoot);
|
||||
server.on("/setup", handleSetup);
|
||||
server.on("/save", handleSave);
|
||||
server.on("/gpio", handleGpio);
|
||||
server.on("/otamode", handleOTA);
|
||||
server.on("/reboot", handleReboot);
|
||||
|
||||
server.onNotFound(handleNotFound);
|
||||
server.begin();
|
||||
|
Loading…
Reference in New Issue
Block a user