Use dynamic registration over MQTT
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

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.
| Method | Request identity information | Returned credentials |
| Pre-registration |
| DeviceSecret |
| Registration-free |
|
|
Examples
- Example of dynamic registration over MQTT.
- aiot_dynregmq_api.hStatus code descriptions.
What to do next
- 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.