@quec-wx-mp/api-ota
v1.0.0
Published
OTA
Readme
设备升级
设备升级模块,提供设备升级计划查询、批量确认升级计划和批量查询升级详情等API。
安装
npm install @quec-wx-mp/api-otaimport apiOTA from '@quec-wx-mp/api-ota'
const plugin = requirePlugin('quecPlugin')
plugin.use(apiOTA)API 列表
| 方法 | 说明 | | ----------------------- | -------------------- | | getDeviceUpgradePlan | 查询设备升级计划 | | userBatchConfirmUpgrade | 用户批量确认升级计划 | | getBatchUpgradeDetails | 批量查询设备升级详情 |
API 详细说明
1) 查询设备升级计划
接口名称
getDeviceUpgradePlan功能描述
CLOAT-OTA 查询设备升级计划。参数
| 属性 | 类型 | 默认值 | 必填 | 说明 | | ------------- | ------------ | ------ | ---- | ------------------------------------------------ | | deviceKey | string | - | 是 | 设备 deviceKey | | productKey | string | - | 是 | 产品 productKey | | moduleVersion | string | - | 是 | 模组版本 | | mcuVersions | McuVersion[] | - | 是 | MCU 版本列表,元素结构:{ componentNo, version } | | success | function | - | 否 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |
返回数据
- success(res):接口成功响应,res.data 为设备升级计划信息。
示例代码
plugin.ota.getDeviceUpgradePlan({
deviceKey: 'device_key',
productKey: 'product_key',
moduleVersion: '1.0.0',
mcuVersions: [
{
componentNo: 'MCU_MAIN',
version: '1.0.0'
}
],
success(res) {
console.log(res)
},
fail(err) {
console.log(JSON.stringify(err))
},
complete() {}
})2) 用户批量确认升级计划
接口名称
userBatchConfirmUpgrade功能描述
用户批量确认升级计划。参数
| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------------------------- | ------ | ---- | -------------------- | | arr | BatchConfirmUpgradeParam[] | - | 是 | 批量确认升级参数列表 | | success | function | - | 否 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |
arr 元素字段说明:
| 字段 | 类型 | 必填 | 说明 | | ---------------- | ------ | ---- | ------------------------------------------------- | | deviceKey | string | 是 | 设备 deviceKey | | productKey | string | 是 | 产品 productKey | | operType | number | 是 | 操作类型(1 马上升级,2 预约升级) | | planId | number | 是 | 计划 ID | | appointStartTime | number | 否 | 预约升级开始时间(毫秒时间戳,operType=2 时必传) | | appointEndTime | number | 否 | 预约升级结束时间(毫秒时间戳,operType=2 时必传) |
返回数据
- success(res):接口成功响应,res.data 为批量确认结果。
示例代码
plugin.ota.userBatchConfirmUpgrade({
arr: [
{
deviceKey: 'device_key',
productKey: 'product_key',
operType: 1,
planId: 1001
}
],
success(res) {
console.log(res)
},
fail(err) {
console.log(JSON.stringify(err))
},
complete() {}
})3) 批量查询设备升级详情
接口名称
getBatchUpgradeDetails功能描述
批量查询设备升级详情。参数
| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------- | -------------------------- | ------ | ---- | ---------------- | | arr | BatchUpgradeDetailsParam[] | - | 是 | 批量查询参数列表 | | success | function | - | 否 | 成功回调 | | fail | function | - | 否 | 失败回调 | | complete | function | - | 否 | 结束回调 |
arr 元素字段说明:
| 字段 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | --------------- | | deviceKey | string | 是 | 设备 deviceKey | | productKey | string | 是 | 产品 productKey | | planId | number | 是 | 计划 ID |
返回数据
- success(res):接口成功响应,res.data 为升级详情列表。
示例代码
plugin.ota.getBatchUpgradeDetails({
arr: [
{
deviceKey: 'device_key',
productKey: 'product_key',
planId: 1001
}
],
success(res) {
console.log(res)
},
fail(err) {
console.log(JSON.stringify(err))
},
complete() {}
})