Device provisioning service

更新时间:
复制 MD 格式

This service provides a set of APIs for device provisioning and binding. You can use these APIs to bind users to Bluetooth, GPRS, and Wi-Fi devices, and perform operations for the sub-device onboarding process.

Note The device provisioning service has been upgraded with new features, such as home, space, and group control. If you do not need these features, see the previous version of the device provisioning service.

Preparation for network provisioning

Device provisioning

Device binding

Get the list of discovered devices

Description

PathVersionDescriptionRequires user authentication
/awss/enrollee/list/get1.0.7Performs a paged query to get the list of discovered devices.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
pageSizeIntegerYesThe number of entries per page. The value must be less than or equal to 99.
pageNumIntegerYesThe page number. The value starts from 1.

Response parameters

ParameterSub-parameterTypeDescription
totalNumIntegerThe total number of entries.
itemsJSON ListAn array of objects.
gmtCreateDateThe time when the entry was created.
gmtModifiedDateThe time when the entry was last modified.
regIotIdStringThe iotId of the provisioned device.
regProductKeyStringThe ProductKey of the provisioned device.
regDeviceNameStringProvisioned device: deviceName
regProductNameStringThe product name of the provisioned device.
enrolleeIotIdStringThe iotId of the device to be provisioned.
enrolleeProductKeyStringThe ProductKey of the device to be provisioned.
enrolleeDeviceNameStringThe DeviceName of the device to be provisioned.
enrolleeProductNameStringThe product name of the device to be provisioned.
bssidStringRouter BSSID
ssidStringHotspot SSID
rssiStringHotspot RSSI
typeIntegerThe type of the discovering device. 0 indicates a device. 1 indicates a router.
statusIntegerThe provisioning status. 0 indicates the initial state. 1 indicates that the device is being provisioned.

Examples

  • Sample request
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "pageSize": 10,
            "pageNum": 1
        }
    }
                        
  • Sample success response
    {
        "code": 200,
        "data": {
            "totalNum":12,
            "items":[
                {
                    "gmtCreate":xxx,
                    "gmtModified":xxx,
                    "regIotId":"xxx",
                    "regProductKey":"xxx",
                    "regDeviceName":"xxx",
                    "enrolleeIotId":"xxx",
                    "enrolleeProductKey":"xxx",
                    "enrolleeDeviceName":"xxx",
                    "bssid":"xxx",
                    "ssid":"xxx",
                    "rssi":"xxx",
                    "type":0,
                    "status":1
                }
            ]
        },
        "message": "success"
    }
                        

Filter the list of locally discovered devices

Description

PathVersionDescriptionRequires user authentication
/awss/enrollee/product/filter1.0.7Filters the list of locally discovered devices to find devices that are not yet bound to a user. The filtering is based on specified rules.
Note By default, this API processes only published products. To process products that are under development, set the PRODUCT_SCOPE_ALL parameter in the SDK before you call this API:
  • Android: setProductScope
  • iOS: [[IMSIotSmart sharedInstance] configProductScope:PRODUCT_SCOPE_ALL];
Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotDevicesJSON ListYesThe list of locally discovered devices.

The following describes the schema of the iotDevices list.

Field nameField typeRequiredDescription
productKeyStringYesProduct Key
deviceNameStringYesThe device name.

Response parameters

ParameterTypeDescription
productKeyStringThe ProductKey of the product. This is the same as the request parameter.
deviceNameStringThe device name. This is the same as the request parameter.
productNameStringThe product name.
netTypeIntegerThe network connection type.
  • 0: LoRa
  • 3: Wi-Fi
  • 4: Zigbee
  • 5: Bluetooth
  • 6: Cellular
  • 7: Ethernet
  • 8: Other
nodeTypeIntegerThe node type. 0 indicates a device. 1 indicates a gateway.
categoryKeyStringThe identifier of the product category.
categoryNameStringThe name of the product category.
categoryIdLongThe ID of the product category.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params":{
            "iotDevices": [{
                "productKey": "a1xxxxm",
                "deviceName": "xxxxxx"
            },
            {
                "productKey": "a1xxxxb",
                "deviceName": "xxxxxx"
            }]
        }
    }
                        
  • Successful response example
    {
        "code": 200,
        "data":[{
                    "productKey":"a1xxxxm",
                    "deviceName":"xxxxxx",
                    "netType":3,
                    "nodeType":0,
                    "categoryKey":"xxx",
                    "categoryName":"xxx",
                    "categoryId":14
                }
        ],
        "message": "success"
    }

Query device certificate information by token

Description

PathVersionDescriptionRequires user authentication
/awss/token/check1.0.9Checks a token.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
tokenStringYesThe token reported by the device.
productKeyStringNoThe ProductKey of the device.
deviceNameStringNoThe DeviceName of the device. If you specify this parameter, you must also specify the productKey parameter.

Response parameters

ParameterTypeDescription
productKeyStringThe ProductKey of the device to be provisioned.
deviceNameStringThe DeviceName of the device to be provisioned.
iotIdStringThe iotId of the device.

Examples

  • Request example
    {
        "request": {
            "iotToken": "109049c80bxxxx62e29a3ba",
            "apiVer": "1.0.9"
        },
        "id": 1508212818676,
        "params": {
            "token":"xxx"
        },
        "version": "1.0"
    }
  • Successful response example
    {
      "code": 200,
      "data": {
          "iotId": "xxxx"
          "productKey": "xxxx",
          "deviceName": "xxxx"
        },
      "id": "e2d74ffe-308e-xxxx-xxxx-9b44a43eabc9"
    }
  • Error response example
    {
     "code":6608,
     "id":"4fa207ca-fffd-xxxx-xxxx-e6f7ca6c99c3",
     "message":"token not found"
    }

Token-based device attachment

Description

PathVersionDescriptionRequires user authentication
/awss/token/user/bind1.0.8Checks a token and binds the device.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
homeIdStringYesThe home ID. This is the unique identifier of a home.
productKeyStringYesThe ProductKey of the device to be provisioned.
deviceNameStringYesThe DeviceName of the device to be provisioned.
tokenStringYesThe token reported by the device.

Response parameters

ParameterTypeDescription
dataStringThe iotId of the provisioned device.

Examples

  • Request example
    {
        "id":"xxx",
        "version":"1.0.0",
        "request":{
            "language":"en-US",
            "appKey":"xxx",
            "iotToken":"xxx",
            "apiVer":"1.0.8"
        },
        "params":{
            "homeId":"50f5op1556xxxxf2f28104512",
            "productKey":"xxx",
            "deviceName":"xxx",
            "token":"xxx"
        }
    }
  • Successful response example
    {
        "id":"xxx",
        "code":200,
        "message":"success",
        "data":"xxxxxxxxxxxxx"
    } 

Attaching devices based on a time window

Description

PathVersionDescriptionRequires user authentication
/awss/time/window/user/bind1.0.8Checks and binds a device within a 600-second time window. The time window starts when the device is powered on.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
homeIdStringYesThe home ID. This is the unique identifier of a home.
productKeyStringYesThe ProductKey of the device to be provisioned.
deviceNameStringYesThe DeviceName of the device to be provisioned.

Response parameters

ParameterTypeDescription
dataStringThe iotId of the provisioned device.

Examples

  • Request example
    {
        "id":"xxx",
        "version":"1.0.0",
        "request":{
            "language":"en-US",
            "appKey":"xxx",
            "iotToken":"xxx",
            "apiVer":"1.0.8"
        },
        "params":{
            "homeId":"50f5op15xxxxca4f2f28104512",
            "productKey":"xxx",
            "deviceName":"xxx"
        }
    }
  • Successful response example
    {
        "id":"xxx",
        "code":200,
        "message":"success",
        "data":"xxxxxxxxxxxxx"
    }

Get a key

Description

