Device registration

更新时间:
复制 MD 格式

Register devices with IoT Platform before they go online.

Registration methods

IoT Platform supports two registration methods:

Dynamic MQTT registration for sub-devices

  • Request topic: /sys/${productKey}/${deviceName}/thing/sub/register

  • Response topic: /sys/${productKey}/${deviceName}/thing/sub/register_reply

Request data format:

{
  "id": "123",
  "version": "1.0",
  "sys":{
      "ack":0
  },
  "params": [
    {
      "deviceName": "deviceName1234",
      "productKey": "a1234******"
    }
  ],
  "method": "thing.sub.register"
}

Response data format:

{
  "id": "123",
  "code": 200,
  "data": [
    {
      "iotId": "12344",
      "productKey": "a1234******",
      "deviceName": "deviceName1234",
      "deviceSecret": "xxxxxx"
    }
  ]
}

Parameters:

Parameter

Type

Description

id

String

The message ID. Must be a unique numeric string per device. Valid values: 0 to 4294967295.

version

String

The protocol version. The only valid value is 1.0.

sys

Object

Extended feature parameters.

Note

If you use a device-side SDK without setting extended features, this parameter is omitted and defaults apply.

ack

Integer

Whether the cloud returns a response. A field under sys.

  • 1: Returns a response.

  • 0: No response returned.

Important

Thing Specification Language model usage examples.

If not configured, this parameter is omitted and a response is returned by default.

params

List

Parameters for the dynamic registration of a sub-device.

deviceName

String

The name of the sub-device.

productKey

String

The ProductKey of the sub-device.

iotId

String

The unique ID of the device.

deviceSecret

String

The device secret.

method

String

The request method. Set to thing.sub.register.

code

Integer

The result code.

Error codes:

Error code

Message

Description

460

request parameter error

The request parameters are invalid.

6402

topo relation cannot add by self

A device cannot be added as its own sub-device.

401

request auth error

Signature verification failed.

Dynamic HTTPS registration for directly connected devices

  • URL template: https://iot-auth.${YourRegionId}.aliyuncs.com/auth/register/device

  • HTTP method: POST

    Request data format:

    POST /auth/register/device  HTTP/1.1
    Host: iot-auth.cn-shanghai.aliyuncs.com
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 123
    productKey=a1234******&deviceName=deviceName1234&random=567345&sign=adfv123hdfdh&signMethod=HmacMD5

    Response format:

    {
      "code": 200,
      "data": {
        "productKey": "a1234******",
        "deviceName": "deviceName1234",
        "deviceSecret": "adsfw******"
      },
      "message": "success"
    }

    Parameters:

    Parameter

    Type

    Description

    Method

    String

    The request method. POST only.

    Host

    String

    The dynamic HTTPS registration endpoint: iot-auth.${YourRegionId}.aliyuncs.com.

    ${YourRegionId}: The region ID of your IoT Platform instance.

    • Supported regions: all regions except China (Beijing) and China (Shenzhen).

    • Region IDs: Supported regions.

    Content-Type

    String

    The encoding format for device-to-cloud data.

    productKey

    String

    The product identifier.

    deviceName

    String

    The device name.

    random

    String

    A random number.

    sign

    String

    The signature.

    Signing method:

    1. Sort all parameters except sign and signMethod alphabetically, then concatenate names and values without delimiters.

    2. Sign the concatenated string using the signMethod and the product's ProductSecret.

    Signature example:

    hmac_sha1(productSecret, deviceNamedeviceName1234productKeya1234******random123)

    signMethod

    String

    The signing algorithm. Valid values: hmacmd5, hmacsha1, hmacsha256.

    code

    Integer

    The result code.

    deviceSecret

    String

    The device secret.