MCPcopy Create free account
hub / github.com/SmingHub/Sming / loadConfig

Function loadConfig

samples/MeteoControl/app/configuration.cpp:5–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3MeteoConfig ActiveConfig;
4
5MeteoConfig loadConfig()
6{
7 DynamicJsonDocument doc(1024);
8 MeteoConfig cfg;
9 if(Json::loadFromFile(doc, METEO_CONFIG_FILE)) {
10 JsonObject network = doc["network"];
11 cfg.NetworkSSID = network["ssid"].as<const char*>();
12 cfg.NetworkPassword = network["password"].as<const char*>();
13
14 JsonObject correction = doc["correction"];
15 cfg.AddT = correction["T"];
16 cfg.AddRH = correction["RH"];
17 cfg.AddTZ = correction["TZ"];
18
19 JsonObject trigger = doc["trigger"];
20 cfg.Trigger = TriggerType(trigger["type"].as<int>());
21 cfg.RangeMin = trigger["min"];
22 cfg.RangeMax = trigger["max"];
23 } else {
24 cfg.NetworkSSID = F(WIFI_SSID);
25 cfg.NetworkPassword = F(WIFI_PWD);
26 }
27 return cfg;
28}
29
30void saveConfig(MeteoConfig& cfg)
31{

Callers 2

onConfigurationFunction · 0.70
initFunction · 0.70

Calls 3

loadFromFileFunction · 0.85
TriggerTypeEnum · 0.50
FFunction · 0.50

Tested by

no test coverage detected