mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2025-12-06 07:42:00 +01:00
+ after reading: https://github.com/espressif/arduino-esp32/issues/1202
rethink implementation overall
This commit is contained in:
parent
53a3f05a32
commit
d69e014beb
|
|
@ -8,13 +8,12 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen
|
||||||
if (data.containsKey("callsign"))
|
if (data.containsKey("callsign"))
|
||||||
conf.callsign = data["callsign"].as<String>();
|
conf.callsign = data["callsign"].as<String>();
|
||||||
|
|
||||||
if (data.containsKey("eth") && data["eth"].containsKey("DHCP")) {
|
if (data.containsKey("network") && data["network"].containsKey("DHCP")) {
|
||||||
conf.eth.DHCP = data["eth"]["DHCP"];
|
conf.network.DHCP = data["network"]["DHCP"];
|
||||||
conf.eth.staticIP.fromString(data["eth"]["staticIP"].as<String>());
|
conf.network.staticIP.fromString(data["network"]["staticIP"].as<String>());
|
||||||
conf.eth.subnet.fromString(data["eth"]["subnet"].as<String>());
|
conf.network.subnet.fromString(data["network"]["subnet"].as<String>());
|
||||||
conf.eth.gateway.fromString(data["eth"]["gateway"].as<String>());
|
conf.network.gateway.fromString(data["network"]["gateway"].as<String>());
|
||||||
conf.eth.dns1.fromString(data["eth"]["dns1"].as<String>());
|
conf.network.dns.fromString(data["network"]["dns"].as<String>());
|
||||||
conf.eth.dns2.fromString(data["eth"]["dns2"].as<String>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
|
JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
|
||||||
|
|
@ -22,17 +21,8 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen
|
||||||
Configuration::Wifi::AP ap;
|
Configuration::Wifi::AP ap;
|
||||||
ap.SSID = v["SSID"].as<String>();
|
ap.SSID = v["SSID"].as<String>();
|
||||||
ap.password = v["password"].as<String>();
|
ap.password = v["password"].as<String>();
|
||||||
if (v.containsKey("DHCP")) {
|
|
||||||
ap.DHCP = v["DHCP"];
|
|
||||||
ap.staticIP.fromString(v["staticIP"].as<String>());
|
|
||||||
ap.subnet.fromString(v["subnet"].as<String>());
|
|
||||||
ap.gateway.fromString(v["Gateway"].as<String>());
|
|
||||||
ap.dns1.fromString(v["dns1"].as<String>());
|
|
||||||
ap.dns2.fromString(v["dns2"].as<String>());
|
|
||||||
}
|
|
||||||
conf.wifi.APs.push_back(ap);
|
conf.wifi.APs.push_back(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.containsKey("beacon") && data["beacon"].containsKey("message"))
|
if (data.containsKey("beacon") && data["beacon"].containsKey("message"))
|
||||||
conf.beacon.message = data["beacon"]["message"].as<String>();
|
conf.beacon.message = data["beacon"]["message"].as<String>();
|
||||||
conf.beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0;
|
conf.beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0;
|
||||||
|
|
@ -82,13 +72,12 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen
|
||||||
void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &conf, DynamicJsonDocument &data) {
|
void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &conf, DynamicJsonDocument &data) {
|
||||||
data["callsign"] = conf.callsign;
|
data["callsign"] = conf.callsign;
|
||||||
|
|
||||||
if (conf.eth.DHCP == false) {
|
if (conf.network.DHCP == false) {
|
||||||
data["eth"]["DHCP"] = conf.eth.DHCP;
|
data["network"]["DHCP"] = conf.network.DHCP;
|
||||||
data["eth"]["staticIP"] = conf.eth.staticIP.toString();
|
data["network"]["staticIP"] = conf.network.staticIP.toString();
|
||||||
data["eth"]["subnet"] = conf.eth.subnet.toString();
|
data["network"]["subnet"] = conf.network.subnet.toString();
|
||||||
data["eth"]["gateway"] = conf.eth.gateway.toString();
|
data["network"]["gateway"] = conf.network.gateway.toString();
|
||||||
data["eth"]["dns1"] = conf.eth.dns1.toString();
|
data["network"]["dns"] = conf.network.dns.toString();
|
||||||
data["eth"]["dns2"] = conf.eth.dns2.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArray aps = data["wifi"].createNestedArray("AP");
|
JsonArray aps = data["wifi"].createNestedArray("AP");
|
||||||
|
|
@ -96,16 +85,7 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co
|
||||||
JsonObject v = aps.createNestedObject();
|
JsonObject v = aps.createNestedObject();
|
||||||
v["SSID"] = ap.SSID;
|
v["SSID"] = ap.SSID;
|
||||||
v["password"] = ap.password;
|
v["password"] = ap.password;
|
||||||
if (ap.DHCP == false) {
|
|
||||||
v["DHCP"] = ap.DHCP;
|
|
||||||
v["staticIP"] = ap.staticIP.toString();
|
|
||||||
v["subnet"] = ap.subnet.toString();
|
|
||||||
v["gateway"] = ap.gateway.toString();
|
|
||||||
v["dns1"] = ap.dns1.toString();
|
|
||||||
v["dns2"] = ap.dns2.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data["beacon"]["message"] = conf.beacon.message;
|
data["beacon"]["message"] = conf.beacon.message;
|
||||||
data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude;
|
data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude;
|
||||||
data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude;
|
data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude;
|
||||||
|
|
|
||||||
|
|
@ -6,34 +6,24 @@
|
||||||
|
|
||||||
class Configuration {
|
class Configuration {
|
||||||
public:
|
public:
|
||||||
class ETH {
|
class NETWORK {
|
||||||
public:
|
public:
|
||||||
ETH() : DHCP(true) {
|
NETWORK() : DHCP(true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DHCP;
|
bool DHCP;
|
||||||
IPAddress staticIP;
|
IPAddress staticIP;
|
||||||
IPAddress subnet;
|
IPAddress subnet;
|
||||||
IPAddress gateway;
|
IPAddress gateway;
|
||||||
IPAddress dns1;
|
IPAddress dns;
|
||||||
IPAddress dns2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Wifi {
|
class Wifi {
|
||||||
public:
|
public:
|
||||||
class AP {
|
class AP {
|
||||||
public:
|
public:
|
||||||
AP() : DHCP(true) {
|
String SSID;
|
||||||
}
|
String password;
|
||||||
|
|
||||||
String SSID;
|
|
||||||
String password;
|
|
||||||
bool DHCP;
|
|
||||||
IPAddress staticIP;
|
|
||||||
IPAddress subnet;
|
|
||||||
IPAddress gateway;
|
|
||||||
IPAddress dns1;
|
|
||||||
IPAddress dns2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Wifi() {
|
Wifi() {
|
||||||
|
|
@ -115,7 +105,7 @@ public:
|
||||||
Configuration() : callsign("NOCALL-10"), board(""), ntpServer("pool.ntp.org"){};
|
Configuration() : callsign("NOCALL-10"), board(""), ntpServer("pool.ntp.org"){};
|
||||||
|
|
||||||
String callsign;
|
String callsign;
|
||||||
ETH eth;
|
NETWORK network;
|
||||||
Wifi wifi;
|
Wifi wifi;
|
||||||
Beacon beacon;
|
Beacon beacon;
|
||||||
APRS_IS aprs_is;
|
APRS_IS aprs_is;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue