配网服务

更新时间: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 设备不存在

results matching ""

    No results matching ""