WiFi.localIP() returns in mode SYSTEM_MODE(SEMI_AUTOMATIC)

WiFi.localIP() returns 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.

Is this a bug in the firmware?


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))) {

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 when NOTconnected to the Spark cloud.
Wifi.localIP() ONLYreturns a valid IP when I connect the core to the Spark cloud.

Ah I see. Maybe check this thread then, hope it helps. There are some quirks with Semi-Automatic mode, but there is usually a workaround.

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 :frowning:
Wifi.localIP() really needs to be fixed for SEMIAUTOMATIC mode.
Is Spark reading this or should I post as a firmware bug somewhere else?

It’s being read but if you want to post a issue on the firmware repo: https://github.com/spark/firmware/issues that would be awesome!

Ok did, Thank You