Try to Wake the Device and wait for it for a awhile

Hi.
I am trying to ping the Device in order to see if it is really online because, Device goes to sleep quite fast.
I am sending a command device.send(“ping”, 0); to the device but I have not managed to write the code to the device where the device wakes up first and then returns “alive” (if the device is truly connected) when the device is connected again…

If this takes more than 5 seconds, perhaps the device is truly offline and the Agent only then reuturns “dead”.

Sample codes really do not illustrate how…
Can some one help a bit?

If your device is online briefly and offline most of the time, you can consider getting the device to ping the agent, and for the agent to respond.

In the agent you cannot be absolutely sure that the device is still connected, even if device.isconnected() still returns true. However, you can be sure that the device is NOT connected if device.isconnected() returns false.