@soszrg
2018-03-05T08:45:59.000000Z
字数 4799
阅读 520
V3.1
POST /v3_1/device/activation/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| fog_id | string | 是 | FogCloud license |
| enduser_id | string | 否 | App用户ID |
| product_id | string | 是 | 产品ID |
| dsn | string | 是 | 设备MAC地址或串号 |
| password | string | 是 | 设备密码(最少16位) |
| time_zone | string | 否 | 设备所在时区 |
| sign | string | 否 | Fogid签名 |
返回值
{"meta": {"message": "activate ok","code": 0},"data": {"host": "4701f1c4f7...","common_port": 1883,"endpoint_name": "4701f1c4f78411e7...","ssl_port": 1884,"password": "i7wZWg+rXH0fH9Gju9k...","device_id": "eee4f85ef78511e..."}}
| 参数名 | 类型 | 说明 |
|---|---|---|
| host | string | MQTT Server地址 |
| endpoint_name | string | MQTT Server实例ID |
| common_port | int | 非加密端口 |
| ssl_port | int | 加密端口 |
| device_id | string | 设备ID |
| password | string | 登录密码 |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message字段 |
| 10201 | 设备已经激活过,但密码错误 |
| 10050 | 未预期的错误:百度iot套件报错等 |
PUT /v3_1/device/superuser/check/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| device_id | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
| req_type | int | 是 | 请求类型(mqtt不需要传该参数) |
| req_id | int | 否 | 请求ID,由设备端生成,用于追踪请求 |
说明
{"type":"superuser","data":{"req_id":123...}}
{"data":{"has_superuser":false},"meta":{"message":"check ok","code":0},"type":"superuser","req_id":123..}
返回值
{"meta":{"message":"check ok","code":0},"data":{"is_virtual":true,"has_superuser":true,"phone":"","req_id":123...,"enduser_id":"4d1939513ede...","email":""}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| has_superuser | bool | 是否有超级用户:True→有,False→没有 |
| is_virtual | bool | 绑定的用户是否为虚拟用户 |
| phone | string | 用户的手机号 |
| string | 用户的邮箱 | |
| enduser_id | string | 用户的ID |
| req_id | string | 请求ID |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少参数或者参数类型错误等 |
PUT /v3_1/device/unbind/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| device_id | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
| req_type | int | 是 | 请求类型(mqtt不需要传该参数) |
| req_id | int | 否 | 请求ID,由设备端生成,用于追踪请求 |
{"type":"unbind","data":{"password": "fabax...""req_id":123...}}
{"data":{},"meta":{"message":"unbind success","code":0},"type":"unbind","req_id":123...}
返回值
{"meta": {"message": "unbind success","code": 0},"req_id": 123,"data": {}}
字段说明
无
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少参数或者参数类型错误等 |
PUT /v3_1/ota/device/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| device_id | string | 是 | 设备ID(mqtt不需要传该参数) |
| password | string | 是 | 设备密码 |
| component | string | 否 | 组件名称(适用于多组件的产品) |
| req_type | int | 否 | 请求类型(mqtt不需要传该参数) |
| req_id | int | 否 | 请求ID,由设备端生成,用于追踪请求 |
{"type":"ota_check","data":{"password": "112xx...","component": "xxxx" # 可选参数"req_id":123...}}
{"type": "ota_check","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":""}],"ot_id":25,"req_id": 123...}}
返回值
{"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":""}],"ot_id":25}}
字段说明
| 返回值字段 | 字段类型 | 字段说明 |
|---|---|---|
| need_upgrade | bool | 是否需要升级 |
| ot_id | int | 任务ID |
| files | list | 升级文件列表 |
| customize | string | 用户自定义字段(公版不需要) |
说明
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:具体信息见Response的message字段 |
PUT /v3_1/ota/device/log/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| device_id | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
| ot_id | int | 是 | 任务ID |
| update_ok | bool | 是 | 设备固件是否更新成功,默认为true |
| components | string Array | 否 | 本次完成更新的组件名称列表 |
| customize | string | 否 | 用户自定义字符串(公版不需要) |
| req_type | int | 是 | 请求类型(mqtt方式调用不需要此参数) |
| req_id | int | 否 | 请求ID,由设备端生成,用于追踪请求 |
{"type":"ota_log","data":{"password": "112xx...","ot_id": 1"is_finished": true,"components": ["bbbb", "aavc"] # 可选参数"req_id":123...}}
{"type":"ota_log","meta":{"message":"ota log ok","code":0},"req_id":123,"data":{}}
返回值
{"meta":{"message":"ok","code":0},"data":{}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:具体信息见Response的message字段 |
PUT /v3_1/device/timezone/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| device_id | string | 是 | 设备ID |
| password | string | 是 | 设备密码 |
| req_type | int | 是 | 请求类型,目前填1 |
返回值
{"meta": {"message": "check ok","code": 0},"data": {"timezone": "+8"}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:具体信息见Response的message字段 |