Sub-Device Registration¶
Register sub-devices under an gateway device.
Upstream
Request TOPIC:
/sys/{productKey}/{deviceKey}/thing/device/register
Reply TOPIC:
/sys/{productKey}/{deviceKey}/thing/device/register_reply
Note
The productKey and deviceKey in the TOPIC are the credentials of the gateway.
Sample Request Format¶
{
"method":"thing.device.register",
"id":"1",
"params":[
{
"timezone":"+08:00",
"deviceKey":"sample_dev_01",
"productKey":"subDeviceProductKey1",
"deviceAttributes":{
"location":"Shanghai",
"name":"dev_01"
},
"deviceName":{
"defaultValue":"sample_dev_01",
"i18nValue":{
"en_US":"eng_dev_01",
"zh_CN":"dev_01"
}
},
"deviceDesc":"dev desc"
},
{
"timezone":"+09:00",
"deviceKey":"sample_dev_02",
"productKey":"subDeviceProductKey2",
"deviceAttributes":{
"location":"Beijing",
"name":"dev_01"
},
"deviceName":{
"defaultValue":"sample_dev_02",
"i18nValue":{
"en_US":"eng_dev_02",
"zh_CN":"dev_02"
}
},
"deviceDesc":"dev desc"
}
],
"version":"1.1"
}
Request Parameter Description¶
Parameter |
Type |
Mandatory/Optional |
Description |
---|---|---|---|
method |
String |
Mandatory |
Specifies the type of operation for the request. |
id |
String |
Optional |
A unique identifier for the request. If you use the EnOS SDK,you don’t need to provide an ID and it will be generated by the system. If you use a third-party MQTT tool, the ID is optional. |
version |
String |
Mandatory |
The protocol version number. |
params |
Array |
Mandatory |
Contains information for one or more sub-devices, with each sub-device represented as an object. |
timezone |
String |
Mandatory |
The time zone of the sub-device, formatted as a UTC offset. E.g., “+08:00”. |
deviceKey |
String |
Optional |
The deviceKey of the sub-device, used alongside productKey to form a unique identity. If not specified, it will be automatically generated by the system. |
productKey |
String |
Mandatory |
The productKey of the sub-device. |
deviceAttributes |
String |
Optional |
Custom attributes for the sub-device, in key-value pair format. |
deviceName |
String |
Mandatory |
The name of the sub-device, supporting multiple languages. Provide at least one of default or en_US. |
deviceDesc |
String |
Optional |
A description of the sub-device. |
Sample Response Format¶
{
"code":200,
"data":[
{
"deviceSecret":"yourDeviceSecret",
"assetId":"assetId1",
"deviceKey":"sample_dev_01",
"productKey":"subDeviceProductKey1"
},
{
"deviceSecret":"yourDeviceSecret",
"assetId":"assetId2",
"deviceKey":"sample_dev_02",
"productKey":"subDeviceProductKey2"
}
]
}
Response Parameter Description¶
Parameter |
Type |
Description |
---|---|---|
code |
Integer |
The status code indicating the result of the request. |
data |
JSON |
Contains information about successfully registered sub-devices, with each sub-device as an object. |
deviceSecret |
String |
A secret key assigned by the cloud for the sub-device, used for authentication and communication. |
assetId |
String |
A unique asset ID assigned by the cloud to represent the sub-device’s resource. |
deviceKey |
String |
The Device Key of the sub-device, matching the deviceKey in the request. |
productKey |
String |
The Product Key of the product the sub-device belongs to, matching the productKey in the request. |
Return Code¶
Return Code |
Error Message |
Explanation |
---|---|---|
702 |
DeviceKey existed |
The device key you defined already exists. |
714 |
Generate deviceKey failed |
EnOS failed to automatically generate a device key for you. |
739 |
Exceed the product max device size |
Adding this device will exceed the limit for the maximum number of devices allowed under this product. |