Files
ESP32_COMM/main/server/wifi_ota.h
T
小龙虾 1586a81b97 feat(main): 将全局函数重构为单例类模式
- 将 debug_log 模块重构为 DebugLog 单例类,封装 UART、UDP 和环形缓冲区日志输出
- 将 health_monitor 模块重构为 HealthMonitor 单例类,统一健康状态管理和监控逻辑
- 更新 main.cpp 中的初始化调用,使用单例实例替代原有全局函数
- 添加健康监控任务作为第四个 FreeRTOS 任务,增强系统监控能力
- 更新固件版本从 0.2.11 到 0.3.0,反映架构重大变更
2026-05-31 03:20:26 +08:00

58 lines
1.5 KiB
C++

/*
* wifi_ota.h - WiFi OTA 服务器
* T4.1 - T4.5
*
* WifiOta 类封装 WiFi 初始化、HTTP OTA 服务器和网络状态查询。
*/
#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"
typedef enum {
OTA_WIFI_MODE_AP,
OTA_WIFI_MODE_STA
} ota_wifi_mode_t;
class WifiOta {
public:
static WifiOta& instance();
bool earlyInit();
static void taskEntry(void *pvParameters);
void signalRelay();
static ota_wifi_mode_t getMode();
static int8_t getRssi();
static bool isConnected();
// 以下状态为 public,供 C 回调函数访问
ota_wifi_mode_t m_wifiMode = OTA_WIFI_MODE_AP;
bool m_coldBoot = false;
bool m_relayTriggered = false;
bool m_staConnected = false;
int m_staRetryCount = 0;
bool m_staRetryExhausted = false;
SemaphoreHandle_t m_staConnectedSem = NULL;
SemaphoreHandle_t m_staGotIpSem = NULL;
bool m_esp32OtaActive = false;
esp_ota_handle_t m_esp32OtaHandle = 0;
const esp_partition_t *m_esp32UpdatePartition = NULL;
size_t m_esp32Received = 0;
bool m_gd32StorageDone = false;
httpd_handle_t m_httpServer = NULL;
void initAp();
esp_err_t initSta();
void setStaticIp();
static void wifiEventHandler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data);
esp_err_t httpServerStart();
esp_err_t waitStaConnected(char *ip_str, size_t ip_len);
};
#endif // WIFI_OTA_H