diff --git a/code/espurna/ws.ino b/code/espurna/ws.ino index 64c830ed..864eb3ab 100644 --- a/code/espurna/ws.ino +++ b/code/espurna/ws.ino @@ -95,6 +95,13 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) { if (strcmp(action, "reboot") == 0) deferredReset(100, CUSTOM_RESET_WEB); if (strcmp(action, "reconnect") == 0) _web_defer.once_ms(100, wifiDisconnect); + + if (strcmp(action, "factory_reset") == 0) + { + DEBUG_MSG_P(PSTR("\n\nFACTORY RESET\n\n")); + resetSettings(); + deferredReset(100, CUSTOM_RESET_FACTORY); + } JsonObject& data = root["data"]; if (data.success()) { diff --git a/code/html/custom.css b/code/html/custom.css index b5be0982..5892c9c3 100644 --- a/code/html/custom.css +++ b/code/html/custom.css @@ -148,7 +148,8 @@ div.state { .button-rfb-forget, .button-del-network, .button-del-schedule, -.button-upgrade { +.button-upgrade, +.button-settings-factory { background: rgb(192, 0, 0); /* redish */ } diff --git a/code/html/custom.js b/code/html/custom.js index aa4b009a..570e005d 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -494,6 +494,16 @@ function doRestore() { return false; } +function doFactoryReset() { + var response = window.confirm("Are you sure you want to restore to factory settings?"); + if (response === false) { + return false; + } + websock.send(JSON.stringify({"action": "factory_reset"})); + doReload(5000); + return false; +} + function doToggle(element, value) { var id = parseInt(element.attr("data"), 10); sendAction("relay", {id: id, status: value ? 1 : 0 }); @@ -1253,6 +1263,7 @@ $(function() { $(".button-wifi-scan").on("click", doScan); $(".button-settings-backup").on("click", doBackup); $(".button-settings-restore").on("click", doRestore); + $(".button-settings-factory").on("click", doFactoryReset); $("#uploader").on("change", onFileUpload); $(".button-upgrade").on("click", doUpgrade); diff --git a/code/html/index.html b/code/html/index.html index 12cdd506..a70e1bdf 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -523,7 +523,8 @@
-
+
+