ソースを参照

Merge pull request #10 from sidoh/fix_blank_settings

apply settings on server boot
Chris Mullins 8 年 前
コミット
3458da1696
共有1 個のファイルを変更した3 個の追加0 個の削除を含む
  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); });