How to actively check whether WiFi is connected?

William_Wu
Posts: 1
Joined: Tue Dec 10, 2019 6:23 am

How to actively check whether WiFi is connected?

Postby William_Wu » Tue Dec 10, 2019 6:54 am

Hi,
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();
}

Who is online

Users browsing this forum: Google [Bot], martins and 95 guests