fixed some bugs with persistent settings and hard reset

pull/111/merge
Ondřej Hruška 8 years ago
parent 50c877d7bb
commit 481c671f03
  1. 4
      user/cgi_persist.c
  2. 14
      user/persist.c
  3. 2
      user/persist.h

@ -67,7 +67,9 @@ cgiPersistRestoreHard(HttpdConnData *connData)
return HTTPD_CGI_DONE; 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); httpdRedirect(connData, SET_REDIR_SUC);
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;

@ -99,7 +99,7 @@ persist_load(void)
} }
if (hard_reset) { if (hard_reset) {
persist_restore_hard_default(); persist_load_hard_default();
// this also stores them to flash and applies to modules // this also stores them to flash and applies to modules
} else { } else {
apply_live_settings(); apply_live_settings();
@ -127,18 +127,18 @@ persist_store(void)
* Restore to built-in defaults * Restore to built-in defaults
*/ */
void ICACHE_FLASH_ATTR 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 // Set live config to default values
restore_live_settings_to_hard_defaults(); restore_live_settings_to_hard_defaults();
// Store current -> default
memcpy(&persist.defaults, &persist.current, sizeof(AppConfigBundle));
persist_store(); 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 apply_live_settings(); // apply
} }

@ -47,7 +47,7 @@ typedef struct {
extern PersistBlock persist; extern PersistBlock persist;
void persist_load(void); void persist_load(void);
void persist_restore_hard_default(void); void persist_load_hard_default(void);
void persist_restore_default(void); void persist_restore_default(void);
void persist_set_as_default(void); void persist_set_as_default(void);
void persist_store(void); void persist_store(void);

Loading…
Cancel
Save