Device.ondisconnect() when power off

device.ondisconnect() when power off does not work. It works when I put it to sleep. It does not work when it moves out of range. How can I achieve this? My goal is to send an SMS message when it disconnects for ANY reason.

You have to wait for the disconnect message to come through. Once you’re out of range for max 9 minutes, you should get the disconnect notification.

Powering off, or moving out of range, are both cases where the imp cannot tell the server that it’s not there (because… it’s not there!). In these cases the server’s link maintenance will eventually notice that the imp is not responding and mark it offline, which is when the ondisconnect() gets called.

Patience is a virtue. Excellent! Thanks.

When will we be able to change these parameters?
1 minute try to connect
9 minutes sleep between tries

You won’t be able to change those parameters, which are hardcoded for cold boots, but will be able to implement your own behavior using the wifi-off APIs available in the next release.

Looking forward to it! Got it working by pinging, Agent notices it’s missing after 10 seconds.