replacing all old configSystem style variables with config.system.something
This commit is contained in:
parent
4f42b64c7e
commit
94e79b8fa2
8 changed files with 154 additions and 154 deletions
|
@ -143,14 +143,14 @@ bool alrdySaved = false;
|
||||||
void loop() {
|
void loop() {
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
|
|
||||||
if(currentMillis - schedulerPrevMillis >= configSystem.schedulerInterval) {
|
if(currentMillis - schedulerPrevMillis >= config.system.schedulerInterval) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if((digitalRead(PinWIPE) != PinWIPE_default) && (alrdySaved == false)) {
|
if((digitalRead(PinWIPE) != PinWIPE_default) && (alrdySaved == false)) {
|
||||||
Serial.println(":: [LOOP] PinWIPE is triggered, saving config.json and set configSystem.httpLogSerial to true");
|
Serial.println(":: [LOOP] PinWIPE is triggered, saving config.json and set config.system.httpLogSerial to true");
|
||||||
configSystem.httpLogSerial = true;
|
config.system.httpLogSerial = true;
|
||||||
// save config to littlefs as json
|
// save config to littlefs as json
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
// only print json to serial
|
// only print json to serial
|
||||||
|
|
|
@ -181,43 +181,43 @@ bool LoadConfig() {
|
||||||
|
|
||||||
// * WiFi *
|
// * WiFi *
|
||||||
JsonObject objWifi = doc["wifi"][0];
|
JsonObject objWifi = doc["wifi"][0];
|
||||||
strlcpy(configWifi.ssid, objWifi["ssid"], sizeof(configWifi.ssid));
|
strlcpy(config.wifi.ssid, objWifi["ssid"], sizeof(config.wifi.ssid));
|
||||||
strlcpy(configWifi.password, objWifi["password"], sizeof(configWifi.password));
|
strlcpy(config.wifi.password, objWifi["password"], sizeof(config.wifi.password));
|
||||||
// Copy bool / int directly into struct
|
// Copy bool / int directly into struct
|
||||||
configWifi.dhcp = objWifi["dhcp"];
|
config.wifi.dhcp = objWifi["dhcp"];
|
||||||
// load the ip addresses as array
|
// load the ip addresses as array
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i <4 ; i++) {
|
for(i=0; i <4 ; i++) {
|
||||||
configWifi.ip[i] = objWifi["ip"][i];
|
config.wifi.ip[i] = objWifi["ip"][i];
|
||||||
configWifi.netmask[i] = objWifi["netmask"][i];
|
config.wifi.netmask[i] = objWifi["netmask"][i];
|
||||||
configWifi.gateway[i] = objWifi["gateway"][i];
|
config.wifi.gateway[i] = objWifi["gateway"][i];
|
||||||
configWifi.dns[i] = objWifi["dns"][i];
|
config.wifi.dns[i] = objWifi["dns"][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * System *
|
// * System *
|
||||||
JsonObject objSystem = doc["system"][0];
|
JsonObject objSystem = doc["system"][0];
|
||||||
configSystem.ntpOffset = objSystem["ntpOffset"];
|
config.system.ntpOffset = objSystem["ntpOffset"];
|
||||||
configSystem.maintenanceDuration = objSystem["maintenanceDuration"];
|
config.system.maintenanceDuration = objSystem["maintenanceDuration"];
|
||||||
strlcpy(configSystem.esp32camIp, objSystem["esp32camIp"], sizeof(configSystem.esp32camIp));
|
strlcpy(config.system.esp32camIp, objSystem["esp32camIp"], sizeof(config.system.esp32camIp));
|
||||||
strlcpy(configSystem.httpUser, objSystem["httpUser"], sizeof(configSystem.httpUser));
|
strlcpy(config.system.httpUser, objSystem["httpUser"], sizeof(config.system.httpUser));
|
||||||
strlcpy(configSystem.httpPass, objSystem["httpPass"], sizeof(configSystem.httpPass));
|
strlcpy(config.system.httpPass, objSystem["httpPass"], sizeof(config.system.httpPass));
|
||||||
configSystem.httpLogSerial = objSystem["httpLogSerial"];
|
config.system.httpLogSerial = objSystem["httpLogSerial"];
|
||||||
configSystem.schedulerInterval = objSystem["schedulerInterval"];
|
config.system.schedulerInterval = objSystem["schedulerInterval"];
|
||||||
|
|
||||||
// * Grow *
|
// * Grow *
|
||||||
JsonObject objGrow = doc["grow"][0];
|
JsonObject objGrow = doc["grow"][0];
|
||||||
strlcpy(configGrow.growName, objGrow["growName"], sizeof(configGrow.growName));
|
strlcpy(config.grow.growName, objGrow["growName"], sizeof(config.grow.growName));
|
||||||
configGrow.dayOfGrow = objGrow["dayOfGrow"];
|
config.grow.dayOfGrow = objGrow["dayOfGrow"];
|
||||||
configGrow.daysSeed = objGrow["daysSeed"];
|
config.grow.daysSeed = objGrow["daysSeed"];
|
||||||
configGrow.daysVeg = objGrow["daysVeg"];
|
config.grow.daysVeg = objGrow["daysVeg"];
|
||||||
configGrow.daysBloom = objGrow["daysBloom"];
|
config.grow.daysBloom = objGrow["daysBloom"];
|
||||||
configGrow.lightHoursVeg = objGrow["lightHoursVeg"];
|
config.grow.lightHoursVeg = objGrow["lightHoursVeg"];
|
||||||
configGrow.lightHoursBloom = objGrow["lightHoursBloom"];
|
config.grow.lightHoursBloom = objGrow["lightHoursBloom"];
|
||||||
configGrow.sunriseHour = objGrow["sunriseHour"];
|
config.grow.sunriseHour = objGrow["sunriseHour"];
|
||||||
configGrow.sunriseMinute = objGrow["sunriseMinute"];
|
config.grow.sunriseMinute = objGrow["sunriseMinute"];
|
||||||
configGrow.sunFade = objGrow["sunFade"];
|
config.grow.sunFade = objGrow["sunFade"];
|
||||||
configGrow.sunFadeDuration = objGrow["sunFadeDuration"];
|
config.grow.sunFadeDuration = objGrow["sunFadeDuration"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,41 +238,41 @@ bool SaveConfig(bool writeToSerial = false) {
|
||||||
|
|
||||||
// * WiFi *
|
// * WiFi *
|
||||||
JsonObject objWifi = doc["wifi"].add<JsonObject>();
|
JsonObject objWifi = doc["wifi"].add<JsonObject>();
|
||||||
objWifi["ssid"] = configWifi.ssid;
|
objWifi["ssid"] = config.wifi.ssid;
|
||||||
objWifi["password"] = configWifi.password;
|
objWifi["password"] = config.wifi.password;
|
||||||
// save the ip addressess as array
|
// save the ip addressess as array
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i <4 ; i++) {
|
for(i=0; i <4 ; i++) {
|
||||||
objWifi["ip"][i] = configWifi.ip[i];
|
objWifi["ip"][i] = config.wifi.ip[i];
|
||||||
objWifi["netmask"][i] = configWifi.netmask[i];
|
objWifi["netmask"][i] = config.wifi.netmask[i];
|
||||||
objWifi["gateway"][i] = configWifi.gateway[i];
|
objWifi["gateway"][i] = config.wifi.gateway[i];
|
||||||
objWifi["dns"][i] = configWifi.dns[i];
|
objWifi["dns"][i] = config.wifi.dns[i];
|
||||||
}
|
}
|
||||||
objWifi["dhcp"] = configWifi.dhcp;
|
objWifi["dhcp"] = config.wifi.dhcp;
|
||||||
|
|
||||||
// * System *
|
// * System *
|
||||||
JsonObject objSystem = doc["system"].add<JsonObject>();
|
JsonObject objSystem = doc["system"].add<JsonObject>();
|
||||||
objSystem["ntpOffset"] = configSystem.ntpOffset;
|
objSystem["ntpOffset"] = config.system.ntpOffset;
|
||||||
objSystem["maintenanceDuration"] = configSystem.maintenanceDuration;
|
objSystem["maintenanceDuration"] = config.system.maintenanceDuration;
|
||||||
objSystem["esp32camIp"] = configSystem.esp32camIp;
|
objSystem["esp32camIp"] = config.system.esp32camIp;
|
||||||
objSystem["httpUser"] = configSystem.httpUser;
|
objSystem["httpUser"] = config.system.httpUser;
|
||||||
objSystem["httpPass"] = configSystem.httpPass;
|
objSystem["httpPass"] = config.system.httpPass;
|
||||||
objSystem["httpLogSerial"] = configSystem.httpLogSerial;
|
objSystem["httpLogSerial"] = config.system.httpLogSerial;
|
||||||
objSystem["schedulerInterval"] = configSystem.schedulerInterval;
|
objSystem["schedulerInterval"] = config.system.schedulerInterval;
|
||||||
|
|
||||||
// * Grow *
|
// * Grow *
|
||||||
JsonObject objGrow = doc["grow"].add<JsonObject>();
|
JsonObject objGrow = doc["grow"].add<JsonObject>();
|
||||||
objGrow["growName"] = configGrow.growName;
|
objGrow["growName"] = config.grow.growName;
|
||||||
objGrow["dayOfGrow"] = configGrow.dayOfGrow;
|
objGrow["dayOfGrow"] = config.grow.dayOfGrow;
|
||||||
objGrow["daysSeed"] = configGrow.daysSeed;
|
objGrow["daysSeed"] = config.grow.daysSeed;
|
||||||
objGrow["daysVeg"] = configGrow.daysVeg;
|
objGrow["daysVeg"] = config.grow.daysVeg;
|
||||||
objGrow["daysBloom"] = configGrow.daysBloom;
|
objGrow["daysBloom"] = config.grow.daysBloom;
|
||||||
objGrow["lightHoursVeg"] = configGrow.lightHoursVeg;
|
objGrow["lightHoursVeg"] = config.grow.lightHoursVeg;
|
||||||
objGrow["lightHoursBloom"] = configGrow.lightHoursBloom;
|
objGrow["lightHoursBloom"] = config.grow.lightHoursBloom;
|
||||||
objGrow["sunriseHour"] = configGrow.sunriseHour;
|
objGrow["sunriseHour"] = config.grow.sunriseHour;
|
||||||
objGrow["sunriseMinute"] = configGrow.sunriseMinute;
|
objGrow["sunriseMinute"] = config.grow.sunriseMinute;
|
||||||
objGrow["sunFade"] = configGrow.sunFade;
|
objGrow["sunFade"] = config.grow.sunFade;
|
||||||
objGrow["sunFadeDuration"] = configGrow.sunFadeDuration;
|
objGrow["sunFadeDuration"] = config.grow.sunFadeDuration;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* END Building config.json here
|
* END Building config.json here
|
||||||
|
|
|
@ -101,7 +101,7 @@ void Webserver_Init() {
|
||||||
|
|
||||||
requestLogger.setOutput(Serial);
|
requestLogger.setOutput(Serial);
|
||||||
// this activates the middleware
|
// this activates the middleware
|
||||||
if(configSystem.httpLogSerial == true) {
|
if(config.system.httpLogSerial == true) {
|
||||||
Serial.println(":: [Webserver] serial logging: enabled");
|
Serial.println(":: [Webserver] serial logging: enabled");
|
||||||
webserver.addMiddleware(&requestLogger);
|
webserver.addMiddleware(&requestLogger);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,16 +29,16 @@
|
||||||
|
|
||||||
|
|
||||||
void Wifi_Connect() {
|
void Wifi_Connect() {
|
||||||
Serial.printf(":: [WiFi] connecting to SSID: %s\n", configWifi.ssid);
|
Serial.printf(":: [WiFi] connecting to SSID: %s\n", config.wifi.ssid);
|
||||||
WiFi.begin(configWifi.ssid, configWifi.password);
|
WiFi.begin(config.wifi.ssid, config.wifi.password);
|
||||||
if(configWifi.dhcp == false) {
|
if(config.wifi.dhcp == false) {
|
||||||
Serial.println(":: [WiFi] using static ip configuration:");
|
Serial.println(":: [WiFi] using static ip configuration:");
|
||||||
Serial.printf(":: [WiFi] IP : %s\n", IP2Char(configWifi.ip));
|
Serial.printf(":: [WiFi] IP : %s\n", IP2Char(config.wifi.ip));
|
||||||
Serial.printf(":: [WiFi] Netmask: %s\n", IP2Char(configWifi.netmask));
|
Serial.printf(":: [WiFi] Netmask: %s\n", IP2Char(config.wifi.netmask));
|
||||||
Serial.printf(":: [WiFi] Gateway: %s\n", IP2Char(configWifi.gateway));
|
Serial.printf(":: [WiFi] Gateway: %s\n", IP2Char(config.wifi.gateway));
|
||||||
Serial.printf(":: [WiFi] DNS : %s\n", IP2Char(configWifi.dns));
|
Serial.printf(":: [WiFi] DNS : %s\n", IP2Char(config.wifi.dns));
|
||||||
|
|
||||||
WiFi.config(configWifi.ip, configWifi.dns, configWifi.gateway, configWifi.netmask);
|
WiFi.config(config.wifi.ip, config.wifi.dns, config.wifi.gateway, config.wifi.netmask);
|
||||||
} else {
|
} else {
|
||||||
Serial.println(":: [WiFi] using DHCP for ip configuration");
|
Serial.println(":: [WiFi] using DHCP for ip configuration");
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ void Wifi_Connect() {
|
||||||
}
|
}
|
||||||
Serial.println("CONNECTED!");
|
Serial.println("CONNECTED!");
|
||||||
|
|
||||||
if(configWifi.dhcp == true) {
|
if(config.wifi.dhcp == true) {
|
||||||
Serial.println(":: [WiFi] DHCP offered ip configuration:");
|
Serial.println(":: [WiFi] DHCP offered ip configuration:");
|
||||||
Serial.printf(":: [WiFi] IP : %s\n", IP2Char(WiFi.localIP()));
|
Serial.printf(":: [WiFi] IP : %s\n", IP2Char(WiFi.localIP()));
|
||||||
Serial.printf(":: [WiFi] Netmask: %s\n", IP2Char(WiFi.subnetMask()));
|
Serial.printf(":: [WiFi] Netmask: %s\n", IP2Char(WiFi.subnetMask()));
|
||||||
|
@ -63,17 +63,17 @@ void Wifi_Connect() {
|
||||||
|
|
||||||
void Wifi_AP() {
|
void Wifi_AP() {
|
||||||
Serial.printf(":: [WiFi] create access point: %s\n", CANGROW_SSID);
|
Serial.printf(":: [WiFi] create access point: %s\n", CANGROW_SSID);
|
||||||
WiFi.softAPConfig(configWifi.ip, configWifi.gateway, configWifi.netmask);
|
WiFi.softAPConfig(config.wifi.ip, config.wifi.gateway, config.wifi.netmask);
|
||||||
WiFi.softAP(CANGROW_SSID);
|
WiFi.softAP(CANGROW_SSID);
|
||||||
Serial.println(":: [WiFi] access point started:");
|
Serial.println(":: [WiFi] access point started:");
|
||||||
Serial.printf(":: [WiFi] IP : %s\n", IP2Char(configWifi.ip));
|
Serial.printf(":: [WiFi] IP : %s\n", IP2Char(config.wifi.ip));
|
||||||
Serial.printf(":: [WiFi] Netmask: %s\n", IP2Char(configWifi.netmask));
|
Serial.printf(":: [WiFi] Netmask: %s\n", IP2Char(config.wifi.netmask));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wifi_Init() {
|
void Wifi_Init() {
|
||||||
Serial.println(":: [WiFi] initializing");
|
Serial.println(":: [WiFi] initializing");
|
||||||
if(strlen(configWifi.ssid) == 0) {
|
if(strlen(config.wifi.ssid) == 0) {
|
||||||
Serial.println(":: [WiFi] configWifi.ssid is unset");
|
Serial.println(":: [WiFi] config.wifi.ssid is unset");
|
||||||
Wifi_AP();
|
Wifi_AP();
|
||||||
} else {
|
} else {
|
||||||
Wifi_Connect();
|
Wifi_Connect();
|
||||||
|
|
|
@ -60,7 +60,7 @@ String AddHeaderFooter(const String& var) {
|
||||||
} else if(var == "CGBUILD") {
|
} else if(var == "CGBUILD") {
|
||||||
return String(CANGROW_BUILD);
|
return String(CANGROW_BUILD);
|
||||||
} else if(var == "GROWNAME") {
|
} else if(var == "GROWNAME") {
|
||||||
return String(configGrow.growName);
|
return String(config.grow.growName);
|
||||||
} else if(var == "CANGROW_CSS") {
|
} else if(var == "CANGROW_CSS") {
|
||||||
return String(File_cangrow_CSS);
|
return String(File_cangrow_CSS);
|
||||||
} else if(var == "NEED_RESTART") {
|
} else if(var == "NEED_RESTART") {
|
||||||
|
|
|
@ -122,10 +122,10 @@ void WebPage_system_update_ApplyUpdate(AsyncWebServerRequest *request, String fi
|
||||||
|
|
||||||
String Proc_WebPage_system_update_POST(const String& var) {
|
String Proc_WebPage_system_update_POST(const String& var) {
|
||||||
if(var == "CONFIGWIFI_IP") {
|
if(var == "CONFIGWIFI_IP") {
|
||||||
if(configWifi.dhcp == true) {
|
if(config.wifi.dhcp == true) {
|
||||||
return WiFi.localIP().toString();
|
return WiFi.localIP().toString();
|
||||||
} else {
|
} else {
|
||||||
return String(IP2Char(configWifi.ip));
|
return String(IP2Char(config.wifi.ip));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return String();
|
return String();
|
||||||
|
|
|
@ -58,15 +58,15 @@ String Proc_WebPage_wifi(const String& var) {
|
||||||
return AddHeaderFooter(var);
|
return AddHeaderFooter(var);
|
||||||
//CURRENT_SETTINGS
|
//CURRENT_SETTINGS
|
||||||
} else if(var == "CURRENT_SETTINGS") {
|
} else if(var == "CURRENT_SETTINGS") {
|
||||||
if(strlen(configWifi.ssid) > 0) {
|
if(strlen(config.wifi.ssid) > 0) {
|
||||||
return String(Page_wifi_HTML_CURRENT_SETTINGS);
|
return String(Page_wifi_HTML_CURRENT_SETTINGS);
|
||||||
} else {
|
} else {
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
} else if(var == "CONFIGWIFI_SSID") {
|
} else if(var == "CONFIGWIFI_SSID") {
|
||||||
return String(configWifi.ssid);
|
return String(config.wifi.ssid);
|
||||||
} else if(var == "CONFIGWIFI_DHCP") {
|
} else if(var == "CONFIGWIFI_DHCP") {
|
||||||
return String(configWifi.dhcp);
|
return String(config.wifi.dhcp);
|
||||||
} else if(var == "CONFIGWIFI_IP") {
|
} else if(var == "CONFIGWIFI_IP") {
|
||||||
return String(WiFi.localIP().toString());
|
return String(WiFi.localIP().toString());
|
||||||
} else if(var == "CONFIGWIFI_NETMASK") {
|
} else if(var == "CONFIGWIFI_NETMASK") {
|
||||||
|
@ -102,93 +102,93 @@ String Proc_WebPage_wifi_POST_ERR(const String& var) {
|
||||||
void WebPage_wifi(AsyncWebServerRequest *request) {
|
void WebPage_wifi(AsyncWebServerRequest *request) {
|
||||||
|
|
||||||
if(request->method() == HTTP_POST) {
|
if(request->method() == HTTP_POST) {
|
||||||
if(request->hasParam("configWifi.ssid", true)) {
|
if(request->hasParam("config.wifi.ssid", true)) {
|
||||||
const AsyncWebParameter* p_ssid = request->getParam("configWifi.ssid", true);
|
const AsyncWebParameter* p_ssid = request->getParam("config.wifi.ssid", true);
|
||||||
Serial.printf(":: [Webserver:wifi] POST[%s]: %s\n", p_ssid->name().c_str(), p_ssid->value().c_str());
|
Serial.printf(":: [Webserver:wifi] POST[%s]: %s\n", p_ssid->name().c_str(), p_ssid->value().c_str());
|
||||||
strlcpy(configWifi.ssid, p_ssid->value().c_str(), sizeof(configWifi.ssid));
|
strlcpy(config.wifi.ssid, p_ssid->value().c_str(), sizeof(config.wifi.ssid));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(request->hasParam("configWifi.password", true)) {
|
if(request->hasParam("config.wifi.password", true)) {
|
||||||
const AsyncWebParameter* p_password = request->getParam("configWifi.password", true);
|
const AsyncWebParameter* p_password = request->getParam("config.wifi.password", true);
|
||||||
Serial.printf(":: [Webserver:wifi] POST[%s]: %s\n", p_password->name().c_str(), p_password->value().c_str());
|
Serial.printf(":: [Webserver:wifi] POST[%s]: %s\n", p_password->name().c_str(), p_password->value().c_str());
|
||||||
strlcpy(configWifi.password, p_password->value().c_str(), sizeof(configWifi.password));
|
strlcpy(config.wifi.password, p_password->value().c_str(), sizeof(config.wifi.password));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(
|
if(
|
||||||
(request->hasParam("configWifi.ip0", true)) &&
|
(request->hasParam("config.wifi.ip0", true)) &&
|
||||||
(request->hasParam("configWifi.ip1", true)) &&
|
(request->hasParam("config.wifi.ip1", true)) &&
|
||||||
(request->hasParam("configWifi.ip2", true)) &&
|
(request->hasParam("config.wifi.ip2", true)) &&
|
||||||
(request->hasParam("configWifi.ip3", true))) {
|
(request->hasParam("config.wifi.ip3", true))) {
|
||||||
|
|
||||||
const AsyncWebParameter* p_ip0 = request->getParam("configWifi.ip0", true);
|
const AsyncWebParameter* p_ip0 = request->getParam("config.wifi.ip0", true);
|
||||||
const AsyncWebParameter* p_ip1 = request->getParam("configWifi.ip1", true);
|
const AsyncWebParameter* p_ip1 = request->getParam("config.wifi.ip1", true);
|
||||||
const AsyncWebParameter* p_ip2 = request->getParam("configWifi.ip2", true);
|
const AsyncWebParameter* p_ip2 = request->getParam("config.wifi.ip2", true);
|
||||||
const AsyncWebParameter* p_ip3 = request->getParam("configWifi.ip3", true);
|
const AsyncWebParameter* p_ip3 = request->getParam("config.wifi.ip3", true);
|
||||||
Serial.printf(":: [Webserver:wifi] POST[configWifi.ip0-3]: %s . %s . %s . %s\n", p_ip0->value().c_str(), p_ip1->value().c_str(), p_ip2->value().c_str(), p_ip3->value().c_str());
|
Serial.printf(":: [Webserver:wifi] POST[config.wifi.ip0-3]: %s . %s . %s . %s\n", p_ip0->value().c_str(), p_ip1->value().c_str(), p_ip2->value().c_str(), p_ip3->value().c_str());
|
||||||
configWifi.ip[0] = p_ip0->value().toInt();
|
config.wifi.ip[0] = p_ip0->value().toInt();
|
||||||
configWifi.ip[1] = p_ip1->value().toInt();
|
config.wifi.ip[1] = p_ip1->value().toInt();
|
||||||
configWifi.ip[2] = p_ip2->value().toInt();
|
config.wifi.ip[2] = p_ip2->value().toInt();
|
||||||
configWifi.ip[3] = p_ip3->value().toInt();
|
config.wifi.ip[3] = p_ip3->value().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(
|
if(
|
||||||
(request->hasParam("configWifi.netmask0", true)) &&
|
(request->hasParam("config.wifi.netmask0", true)) &&
|
||||||
(request->hasParam("configWifi.netmask1", true)) &&
|
(request->hasParam("config.wifi.netmask1", true)) &&
|
||||||
(request->hasParam("configWifi.netmask2", true)) &&
|
(request->hasParam("config.wifi.netmask2", true)) &&
|
||||||
(request->hasParam("configWifi.netmask3", true))) {
|
(request->hasParam("config.wifi.netmask3", true))) {
|
||||||
|
|
||||||
const AsyncWebParameter* p_netmask0 = request->getParam("configWifi.netmask0", true);
|
const AsyncWebParameter* p_netmask0 = request->getParam("config.wifi.netmask0", true);
|
||||||
const AsyncWebParameter* p_netmask1 = request->getParam("configWifi.netmask1", true);
|
const AsyncWebParameter* p_netmask1 = request->getParam("config.wifi.netmask1", true);
|
||||||
const AsyncWebParameter* p_netmask2 = request->getParam("configWifi.netmask2", true);
|
const AsyncWebParameter* p_netmask2 = request->getParam("config.wifi.netmask2", true);
|
||||||
const AsyncWebParameter* p_netmask3 = request->getParam("configWifi.netmask3", true);
|
const AsyncWebParameter* p_netmask3 = request->getParam("config.wifi.netmask3", true);
|
||||||
Serial.printf(":: [Webserver:wifi] POST[configWifi.netmask0-3]: %s . %s . %s . %s\n", p_netmask0->value().c_str(), p_netmask1->value().c_str(), p_netmask2->value().c_str(), p_netmask3->value().c_str());
|
Serial.printf(":: [Webserver:wifi] POST[config.wifi.netmask0-3]: %s . %s . %s . %s\n", p_netmask0->value().c_str(), p_netmask1->value().c_str(), p_netmask2->value().c_str(), p_netmask3->value().c_str());
|
||||||
configWifi.netmask[0] = p_netmask0->value().toInt();
|
config.wifi.netmask[0] = p_netmask0->value().toInt();
|
||||||
configWifi.netmask[1] = p_netmask1->value().toInt();
|
config.wifi.netmask[1] = p_netmask1->value().toInt();
|
||||||
configWifi.netmask[2] = p_netmask2->value().toInt();
|
config.wifi.netmask[2] = p_netmask2->value().toInt();
|
||||||
configWifi.netmask[3] = p_netmask3->value().toInt();
|
config.wifi.netmask[3] = p_netmask3->value().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
(request->hasParam("configWifi.gateway0", true)) &&
|
(request->hasParam("config.wifi.gateway0", true)) &&
|
||||||
(request->hasParam("configWifi.gateway1", true)) &&
|
(request->hasParam("config.wifi.gateway1", true)) &&
|
||||||
(request->hasParam("configWifi.gateway2", true)) &&
|
(request->hasParam("config.wifi.gateway2", true)) &&
|
||||||
(request->hasParam("configWifi.gateway3", true))) {
|
(request->hasParam("config.wifi.gateway3", true))) {
|
||||||
|
|
||||||
const AsyncWebParameter* p_gateway0 = request->getParam("configWifi.gateway0", true);
|
const AsyncWebParameter* p_gateway0 = request->getParam("config.wifi.gateway0", true);
|
||||||
const AsyncWebParameter* p_gateway1 = request->getParam("configWifi.gateway1", true);
|
const AsyncWebParameter* p_gateway1 = request->getParam("config.wifi.gateway1", true);
|
||||||
const AsyncWebParameter* p_gateway2 = request->getParam("configWifi.gateway2", true);
|
const AsyncWebParameter* p_gateway2 = request->getParam("config.wifi.gateway2", true);
|
||||||
const AsyncWebParameter* p_gateway3 = request->getParam("configWifi.gateway3", true);
|
const AsyncWebParameter* p_gateway3 = request->getParam("config.wifi.gateway3", true);
|
||||||
Serial.printf(":: [Webserver:wifi] POST[configWifi.gateway0-3]: %s . %s . %s . %s\n", p_gateway0->value().c_str(), p_gateway1->value().c_str(), p_gateway2->value().c_str(), p_gateway3->value().c_str());
|
Serial.printf(":: [Webserver:wifi] POST[config.wifi.gateway0-3]: %s . %s . %s . %s\n", p_gateway0->value().c_str(), p_gateway1->value().c_str(), p_gateway2->value().c_str(), p_gateway3->value().c_str());
|
||||||
configWifi.gateway[0] = p_gateway0->value().toInt();
|
config.wifi.gateway[0] = p_gateway0->value().toInt();
|
||||||
configWifi.gateway[1] = p_gateway1->value().toInt();
|
config.wifi.gateway[1] = p_gateway1->value().toInt();
|
||||||
configWifi.gateway[2] = p_gateway2->value().toInt();
|
config.wifi.gateway[2] = p_gateway2->value().toInt();
|
||||||
configWifi.gateway[3] = p_gateway3->value().toInt();
|
config.wifi.gateway[3] = p_gateway3->value().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
(request->hasParam("configWifi.dns0", true)) &&
|
(request->hasParam("config.wifi.dns0", true)) &&
|
||||||
(request->hasParam("configWifi.dns1", true)) &&
|
(request->hasParam("config.wifi.dns1", true)) &&
|
||||||
(request->hasParam("configWifi.dns2", true)) &&
|
(request->hasParam("config.wifi.dns2", true)) &&
|
||||||
(request->hasParam("configWifi.dns3", true))) {
|
(request->hasParam("config.wifi.dns3", true))) {
|
||||||
|
|
||||||
const AsyncWebParameter* p_dns0 = request->getParam("configWifi.dns0", true);
|
const AsyncWebParameter* p_dns0 = request->getParam("config.wifi.dns0", true);
|
||||||
const AsyncWebParameter* p_dns1 = request->getParam("configWifi.dns1", true);
|
const AsyncWebParameter* p_dns1 = request->getParam("config.wifi.dns1", true);
|
||||||
const AsyncWebParameter* p_dns2 = request->getParam("configWifi.dns2", true);
|
const AsyncWebParameter* p_dns2 = request->getParam("config.wifi.dns2", true);
|
||||||
const AsyncWebParameter* p_dns3 = request->getParam("configWifi.dns3", true);
|
const AsyncWebParameter* p_dns3 = request->getParam("config.wifi.dns3", true);
|
||||||
Serial.printf(":: [Webserver:wifi] POST[configWifi.dns0-3]: %s . %s . %s . %s\n", p_dns0->value().c_str(), p_dns1->value().c_str(), p_dns2->value().c_str(), p_dns3->value().c_str());
|
Serial.printf(":: [Webserver:wifi] POST[config.wifi.dns0-3]: %s . %s . %s . %s\n", p_dns0->value().c_str(), p_dns1->value().c_str(), p_dns2->value().c_str(), p_dns3->value().c_str());
|
||||||
configWifi.dns[0] = p_dns0->value().toInt();
|
config.wifi.dns[0] = p_dns0->value().toInt();
|
||||||
configWifi.dns[1] = p_dns1->value().toInt();
|
config.wifi.dns[1] = p_dns1->value().toInt();
|
||||||
configWifi.dns[2] = p_dns2->value().toInt();
|
config.wifi.dns[2] = p_dns2->value().toInt();
|
||||||
configWifi.dns[3] = p_dns3->value().toInt();
|
config.wifi.dns[3] = p_dns3->value().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(request->hasParam("configWifi.dhcp", true)) {
|
if(request->hasParam("config.wifi.dhcp", true)) {
|
||||||
const AsyncWebParameter* p_dhcp = request->getParam("configWifi.dhcp", true);
|
const AsyncWebParameter* p_dhcp = request->getParam("config.wifi.dhcp", true);
|
||||||
Serial.printf(":: [Webserver:wifi] POST[%s]: %s\n", p_dhcp->name().c_str(), p_dhcp->value().c_str());
|
Serial.printf(":: [Webserver:wifi] POST[%s]: %s\n", p_dhcp->name().c_str(), p_dhcp->value().c_str());
|
||||||
configWifi.dhcp = p_dhcp->value().toInt();
|
config.wifi.dhcp = p_dhcp->value().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SaveConfig()) {
|
if(SaveConfig()) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ const char* Page_wifi_HTML PROGMEM = R"(%HEADER%
|
||||||
<form method='post' action='/wifi/'>
|
<form method='post' action='/wifi/'>
|
||||||
|
|
||||||
<u>SSID</u>:<br>
|
<u>SSID</u>:<br>
|
||||||
<select id='configWifi.ssid' name='configWifi.ssid' required>
|
<select id='config.wifi.ssid' name='config.wifi.ssid' required>
|
||||||
<option disabled value='' selected hidden>-Select your network-</option>
|
<option disabled value='' selected hidden>-Select your network-</option>
|
||||||
|
|
||||||
%WIFI_LIST%
|
%WIFI_LIST%
|
||||||
|
@ -46,38 +46,38 @@ const char* Page_wifi_HTML PROGMEM = R"(%HEADER%
|
||||||
</select><br>
|
</select><br>
|
||||||
|
|
||||||
<u>Password</u>:<br>
|
<u>Password</u>:<br>
|
||||||
<input type='password' name='configWifi.password'><br>
|
<input type='password' name='config.wifi.password'><br>
|
||||||
|
|
||||||
<u>DHCP</u>:<br>
|
<u>DHCP</u>:<br>
|
||||||
<select name='configWifi.dhcp' required>
|
<select name='config.wifi.dhcp' required>
|
||||||
<option disabled value='' selected hidden>---</option>
|
<option disabled value='' selected hidden>---</option>
|
||||||
<option value='1'>On</option>
|
<option value='1'>On</option>
|
||||||
<option value='0'>Off</option>
|
<option value='0'>Off</option>
|
||||||
</select><br>
|
</select><br>
|
||||||
|
|
||||||
<u>IP</u>:<br>
|
<u>IP</u>:<br>
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.ip0'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.ip0'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.ip1'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.ip1'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.ip2'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.ip2'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.ip3'><br>
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.ip3'><br>
|
||||||
|
|
||||||
<u>Netmask</u>:<br>
|
<u>Netmask</u>:<br>
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.netmask0'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.netmask0'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.netmask1'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.netmask1'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.netmask2'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.netmask2'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.netmask3'><br>
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.netmask3'><br>
|
||||||
|
|
||||||
<u>Gateway</u>:<br>
|
<u>Gateway</u>:<br>
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.gateway0'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.gateway0'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.gateway1'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.gateway1'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.gateway2'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.gateway2'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.gateway3'><br>
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.gateway3'><br>
|
||||||
|
|
||||||
<u>DNS</u>:<br>
|
<u>DNS</u>:<br>
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.dns0'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.dns0'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.dns1'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.dns1'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.dns2'> .
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.dns2'> .
|
||||||
<input class='inputShort' type='number' min='0' max='255' name='configWifi.dns3'><br>
|
<input class='inputShort' type='number' min='0' max='255' name='config.wifi.dns3'><br>
|
||||||
|
|
||||||
|
|
||||||
<input type='submit' value='💾 Save settings'>
|
<input type='submit' value='💾 Save settings'>
|
||||||
|
|
Loading…
Reference in a new issue