Using the communications contract, check if your device is online or not.
How to check if the device is online
It is challenging to determine if a device is online or offline definitively. Some transport layer technologies, like MQTT, keep an open socket, which it then monitors to know if the device is still connected to the platform. However, not all devices use this. Connect addresses this problem by defining a contract between the device and the platform. This contract determines the regularity with which the device should report into the system. We call this the Communication Contract.
A communication contract defines up to three deadlines that the device must honour. If a device fails to report regularly, the system will change its communication state to indicate which deadline it has missed.
The possible statuses are:
- OK - Transmitted as scheduled.
- Over Deadline 1 - Missed the first transmission deadline.
- Over Deadline 2 - Missed the second transmission deadline.
- Over Deadline 3 - Missed the third transmission deadline.
- Unknown - The device has no Communication Contract associated with it, and so the system can not determine if its communication state is healthy.