How to tell the state from api to know the photon is trying to connect the cloud, wifi?

when photon is connecting to WIFI, it will flash green light, and when it is connecting the cloud, it will flash cyan light, From the API, I can know whether the photon is connected to cloud or not connected to cloud through spark.connected(), but there is no api on spark.connecting(), so how would i tell when it is currently trying to connect to cloud, or trying to connect to wifi or has already connected to wifi?

You can use WiFi.connecting() to check if a WiFi connection in progress, WiFi.ready() to check if the device has an IP address on the network and Spark.connected() to check if the cloud connection is complete.

The device will always try to connect to the cloud when the WiFi is connected unless you call Spark.disconnect(), so there’s no Spark.connecting() API. (In case you are using different system modes, it’s a little more complicated. You can read up on system modes here).