WiFi.localIP() returns 0.0.0.0 when the core is put in SYSTEM_MODE(SEMI_AUTOMATIC) mode (not connected to the Spark cloud) and the core IS connected to the local Wifi.
WiFi.localIP() only returns a valid address if the core is connected to the Spark cloud.
WiFi.localIP() should return a valid IP address when connected to Wifi even though its not connected to the Spark cloud.
This happened to me sometimes in AUTOMATIC mode, but it resolves quicky. It looks like WiFi.ready() returns true before IP address is received from DHCP. I use this code in setup() to ensure I have valid IP before I start spewing packets.
while (!WiFi.ready() || (WiFi.localIP() == IPAddress(0,0,0,0))) {
Spark.process();
}
Thanks for the reply Iami, however that is not the case for me.
Even after waiting a very long time (minutes) Wifi.localIP() still returns 0.0.0.0 when NOTconnected to the Spark cloud.
Wifi.localIP() ONLYreturns a valid IP when I connect the core to the Spark cloud.
TJ
Hi Iami, Thanks for the link.
After reading that, I put the core in MANUAL instead of SEMI_AUTOMATIC mode and now Wifi.localIP() returns a valid IP. Of course now using MANUAL mode I now need to be careful to put Spark.process() in all my critical loops
Wifi.localIP() really needs to be fixed for SEMIAUTOMATIC mode.
Is Spark reading this or should I post as a firmware bug somewhere else?
Thanks,
TJ