Hmm thats strange, according to the docs the function becomes true when the core has obtained an IP address. Having an IP address is rather hard without an SSID so I’m not sure what is going on here.
Are you connecting to the cloud or only WLAN? If you are connecting to the cloud you could also slip in
I think the problem is in the time to write the ssid to the registers. The WiFi might be ready but the data is still being written into the memory. Perhaps @bko can help
@blondie63 & @TheHawk1337 I agree it is a bug or at least poor documentation I find it takes at least 800 milliseconds to get a valid response from WIFI.SSID() once WiFi.ready() is true.
WiFi.ready only checks to see if the TI part has reported that it got a DHCP address.
There is a call in SPARK_WLAN_Loop() after the DHCP address is set that fills out SSID and local IP, gateway IP, subnet mask, and MAC address from information provided by the TI WiFi part.
If you are not calling SPARK_WLAN_Loop() in your own while loop, this will not happen until you go around loop().
If you are calling SPARK_WLAN_Loop() either directly or by going around loop(), it asks the TI part for this info after a delay of 100ms, so in the 800ms case, it looks to me like it takes 8 call attempts to get the data from the TI part.
I don’t think the Spark guys wanted to block waiting for this data but you certainly can.
The first part of the doc for WiFi.ready() is correct–just when the DHCP address is set, but the second part is not right: you should wait for local IP and friends to get filled in before starting a connection.
SPARK_WLAN_Loop() is an internal function that gets called lots of places to keep the cloud alive.
It gets called when you go around the loop() and it gets called during delay() when either the delay value is large enough to mask the call time or when enough small delays have accumulated.
So yes, it is called and it does fill out the SSID etc.