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

Function loadConfig

samples/Basic_WebSkeletonApp/app/configuration.cpp:20–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18ThermConfig activeConfig;
19
20ThermConfig loadConfig()
21{
22 StaticJsonDocument<ConfigJsonBufferSize> doc;
23 ThermConfig cfg;
24 if(Json::loadFromFile(doc, THERM_CONFIG_FILE)) {
25 JsonObject network = doc[KEY_NETWORK];
26 cfg.StaSSID = network[KEY_SSID].as<const char*>();
27 cfg.StaPassword = network[KEY_PASS].as<const char*>();
28 cfg.StaEnable = network[KEY_ENABLE];
29 } else {
30 // Factory defaults if no config file present, or could not access it
31 cfg.StaSSID = F(WIFI_SSID);
32 cfg.StaPassword = F(WIFI_PWD);
33 }
34 return cfg;
35}
36
37void saveConfig(ThermConfig& cfg)
38{

Callers 1

initFunction · 0.70

Calls 2

loadFromFileFunction · 0.85
FFunction · 0.50

Tested by

no test coverage detected