Browse Source

Do not need to be setup to play with gpio or OTA

And reindent
prod_1
Mathieu Maret 5 years ago
parent
commit
5007b652d9
2 changed files with 16 additions and 19 deletions
  1. +7
    -9
      WiFiAccessPointConfigurator/WebServer.ino
  2. +9
    -10
      WifiControlSensor/WebServer.ino

+ 7
- 9
WiFiAccessPointConfigurator/WebServer.ino View File

@ -43,14 +43,14 @@ void handleSave() {
}
server.send(200, "text/html", "<h1>Configuration Saved</h1><br/>"
"You can reboot now");
"You can reboot now");
}
void handleOTA() {
Serial.println("Boot mode Set to OTA");
saveBootMode(BOOTMODE_OTA);
server.send(200, "text/html", "<h1>OTA Mode set</h1><br/>"
"You can reboot now");
Serial.println("Boot mode Set to OTA");
saveBootMode(BOOTMODE_OTA);
server.send(200, "text/html", "<h1>OTA Mode set</h1><br/>"
"You can reboot now");
}
void handleNotFound() {
@ -72,10 +72,8 @@ void setupWebServer(int bootmode) {
server.on("/", handleRoot);
server.on("/setup", handleSetup);
server.on("/save", handleSave);
if (bootmode == BOOTMODE_NORMAL){
server.on("/gpio", handleGpio);
server.on("/otamode", handleOTA);
}
server.on("/gpio", handleGpio);
server.on("/otamode", handleOTA);
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");


+ 9
- 10
WifiControlSensor/WebServer.ino View File

@ -1,6 +1,6 @@
void handleRoot() {
server.send(200, "text/html", "<h1>You are connected</h1><br/>"
"Current temperature "+String(temp,2)+"C<br/>"
"Current temperature " + String(temp, 2) + "C<br/>"
"<a href=\"/setup\">Setup</a><br/>"
"<a href=\"/otamode\">OTA mode</a><br/>"
"<a href=\"/gpio?gpio=2&amp;value=1\">ON</a><br/>"
@ -44,14 +44,14 @@ void handleSave() {
}
server.send(200, "text/html", "<h1>Configuration Saved</h1><br/>"
"You can reboot now");
"You can reboot now");
}
void handleOTA() {
Serial.println("Boot mode Set to OTA");
saveBootMode(BOOTMODE_OTA);
server.send(200, "text/html", "<h1>OTA Mode set</h1><br/>"
"You can reboot now");
Serial.println("Boot mode Set to OTA");
saveBootMode(BOOTMODE_OTA);
server.send(200, "text/html", "<h1>OTA Mode set</h1><br/>"
"You can reboot now");
}
void handleNotFound() {
@ -73,10 +73,9 @@ void setupWebServer(int bootmode) {
server.on("/", handleRoot);
server.on("/setup", handleSetup);
server.on("/save", handleSave);
if (bootmode == BOOTMODE_NORMAL){
server.on("/gpio", handleGpio);
server.on("/otamode", handleOTA);
}
server.on("/gpio", handleGpio);
server.on("/otamode", handleOTA);
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");


Loading…
Cancel
Save