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

Function loadConfig

samples/Basic_WebSkeletonApp_LTS/app/configuration.cpp:11–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9ThermConfig ActiveConfig;
10
11ThermConfig loadConfig()
12{
13 StaticJsonBuffer<ConfigJsonBufferSize> jsonBuffer;
14 ThermConfig cfg;
15 if(fileExist(THERM_CONFIG_FILE)) {
16 int size = fileGetSize(THERM_CONFIG_FILE);
17 char* jsonString = new char[size + 1];
18 fileGetContent(THERM_CONFIG_FILE, jsonString, size + 1);
19 JsonObject& root = jsonBuffer.parseObject(jsonString);
20
21 JsonObject& network = root["network"];
22 cfg.StaSSID = String((const char*)network["StaSSID"]);
23 cfg.StaPassword = String((const char*)network["StaPassword"]);
24 cfg.StaEnable = network["StaEnable"];
25
26 delete[] jsonString;
27 } else {
28 //Factory defaults if no config file present
29 cfg.StaSSID = WIFI_SSID;
30 cfg.StaPassword = WIFI_PWD;
31 }
32 return cfg;
33}
34
35void saveConfig(ThermConfig& cfg)
36{

Callers 1

initFunction · 0.70

Calls 4

fileExistFunction · 0.85
fileGetSizeFunction · 0.85
fileGetContentFunction · 0.85
StringClass · 0.50

Tested by

no test coverage detected