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:
@@ -22,7 +22,6 @@
|
||||
#include "esp_mac.h"
|
||||
|
||||
#include "app_config.h"
|
||||
#include "ota_mutex.h"
|
||||
#include "wifi_ota.h"
|
||||
#include "esp32_ota_core.h"
|
||||
#include "ota_coordinator.h"
|
||||
@@ -149,6 +148,8 @@ void WifiOta::wifiEventHandler(void* arg, esp_event_base_t event_base,
|
||||
inst.setStaRetryCount(0);
|
||||
inst.setStaRetryExhausted(false); // ★ 连接成功,重置耗尽标志
|
||||
inst.stateUnlock();
|
||||
// ★ M2: 推送 WiFi 连接状态给 HealthMonitor(解耦监控层主动查询)
|
||||
HealthMonitor::instance().setWifiConnected(true);
|
||||
if (inst.m_staConnectedSem) {
|
||||
xSemaphoreGive(inst.m_staConnectedSem);
|
||||
}
|
||||
@@ -161,6 +162,8 @@ void WifiOta::wifiEventHandler(void* arg, esp_event_base_t event_base,
|
||||
bool exhausted = inst.getStaRetryExhausted();
|
||||
int retryCount = inst.getStaRetryCount();
|
||||
inst.stateUnlock();
|
||||
// ★ M2: 推送 WiFi 断开状态给 HealthMonitor
|
||||
HealthMonitor::instance().setWifiConnected(false);
|
||||
|
||||
if (!exhausted) {
|
||||
DEBUG_WARN("WIFI", "STA 断开, reason=%d, retry=%d",
|
||||
@@ -602,6 +605,19 @@ bool WifiOta::isConnected()
|
||||
return WifiOta::instance().getStaConnected();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// IBleCoexListener 接口实现(L1: 通过协调器接收 BLE 共存通知)
|
||||
// ============================================================
|
||||
void WifiOta::onBleOtaStart()
|
||||
{
|
||||
setBleOtaActive(true);
|
||||
}
|
||||
|
||||
void WifiOta::onBleOtaEnd()
|
||||
{
|
||||
setBleOtaActive(false);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// ★ WiFi 早期初始化(在 app_main 调度器启动前调用)
|
||||
// 包括:NVS → netif → event handler → WiFi driver → 配置 → connect
|
||||
|
||||
Reference in New Issue
Block a user