Initial commit: CCU621_M firmware project with BLE debug link support.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-08 17:28:36 +08:00
commit 9ceb218f80
1597 changed files with 724159 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
/**
* @file fc41d_ble_priv.h
* @brief FC41D BLE 后端私有上下文(与 tcp_link_ctx_t 在 comm_link 中 union 复用)
*/
#ifndef FC41D_BLE_PRIV_H
#define FC41D_BLE_PRIV_H
#include <stdint.h>
#include "fc41d_ble.h"
#define FC41D_AT_RX_ACC_SIZE 768U
#define FC41D_AT_LINE_MAX 128U
#define FC41D_AT_CMD_MAX 1200U
/** link 解析缓冲(AT 行与 +QBLERECV */
#define FC41D_LINK_RX_NORMAL 512U
/** 固件升级:单包 1024B Base64 JSON + UART 残包 */
#define FC41D_LINK_RX_UPGRADE 2048U
/** 应用 RX 环(心跳/参数查询等) */
#define FC41D_APP_RX_NORMAL 1024U
/** 固件升级 Data JSON 拼包(1024B 载荷约 1.6KB JSON */
#define FC41D_APP_RX_UPGRADE 2048U
typedef enum {
FC41D_BLE_ST_IDLE = 0,
FC41D_BLE_ST_POWER_ON,
FC41D_BLE_ST_WAIT_CONNECT,
FC41D_BLE_ST_CONNECTED,
FC41D_BLE_ST_ERROR,
} fc41d_ble_state_t;
typedef enum {
FC41D_BLE_URC_NONE = 0,
FC41D_BLE_URC_CONNECTED,
FC41D_BLE_URC_DISCONNECTED,
} fc41d_ble_urc_t;
typedef struct {
char rx_acc[FC41D_AT_RX_ACC_SIZE];
uint16_t rx_acc_len;
fc41d_ble_urc_t pending_urc;
char at_cmd_buf[FC41D_AT_LINE_MAX];
char ble_cmd_buf[64];
char gatt_at_cmd[FC41D_AT_CMD_MAX];
} fc41d_ble_at_t;
typedef struct {
uint8_t *link_rx_acc;
uint16_t link_rx_acc_cap;
uint16_t link_rx_acc_len;
uint16_t qble_payload_need;
uint8_t *app_rx;
uint16_t app_rx_cap;
uint16_t app_rx_wr;
uint16_t app_rx_rd;
} fc41d_ble_io_t;
typedef struct {
fc41d_ble_state_t state;
uint64_t connect_deadline_ms;
uint64_t power_on_deadline_ms;
uint64_t last_stat_poll_ms;
uint8_t transparent; /* 1=QBLETRANMODE 已生效,UART 直传 JSON */
uint8_t gatt_fallback; /* 1=透传 AT 失败,回退 +QBLERECV/QBLEGATTSNTFY */
} fc41d_ble_sm_t;
typedef struct {
fc41d_ble_at_t at;
fc41d_ble_io_t io;
fc41d_ble_sm_t sm;
} fc41d_ble_ctx_t;
#endif /* FC41D_BLE_PRIV_H */