Files
ESP32_COMM/main/server/ble_ota.h
T
小龙虾 00ce8dbbb5 feat(ota): 实现 GD32 Flash 存储抽象层和 OTA 协调器接口解耦
- 新增 storage/gd32_flash_store.cpp 组件,提供 GD32 Flash 存储抽象层
- 修改 ota_coordinator.cpp/h 使其继承 IRelayListener 接口,实现与
  OtaRelay 的解耦设计
- 将 GD32 相关存储操作统一通过协调器访问,解决 H3 绕过协调器的问题
- 添加完整的 Doxygen 注释到所有公共接口和关键函数
- 更新 CMakeLists.txt 构建配置,添加 storage 组件依赖
- 重构元数据加载/清除操作使用 Gd32FlashStore 实例而非 OtaRelay 直接访问
- 添加中继事件回调接口实现,使 OtaRelay 可通知协调器状态变化
2026-06-21 23:48:31 +08:00

66 lines
2.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* ble_ota.h - BLE OTA GATT 服务器
* T5.1 - T5.5
*
* ESP32 本机 OTA 的写入/收尾逻辑已抽离到 Esp32OtaCore(WiFi/BLE 共用)。
* 本类仅保留 BLE 传输层相关状态(连接、收尾任务去重、ACK 窗口)。
*/
#ifndef BLE_OTA_H
#define BLE_OTA_H
#include <stdint.h>
#include "esp_err.h"
#include "esp_ota_ops.h"
#include "freertos/task.h"
class BleOta {
public:
/**
* @brief 获取 BleOta 单例实例。
* @return BleOta 类引用。
*/
static BleOta& instance();
/**
* @brief BLE OTA FreeRTOS 任务入口。
* @param pvParameters 任务参数,未使用。
*/
static void taskEntry(void *pvParameters);
/**
* @brief 启动 BLE GATT 服务器并注册 OTA 服务。
* @return ESP_OK 成功,其他失败。
*/
esp_err_t serverStart();
/**
* @brief 通过 BLE Notify 推送响应数据。
* @param data 待推送的数据指针。
* @param len 数据长度。
* @return ESP_OK 成功,其他失败。
*/
esp_err_t notifyResponse(const uint8_t *data, size_t len);
/**
* @brief 检查 BLE 客户端连接状态。
* @return 已连接返回 true,未连接返回 false。
*/
bool isConnected();
/** @brief 获取 BLE OTA 守护任务句柄。 */
TaskHandle_t getTaskHandle() const { return m_taskHandle; }
/** @brief 获取 BLE OTA 数据工作线程句柄。 */
TaskHandle_t getWorkerTaskHandle() const { return m_workerTaskHandle; }
// 以下状态为 public,供 C 回调函数访问
bool m_bleReady = false; ///< BLE GATT 服务注册完成标志
bool m_bleConnected = false; ///< BLE 客户端连接状态
uint16_t m_connHandle = 0xFFFF; ///< BLE 连接句柄(0xFFFF=未连接)
// BLE 传输相关(OTA 写入状态已移至 Esp32OtaCore)
bool m_esp32RebootPending = false; ///< 收尾任务去重标志
uint8_t m_esp32LastCmd = 0; ///< 最后一次数据包命令(用于补发 ACK)
uint16_t m_esp32LastSeq = 0xFFFFU; ///< 最后一次数据包序号(用于补发 ACK)
TaskHandle_t m_taskHandle = nullptr; ///< BLE OTA 守护任务句柄
TaskHandle_t m_workerTaskHandle = nullptr; ///< BLE OTA 数据工作线程句柄
};
#endif // BLE_OTA_H