diff --git a/Arduino/CanGrow/include/CanGrow_Webserver.h b/Arduino/CanGrow/include/CanGrow_Webserver.h index 19f7a47..2d3cec0 100644 --- a/Arduino/CanGrow/include/CanGrow_Webserver.h +++ b/Arduino/CanGrow/include/CanGrow_Webserver.h @@ -75,6 +75,7 @@ void SetupWebserver() { /* url handler definition */ webserver.on("/", HTTP_GET, WebPage_root); webserver.on("/cangrow.css", HTTP_GET, WebFile_cangrow_CSS); + webserver.on("/wifiSettings", HTTP_GET, WebPage_wifi); requestLogger.setOutput(Serial); // this activates the middleware diff --git a/Arduino/CanGrow/include/Webserver/Page_root.h b/Arduino/CanGrow/include/Webserver/Page_root.h index 514c544..045b543 100644 --- a/Arduino/CanGrow/include/Webserver/Page_root.h +++ b/Arduino/CanGrow/include/Webserver/Page_root.h @@ -35,9 +35,7 @@ String Proc_WebPage_root(const String& var) { if(TestHeaderFooter(var)) { return AddHeaderFooter(var); - } - - if(var == "LOL") { + } else if(var == "LOL") { return String("Nice"); } else if(var == "LOL") { return String("Jojoojo :)"); diff --git a/Arduino/CanGrow/include/Webserver/Page_wifi.h b/Arduino/CanGrow/include/Webserver/Page_wifi.h index b94b7cd..682b708 100644 --- a/Arduino/CanGrow/include/Webserver/Page_wifi.h +++ b/Arduino/CanGrow/include/Webserver/Page_wifi.h @@ -28,3 +28,34 @@ */ +#include "Page_wifi_HTML.h" + + + +// https://techtutorialsx.com/2018/07/23/esp32-arduino-http-server-template-processing-with-multiple-placeholders/ +String Proc_WebPage_wifi(const String& var) { + if(TestHeaderFooter(var)) { + return AddHeaderFooter(var); + //SNIP_CURRSETTINGS + } else if(var == "CONFIGWIFI_SSID") { + return String(configWifi.ssid); + } else if(var == "CONFIGWIFI_DHCP") { + return String(configWifi.dhcp); + } else if(var == "CONFIGWIFI_IP") { + return String(WiFi.localIP().toString()); + } else if(var == "CONFIGWIFI_NETMASK") { + return String(WiFi.subnetMask().toString()); + } else if(var == "CONFIGWIFI_GATEWAY") { + return String(WiFi.gatewayIP().toString()); + } else if(var == "CONFIGWIFI_DNS") { + return String(WiFi.dnsIP().toString()); + } else if(var == "WIFI_LIST") { + return String(""); + } else { + return String(); + } +} + +void WebPage_wifi(AsyncWebServerRequest *request) { + request->send_P(200, "text/html", Page_wifi_HTML, Proc_WebPage_wifi); +} diff --git a/Arduino/CanGrow/include/Webserver/Page_wifi_HTML.h b/Arduino/CanGrow/include/Webserver/Page_wifi_HTML.h index 28aaa6b..2923b12 100644 --- a/Arduino/CanGrow/include/Webserver/Page_wifi_HTML.h +++ b/Arduino/CanGrow/include/Webserver/Page_wifi_HTML.h @@ -26,3 +26,29 @@ * THE SOFTWARE. * */ + +const char* Page_wifi_HTML PROGMEM = R"(%HEADER% +
Select your wifi network from the SSID list.
+
To use DHCP leave IP, Subnet, Gateway and DNS fields blank!