@soszrg
2018-11-15T06:49:27.000000Z
字数 4074
阅读 857
anxin
http://121.40.214.215:8000
Authorization: token d79be1d657d9a8b45f6f903620e84b06cbf225e0
获取oss token(token)
接口地址
GET /oss_token/ota/
请求参数
无
返回参数
{"meta":{"code":0,"message":"oss token"},"data":{"accessid":"wHQNXGL...","host":"https://mxchip-fog.oss...","policy":"eyJleHBpcmF0aW9uIjog...","signature":"gXOilR99=...","expire":1541665617,"dir":"ota/","callback":"eyJjYWxsYm..."}}
返回参数说明
无
POST /api/v1/ota/[product_id]/files/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| file_name | string | 是 | 固件名 |
| file_url | string | 是 | 固件地址 |
| md5 | string | 是 | 固件的MD5值 |
| size | string | 是 | 固件大小 |
| ug_type | int | 否 | OTA类型:0 mcu升级(默认类型);1 wifi升级 |
| version | string | 是 | 固件版本 |
| description | string | 否 | 固件描述 |
| mac_range | string list | 否 | 要升级的MAC地址范围 |
| customize | string | 否 | 用户自定义字段 |
返回值
{"meta":{"code":0,"message":"upload file ok"},"data":{"id":1,"product":"test","ota_type":0,"file_name":"ota.bin","file_url":"https://xxx.com/a.bin","size":"20kb","md5":"gzsf12jkiu...","version":"1.0.1","mac_range":null,"customize":"xxx","created_at":"2018-11-13T22:34:47","updated_at":"2018-11-13T22:34:47","description":'',"status":0,"is_delete":false,"extra":{}}}
返回值说明
| 字段 | 类型 | 说明 |
|---|---|---|
| id | int | 固件ID,固件唯一标识,用于后续固件的修改和删除等 |
| status | int | 文件当前状态:0 测试,1 上线,2 无效 |
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少product参数 |
GET /api/v1/ota/[product_id]/files/
返回值
{"meta":{"message":"info list","code":0},"data":{"count":1,"page_size":10,"next":null,"previous":null,"results":[{"id":1,"product":"test","ota_type":0,"file_name":"ota.bin","file_url":"https://a.com/a.bin","size":"20kb","md5":"f6hk9vgc4...","version":"1.0.1","mac_range":null,"customize":"xxxx","created_at":"2018-11-13T22:34:47","updated_at":"2018-11-13T22:34:47","description":"","status":0,"is_delete":false,"extra":{}}]}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:缺少product参数 |
GET /api/v1/ota/[product_id]/files/[id]
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| id | int | 是 | 固件id(该参数放于url中) |
返回值
{"meta":{"code":0,"message":"file info"},"data":{"id":1,"product":"test","ota_type":0,"file_name":"ota.bin","file_url":"https://a.com/a.bin","size":"20kb","md5":"abki2lnb...","version":"1.0.1","mac_range":null,"customize":"xxxx","created_at":"2018-11-13T22:34:47","updated_at":"2018-11-13T22:34:47","description":"","status":0,"is_delete":false,"extra":{}}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message |
DELETE /api/v1/ota/[product_id]/files/[id]
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| id | int | 是 | 固件ID(该参数放于url) |
返回值
{"meta":{"message":"任务删除成功","code":0},"data":{"ot_id":null}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message |
| 10500 | ot_id错误,找不到任务 |
| 10501 | 任务状态错误:仅有测试中的任务可以删除 |
PUT /api/v1/ota/[product_id]/files/[id]
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| ot_id | int | 是 | 任务ID(拼接于url中) |
| file_url | string | 是 | 固件地址 |
| version | string | 是 | 固件版本(同一产品下不可重复) |
| md5 | string | 是 | 固件的MD5值 |
| size | string | 是 | 固件大小 |
| file_name | string | 否 | 固件名 |
| description | string | 否 | 任务描述 |
| mac_range | string list | 否 | 要升级的MAC地址范围 |
返回值
{"meta":{"code":0,"message":"update file ok"},"data":{"ota_type":0,"file_name":"ota.bin","file_url":"https://xxx.com/a.bin","size":"20kb","md5":"fg2bz4...","version":"1.0.1","mac_range":["DEF1LUK","DEF1L2G"],"extra":{}}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message |
GET /api/v1/ota/device/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| product_id | string | 是 | 产品id |
| wifi_version | string | 是 | wifi当前版本号 |
| mcu_version | string | 是 | mcu当前版本号 |
注意:
http://121.40.214.215:8000/api/v1/ota/devce/?product_id=xxx&wifi_version=xxx&mcu_version=xxx
返回值
{"meta":{"code":0,"message":"ota file info"},"data":{"need_ota":true,"files":[{"file_url":"https://xxx.com/mcu.bin","md5":"xxzz...","version":"1.0.1","ota_type":0,"customize":""},{"file_url":"https://xxx.com/wifi.bin","md5":"xxzz...","version":"1.0.1","ota_type":1,"customize":""}]}}
返回值说明
| 字段 | 类型 | 说明 |
|---|---|---|
| need_ota | boolean | 是否需要OTA,true:需要,false:不需要 |
| files | array | 固件列表(可能为空) |
| files.file_url | string | 固件下载链接 |
| files.md5 | string | md5 |
| files.version | string | 版本号 |
| files.ota_type | int | 固件类型,0:mcu;1:wifi |
| files.customize | string | 拓展字段 |
说明
- files:need_ota为false时,表示云端认为设备此时不需要ota,fiels为空;need_ota为true时,files有三种情况:两个文件(mcu和wifi都有),一个mcu文件,一个wifi文件
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message |
PUT /api/v1/ota/version/
请求参数
| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
| device_id | string | 是 | 设备id |
| wifi_version | string | 是 | wifi当前版本号 |
| mcu_version | string | 是 | mcu当前版本号 |
返回值
{"meta":{"code":0,"message":"update version ok"},"data":{}}
错误码
| 错误代码 | 错误说明 |
|---|---|
| 10000 | 参数错误:参考Response中的message |