配网服务
更新时间:2018-03-15 20:34:06
蓝牙设备绑定
定义描述
| path | 版本 | 描述 | 是否需要登陆 |
|---|---|---|---|
| /awss/ble/user/bind | 1.0.0 | 蓝牙设备绑定 | 是 |
请求参数
参数 |
子键 |
类型 |
必填 |
描述 |
deviceInfoForCipher |
是 |
JSON对象 |
||
deviceName |
String |
是 |
deviceName |
|
productId |
String |
是 |
productId,16进制字符串 |
|
sign |
String |
是 |
签名 |
|
signMethod |
String |
是 |
signMethod,可支持hmacSha1,hmacSha256,hmacMd5,sha256 |
|
signParams |
JSON |
是 |
加签扩展参数 |
返回参数
| 名称 | 类型 | 描述 |
|---|---|---|
| iotId | String | 全部蓝牙设备的iotId |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"deviceInfoForCipher": {
"deviceName": "xxxx",
"productId": "001e7",
"sign": "xxxxxxx",
"signMethod": "hmacSha1",
"signParams": {
"mac":"xxx"
}
}
}
}
正常返回示例
{
"code": 200,
"data": "xxxx",
"message": "success"
}
错误码
| 错误码 | 错误信息 | 详细描述 |
|---|---|---|
| 28560 | device not exist | 设备不存在 |
| 28563 | ble device bind sign error | 蓝牙设备验签不通过 |
附录一.签名算法
蓝牙设备进行身份认证,蓝牙不传pk传的是productId
验签是将productKey + deviceName + map里的参数 按照字典进行升序排序,然后组成kv串即为待加密的签名
支持hmacSha1,hmacSha256,hmacMd5 忽略大小写
sign规则 hmac_md5(deviceSecret, clientId***deviceName***productKey***timestamp***)
hmac_sha1(deviceSecret, clientId***deviceName***productKey***timestamp***)
hmac_sha256(deviceSecret, clientId***deviceName***productKey***timestamp***)
sha256(clientId***deviceName***deviceSecret***productKey***timestamp***)
配网设备连接
定义描述
| path | 版本 | 描述 | 是 |
|---|---|---|---|
| /awss/enrollee/connect | 1.0.0 | 待配网设备请求连接配网 | 是 |
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| regProductKey | String | 是 | 已联网/路由器设备productKey |
| regDeviceName | String | 是 | 已联网/路由器设备deviceName |
| enrolleeProductKey | String | 是 | 待配网者productKey |
| enrolleeDeviceName | String | 否 | 待配网者deviceName |
返回参数
| 名称 | 类型 | 描述 |
|---|---|---|
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"regProductKey": "regPk",
"regDeviceName": "regDn",
"enrolleeProductKey": "erPk",
"enrolleeDeviceName": "erDn"
}
}
正常返回参数
{
"code": 200,
"data": null,
"message": "success"
}
错误码
| 错误码 | 错误信息 | 详细描述 |
|---|---|---|
| 28561 | router has been locked | 路由器已被锁定 |
| 28559 | no device connect | 无已连接设备 |
| 28558 | connect timeout | 连接超时 |
| 28557 | device connect fault | 配网连接异常 |
获取发现设备列表
定义描述
| path | 版本 | 描述 | 是否需要登陆 |
|---|---|---|---|
| /awss/enrollee/list/get | 1.0.0 | 分页查询发现设备列表 | 是 |
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| pageSize | Integer | 是 | 分页大小 |
| pageNum | Integer | 是 | 页编号 |
返回参数
参数 |
子键 |
类型 |
描述 |
totalNum |
|
Integer |
总数 |
items |
List |
对象数组 |
|
gmtCreate |
Date |
创建时间 |
|
gmtModified |
Date |
修改时间 |
|
identityId |
String |
用户身份 |
|
regIotId |
String |
已配网设备iotId |
|
regProductKey |
String |
已配网设备productKey |
|
regDeviceName |
String |
已配网设备deviceName |
|
enrolleeIotId |
String |
待配网设备iotId |
|
enrolleeProductKey |
String |
待配网设备productKey |
|
enrolleeDeviceName |
String |
待配网设备deviceName |
|
bssid |
String |
路由器bssid |
|
ssid |
String |
热点ssid |
|
rssi |
String |
热点rssi |
|
type |
Integer |
发现者设备类型(0:device, 1:router) |
|
status |
Byte |
配网过程状态(0:初始态, 1:配网完成) |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"pageSize": 10,
"pageNum": 1
}
}
正常返回示例
{
"code": 200,
"data": {
"totalNum":12,
"items":[
{
"gmtCreate":xxx,
"gmtModified":xxx,
"identityId":"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"
}
错误码
| 错误码 | 错误信息 | 详细描述 |
|---|---|---|
| 28551 | user no register or router | 用户没有绑定已配网设备或路由器 |
GPRS设备绑定
定义描述
| path | 版本 | 描述 | 是否需要登陆 |
|---|---|---|---|
| /awss/gprs/user/bind | 1.0.0 | gprs设备绑定 | 是 |
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| productKey | String | 是 | 待配网设备productKey |
| deviceName | String | 是 | 待配网设备deviceName |
返回参数
| 名称 | 类型 | 描述 |
|---|---|---|
| iotId | String | 已配网设备iotId |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"productKey": "xxx",
"deviceName": "xxx"
}
}
正常返回示例
{
"code": 200,
"data": "xxxx",
"message": "success"
}
错误码
| 错误码 | 错误信息 | 详细描述 |
|---|---|---|
| 28566 | product not exist | 产品不存在 |
| 28567 | device must be gprs device | 必须是GPRS设备 |
| 28560 | device not exist | 设备不存在 |
获取秘钥
定义描述
| path | 版本 | 描述 | 是否需要登陆 |
|---|---|---|---|
| /awss/cipher/get | 1.0.0 | 获取秘钥 | 是 |
请求参数
参数 |
子键 |
类型 |
必填 |
描述 |
deviceInfoForCipher |
|
|
是 |
JSON对象 |
|
deviceName |
String |
是 |
deviceName |
|
productKey |
String |
是 |
productKey,16进制字符串(蓝牙设备传,非蓝牙设备需传null,不是null字符串) |
|
productId |
String |
是 |
productId(蓝牙设备传,非蓝牙设备需要传null,不是null字符串) |
|
cipherType |
Integer |
是 |
生成秘钥的类型,如果为空默认一型一密(详见附录) |
|
random |
String |
是 |
随机数(32字节16进制字符串) |
params |
JSON |
是 |
扩展参数(蓝牙设备需要传mac,非蓝牙设备传空map) |
返回参数
| 名称 | 类型 | 描述 |
|---|---|---|
| secret | Integer | 全部数据数量 |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"deviceInfoForCipher": {
"deviceName": "xxxx",
"productKey": "xxxx",
"productId": "001e7",
"cipherType": 3,
"random": "00000000000000000000000000000000",
"params": {
"mac":"xxx"
}
}
}
}
正常返回示例
{
"code": 200,
"data": "xxxx",
"message": "success"
}
错误码
| 错误码 | 错误信息 | 详细描述 |
|---|---|---|
附录一.秘钥生成规则
cipherType=3 一型一密:根据productKey查询productSecret,密钥算法sha256(contentByteArray)。
contentByteArray=productSecret.getByte()+0x2c+hexToByte(random)
cipherType=4 一机一密:根据productKey和deviceName查询deviceSecret,密钥算法sha256(contentByteArray)。
contentByteArray=deviceSecret.getByte()+0x2c+hexToByte(random)
(暂不开放)
cipherType=5 一厂一密:根据model查询manufacturer的accessKey&accessSecret(目前model新增时需要手动录入),密钥算法sha256(contentByteArray)。
contentByteArray=accessSecret.getByte()+0x2c+hexToByte(random)
cipherType=6 BLE一型一密:密钥算法sha256(contentByteArray)。
contentByteArray=productSecret.getByte()+0x2c+hexToByte(mac)+0x2c+hexToByte(random)
cipherType=7 BLE一机一密:密钥算法sha256(contentByteArray)
contentByteArray=deviceSecret.getByte()+0x2c+hexToByte(mac)+0x2c+hexToByte(random)
Wifi设备绑定
定义描述
| path | 版本 | 描述 | 是否需要登陆 |
|---|---|---|---|
| /awss/enrollee/user/bind | 1.0.0 | wifi设备绑定 | 是 |
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| productKey | String | 是 | 待配网设备productKey |
| deviceName | String | 是 | 待配网设备deviceName |
| token | String | 是 | 设备上报的token |
返回参数
| 名称 | 类型 | 描述 |
|---|---|---|
| iotId | String | 已配网设备iotId |
示例
请求示例
{
"id": "1509086454180",
"version": "1.0",
"request": {
"apiVer": "1.0.0",
"iotToken": "token"
},
"params": {
"productKey": "xxx",
"deviceName": "xxx"
"token":"xxx"
}
}
正常返回示例
{
"code": 200,
"data": "xxxx",
"message": "success"
}
错误码
| 错误码 | 错误信息 | 详细描述 |
|---|---|---|
| 6100 | device not found | 设备不存在 |