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:
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* ota_mutex.h - ESP32 OTA 全局互斥(BLE / WiFi 通道共享)
|
||||
*
|
||||
* 同一时刻只允许一个 OTA 源(BLE 或 WiFi)操作 ESP32 OTA 分区。
|
||||
* 变量定义 + Mutex 创建在 main.cpp app_main()。
|
||||
*/
|
||||
#pragma once
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include <cstdint>
|
||||
|
||||
extern SemaphoreHandle_t g_esp32OtaMutex; ///< ESP32 OTA 全局互斥锁句柄(main.cpp 中创建)
|
||||
extern volatile bool g_esp32OtaOccupied; ///< ESP32 OTA 分区占用标志(true=正在OTA)
|
||||
|
||||
/**
|
||||
* @brief 获取全局 OTA 占用标志(带超时)。
|
||||
* @param timeout_ms 等待互斥锁的超时时间(毫秒)。
|
||||
* @return true 成功获取并置占用标志,false 已占用或超时。
|
||||
*/
|
||||
static inline bool esp32_ota_mutex_acquire(uint32_t timeout_ms) {
|
||||
if (!g_esp32OtaMutex) return false;
|
||||
if (xSemaphoreTake(g_esp32OtaMutex, pdMS_TO_TICKS(timeout_ms)) != pdTRUE) return false;
|
||||
if (g_esp32OtaOccupied) {
|
||||
xSemaphoreGive(g_esp32OtaMutex);
|
||||
return false;
|
||||
}
|
||||
g_esp32OtaOccupied = true;
|
||||
xSemaphoreGive(g_esp32OtaMutex);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 释放全局 OTA 占用标志。
|
||||
* @note 内部: Take Mutex → 清除标志 → Give Mutex。
|
||||
*/
|
||||
static inline void esp32_ota_mutex_release(void) {
|
||||
if (!g_esp32OtaMutex) return;
|
||||
xSemaphoreTake(g_esp32OtaMutex, portMAX_DELAY);
|
||||
g_esp32OtaOccupied = false;
|
||||
xSemaphoreGive(g_esp32OtaMutex);
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
// 固件版本
|
||||
#define FW_VERSION_MAJOR 0
|
||||
#define FW_VERSION_MINOR 3
|
||||
#define FW_VERSION_PATCH 30
|
||||
#define FW_VERSION_STRING "0.3.30"
|
||||
#define FW_VERSION_PATCH 31
|
||||
#define FW_VERSION_STRING "0.3.31"
|
||||
|
||||
// 编译时间
|
||||
#define BUILD_TIME "2026-06-21 23:33:01"
|
||||
#define BUILD_TIME "2026-06-22 00:43:09"
|
||||
|
||||
// Git 信息
|
||||
#define GIT_HASH "3fff959"
|
||||
#define GIT_HASH "00ce8db"
|
||||
|
||||
Reference in New Issue
Block a user