From cda9ae65c8ed6bf97ef7d4a1705b047dc6702c8f Mon Sep 17 00:00:00 2001 From: lorol Date: Thu, 12 Mar 2020 10:32:06 -0400 Subject: [PATCH] Added an authentication define to SmartSwitch.ino to be able to activate on all static pages. Same credentials as the /edit --- examples/SmartSwitch/README.md | 8 ++++---- examples/SmartSwitch/SmartSwitch.ino | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/SmartSwitch/README.md b/examples/SmartSwitch/README.md index fc0bdfa..1a9c83e 100644 --- a/examples/SmartSwitch/README.md +++ b/examples/SmartSwitch/README.md @@ -1,11 +1,11 @@ -![](SCREENSHOT.PNG) ![](AWIFIMAN.JPG) +![](AWIFIMAN.JPG) ![](SCREENSHOT.PNG) ## SmartSwitch -* Based on ESP_AsyncFSBrowser -* Temperature Control for heater with schedule for car block heater or battery charger +* Remote Temperature Control application with schedule (example car block heater or battery charger) +* Based on the ESP_AsyncFSBrowser example * Wide browser compatibility, no extra server-side needed. * HTTP server and WebSocket, single port -* Standalone, no JS dependencies for the browser from Internet (I hope) +* Standalone, no JS dependencies for the browser from Internet (I hope), ace editor included * Added ESPAsyncWiFiManager * Real Time (NTP) w/ Time Zones * Memorized settings to EEPROM diff --git a/examples/SmartSwitch/SmartSwitch.ino b/examples/SmartSwitch/SmartSwitch.ino index e7927a1..a1d2c95 100644 --- a/examples/SmartSwitch/SmartSwitch.ino +++ b/examples/SmartSwitch/SmartSwitch.ino @@ -13,7 +13,8 @@ Multiple clients can be connected at same time, they see each other requests Use latest ESP core lib (from github) */ -#define USE_WFM // to use ESPAsyncWiFiManager +#define USE_WFM // to use ESPAsyncWiFiManager +#define USE_AUTH // .setAuthentication for all static #include #ifdef ESP32 @@ -449,8 +450,11 @@ void setup(){ request->send(200, "text/plain","Erasing WiFi data ..."); }); - server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm"); //.setAuthentication(http_username,http_password); //append or remove auth part - +#ifdef USE_AUTH + server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm").setAuthentication(http_username,http_password); +#else + server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm"); +#endif server.onNotFound([](AsyncWebServerRequest *request){ // nothing known Serial.print(F("NOT_FOUND: "));