fix: 0xC0 帧通过回调直接驱动网络上报
loop_uart_proto: - 新增 lup_sensor_cb_t 回调类型 + lup_set_sensor_callback - lup_process_frame 收到 0xC0 → 调用注册的回调推送数据 tcp_json_srv: - json_sensor_callback: 检查 g_report_active → 解析 → TCP 发送 - tcp_json_srv_init: 注册回调 usart_biz: - uart_srv: 0xC0 由回调直接 TCP 推送,BLE 连接时也转发 BLE - 移除旧的 _report_flag 轮询路径 数据流: ISR → lup_process_frame(校验) → json_sensor_callback → WCHNET_SocketSend
This commit is contained in:
@@ -161,22 +161,20 @@ void uart_srv(void)
|
||||
uint8_t cmd = g_pkg_uart_2.pkg[3];
|
||||
|
||||
// --- 所有 0x7F 帧先经过 lup_process_frame 校验 ---
|
||||
// 对于 0xC0 帧: 校验 checksum,但不消费为命令响应
|
||||
// 对于其他帧: 校验 checksum,匹配挂起命令
|
||||
// 0xC0: 校验后通过回调直接推送 TCP JSON
|
||||
// 其他: 校验后匹配挂起命令
|
||||
lup_process_frame(g_pkg_uart_2.pkg, g_pkg_uart_2.offset);
|
||||
|
||||
// --- 传感器上报 (0xC0) 分流 ---
|
||||
// 回调已处理 TCP 推送,此处仅处理 BLE 转发
|
||||
if(cmd == LUP_CMD_SENSOR_REPORT)
|
||||
{
|
||||
// SensType=0x0C → 多线圈传感信息
|
||||
if(g_dbn_ble_state_acs_enable.flag == 0){
|
||||
// 无 BLE ACS 连接 → 标记为 TCP JSON 上报
|
||||
_report_flag = 1;
|
||||
}
|
||||
else{
|
||||
if(g_dbn_ble_state_acs_enable.flag != 0){
|
||||
// BLE ACS 已连接 → 改 Magic 为 0x8F 发给 BLE
|
||||
g_pkg_uart_2.pkg[0] = 0x8F;
|
||||
_report_flag = 1; // 保留给 BLE
|
||||
}
|
||||
// else: 回调已推送 TCP,直接清理
|
||||
}
|
||||
|
||||
// 调试打印
|
||||
|
||||
Reference in New Issue
Block a user