MCPcopy Create free account
hub / github.com/Blueforcer/awtrix3 / loadSettings

Method loadSettings

src/ServerManager.cpp:351–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351void ServerManager_::loadSettings()
352{
353 if (LittleFS.exists("/DoNotTouch.json"))
354 {
355 File file = LittleFS.open("/DoNotTouch.json", "r");
356 DynamicJsonDocument doc(file.size() * 1.33);
357 DeserializationError error = deserializeJson(doc, file);
358 if (error)
359 return;
360
361 NTP_SERVER = doc["NTP Server"].as<String>();
362 NTP_TZ = doc["Timezone"].as<String>();
363 MQTT_HOST = doc["Broker"].as<String>();
364 MQTT_PORT = doc["Port"].as<uint16_t>();
365 MQTT_USER = doc["Username"].as<String>();
366 MQTT_PASS = doc["Password"].as<String>();
367 MQTT_PREFIX = doc["Prefix"].as<String>();
368 MQTT_PREFIX.trim();
369 NET_STATIC = doc["Static IP"];
370 HA_DISCOVERY = doc["Homeassistant Discovery"];
371 NET_IP = doc["Local IP"].as<String>();
372 NET_GW = doc["Gateway"].as<String>();
373 NET_SN = doc["Subnet"].as<String>();
374 NET_PDNS = doc["Primary DNS"].as<String>();
375 NET_SDNS = doc["Secondary DNS"].as<String>();
376 if (doc["Auth Username"].is<String>())
377 AUTH_USER = doc["Auth Username"].as<String>();
378 if (doc["Auth Password"].is<String>())
379 AUTH_PASS = doc["Auth Password"].as<String>();
380
381 file.close();
382 DisplayManager.applyAllSettings();
383 if (DEBUG_MODE)
384 DEBUG_PRINTLN(F("Webserver configuration loaded"));
385 doc.clear();
386 return;
387 }
388 else if (DEBUG_MODE)
389 DEBUG_PRINTLN(F("Webserver configuration file not exist"));
390 return;
391}
392
393void ServerManager_::sendButton(byte btn, bool state)
394{

Callers 2

saveHandlerFunction · 0.80
setupFunction · 0.80

Calls 2

applyAllSettingsMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected