优化OTA升级流程,增加用户确认对话框;更新设备名称提示

This commit is contained in:
2026-01-28 13:40:01 +08:00
parent ef37eeac59
commit ea6f1f12cd
2 changed files with 25 additions and 7 deletions

View File

@@ -843,13 +843,31 @@ Page({
// 开始OTA升级命令0x0B, P0=0x01
onStartOta() {
try {
const pkt = buildCommand(COMMANDS.OTA_START, [0x01])
this.appendLog('TX', `OTA开始: ${this.toHex(pkt)}`)
// 通过统一发送函数发送包(会检查连接并发现通道)
this.transmitPacket(pkt, 'OTA开始')
wx.showToast({ title: '发送OTA开始', icon: 'success' })
if (!this.data.isConnected) { wx.showToast({ title: '未连接设备', icon: 'none' }); return }
wx.showModal({
title: '确认发送',
content: '确定要发送 OTA 升级命令吗?',
confirmText: '发送',
cancelText: '取消',
success: (res) => {
if (res && res.confirm) {
try {
const pkt = buildCommand(COMMANDS.OTA_START, [0x01])
this.appendLog('TX', `OTA开始: ${this.toHex(pkt)}`)
// 通过统一发送函数发送包(会检查连接并发现通道)
this.transmitPacket(pkt, 'OTA开始')
wx.showToast({ title: '已发送OTA开始', icon: 'success' })
} catch (err) {
wx.showToast({ title: '构包失败', icon: 'none' })
}
} else {
this.appendLog('UI', '用户取消 OTA 发送')
}
},
fail: () => { this.appendLog('WARN', 'showModal 调用失败,取消 OTA 发送') }
})
} catch (err) {
wx.showToast({ title: '构包失败', icon: 'none' })
wx.showToast({ title: '操作异常', icon: 'none' })
}
},

View File

@@ -475,7 +475,7 @@
<text>2. 打开已下载并安装的 OTA 升级工具。</text>
</view>
<view class="tucontainer">
<text>3. 手机蓝牙扫描并连接名称为:<text class="bold-text">“OTAOTA_OTAOTA_OTA”</text>的设备。</text>
<text>3. 手机蓝牙扫描并连接名称为:<text class="bold-text">“BLV_W13_OTAOTAOTA”</text>的设备。</text>
</view>
<view class="tucontainer">
<text>4. 连接后依次点击<text class="bold-text">GETINFO</text>→<text class="bold-text">IMAGEA</text>。</text>