WiFi.setAutoReconnect function
Posted: Wed Mar 27, 2024 2:39 pm
Hello,
I'm new to ESP32 WiFi and I'm exploring some of the features.
When I set AutoReconnect to 'true' using the WiFi.setAutoReconnect() function I expect that ESP32 will immediately attempt to re-establish the WiFi connection when that connection is lost. To test this, I used the function WiFi.disconnect(false) by inputting a command using the Serial monitor in the IDE - 'false' implies that the WiFi radio stays ON - and I get the WiFi event 'ARDUINO_EVENT_WIFI_STA_DISCONNECTED', which is what I expected. However, since WiFi has been configured to auto-reconnect, I expect a new event like ' ARDUINO_EVENT_WIFI_STA_CONNECTED', but nothing happens. The WiFi remains disconnected. How is the auto-reconnect supposed act when the connection is lost?
I also tried with WiFi.disconnect(true), which implies that the radio is turned off, but also then, the WiFi remains disconnected - which makes more sense than in the previous case.
Of course I can restart the WiFi using Wifi.begin(), but that means that I have to monitor the Wifi status in my code and manage the connection by my own code. Kinda defeats the purpose (at least that is my expectation) to have a feaure for automatic reconnection?
To be honest, I haven't tried this by turning my AP off. Would that make a difference?
I'm new to ESP32 WiFi and I'm exploring some of the features.
When I set AutoReconnect to 'true' using the WiFi.setAutoReconnect() function I expect that ESP32 will immediately attempt to re-establish the WiFi connection when that connection is lost. To test this, I used the function WiFi.disconnect(false) by inputting a command using the Serial monitor in the IDE - 'false' implies that the WiFi radio stays ON - and I get the WiFi event 'ARDUINO_EVENT_WIFI_STA_DISCONNECTED', which is what I expected. However, since WiFi has been configured to auto-reconnect, I expect a new event like ' ARDUINO_EVENT_WIFI_STA_CONNECTED', but nothing happens. The WiFi remains disconnected. How is the auto-reconnect supposed act when the connection is lost?
I also tried with WiFi.disconnect(true), which implies that the radio is turned off, but also then, the WiFi remains disconnected - which makes more sense than in the previous case.
Of course I can restart the WiFi using Wifi.begin(), but that means that I have to monitor the Wifi status in my code and manage the connection by my own code. Kinda defeats the purpose (at least that is my expectation) to have a feaure for automatic reconnection?
To be honest, I haven't tried this by turning my AP off. Would that make a difference?