add wifiSettings page , wip

This commit is contained in:
Marcus 2024-10-20 15:52:25 +02:00
parent b5991a576b
commit 6e4127398b
5 changed files with 60 additions and 4 deletions

View file

@ -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

View file

@ -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 :)");

View file

@ -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);
}

View file

@ -26,3 +26,29 @@
* THE SOFTWARE.
*
*/
const char* Page_wifi_HTML PROGMEM = R"(%HEADER%
<h2>&#128225; WiFi settings</h2>
%SNIP_CURRSETTINGS%
<p>Select your wifi network from the SSID list.
<br>To use DHCP leave IP, Subnet, Gateway and DNS fields blank!</p>
<form method='post' action='/wifiSettings/save'>
SSID: <select id='configWifi.ssid' name='configWifi.ssid' required>
<option disabled value='' selected hidden>-Select your network-</option>
%WIFI_LIST%
</select><br>
Password: <input type='password' name='configWifi.password'><br>
IP: <input type='text' name='configWifi.ip'><br>
Subnet mask: <input type='text' name='configWifi.netmask'><br>
Gateway: <input type='text' name='configWifi.gateway'><br>
DNS: <input type='text' name='configWifi.dns'><br>
<input type='submit' value='&#x1F4BE; Save settings'>
</form>
%FOOTER%)";
const char* Page_wifi_HTML_curSettings PROGMEM = R"(<u>Current Settings:</u><br>WiFi SSID: <b>%CONFIGWIFI_SSID%</b><br>
Use DHCP: <b>%CONFIGWIFI_DHCP%</b><br>
IP address: <b>%CONFIGWIFI_IP%</b><br>
Subnet mask: <b>%CONFIGWIFI_NETMASK%</b><br>
Gateway: <b>%CONFIGWIFI_GATEWAY%</b><br>
DNS: <b>%CONFIGWIFI_DNS%</b><br><br>)";

View file

@ -42,7 +42,7 @@ const char* Header_HTML PROGMEM = R"(<!DOCTYPE html>
<ul class='nav'><li><a href='/'>&#x1F331; %GROWNAME%</a></li>
<li><a href='/growSettings' >&#128262; Grow settings</a></li>
<li><a href='/systemSettings' >&#9881; System settings</a></li>
<li><a href='/wifiSettings' class='activeMenu'>&#128225; WiFi settings</a></li>
<li><a href='/wifiSettings' >&#128225; WiFi settings</a></li>
<li><a href='/help' >&#x2753; Help</a></li>
<li><span class='MenuTime'>05:01:40</span></li>
<li><a href='https://git.la10cy.net/DeltaLima/CanGrow' target='_blank'>CanGrow v%CGVER% - %CGBUILD%</a></li>