persist tweaks

pull/111/merge
Ondřej Hruška 8 years ago
parent 481c671f03
commit 97d4ff12da
  1. 1
      user/cgi_persist.c
  2. 7
      user/io.c
  3. 5
      user/persist.c

@ -55,6 +55,7 @@ cgiPersistRestoreDefaults(HttpdConnData *connData)
} }
persist_restore_default(); persist_restore_default();
httpdRedirect(connData, SET_REDIR_SUC); httpdRedirect(connData, SET_REDIR_SUC);
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;
} }

@ -76,16 +76,17 @@ static void ICACHE_FLASH_ATTR resetBtnTimerCb(void *arg) {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK);
if (resetCnt>=10) { //5 secs pressed - FR (timer is at 500 ms) if (resetCnt>=12) { //6 secs pressed - FR (timer is at 500 ms)
info("BOOT-button triggered FACTORY RESET!"); info("Restoring to default settings via BOOT button!");
persist_restore_default(); persist_restore_default();
} }
else if (resetCnt>=2) { //1 sec pressed else if (resetCnt>=2) { //1 sec pressed
info("BOOT-button triggered reset to AP mode..."); info("BOOT-button triggered reset to AP mode...");
// Enter "rescue mode".
wificonf->opmode = STATIONAP_MODE; wificonf->opmode = STATIONAP_MODE;
persist_store();
wifimgr_apply_settings(); wifimgr_apply_settings();
persist_store();
} }
resetCnt=0; resetCnt=0;
} }

@ -144,14 +144,17 @@ persist_load_hard_default(void)
} }
/** /**
* Restore default settings & apply * Restore default settings & apply. also persists.
*/ */
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
persist_restore_default(void) persist_restore_default(void)
{ {
info("[Persist] Restoring live settings to stored defaults..."); info("[Persist] Restoring live settings to stored defaults...");
memcpy(&persist.current, &persist.defaults, sizeof(AppConfigBundle)); memcpy(&persist.current, &persist.defaults, sizeof(AppConfigBundle));
apply_live_settings(); apply_live_settings();
persist_store();
info("[Persist] Settings restored to stored defaults."); info("[Persist] Settings restored to stored defaults.");
} }

Loading…
Cancel
Save