All Products
Search
Document Center

IoT Platform:Connect and disconnect devices

Last Updated:Jul 17, 2023

If a device is connected to IoT Platform, the device is in the Online state. If a device is disconnected from IoT Platform, the device is in the Offline state.

Connect a device to IoT Platform

Configure a device and connect the device to IoT Platform.

Note

The following section describes how to directly connect a device to IoT Platform. For more information about how to connect a sub-device, see Connect sub-devices to IoT Platform.

  1. Configure a device

    IoT Platform provides Link SDKs for multiple programming languages. These SDKs encapsulate protocols for communication between devices and IoT Platform. For more information, see Link SDKs.

    When you configure a device, specify the identity information of the device. The identity information is used to verify the device when you connect the device to IoT Platform.

    IoT Platform supports the following methods to verify directly connected devices:

    • Unique-certificate-per-device verification: Burn a unique device certificate to each device in advance. The device certificate includes the ProductKey, DeviceName, and DeviceSecret.

    • Unique-certificate-per-product verification: Burn a product certificate to all devices of the product. The product certificate includes the ProductKey and ProductSecret. You must also enable dynamic registration on the Product Details page in the IoT Platform console. When a device initiates a connection request, IoT Platform verifies the product certificate. If the device passes the verification, IoT Platform issues a DeviceSecret to the device.

  2. Install a Link SDK on the device.

  3. Power on the device, connect the device to the network, and then connect the device to IoT Platform.

Disconnect a device from IoT Platform

After a device is disconnected from IoT Platform, the device is in the Offline state in IoT Platform. Device disconnection is categorized into the following types:

  • Active disconnection: A device closes the connection to IoT Platform.

  • Forcible disconnection: IoT Platform closes the connection to a device.

    For example, a device is forced to disconnect from IoT Platform if another device uses the same device certificate to access IoT Platform. A forcible disconnection also occurs if you delete or disable the device in IoT Platform.

Message Queuing Telemetry Transport (MQTT) keep-alive mechanism

The heartbeat interval for an MQTT connection ranges from 30 to 1,200 seconds. If a heartbeat interval is not within the specified value range, the server rejects the connection request. We recommend that you specify an interval that is greater than 300 seconds.

A timer starts when IoT Platform sends a CONNACK message as a response to a CONNECT message. When IoT Platform receives a PUBLISH, SUBSCRIBE, PING, or PUBACK message, the timer is reset. IoT Platform checks the heartbeat of the MQTT connection every 30 seconds. The wait time for the heartbeat check is the period between the point in time at which a device connects to IoT Platform and the point in time at which the next heartbeat check is performed. The maximum timeout period is calculated by using the following formula: Heartbeat interval × 1.5 + Wait time for the heartbeat check. If the server receives no messages from the device within the maximum timeout period, the server ends the connection with the device.

References