tonyp7 / esp32-wifi-manager

Captive Portal for ESP32 that can connect to a saved wireless network or start an access point where you can connect to existing wifis.
MIT License
652 stars 214 forks source link

When trying to switch from one wifi network to another I have not been able to make the change over reliably. #109

Open MPC-BlackBox opened 3 years ago

MPC-BlackBox commented 3 years ago

Prerequisites

Description

When trying to change the wifi details from one network to another problems occur. Many end in a crash with the wifi and password details being erased.

Steps to Reproduce

If you setup your phone to act as an access point and connect to the phone AP using the wifi manager you can switch off the phone AP and try to change wifi networks. The application also has a button which will stop the STA and restart the wifi manager AP.

System Configuration

I have corrected for the malloc issue: wifi_event_sta_disconnected_t wifi_event_sta_disconnected = (wifi_event_sta_disconnected_t)malloc(sizeof(wifi_event_sta_disconnected_t));

I have also included the following in the WM_ORDER_START_WIFI_SCAN code as the error check was stalling the code. / if a scan is already in progress this message is simply ignored thanks to the WIFI_MANAGER_SCAN_BIT uxBit / uxBits = xEventGroupGetBits(wifi_manager_event_group); if(! (uxBits & WIFI_MANAGER_SCAN_BIT) ){ xEventGroupSetBits(wifi_manager_event_group, WIFI_MANAGER_SCAN_BIT); // ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, false)); esp_err_t error = esp_wifi_scan_start(&scan_config, false); if (error!=ESP_OK) ESP_LOGI(TAG, "MESSAGE: WIFI SCAN FAILED WITH CODE %d",error); } }

When trying to switch from one wifi network to another I have not been able to make the change over reliably. The application has a button which if you hold for 6 seconds the wifi configuration can be changed. This button executes the following.... wifi_manager_send_message(WM_ORDER_DISCONNECT_STA, NULL); wifi_manager_send_message(WM_ORDER_START_AP, NULL);

Connecting to the ESP32 wifi manager AP I have had several different problems which often cause a crash. On some occasions the SSID and password are erased. Crash reports are listed below.

** Following happened when stopped STA and started AP then entered new wifi details. Please note I have not removed the SSID and Password. The wifi manager has saved these as blank for no reason.**

I (198409) wifi_manager: WIFI_EVENT_STA_DISCONNECTED I (198409) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 200 I (198409) wifi_manager: Set STA IP String to: 0.0.0.0 I (198419) wifi_manager: About to save config to flash!! I (198479) wifi_manager: wifi_manager_wrote wifi_sta_config: ssid: I (198489) wifi_manager: wifi_manager_wrote wifi_sta_config: password: I (198489) wifi_manager: MESSAGE: ORDER_START_AP /home/melvin/Desktop/esp/esp-idf/components/freertos/tasks.c:3094 (xTaskRemoveFromEventList)- assert failed!

abort() was called at PC 0x4008ab4e on core 1 Setting breakpoint at 0x4008909e and returning...

**** following happened when reset ESP32 and tried to setup new wifi details

I (165919) dns_server: Replying to DNS request for go.trouter.skype.com from 10.10.0.2 I (165919) dns_server: Replying to DNS request for go.trouter.skype.com from 10.10.0.2 I (166109) GATEWAY_MAIN: Host lookup failed. Will Retry W (167979) httpd: httpd_accept_conn: error in accept (23) W (167979) httpd: httpd_server: error accepting new connection W (167989) httpd: httpd_accept_conn: error in accept (23) W (167989) httpd: httpd_server: error accepting new connection W (167999) httpd: httpd_accept_conn: error in accept (23) W (167999) httpd: httpd_server: error accepting new connection I (170259) dns_server: Replying to DNS request for browser.pipe.aria.microsoft.com from 10.10.0.2 I (171489) dns_server: Replying to DNS request for blackboxcontrols-my.sharepoint.com from 10.10.0.2 I (176109) GATEWAY_MAIN: Host lookup failed. Will Retry I (186109) GATEWAY_MAIN: Host lookup failed. Will Retry I (188339) wifi_manager: WIFI_EVENT_AP_STACONNECTED I (189309) dns_server: Replying to DNS request for content-notes-pa.googleapis.com from 10.10.0.2 I (189309) dns_server: Replying to DNS request for clients4.google.com from 10.10.0.2 I (189329) dns_server: Replying to DNS request for content-notes-pa.googleapis.com from 10.10.0.2 I (189339) dns_server: Replying to DNS request for clients4.google.com from 10.10.0.2 I (189349) http_server: POST /connect.json I (189349) http_server: ssid: G5_2388, password: MyPassword I (189349) wifi_manager: MESSAGE: ORDER_CONNECT_STA I (189369) dns_server: Replying to DNS request for content-notes-pa.googleapis.com from 10.10.0.2 I (189379) dns_server: Replying to DNS request for clients4.google.com from 10.1 SP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x40087f54 file: "../components/esp32-wifi-manager/src/wifi_manager.c" line 1020 func: wifi_manager expression: esp_wifi_scan_start(&scan_config, false)

abort() was called at PC 0x40087f57 on core 1 Setting breakpoint at 0x4008909e and returning...

Many Thanks,

MPC.

hqawasmi commented 3 years ago

I am also have same issue and reported here https://github.com/tonyp7/esp32-wifi-manager/issues/118