- 新增ota目录和esp32_ota_core.cpp实现ESP32 OTA核心功能,支持begin/write/finalize操作 - 修改CMakeLists.txt添加ota源文件和包含目录 - 重构ble_ota.cpp将OTA写入/收尾逻辑委托给Esp32OtaCore,移除mbedtls直接引用 - 新增BLE_OTA_CTRL_RESTART_ESP32(0xFA)命令用于重启ESP32设备 - 更新BLE_OTA_CTRL_TRIGGER_ESP32(0xF8)逻辑,要求前端提供SHA-256校验并比对 - 添加SHA-256校验不匹配错误码BLE_OTA_FINISH_ERR_SHA_MISMATCH(0x85) - 优化OTA收尾流程,设备端读取分区计算SHA-256并与前端提供的哈希比对 - 添加BLE_OTA_NOTIFY_SHA256通知类型用于上报设备端计算的SHA-256值 - 更新app_config.h中的BLE OTA命令描述文档 - 移除BleOta类中的OTA状态变量,仅保留BLE传输层相关状态 - 更新版本构建时间和Git哈希信息
21 lines
1.1 KiB
Python
21 lines
1.1 KiB
Python
path = r'tools\ble_ota.html'
|
|
with open(path, 'r', encoding='utf-8-sig') as f:
|
|
html = f.read()
|
|
|
|
old_hint = " hint: '当前目标:ESP32。页面会使用 <b>cmd=0x01</b> 发送数据,<mark>写入完成后会先发 0xF9 让设备端读回算 SHA-256</mark>,前端比对一致后才发 0xF8 触发收尾(end + set_boot + reboot)。'"
|
|
new_hint = " hint: '当前目标:ESP32。页面会使用 <b>cmd=0x01</b> 发送数据,写入完成后发 <b>0xF8</b> + 32 字节 SHA-256 触发设备端收尾:设备端读 OTA 分区算 SHA 并比对,一致则 end+set_boot+reboot;不一致上报 0x85,不重启。'"
|
|
print('old in html:', old_hint in html)
|
|
html2 = html.replace(old_hint, new_hint, 1)
|
|
print('changed:', html2 != html)
|
|
print('new still present:', new_hint in html2)
|
|
with open(path, 'w', encoding='utf-8-sig') as f:
|
|
f.write(html2)
|
|
print('written, file len:', len(html2))
|
|
|
|
# verify
|
|
with open(path, 'r', encoding='utf-8-sig') as f:
|
|
reread = f.read()
|
|
print('re-read len:', len(reread))
|
|
print('new in reread:', new_hint in reread)
|
|
print('old in reread:', old_hint in reread)
|