|
|
|
@ -232,7 +232,9 @@ apars_handle_RESET_cmd(void) |
|
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
|
apars_handle_OSC_FactoryReset(void) |
|
|
|
|
{ |
|
|
|
|
info("OSC: Factory reset"); |
|
|
|
|
warn("-------- Factory reset --------"); |
|
|
|
|
|
|
|
|
|
dbg("Switching to Client+AP mode"); |
|
|
|
|
|
|
|
|
|
// Send acknowledgement message to UART0
|
|
|
|
|
// User is performing this manually, so we can just print it as string
|
|
|
|
@ -248,10 +250,12 @@ apars_handle_OSC_FactoryReset(void) |
|
|
|
|
wifi_set_opmode(STATIONAP_MODE); |
|
|
|
|
|
|
|
|
|
// --- AP config ---
|
|
|
|
|
dbg("AP WiFi channel: 6"); |
|
|
|
|
|
|
|
|
|
struct softap_config apconf; |
|
|
|
|
wifi_softap_get_config(&apconf); |
|
|
|
|
apconf.authmode=AUTH_OPEN; // Disable access protection
|
|
|
|
|
apconf.channel=1; // Reset channel; user may have set bad channel in the UI
|
|
|
|
|
apconf.channel=6; // Reset channel; user may have set bad channel in the UI
|
|
|
|
|
|
|
|
|
|
// generate unique AP name
|
|
|
|
|
u8 mac[6]; |
|
|
|
@ -259,7 +263,11 @@ apars_handle_OSC_FactoryReset(void) |
|
|
|
|
sprintf((char*)apconf.ssid, "TERM-%02X%02X%02X", mac[3], mac[4], mac[5]); |
|
|
|
|
apconf.ssid_len = (u8)strlen((char*)apconf.ssid); |
|
|
|
|
|
|
|
|
|
info("New AP name: %s", (char*)apconf.ssid); |
|
|
|
|
|
|
|
|
|
// --- Station ---
|
|
|
|
|
dbg("Erasing stored WiFi credentials..."); |
|
|
|
|
|
|
|
|
|
struct station_config staconf; |
|
|
|
|
wifi_station_get_config(&staconf); |
|
|
|
|
|
|
|
|
@ -268,12 +276,16 @@ apars_handle_OSC_FactoryReset(void) |
|
|
|
|
staconf.bssid_set=0; |
|
|
|
|
staconf.password[0]=0; |
|
|
|
|
|
|
|
|
|
dbg("Commiting changes..."); |
|
|
|
|
wifi_softap_set_config(&apconf); |
|
|
|
|
wifi_station_set_config(&staconf); |
|
|
|
|
|
|
|
|
|
UART_WriteString(UART0, "Factory Reset complete, device reset.\r\n\r\n", UART_TIMEOUT_US); |
|
|
|
|
|
|
|
|
|
// Reboot to clean STA+AP mode with Channel 1 & reset AP SSID.
|
|
|
|
|
info("*** FACTORY RESET COMPLETE ***"); |
|
|
|
|
dbg("Device reset..."); |
|
|
|
|
|
|
|
|
|
// Reboot to clean STA+AP mode with Channel X & reset AP SSID.
|
|
|
|
|
system_restart(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|