I have a problem with detecting the WiFi status.
First, I connect the ESP32 to the AP, and I keep sending some messages in a while loop.
Then I turn off the AP, but the loop keep working until the bcn timeout is triggered.
Is there any method to actively check whether the WiFi is connected before sending messages?
I have tried to check the WIFI_EVENT but it wouldn't be triggered after I turn off the AP.
The following code is what I expected:
Code: Select all
WiFi_init();
WiFi_connect();
while(1){
if (check_wifi_status() == connected)
send_msg();
else
WiFi_reconnect();
}