42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#ifndef SYS_OTA_BOOT_REQUEST_H
|
|||
|
|
#define SYS_OTA_BOOT_REQUEST_H
|
||
|
|
|
||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief DCU_APP 进入 Bootloader OTA 窗口控制模块。
|
||
|
|
* @note ESP32 通过 CAN-FD 发送受保护命令,APP 写 OTA 标志后软复位,
|
||
|
|
* Bootloader 下次启动会停留在 OTA 等待窗口。
|
||
|
|
*/
|
||
|
|
class OtaBootRequest {
|
||
|
|
public:
|
||
|
|
/** @brief 初始化内部状态。 */
|
||
|
|
static void init();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief 尝试处理一帧 CAN 接收报文。
|
||
|
|
* @param[in] channel 报文来源 CAN 通道。
|
||
|
|
* @param[in] id 报文 ID。
|
||
|
|
* @param[in] data 报文负载。
|
||
|
|
* @param[in] length 报文负载长度。
|
||
|
|
* @retval true 该报文已被 OTA/BOOT 控制模块消费。
|
||
|
|
* @retval false 该报文不是 OTA/BOOT 控制报文。
|
||
|
|
*/
|
||
|
|
static bool handleCanFrame(uint8_t channel, uint32_t id, const uint8_t *data, uint8_t length);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief 设置 Bootloader OTA 等待标志并安排软复位。
|
||
|
|
* @retval true 标志写入成功,稍后会复位进入 Bootloader。
|
||
|
|
* @retval false Flash 标志写入失败。
|
||
|
|
*/
|
||
|
|
static bool requestEnterBoot();
|
||
|
|
|
||
|
|
/** @brief 若已确认进入 BOOT 请求,则延迟片刻后复位。 */
|
||
|
|
static void process();
|
||
|
|
|
||
|
|
private:
|
||
|
|
static volatile bool s_rebootPending;
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif /* SYS_OTA_BOOT_REQUEST_H */
|