PathVersionDescriptionRequires user authentication
/awss/cipher/get1.0.7Gets a key.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterSubkeyTypeRequiredDescription
deviceInfoForCipherYesA JSON object.
deviceNameStringYesdeviceName
productKeyStringYesThe ProductKey. This parameter is required for non-Bluetooth devices. It is not required for Bluetooth devices.
productIdStringYesThe hexadecimal string of the ProductKey. This parameter is required for Bluetooth devices. It is not required for non-Bluetooth devices.
cipherTypeIntegerYesThe type of key to generate. For more information, see the description after this table. If this parameter is empty, the default value indicates per-product keys.
randomStringYesA random number. This is a 32-byte hexadecimal string.
paramsJSONYesExtension parameters. For Bluetooth devices, you must pass the MAC address. For non-Bluetooth devices, pass an empty map.

The following list describes the valid values for the cipherType parameter.

cipherType=3 Per-product key: Queries the productSecret based on the ProductKey. Key algorithm: sha256(contentByteArray).
contentByteArray=productSecret.getByte()+0x2c+hexToByte(random) 

cipherType=4 Per-device key: Queries the deviceSecret based on the ProductKey and DeviceName. Key algorithm: sha256(contentByteArray).
contentByteArray=deviceSecret.getByte()+0x2c+hexToByte(random)

cipherType=6 BLE per-product key: Key algorithm: sha256(contentByteArray).
contentByteArray=productSecret.getByte()+0x2c+hexToByte(mac)+0x2c+hexToByte(random)

cipherType=7 BLE per-device key: Key algorithm: sha256(contentByteArray).
contentByteArray=deviceSecret.getByte()+0x2c+hexToByte(mac)+0x2c+hexToByte(random)
            

The following list describes the differences between per-product keys and per-device keys.

  • Per-product key: The system uses the product key (productSecret) to generate the encryption key for local communication during provisioning. You only need to provide the ProductKey.
  • Per-device key: The system uses the device key (deviceSecret) to generate the encryption key for local communication during provisioning. You must provide both the ProductKey and the DeviceName.

Response parameters

NameTypeDescription
secretIntegerThe encryption key for local communication during provisioning.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "deviceInfoForCipher": {
                "deviceName": "xxxx",
               "productKey": "xxxx",
                "productId": "001e7",
                "cipherType": 3, 
                "random": "00000000000000000000000000000000",
                "params": {
                    "mac":"xxx"
                }
            }
        }
    }     
  • Successful response example
    {
        "code": 200,
        "data": "xxxx",
        "message": "success"
    }

Add a sub-device to a gateway

Description

PathVersionDescriptionRequires user authentication
/thing/gateway/permit1.0.2Allows a gateway to process requests to add sub-devices.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesThe iotId of the gateway device.
productKeyStringYesThe ProductKey of the sub-device product that is allowed to connect to the gateway.
timeIntegerYes
  • 0: The gateway always allows sub-devices to be added.
  • 0-65535: The duration in seconds that the gateway allows sub-devices to be added.
  • 65535: The gateway does not allow sub-devices to be added.

Response parameters

There are no specific response parameters for this operation.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "iotId": "xxxxxxxxxxxxxx",
            "productKey": "xxxxxxxxx", 
            "time": 60                   
        }
    }             
  • Successful response example
    {
        "id":"xxx",
        "code":200,
        "message":"success",
        "data":null
    }

Remove a sub-device from the network topology

Description

PathVersionDescriptionRequires user authentication
/thing/topo/remove1.0.2Removes a sub-device from the network topology.Yes. The client SDK must enable identity authentication.

Request parameters

ParameterTypeRequiredDescription
iotIdStringYesDevice IoT ID
subIotidStringYesThe iotId of the sub-device.

Response parameters

There are no specific response parameters for this operation.

Examples

  • Request example
    {
        "id": "1509086454180",
        "version": "1.0",
        "request": {
            "apiVer": "1.0.2",
            "iotToken": "token"
        },
        "params": {
            "iotId": "xxxxxxxxxxxxxx",
            "subIotId": "xxxxxxxxx"                
        }
    }                    
  • Successful response example
    {
        "id":"xxx",
        "code":200,
        "message":"success",
        "data":null
    }