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
673 stars 220 forks source link

Bugfix for crash when scanning while attempting to join #137

Open someone42 opened 3 years ago

someone42 commented 3 years ago

The main commit here (1af351e) is to deal with an issue where if esp32-wifi-manager is attempting to join an AP using stored AP details and can't join, when it attempts to scan for new APs there will be a crash. For example:

esp32-wifi-manager will then crash. This is because join attempts to the old router are still happening in the background, but the user connecting to esp32-wifi-manager's AP will trigger scan requests. As per esp-idf documentation (https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#scan-when-wi-fi-is-connecting), esp_wifi_scan_start() will fail immediately if a join attempt is in progress. The use of the ESP_ERROR_CHECK macro then causes a crash.

The commit introduces a software timer which will retry the scan later if it fails.

The other commit (9ddab86) is just something to deal with compilation errors I was getting when trying to include wifi_manger.h in my own application.

dzanis commented 3 years ago

someone42 thank you friend. This helped fix the incorrect password error. :) ESP32C3 Error if password incorrect