1、新增Dengle定时参数下发功能,支持最多10条配置,断电保存到Flash,COM打开时暂停发送、关闭后恢复

2、新增USB查询产品码(0x66)和查询Dengle配置(0x74)命令
3、修复bleproto组包栈溢出导致设置Dengle后复位的问题,并完善CDC的DTR状态判断
This commit is contained in:
2026-07-31 14:54:26 +08:00
parent 79e15a9ccc
commit 2260768167
38 changed files with 1742 additions and 717 deletions
+88
View File
@@ -0,0 +1,88 @@
/******************************************************************************
* @file usr_dengle_sched.h
* @brief Dengle 参数定时下发:USB 配置最多 10 条,按周期经 BLE 发出
* @author cyWu <1917507415@qq.com>
* @date 2026.07.30
* @version V1.2.0
* @history
* - V1.0.0, 2026.07.30, cyWu, 首次发布
* - V1.1.0, 2026.07.30, cyWu, 增加 Flash 断电保存
* - V1.2.0, 2026.07.30, cyWu, USB 连接时暂停定时发送
* - V1.2.1, 2026.07.30, cyWu, 改为 COM(DTR) 开闭控制暂停/恢复
******************************************************************************/
#ifndef __USR_DENGLE_SCHED_H__
#define __USR_DENGLE_SCHED_H__
#include <stdint.h>
/*============================================================================*/
/* 宏定义 */
/*============================================================================*/
#define DENGLE_SLOT_MAX (10) /**< 最多定时条目数 */
#define DENGLE_INT_MAX (16) /**< CBCT/CBFD:最多 int32 个数 */
#define DENGLE_BYTES_MAX (64) /**< 其它产品:最多 bytes 长度 */
#define DENGLE_TICK_MS (100) /**< 调度节拍 */
/*============================================================================*/
/* 错误码 */
/*============================================================================*/
typedef enum {
DENGLE_OK = 0,
DENGLE_ERR_PARAM,
DENGLE_ERR_SLOT,
DENGLE_ERR_MODE,
DENGLE_ERR_NOT_INIT
} Dengle_Ret_t;
/*============================================================================*/
/* 外部接口 */
/*============================================================================*/
/**
* @brief 初始化 Dengle 定时模块(启动 100ms 节拍)
* @return Dengle_Ret_t
*/
Dengle_Ret_t dengle_sched_init(void);
/**
* @brief USB 设置一条定时任务
* @note payload 格式见 .c 文件头注释
* @param payload USB 帧 payload(不含 55AA/LEN/CMD/SN/CKSUM
* @param payload_len 长度
* @return Dengle_Ret_t
*/
Dengle_Ret_t dengle_sched_usb_set(const uint8_t *payload, uint16_t payload_len);
/**
* @brief 清除全部定时任务
* @return Dengle_Ret_t
*/
Dengle_Ret_t dengle_sched_clear_all(void);
/**
* @brief 打包单个槽位配置(格式与 0x70 设置 payload 一致)
* @param slot_id 槽位 0~9
* @param buf 输出缓冲
* @param max_len 缓冲最大长度
* @return >0 写入字节数;<=0 失败
*/
int dengle_sched_pack_slot(uint8_t slot_id, uint8_t *buf, uint16_t max_len);
/**
* @brief 打包全部槽位配置(连续拼接多个 0x70 风格记录)
* @param buf 输出缓冲
* @param max_len 缓冲最大长度
* @return >0 写入字节数;<=0 失败
*/
int dengle_sched_pack_all(uint8_t *buf, uint16_t max_len);
/**
* @brief 获取有效条目数(调试用)
* @return 已使能槽位数
*/
uint8_t dengle_sched_get_active_count(void);
#endif /* __USR_DENGLE_SCHED_H__ */