What is the best way to check if Spark Core is online and connected to the cloud?


#1

Hello.

I’m having hard time implementing this.

particleDevice.isConnected function informs me way too late. ( I’m unplugging the device, so probably it cant clear its socket properly).

I tried to read some dummy variable but again, 10 to 15 seconds delay which not gonna work on my project.

Can you guys help me a lil bit?

Thank you.


#2

From where do you need to check if the device is online? Can you explain why you need to get this information with no appreciable delay? A little context might help us help you.


#3

I’m currently developing an Android app for the Core. We are using core as a plug for reading the electric energy consumption etc. Core’s D0 pin controls the electricity switch. We need to control this switch without delay(well except reasonable delay like 2 to 3 seconds).

Thank you.


#4

Sorry, but I’m still not understanding what you’re trying to do. If you unplug the device, then you can’t control the switch anyway, so why do you need to know quickly that it’s not online?


#5

Because I want to prevent and inform the user that device is unavailable to them. I tried to read an event with publish but again, 30-60 seconds delay.

Oh and I’m a complete beginner with Particle devices. Sorry if I am talking nonsense.


#6

The only way I can think of to quickly know if your device is online would be to have the device publish something every couple of seconds. Your app would subscribe to that event, and if it doesn’t get one after waiting a few seconds, you could assume the device is offline.