Pārlūkot izejas kodu

apply settings on server boot

Chris Mullins 8 gadi atpakaļ
vecāks
revīzija
f03524329d
1 mainītis faili ar 3 papildinājumiem un 0 dzēšanām
  1. 3 0
      lib/WebServer/MiLightHttpServer.cpp

+ 3 - 0
lib/WebServer/MiLightHttpServer.cpp

@@ -6,9 +6,12 @@
 #include <MiLightRadioConfig.h>
 
 void MiLightHttpServer::begin() {
+  applySettings(settings);
+  
   server.on("/", HTTP_GET, handleServeFile(WEB_INDEX_FILENAME, "text/html"));
   server.on("/settings", HTTP_GET, handleServeFile(SETTINGS_FILE, "application/json"));
   server.on("/settings", HTTP_PUT, [this]() { handleUpdateSettings(); });
+  server.on("/settings", HTTP_POST, [this]() { server.send(200, "text/plain", "success"); }, handleUpdateFile(SETTINGS_FILE));
   server.on("/gateway_traffic", HTTP_GET, [this]() { handleListenGateway(); });
   server.onPattern("/gateways/:device_id/:type/:group_id", HTTP_PUT, [this](const UrlTokenBindings* b) { handleUpdateGroup(b); });
   server.onPattern("/gateways/:device_id/:type", HTTP_PUT, [this](const UrlTokenBindings* b) { handleUpdateGateway(b); });