| 349 | } |
| 350 | |
| 351 | void 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 | |
| 393 | void ServerManager_::sendButton(byte btn, bool state) |
| 394 | { |
no test coverage detected