SpejsNode: add JSON network configuration loading
parent
5879a80f48
commit
24924811b2
|
@ -58,7 +58,21 @@ void SpejsNode::loadJSON(std::vector<EndpointInitializer> initializers) {
|
||||||
if (root.containsKey("name"))
|
if (root.containsKey("name"))
|
||||||
deviceType = (root["name"]).asString();
|
deviceType = (root["name"]).asString();
|
||||||
|
|
||||||
JsonObject& data = root["endpoints"].asObject();
|
JsonArray& networks = root.get<JsonArray&>("networks");
|
||||||
|
if (networks.success() && networks.size()) {
|
||||||
|
debugf("got networks");
|
||||||
|
JsonObject& network = networks.get<JsonObject&>(0);
|
||||||
|
|
||||||
|
if (network.success() && network.containsKey("ssid")) {
|
||||||
|
debugf("Loaded JSON network configuration");
|
||||||
|
wifiSSID = network["ssid"].as<String>();
|
||||||
|
wifiPassword = network["psk"].as<String>();
|
||||||
|
} else {
|
||||||
|
debugf("invalid network configuration");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject& data = root.get<JsonObject&>("endpoints");
|
||||||
for (auto it: data) {
|
for (auto it: data) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ protected:
|
||||||
void mqttCallback(String, String);
|
void mqttCallback(String, String);
|
||||||
void otaUpdateCallback(bool result);
|
void otaUpdateCallback(bool result);
|
||||||
void httpFile(HttpRequest &request, HttpResponse &response);
|
void httpFile(HttpRequest &request, HttpResponse &response);
|
||||||
|
void httpConfig(HttpRequest &request, HttpResponse &response);
|
||||||
void httpIndex(HttpRequest &request, HttpResponse &response);
|
void httpIndex(HttpRequest &request, HttpResponse &response);
|
||||||
|
|
||||||
void systemReady(void);
|
void systemReady(void);
|
||||||
|
|
Loading…
Reference in New Issue