The Core initiates a offline event when it goes offline, but this offline event isn’t received until it comes online. You receive the offline event and right after receive the online event. If I publish my own offline event right before sleep with Spark.process() right after that works. How do we get the stock online/offline events to work properly? I can use my own events, but I like using what is already there plus I am curious why this happens.
The device service will automatically publish an offline event after 60 seconds of time-out (if i remember correctly) so there’s no need to do that yourself.
There’s is actually no event sent to the cloud when the core “goes offline”. It is detected on the server side instead.
Ah, I did not know that. Is this the same logic that controls the “connected” flag when polling the device via the cloud API?
Are you referring to listing all the device status in your account?
I believe it will “ping” the device and sees if a response is received before showing the appropriate status.
I do a GET to /v1/devices/%devid%?access_token=%accesstok% and no matter what it is saying connected=true even when it is a asleep.
EDIT: Actually it sometimes returns false and sometimes it takes a while times out and returns false without any of the variable/function definitions. Doesn’t seem consistent.