From 5007b652d93eada560acf8bc333cc66625a40d19 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Fri, 11 Mar 2016 01:41:21 +0100 Subject: [PATCH] Do not need to be setup to play with gpio or OTA And reindent --- WiFiAccessPointConfigurator/WebServer.ino | 16 +++++++--------- WifiControlSensor/WebServer.ino | 19 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/WiFiAccessPointConfigurator/WebServer.ino b/WiFiAccessPointConfigurator/WebServer.ino index 9c8fbb2..df6cc31 100644 --- a/WiFiAccessPointConfigurator/WebServer.ino +++ b/WiFiAccessPointConfigurator/WebServer.ino @@ -43,14 +43,14 @@ void handleSave() { } server.send(200, "text/html", "

Configuration Saved


" - "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", "

OTA Mode set


" - "You can reboot now"); + Serial.println("Boot mode Set to OTA"); + saveBootMode(BOOTMODE_OTA); + server.send(200, "text/html", "

OTA Mode set


" + "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"); diff --git a/WifiControlSensor/WebServer.ino b/WifiControlSensor/WebServer.ino index f6e13bb..607b1e3 100644 --- a/WifiControlSensor/WebServer.ino +++ b/WifiControlSensor/WebServer.ino @@ -1,6 +1,6 @@ void handleRoot() { server.send(200, "text/html", "

You are connected


" - "Current temperature "+String(temp,2)+"C
" + "Current temperature " + String(temp, 2) + "C
" "Setup
" "OTA mode
" "ON
" @@ -44,14 +44,14 @@ void handleSave() { } server.send(200, "text/html", "

Configuration Saved


" - "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", "

OTA Mode set


" - "You can reboot now"); + Serial.println("Boot mode Set to OTA"); + saveBootMode(BOOTMODE_OTA); + server.send(200, "text/html", "

OTA Mode set


" + "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");