refactor(main): 移除ota_mutex.h全局变量并重构ESP32 OTA互斥锁管理
- 将全局变量g_esp32OtaMutex和g_esp32OtaOccupied内聚到Esp32OtaCore类中 - 通过Esp32OtaCore::initMutex()方法初始化互斥锁替代原main.cpp中的全局初始化 - 重构HealthMonitor中WiFi连接状态管理,推送连接状态到本地成员而非直接查询 - 优化OtaCoordinator中const方法的线程安全实现,移除不必要的const_cast转换 - 封装OtaRelay的队列访问器,提供getDispatchQueue()和getResultQueue()方法 - 解决BLE与WiFi之间的横向耦合问题,通过OtaCoordinator进行射频共存管理 - 移除transport/spi_master.cpp中的CANFD接口实现到独立的canfd_bridge模块 - 优化BLE OTA中ESP32会话的幂等性和新会话处理逻辑 BREAKING CHANGE: 移除了ota_mutex.h全局头文件,相关功能迁移至Esp32OtaCore类中管理
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_partition.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
class Esp32OtaCore {
|
||||
public:
|
||||
@@ -99,9 +101,22 @@ public:
|
||||
bool isActive() const { return m_active; }
|
||||
/** @brief 获取已接收的字节数。 */
|
||||
size_t getReceived() const { return m_received; }
|
||||
|
||||
// ── 分区互斥锁管理(M1: 从 ota_mutex.h 全局变量内聚到此类)──
|
||||
/**
|
||||
* @brief 初始化 ESP32 OTA 分区互斥锁(在 app_main 中调用)。
|
||||
* 替代旧的全局 g_esp32OtaMutex / g_esp32OtaOccupied。
|
||||
*/
|
||||
static void initMutex();
|
||||
private:
|
||||
Esp32OtaCore() = default;
|
||||
|
||||
// ── 分区互斥锁(M1: 内聚自 ota_mutex.h)──
|
||||
static SemaphoreHandle_t s_mutex; ///< ESP32 OTA 分区互斥锁
|
||||
static volatile bool s_occupied; ///< 分区占用标志
|
||||
static bool acquireMutex(uint32_t timeout_ms);
|
||||
static void releaseMutex();
|
||||
|
||||
// 从 OTA 分区读回计算 SHA-256(WiFi 风格),结果写入 m_sha256,置 m_shaComputed=true
|
||||
/**
|
||||
* @brief 从 OTA 分区读回计算 SHA-256。
|
||||
|
||||
Reference in New Issue
Block a user