Просмотр исходного кода

Merge pull request #80 from nothingmn/master

added a system command to reset the wifi and then restart the device
Chris Mullins лет назад: 8
Родитель
Сommit
0765404fa5
2 измененных файлов с 18 добавлено и 2 удалено
  1. 5 1
      data/web/index.html
  2. 13 1
      lib/WebServer/MiLightHttpServer.cpp

+ 5 - 1
data/web/index.html

@@ -12,7 +12,7 @@
   <link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet"/>
   <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.7.0/css/bootstrap-slider.min.css" rel="stylesheet"/>
   <link href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.4/css/selectize.bootstrap3.min.css" rel="stylesheet"/>
-
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <!--[if lt IE 9]>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
   <![endif]-->
@@ -1039,6 +1039,10 @@
           Restart
         </button>
 
+        <button type="button" class="btn btn-danger system-btn" data-command="clear_wifi_config">
+          Clear Wifi Config
+        </button>
+
         <button type="button" id="updates-btn" class="btn btn-primary">
           Check for Updates
         </button>

+ 13 - 1
lib/WebServer/MiLightHttpServer.cpp

@@ -128,7 +128,19 @@ void MiLightHttpServer::handleSystemPost() {
       delay(100);
 
       ESP.restart();
-    }
+
+      handled = true;
+    } else if (request["command"] == "clear_wifi_config") {
+        Serial.println(F("Resetting Wifi and then Restarting..."));
+        server.send(200, TEXT_PLAIN, "true");
+
+        delay(100);
+        ESP.eraseConfig();
+        delay(100);
+        ESP.restart();
+
+        handled = true;
+      }
   }
 
   if (handled) {