Commit 8d0b536d authored by Jerome Courat's avatar Jerome Courat

Added missing WiFi configuration parameters

parent 09ef3b69
......@@ -13,6 +13,10 @@ struct WifiConfiguration
boolean wifi_sta_active;
String wifi_sta_ssid;
String wifi_sta_pwd;
String wifi_sta_mode; // either "dhcp" or "static"
String wifi_sta_network_ip;
String wifi_sta_network_netmask;
String wifi_sta_network_gateway;
};
extern WifiConfiguration wifi_settings;
......
......@@ -30,13 +30,14 @@ boolean readWifiSettings()
// use configFile.readString instead.
configFile.readBytes(buf.get(), size);
// ArduinoJson 6 migration now...
StaticJsonDocument<200> doc;
StaticJsonDocument<400> doc;
auto error = deserializeJson(doc, buf.get());
if (error)
{
Serial.println("Failed to parse config file");
Serial.println(error.c_str());
LittleFS.end();
return false;
}
......@@ -54,6 +55,13 @@ boolean readWifiSettings()
wifi_settings.wifi_sta_active = doc["wifi"]["sta"]["enabled"].as<boolean>();
wifi_settings.wifi_sta_ssid = doc["wifi"]["sta"]["ssid"].as<String>();
wifi_settings.wifi_sta_pwd = doc["wifi"]["sta"]["password"].as<String>();
wifi_settings.wifi_sta_mode = doc["wifi"]["sta"]["mode"].as<String>();
if (strcmp(wifi_settings.wifi_sta_mode.c_str(), "static") == 0)
{
wifi_settings.wifi_sta_network_ip = doc["wifi"]["sta"]["network"]["ip"].as<String>();
wifi_settings.wifi_sta_network_gateway = doc["wifi"]["sta"]["network"]["gateway"].as<String>();
wifi_settings.wifi_sta_network_netmask = doc["wifi"]["sta"]["network"]["subnet"].as<String>();
}
Serial.println("End of Wifi Config");
LittleFS.end();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment