From 481c671f0314ebb70908cdb0e7707a528c2a20f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 24 Jul 2017 00:59:56 +0200 Subject: [PATCH] fixed some bugs with persistent settings and hard reset --- user/cgi_persist.c | 4 +++- user/persist.c | 14 +++++++------- user/persist.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/user/cgi_persist.c b/user/cgi_persist.c index 7f2faac..667baaa 100644 --- a/user/cgi_persist.c +++ b/user/cgi_persist.c @@ -67,7 +67,9 @@ cgiPersistRestoreHard(HttpdConnData *connData) return HTTPD_CGI_DONE; } - persist_restore_hard_default(); + // this only changes live settings (and persists it) + // Defaults are not changed. + persist_load_hard_default(); httpdRedirect(connData, SET_REDIR_SUC); return HTTPD_CGI_DONE; diff --git a/user/persist.c b/user/persist.c index c1b7541..c521ee9 100644 --- a/user/persist.c +++ b/user/persist.c @@ -99,7 +99,7 @@ persist_load(void) } if (hard_reset) { - persist_restore_hard_default(); + persist_load_hard_default(); // this also stores them to flash and applies to modules } else { apply_live_settings(); @@ -127,18 +127,18 @@ persist_store(void) * Restore to built-in defaults */ void ICACHE_FLASH_ATTR -persist_restore_hard_default(void) +persist_load_hard_default(void) { - info("[Persist] Restoring all settings to hard defaults..."); + info("[Persist] Restoring live settings to hard defaults..."); // Set live config to default values restore_live_settings_to_hard_defaults(); - - // Store current -> default - memcpy(&persist.defaults, &persist.current, sizeof(AppConfigBundle)); persist_store(); - info("[Persist] All settings restored to hard defaults."); +// // Store current -> default +// memcpy(&persist.defaults, &persist.current, sizeof(AppConfigBundle)); + + info("[Persist] Settings restored to hard defaults."); apply_live_settings(); // apply } diff --git a/user/persist.h b/user/persist.h index be334e4..c5b6b87 100644 --- a/user/persist.h +++ b/user/persist.h @@ -47,7 +47,7 @@ typedef struct { extern PersistBlock persist; void persist_load(void); -void persist_restore_hard_default(void); +void persist_load_hard_default(void); void persist_restore_default(void); void persist_set_as_default(void); void persist_store(void);