Particle.connected test in loop not working

I want to show an indicator led for the connection of my Electron to the cloud. for this reason I wrote following code:

 void loop(){
// check if connected to cloud
if (Particle.connected()){
    Status = 0; // Status OK
    Status = 1; // Status Error

    case 0:
    digitalWrite(D0, HIGH);
    case 1:
    digitalWrite(D0, HIGH);
    digitalWrite(D0, LOW);

So theoretically the LED on D0 should blink until connected.
Instead it is dark during the status LED is flashing green and it goes on when the connection is established so the status LED is slowly blinking cyan.

Does this mean that the loop is not entered until the connection is established?

Any ideas?

Yes, this does mean exactly that and this is the intended behaviour for default SYSTEM_MODE(AUTOMATIC).

If you want to have your code run before hand have a look at the docs about SYSTEM_MODE()


Thanks for this information. I was not aware about the system modes. will try it out.