Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reboot after restore config #1862

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/espurna/config/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@
#define CUSTOM_RESET_NOFUSS 8 // Reset after successful NOFUSS update
#define CUSTOM_RESET_UPGRADE 9 // Reset after update from web interface
#define CUSTOM_RESET_FACTORY 10 // Factory reset from terminal
#define CUSTOM_RESET_CONFIG_UPDATE 11 // Reset after configuration update


#define CUSTOM_RESET_MAX 10

Expand Down
3 changes: 3 additions & 0 deletions code/espurna/web.ino
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void _onPostConfig(AsyncWebServerRequest *request) {
if (!webAuthenticate(request)) {
return request->requestAuthentication(getSetting("hostname").c_str());
}
if (_webConfigSuccess) deferredReset(100, CUSTOM_RESET_CONFIG_UPDATE);
request->send(_webConfigSuccess ? 200 : 400);
}

Expand All @@ -143,6 +144,7 @@ void _onPostConfigData(AsyncWebServerRequest *request, String filename, size_t i
// No buffer
if (final && (index == 0)) {
_webConfigSuccess = settingsRestoreJson((char*) data);
if (_webConfigSuccess) deferredReset(100, CUSTOM_RESET_CONFIG_UPDATE);
return;
}

Expand Down Expand Up @@ -175,6 +177,7 @@ void _onPostConfigData(AsyncWebServerRequest *request, String filename, size_t i
delete _webConfigBuffer;

}
if (_webConfigSuccess) deferredReset(100, CUSTOM_RESET_CONFIG_UPDATE);

}

Expand Down
1 change: 1 addition & 0 deletions code/espurna/ws.ino
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
if (strcmp(action, "restore") == 0) {
if (settingsRestoreJson(data)) {
wsSend_P(client_id, PSTR("{\"message\": 5}"));
deferredReset(100, CUSTOM_RESET_CONFIG_UPDATE);
} else {
wsSend_P(client_id, PSTR("{\"message\": 4}"));
}
Expand Down
2 changes: 1 addition & 1 deletion code/html/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function initMessages() {
messages[2] = "OTA update started";
messages[3] = "Error parsing data!";
messages[4] = "The file does not look like a valid configuration backup or is corrupted";
messages[5] = "Changes saved. You should reboot your board now";
messages[5] = "Changes saved. Device will now reboot";
messages[7] = "Passwords do not match!";
messages[8] = "Changes saved";
messages[9] = "No changes detected";
Expand Down