Why is it not good practice to call esp_wifi_connect() after esp_wifi_disconnect()?
Re: Why is it not good practice to call esp_wifi_connect() after esp_wifi_disconnect()?
Calling esp_wifi_connect() immediately after esp_wifi_disconnect() can lead to unpredictable behavior and potential conflicts in the Wi-Fi connection process. It's important to allow sufficient time for the disconnection process to complete before initiating a new connection to ensure stability and avoid potential race conditions or resource conflicts.
-
- Posts: 9052
- Joined: Thu Nov 26, 2015 4:08 am
Re: Why is it not good practice to call esp_wifi_connect() after esp_wifi_disconnect()?
Because esp_wifi_disconnect() doesn't disconnect WiFi and then return; rather it tells the WiFi stack to initiate a disconnect. The WiFi stack will then in the background go through all things needed to disconnect gracefully (e.g. inform the AP that the connection is broken) and will finally return an event telling you the ESP is actually disconnected. If you call esp_wifi_connect() directly after esp_wifi_disconnect() (without waiting for that event), the disconnect procedure might still be underway and results will be unpredictable.
Who is online
Users browsing this forum: No registered users and 167 guests