Use dynamic registration over MQTT

Updated at:

The C Link software development kit (SDK) for IoT Platform provides a dynamic registration feature, also known as one-type-one-secret. This feature helps reduce provisioning costs by removing the need to provision each device with a unique device secret. Using dynamic registration over Message Queuing Telemetry Transport (MQTT), a device can obtain the credentials required to connect to IoT Platform.

Prerequisites

  • Set up the development environment.
  • On the SDK Customization page, in the Device Authentication Method section, select Dynamic Registration.

  • created a product, retrieved the ProductName and ProductSecret, and enabled Dynamic Registration.
  • If you use the pre-registration authentication method, add one or more devices to the product and obtain the DeviceName for each device.

    For more information about the features and limits of the pre-registration and registration-free methods, see One-Type-One-Secret.

How it works

MQTT protocol to dynamically register and obtain the credentials required to connect to IoT Platform.

./demos/dynregmq_basic_demo.c

MQTT dynamic registration sequence diagram

For more information about the MQTT dynamic registration APIs, see aiot_dynregmq_api.h.

The following table lists the identity information sent in a registration request and the credentials returned for the pre-registration and registration-free methods.

MethodRequest identity informationReturned credentials
Pre-registration
  • ProductKey
  • ProductSecret
  • DeviceName
DeviceSecret
Registration-free
  • ProductKey
  • ProductSecret
  • clientId
  • userName
  • password

Examples

What to do next

After the device is dynamically registered, you can use the returned credentials to activate the device and connect it to IoT Platform. Depending on the protocol your device uses, see one of the following topics:
Note
  • Before a device is activated, you can perform dynamic registration multiple times. The latest generated DeviceSecret takes precedence. Make sure that the DeviceSecret burned to the device is the latest one.
  • After a device is activated, you must call the ResetThing API operation to reset the device's dynamic registration status to unregistered. You can then dynamically register the device again.