B4R Question WiFi.IsConnected returns true but IP address is (IP unset)

BertI

Member
Licensed User
Longtime User
Using an ESP8266: I have a simple timer to check that a WiFi connection is still in place (every 5 seconds). To test this (after being successfully connected and with a valid IP address) I turned off the hotspot which was being used as the router, but WiFi.IsConnected still kept returning True in the 5 second checking sub. However I noticed that now WiFi.LocalIP returned "(IP unset)". So I can use the latter as an extra check and force a WiFi Disconnect in that case but I'm curious about why WiFi.IsConnected still returns True even though clearly there can be no connection with the hotspot turned off. Anyone seen this behaviour before or have an idea as to why?
 

RJB

Active Member
Licensed User
Longtime User
Not exactly the same but I am using an ESP32 as a server. After I disable the server or remove the power (so the server is certainly off) a PC and an Android device continue to show the server SSID. I presume they are waiting to make sure the server has actually gone, rather than a temporary interruption. So perhaps the ESP8266 is doing the same?
 
Upvote 0

BertI

Member
Licensed User
Longtime User
Yes I wondered about something like that but it did seem to last for the time that I kept looking at the 5s logs (a few minutes). I suppose maybe I should try and re-create the issue and wait for a long period to see if there is some eventual timeout mechanism. That being said, the symptom which led me to investigate this bit of code lasted hours - failure to reconnect even when the hotspot had been turned back on. I have switched off the lower level autoreconnect feature because of other issues this causes so have this monitoring process in place to do it via the main code
 
Upvote 0
Top