Bring devices online and offline
When a device connects to IoT Platform, its status is displayed as Online. When it disconnects, its status changes to Offline.
Bring a device online
You must develop a device-side program to connect a device to IoT Platform.
The following procedure applies to directly connected devices. For information about sub-devices, see Bring a sub-device online.
-
Develop the device-side program.
IoT Platform provides device-side Link SDKs for multiple languages. These SDKs encapsulate the interaction protocols between devices and IoT Platform. For more information, see Device connection.
When you develop the device-side program, configure the device identity information on the device. IoT Platform uses this information for identity verification during connection.
IoT Platform supports the following identity authentication methods for directly connected devices:
-
Device-specific certificate: Pre-burn a unique device certificate (ProductKey, DeviceName, and DeviceSecret) into each device.
-
Product-level certificate: Burn the same firmware (ProductKey and ProductSecret) to all devices of the same product, and enable dynamic registration on the Product Details page in the console. When a device sends a connection request, IoT Platform authenticates the product certificate and, if successful, issues the corresponding DeviceSecret to the device.
-
-
Install the device-side SDK on the device.
-
Power on the device and connect it to the internet to access IoT Platform.
Bring a device offline
When a device goes offline, its status changes to Offline. A device can go offline in the following ways:
-
Active disconnection: The device disconnects from IoT Platform.
-
Passive disconnection: IoT Platform disconnects the device.
This occurs when another device connects with the same device certificate, forcing the current device offline, or when you delete or disable the device in the IoT Platform console.
LoRa devices have only two statuses: Inactive and Online. After a LoRa device connects to IoT Platform, the platform cannot detect if the device disconnects.
MQTT keepalive
The MQTT keepalive interval must be between 30 and 1,200 seconds. If the interval is outside this range, the server rejects the connection. A value of 300 seconds or more is recommended.
The heartbeat timer starts when IoT Platform sends a CONNACK message in response to a CONNECT message. The timer is reset when a PUBLISH, SUBSCRIBE, PING, or PUBACK message is received. IoT Platform checks the keepalive heartbeat of the device every 30 seconds. The waiting time for scheduled detection is the period of time from when the device goes online to the latest scheduled detection. The maximum timeout period is calculated using the following formula: (keepalive interval × 1.5) + (waiting time for scheduled detection). If no message is received from the device after the maximum timeout period, the server automatically disconnects the device.