feat(equipment): 设备页新增 OTA 升级与初始化功能
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
109c9e1b70
commit
9332990a77
@@ -423,6 +423,34 @@ class LeFuService {
|
||||
})
|
||||
}
|
||||
|
||||
// ─── OTA 升级 ─────────────────────────────
|
||||
/**
|
||||
* 下发 OTA 固件升级指令
|
||||
* 只负责调用协议层 codeOtaUpdate,是否需要升级、版本比较等业务判断由调用方处理。
|
||||
*/
|
||||
otaUpdate(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this._activeProtocol) { reject(new Error('设备未连接')); return }
|
||||
this._activeProtocol.codeOtaUpdate((status: number) => {
|
||||
status === 0 ? resolve() : reject(new Error('升级指令下发失败'))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ─── 设备初始化 ───────────────────────────
|
||||
/**
|
||||
* 初始化设备信息
|
||||
* 下发 codeClearDeviceData('00') 指令清除设备信息,区别于 clearDeviceMembers 的 '01'(清空用户数据)。
|
||||
*/
|
||||
initDevice(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this._activeProtocol) { reject(new Error('设备未连接')); return }
|
||||
this._activeProtocol.codeClearDeviceData('00', (res: number) => {
|
||||
res === 0 ? resolve() : reject(new Error('请求失败'))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ─── 用户同步 ─────────────────────────────
|
||||
/**
|
||||
* 清空设备内的用户数据
|
||||
|
||||
Reference in New Issue
Block a user