@soszrg
2017-09-12T14:58:34.000000Z
字数 5045
阅读 473
v3文档 v3设备端文档
POST /v3/device/activation/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| productid | string | 是 | 产品唯一标识 |
| dsn | string | 是 | 设备串号或MAC |
| password | string | 是 | 设备端产生的随机数(至少16位)作为设备密码 |
返回值
{"meta": {"message": "activate ok","code": 0},"data": {"fog_deviceid": "37db3..."}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| fog_deviceid | string | 设备ID |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误 |
| 10201 | 设备已经激活且密码错误(密码正确返回的code为0) |
| 10202 | 设备被禁用 |
| 10204 | 后激活设备使用后激活接口激活 |
| 10050 | 内部错误 |
注意:
只有密码正确的情况下,设备可以再次激活成功,但不会更新设备相关数据。
POST /v3/device/delayActivation/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| productid | string | 是 | 产品唯一标识 |
| dsn | string | 是 | 设备串号或MAC |
| password | string | 是 | 设备端产生的随机数(至少16位)作为设备密码 |
返回值
{"meta": {"message": "activate ok","code": 0},"data": {"fog_deviceid": "37db3..."}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| fog_deviceid | string | 设备ID |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误 |
| 10200 | 没有找到相关设备,确认dsn,产品ID和设备是否为后激活设备 |
| 10201 | 设备已经激活且密码错误(密码正确返回的code为0) |
| 10202 | 设备被禁用 |
| 10203 | 设备已经在FogCloud控制台删除 |
| 10050 | 内部错误 |
注意:
只有密码正确的情况下,设备可以再次激活成功,但不会更新设备相关数据。
POST /v3/device/auth/
请求参数
| 参数 | 类型 | 必须 | 说明 |
|---|---|---|---|
| deviceid | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
返回结果
{"meta": {"message": "auth info","code": 0},"data": {"endpointname": "8d69e58212cd11e7a...","commonport": 1883,"password": "iLBZ48jfB6tUBIoS8MS...","commonhost": "8d69e58212c...e.com","sslhost": "8d69e58212cd11e7...e.com","sslport": 1884}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| endpointname | string | topic第一部分 |
| password | string | 登录mqtt密码 |
| commonhost | string | 非加密mqtt host |
| commonport | string | 非加密mqtt port |
| sslhost | string | 加密mqtt host |
| sslport | string | 加密mqtt host |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误 |
| 10202 | 设备被禁用 |
| 10205 | 设备未激活 |
| 10050 | 内部错误 |
POST /v3/wechat/activate/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| productid | string | 是 | 产品唯一标识 |
| dsn | string | 是 | 设备串号或MAC |
| password | string | 是 | 设备端产生的随机数(至少16位)作为设备密码 |
返回值
{"meta": {"message": "activate ok","code": 0},"data": {"deviceid": "37db31..."}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| deviceid | string | 设备ID |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response的message字段 |
| 10050 | 内部错误 |
| 10201 | 设备已经激活且密码错误 |
| 10202 | 设备被禁用 |
| 10204 | IP设备需要使用后激活接口(/v3/device/delayActivation/) |
| 10301 | 没有在Fogcloud控制台配置APP的微信参数 |
| 11500 | 向微信服务器注册设备失败 |
注意:
只有密码正确的情况下,设备可以再次激活成功,但不会更新设备相关数据。
GET /server/time/
请求参数
无
返回值
{"meta": {"message": "server time","code": 0},"data": {"week2": "Friday","timestamp1": 1494558458,"datetime1": "2017-05-12 11:07:38","datetime2": "2017年5月12日 11时7分38秒","week1": 5,"week3": "周五","timestamp1": "1494558458","week4": "星期五"}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| timestamp1 | int | 整型时间戳 |
| timestamp2 | string | 时间戳字符串 |
| week1 | int | 整型星期,从1开始计数(即:周一为1,周日为7) |
| week2 | string | 英文星期 |
| week3 | string | 中文星期格式一 |
| week4 | string | 中文星期格式二 |
错误码
无
PUT /v3/ota/device/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| deviceid | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
| component | string | 是 | 固件名称 |
返回值
{"meta":{"message":"ota file info","code":0},"data":{"files":[{"file_url":"https://test.com/a.bin","component":"test1","md5":"1abx..","version":"1.0.1","customize":""},{"file_url":"https://test.com/a.bin","component":"test2","md5":"1safa...","version":"1.0.1","customize":""}],"otid":25}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| need_upgrade | bool | 是否需要升级 |
| otid | int | 任务ID |
| files | list | 升级文件列表 |
说明
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:具体信息见Response的message字段 |
PUT /v3/ota/product/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| productid | string | 是 | 产品ID |
| dsn | string | 否 | 设备串号或MAC地址 |
| component | string | 否 | 固件名称 |
返回值
{"meta":{"message":"ota file info","code":0},"data":{"files":[{"file_url":"https://test.com/a.bin","component":"test1","md5":"1abx..","version":"1.0.1","customize":""},{"file_url":"https://test.com/a.bin","component":"test2","md5":"1safa...","version":"1.0.1","customize":""}],"otid":25}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| need_upgrade | bool | 是否需要升级 |
| otid | int | 任务ID |
| files | list | 升级文件列表 |
说明
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:具体信息见Response的message字段 |
PUT /v3/ota/device/log/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| deviceid | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
| otid | string | 是 | 任务ID |
| isfinished | bool | 否 | 设备固件是否全部更新完成,默认为true |
| components | string Array | 否 | 本次更新完成的固件名称列表 |
| customize | string | 否 | 用户自定义字符串 |
返回值
{"meta":{"message":"ok","code":0},"data":{}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:具体信息见Response的message字段 |
PUT /v3/ota/product/log/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| productid | string | 是 | 设备ID |
| dsn | string | 是 | 设备串号或MAC地址 |
| otid | string | 是 | 任务ID |
| isfinished | bool | 否 | 设备固件是否全部更新完成,默认为true |
| components | string Array | 否 | 本次更新完成的固件名称列表 |
| customize | string | 否 | 用户自定义字符串 |
返回值
{"meta":{"message":"ok","code":0},"data":{}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:具体信息见Response的message字段 |
PUT /v3/device/superuser/check/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| deviceid | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
| req_type | int | 是 | 请求类型 |
| req_id | int | 否 | 请求ID,由设备端生成,用于追踪请求 |
说明
返回值
{"meta":{"message":"check ok","code":0},"data":{"isvirtual":true,"hassuperuser":true,"phone":"","req_id":123...,"enduserid":"4d1939513ede...","email":""}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| hassuperuser | bool | 是否有超级用户:True→有,False→没有 |
| isvirtual | bool | 绑定的用户是否为虚拟用户 |
| phone | string | 用户的手机号 |
| string | 用户的邮箱 | |
| enduserid | string | 用户的ID |
| req_id | string | 请求ID |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少参数或者参数类型错误等 |
POST /v3/device/datapoint/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| deviceid | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
返回值
{"meta": {"message": "data point info","code": 0},"data": {"dp": [{"key_name": "a","type": "string","id": 1,"attr": "w"},{"key_name": "d","type": "float","id": 3,"attr": "r"}]}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少参数或者参数类型错误等 |