feat(ota): 解耦ESP32 OTA核心逻辑到独立模块并增强BLE控制功能
- 新增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哈希信息
This commit is contained in:
+3
-13
@@ -3,11 +3,11 @@
|
||||
* T4.1 - T4.5
|
||||
*
|
||||
* WifiOta 类封装 WiFi 初始化、HTTP OTA 服务器和网络状态查询。
|
||||
* ESP32 本机 OTA 的写入/收尾逻辑已抽离到 Esp32OtaCore(WiFi/BLE 共用)。
|
||||
*/
|
||||
#ifndef WIFI_OTA_H
|
||||
#define WIFI_OTA_H
|
||||
|
||||
#include "ota_relay.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_http_server.h"
|
||||
#include "esp_event.h"
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
static int8_t getRssi();
|
||||
static bool isConnected();
|
||||
|
||||
// ── WiFi 连接状态(WiFi 事件回调 / HTTP / reconnect 任务共享,需 mutex 保护)──
|
||||
// ── WiFi 连接状态(WiFi 事件回调 / HTTP / reconnect task 共享,需 mutex 保护)──
|
||||
bool getStaConnected() const { return m_staConnected.load(); }
|
||||
void setStaConnected(bool v) { m_staConnected.store(v); }
|
||||
int getStaRetryCount() const { return m_staRetryCount.load(); }
|
||||
@@ -55,18 +55,8 @@ public:
|
||||
SemaphoreHandle_t m_staGotIpSem = NULL;
|
||||
TaskHandle_t m_reconnectTask = nullptr;
|
||||
|
||||
bool m_esp32OtaActive = false;
|
||||
esp_ota_handle_t m_esp32OtaHandle = 0;
|
||||
const esp_partition_t *m_esp32UpdatePartition = NULL;
|
||||
size_t m_esp32Received = 0;
|
||||
httpd_handle_t m_httpServer = NULL;
|
||||
|
||||
// ── SHA-256 哈希校验 ──
|
||||
uint8_t m_esp32Sha256[32] = {0}; // 重启前验证计算的SHA-256哈希值
|
||||
bool m_esp32HashComputed = false; // 是否已计算哈希
|
||||
char m_frontendSha256[65] = {0}; // 前端提供的SHA-256(上传时存储)
|
||||
bool m_hasFrontendSha256 = false; // 前端是否提供了SHA-256
|
||||
|
||||
private:
|
||||
// ── 跨任务共享状态(atomic + m_stateMutex 保护)──
|
||||
std::atomic<bool> m_staConnected{false};
|
||||
@@ -86,4 +76,4 @@ private:
|
||||
esp_err_t waitStaConnected(char *ip_str, size_t ip_len);
|
||||
};
|
||||
|
||||
#endif // WIFI_OTA_H
|
||||
#endif // WIFI_OTA_H
|
||||
|
||||
Reference in New Issue
Block a user