Skip to content

Commit

Permalink
Merge pull request #80 from nothingmn/master
Browse files Browse the repository at this point in the history
added a system command to reset the wifi and then restart the device
  • Loading branch information
sidoh authored May 11, 2017
2 parents a2dae74 + 3777e6e commit 0765404
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion data/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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]-->
Expand Down Expand Up @@ -1039,6 +1039,10 @@ <h1>Admin</h1>
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>
Expand Down
14 changes: 13 additions & 1 deletion lib/WebServer/MiLightHttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0765404

Please sign in to comment.