@soszrg
2019-06-19T01:52:49.000000Z
字数 8766
阅读 622
v3文档 v3前端接口 v3设备端文档
POST /v3/ota/files/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| product | string | 是 | 产品ID |
| file_name | string | 是 | 文件名 |
| file_url | string | 是 | 固件下载链接 |
| size | int | 是 | 固件大小 |
| md5 | string | 是 | 固件的md5 |
| version | string | 否 | 用户定义的固件版本号 |
| component | string | 否 | 用户定义的固件名称 |
| description | string | 是 | 固件描述 |
| extend | json对象 | 否 | 扩展字段 |
字段说明
返回值
{"meta":{"message":"固件创建成功","code":0},"data":{"ofid":4,"file_name":"a.bin","file_url":"https://test.com/a.bin","size":10,"md5":"abcde...","version":1,"component":"test","description":"bin file","extend":{"customize":1},"product":"test01"}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误 |
GET /v3/ota/files/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| product | string | 是 | 产品ID |
返回值
{"meta":{"message":"固件列表","code":0},"data":[{"ofid":5,"file_name":"a.bin","file_url":"https://test.com/a.bin","size":10,"md5":"aabbxx...","version":1,"component":"test","upload_time":"2017-05-09T14:30:39.570000","description":"","extend":{"a":1},"product":"8d01f204150911e7a554fa163e876164"},{"ofid":4,"file_name":"a.bin","file_url":"https://test.com/a.bin","size":10,"md5":"122aaa","version":2,"component":"test","upload_time":"2017-05-09T14:30:20.511000","description":"","extend":{},"product":"8d01f204150911e7a554fa163e876164"}]}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 29010 | 参数错误:缺少product参数 |
GET /v3/ota/files/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| type | int | 是 | 产品类别:0→CP产品,1→IP产品,2→OTA产品 |
返回值
{"meta":{"message":"固件列表","code":0},"data":[{"ofid":5,"file_name":"a.bin","file_url":"https://test.com/a.bin","size":10,"md5":"aabbxx...","version":1,"component":"test","upload_time":"2017-05-09T14:30:39.570000","description":"","extend":{"a":1},"product":"8d01f204150911e7a554fa163e876164"},{"ofid":4,"file_name":"a.bin","file_url":"https://test.com/a.bin","size":10,"md5":"122aaa","version":2,"component":"test","upload_time":"2017-05-09T14:30:20.511000","description":"","extend":{},"product":"8d01f204150911e7a554fa163e876164"}]}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 29010 | 参数错误:缺少product参数 |
GET /v3/ota/files/<ofid>/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| ofid | int | 是 | 固件ID |
返回值
{"ofid":2,"file_name":"1","file_url":"upload_time","size":1,"md5":"1","version":"1","component":"test","upload_time":"2017-05-07T19:58:17.817000","description":"1","customize":"","extend":null,"product":"8d01f204150911e7a554fa163e876164"}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message |
POST /v3/ota/tasks/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| ota_files | list | 是 | OTA文件ID list |
| status | string | 是 | 任务状态:测试,上线 |
| onset_time | string | 是 | 任务起效时间 |
| description | string | 否 | 任务描述 |
| is_fog | int | 否 | 是否为fog产品 |
| notify_type | int | 否 | 通知类型 |
| ug_type | int | 否 | 升级类型 |
| ug_range | int | 否 | 升级范围类型 |
| version_range | int | 否 | 要升级的版本范围 |
| area_range | string | 否 | 要升级的设备所在的地域 |
| mac_range | string | 否 | 要升级的MAC地址范围 |
| extend | string | 否 | 扩展字段 |
返回值
{"meta":{"message":"ota file info","code":0},"data":{"ofid":8,"file_name":"a.bin","file_url":"https://test.com/a.bin","size":10,"md5":"122aaa","version":1,"component":"test","description":"","extend":{},"product":"test"}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少product参数 |
GET /v3/ota/tasks/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| ofid | int | 否 | OTA文件ID list |
| product | string | 否 | 产品ID |
说明
返回值
{"meta":{"message":"","code":0},"data":{"count":1,"next":null,"previous":null,"results":[{"otid":25,"product":{"productid":"8d01f204150911e7a554fa163e876164","pname":"zrgtest033001"},"status":1,"onset_time":"2017-05-05T00:59:00","description":"","is_fog":1,"notify_type":1,"ug_type":1,"ug_range":0,"mac_range":[],"create_time":"2017-05-11T10:25:50.221000","extend":null,"ota_files":[3,2]}]}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少product参数 |
GET /v3/ota/tasks/<otid>/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| otid | int | 是 | 任务ID |
返回值
{"otid": 25,"status": 1,"onset_time": "2017-05-05T00:59:00","description": "","is_fog": 1,"notify_type": 1,"ug_type": 1,"ug_range": 0,"mac_range": [],"create_time": "2017-05-11T10:25:50.221000","extend": null,"product": "8d01f204150911e7a554fa163e876164","ota_files": [3,2]}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message |
PUT /v3/ota/tasks/<otid>/release/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| otid | int | 是 | 任务ID |
返回值
{"meta":{"message":"发布成功","code":0},"data":{"otid":27,"product":{"productid":"8d01f204150911e7a554fa163e876164","pname":"zrgtest033001"},"ota_files":[{"ofid":3,"file_name":"1","component":"test","description":"1","version":"1","upload_time":"2017-05-07T19:58:17.817000"},],"status":1,"onset_time":"2017-05-05T00:59:00","description":"","is_fog":1,"notify_type":1,"ug_type":1,"ug_range":0,"mac_range":[],"create_time":"2017-05-12T10:32:41.138000","extend":null}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message |
GET /v3/ota/devices/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| otid | int | 是 | 任务ID |
返回值
{"meta":{"message":"OTA设备列表","code":0},"data":{"count":5,"next":null,"previous":null,"results":[{"odid":"9b59b080-3494-11e7-91bc-dc536017523b","otid":22,"product_id":"8d01f204150911e7a554fa163e876164","device_id":"dba54e9e346311e79216dc536017523b","dsn":"zrgtest050905","status":0,"onset_time":"2017-05-10 16:50:54.528000","create_time":"2017-05-09 16:50:54.528000"},{"odid":"9b59b080-3494-11e7-91bc-dc536017523b","otid":22,"product_id":"8d01f204150911e7a554fa163e876164","device_id":"dba54e9e346311e79216dc536017523b","dsn":"zrgtest050905","status":0,"onset_time":"2017-05-10 16:50:54.528000","create_time":"2017-05-09 16:50:54.528000"}]}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少otid参数 |
GET /v3/ota/tasks/<odid>/logs/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| odid | string | 是 | OTA设备ID,不是设备ID,放在URL中 |
返回值
{"meta":{"message":"Log列表","code":0},"data":{"count":2,"next":null,"previous":null,"results":[{"olid":"9b76ff91-3620-11e7-af30-dc536017523b","product_id":"8d01f204150911e7a554fa163e876164","device_id":"bbddc751346311e7bc7bdc536017523b","dsn":"zrgtest050901","content":"OTA任务完成","customize":null,"create_time":"2017-05-11T16:05:33.321000"},{"olid":"9b761530-3620-11e7-be45-dc536017523b","product_id":"8d01f204150911e7a554fa163e876164","device_id":"bbddc751346311e7bc7bdc536017523b","dsn":"zrgtest050901","content":"固件[test]更新完成","customize":null,"create_time":"2017-05-11T16:05:33.315000"}]}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误 |
GET /v3/ota/logs/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| type | int | 是 | 产品类型:0→CP产品,1→IP产品,2→OTA产品 |
返回值
{"meta":{"message":"Log列表","code":0},"data":{"count":2,"next":null,"previous":null,"results":[{"olid":"9b76ff91-3620-11e7-af30-dc536017523b","product_id":"8d01f204150911e7a554fa163e876164","device_id":"bbddc751346311e7bc7bdc536017523b","dsn":"zrgtest050901","content":"OTA任务完成","customize":null,"create_time":"2017-05-11T16:05:33.321000"},{"olid":"9b761530-3620-11e7-be45-dc536017523b","product_id":"8d01f204150911e7a554fa163e876164","device_id":"bbddc751346311e7bc7bdc536017523b","dsn":"zrgtest050901","content":"固件[test]更新完成","customize":null,"create_time":"2017-05-11T16:05:33.315000"}]}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误 |
POST /v3/ota/tasks/<otid>/push/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| otid | int | 是 | OTA任务ID,放在URL中 |
| dsn_list | string list | 是 | 需要接收推送通知的设备的串号或MAC地址列表 |
返回值
{"meta":{"message":"推送完成","code":0},"data":{"successes":["zrgtest051501"],"errors":[]}}
返回值字段说明
| 字段 | 说明 |
|---|---|
| successes | 推送成功的串号或MAC地址列表 |
| errors | 推送失败的串号或MAC地址列表 |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误,参考返回数据中的message |
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字段 |