cleaning & linked boot button to new factory reset impl

pull/30/head
Ondřej Hruška 8 years ago
parent 5c8eab387e
commit d5bd53b78a
  1. 14
      user/io.c
  2. 2
      user/user_main.c
  3. 11
      user/wifimgr.c

@ -11,6 +11,8 @@
#include <esp8266.h> #include <esp8266.h>
#include "ansi_parser_callbacks.h" #include "ansi_parser_callbacks.h"
#include "wifimgr.h"
#include "persist.h"
#define BTNGPIO 0 #define BTNGPIO 0
@ -74,16 +76,16 @@ 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 if (resetCnt>=10) { //5 secs pressed - FR (timer is at 500 ms)
info("BOOT-button triggered FACTORY RESET!"); info("BOOT-button triggered FACTORY RESET!");
apars_handle_OSC_FactoryReset(); persist_restore_default();
} }
else if (resetCnt>=2) { //1 sec pressed else if (resetCnt>=2) { //1 sec pressed
wifi_station_disconnect(); info("BOOT-button triggered reset to AP mode...");
wifi_set_opmode(STATIONAP_MODE); //reset to AP+STA mode
info("BOOT-button triggered reset to AP mode, restarting...");
system_restart(); wificonf->opmode = STATIONAP_MODE;
persist_store();
wifimgr_apply_settings();
} }
resetCnt=0; resetCnt=0;
} }

@ -91,7 +91,7 @@ void ICACHE_FLASH_ATTR user_init(void)
// Prevent WiFi starting and connecting by default // Prevent WiFi starting and connecting by default
// let wifi manager handle it // let wifi manager handle it
wifi_station_set_auto_connect(false); wifi_station_set_auto_connect(false);
wifi_set_opmode(NULL_MODE); wifi_set_opmode(NULL_MODE); // save to flash if changed - this might avoid the current spike on startup?
printf("\r\n"); printf("\r\n");
banner("====== ESP8266 Remote Terminal ======"); banner("====== ESP8266 Remote Terminal ======");

@ -159,8 +159,15 @@ wifimgr_apply_settings(void)
info("[WiFi] Initializing..."); info("[WiFi] Initializing...");
// Force wifi cycle // Force wifi cycle
wifi_set_opmode(NULL_MODE); // Disconnect - may not be needed?
wifi_set_opmode(wificonf->opmode); WIFI_MODE opmode = wifi_get_opmode();
if (opmode == STATIONAP_MODE || opmode == STATION_MODE) {
wifi_station_disconnect();
}
// This should hopefully deinit everything
wifi_set_opmode_current(NULL_MODE);
wifi_set_opmode_current(wificonf->opmode);
// Configure the client // Configure the client
if (wificonf->opmode == STATIONAP_MODE || wificonf->opmode == STATION_MODE) { if (wificonf->opmode == STATIONAP_MODE || wificonf->opmode == STATION_MODE) {

Loading…
Cancel
Save