上线子设备¶
在子设备上线前,需要确保子设备身份已经在 EnOS 云端中注册,并在 Edge 中添加拓扑关系。云端需要根据拓扑关系对子设备进行身份校验,以确定子设备具有使用网关通道的能力,才会上线该子设备。
上行
请求 TOPIC:
/ext/session/{productKey}/{deviceKey}/combine/login响应 TOPIC:
/ext/session/{productKey}/{deviceKey}/combine/login_reply
备注
TOPIC 中的 productKey 和 deviceKey 为网关的三元组。
请求数据格式¶
{
    "id": "123",
    "params": {
        "productKey": "theSubProductKey",
        "deviceKey": "theSubDeviceKey",
        "clientId": "theSubDeviceId",
        "timestamp": "1524448722000",
        "signMethod": "hmacmd5",
        "sign": "theSignature",
        "cleanSession": "true"
    },
    "method":"combine.login"
}
响应数据格式¶
{
  "id":"123",
  "code":200,
  "message":"success",
  "data": {
    "assetId": "assetId",
    "productKey": "theSubProductKey",
    "deviceKey": "theSubDeviceKey"
  }
}
所有发往 EnOS 云端的参数都会被加密,除了 sign 和 signmethod 之外。EnOS 云端会将参数按照字母顺序排序,然后将参数和值依次拼接(无拼接符号)。对加签内容,需使用 signMethod 指定的加签算法进行加签。
例如,在如下 request 请求中,对 params 中除了 cleanSession 以外的参数按照字母顺序依次拼接后进行加签。
sign=uppercase(hmacsha1( clientIdtheSubDeviceIddeviceKeytheSubDeviceKeyproductKeytheSubProductKeytimestamp1524448722000{deviceSecret}))
请求参数说明¶
参数  | 
类型  | 
是否必需  | 
描述  | 
|---|---|---|---|
id  | 
String  | 
可选  | 
消息 ID 号,保留值。  | 
params  | 
List  | 
必需  | 
子设备上线的参数。  | 
deviceKey  | 
String  | 
必需  | 
子设备的 deviceKey。  | 
productKey  | 
String  | 
必需  | 
子设备的 productKey。  | 
sign  | 
String  | 
必需  | 
子设备签名,规则与网关相同。  | 
signmethod  | 
String  | 
必需  | 
签名方法,支持   | 
timestamp  | 
String  | 
必需  | 
时间戳。  | 
clientId  | 
String  | 
必需  | 
设备端标识,可以为   | 
cleanSession  | 
String  | 
必需  | 
值为   | 
method  | 
String  | 
必需  | 
请求方法  | 
要生成 sign,你需要使用 params 参数中除 sign 和 signmethod 之外的每个键值对。步骤如下。
将除
sign和signmethod之外的每个键值对按字母顺序连接起来,形式为“key+value”“key+value”“key+value”。例如,根据上一步请求的
params,应生成如下连接字符串:clientIdtheSubDeviceIddeviceKeyyourDeviceKeyproductKeyyourProductKeytimestamp1524448722000将设备的 Device Secret 添加到上一步连接字符串的末尾。使用
signmethod指定的算法计算包含设备密钥的字符串。将结果中的所有字母大写,即可得到sign。
例如,如果 Device Secret 是“xyz123”,则可以使用以下命令生成“sign”的值:
sign=uppercase(hmacsha1(clientIdtheSubDeviceIddeviceKeyyourDeviceKeyproductKeyyourProductKeytimestamp1524448722000xyz123))
响应参数说明¶
参数  | 
类型  | 
描述  | 
|---|---|---|
message  | 
String  | 
结果返回信息。  | 
code  | 
Integer  | 
结果返回码,200 代表请求成功执行。  | 
data  | 
JSON  | 
返回的详细信息,JSON 格式。  | 
结果返回码¶
返回码  | 
错误消息  | 
释义  | 
|---|---|---|
705  | 
It failed to query device, not existed this device  | 
子设备不存在  | 
723  | 
Device is disable  | 
子设备被禁用  | 
770  | 
Dynamic activate is not allowed  | 
该产品未启用动态激活  | 
771  | 
Sub device cannot connect to mqtt broker directly  | 
子设备不能与 EnOS 云端直连  | 
740  | 
Sub device not belong the gateway  | 
该设备并非该网关的子设备  | 
742  | 
Sign check failed  | 
Hash 签名验证失败  | 
746  | 
The device must login by ssl  | 
该产品启用了证书双向认证  |