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

Function saveConfig

samples/MeteoControl/app/configuration.cpp:30–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30void saveConfig(MeteoConfig& cfg)
31{
32 ActiveConfig = cfg;
33
34 DynamicJsonDocument doc(1024);
35 auto network = doc.createNestedObject("network");
36 network["ssid"] = cfg.NetworkSSID;
37 network["password"] = cfg.NetworkPassword;
38
39 auto correction = doc.createNestedObject("correction");
40 correction["T"] = cfg.AddT;
41 correction["RH"] = cfg.AddRH;
42 correction["TZ"] = cfg.AddTZ;
43
44 auto trigger = doc.createNestedObject("trigger");
45 trigger["type"] = (int)cfg.Trigger;
46 trigger["min"] = cfg.RangeMin;
47 trigger["max"] = cfg.RangeMax;
48
49 Json::saveToFile(doc, METEO_CONFIG_FILE, Json::Pretty);
50}

Callers 1

onConfigurationFunction · 0.70

Calls 1

saveToFileFunction · 0.85

Tested by

no test coverage detected