| 9 | ThermConfig ActiveConfig; |
| 10 | |
| 11 | ThermConfig 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 | |
| 35 | void saveConfig(ThermConfig& cfg) |
| 36 | { |
no test coverage detected