diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/usart_biz.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/usart_biz.c index 50dcc0a..69ba924 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/usart_biz.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/usart_biz.c @@ -160,9 +160,15 @@ void uart_srv(void) if(g_pkg_uart_2.pkg[0] == 0x7F){ uint8_t cmd = g_pkg_uart_2.pkg[3]; - // --- 传感器上报 (0xC0) --- - if(cmd == 0xC0 && g_pkg_uart_2.pkg[4] == 0x0C) + // --- 所有 0x7F 帧先经过 lup_process_frame 校验 --- + // 对于 0xC0 帧: 校验 checksum,但不消费为命令响应 + // 对于其他帧: 校验 checksum,匹配挂起命令 + lup_process_frame(g_pkg_uart_2.pkg, g_pkg_uart_2.offset); + + // --- 传感器上报 (0xC0) 分流 --- + if(cmd == LUP_CMD_SENSOR_REPORT) { + // SensType=0x0C → 多线圈传感信息 if(g_dbn_ble_state_acs_enable.flag == 0){ // 无 BLE ACS 连接 → 标记为 TCP JSON 上报 _report_flag = 1; @@ -172,10 +178,6 @@ void uart_srv(void) g_pkg_uart_2.pkg[0] = 0x8F; } } - else { - // --- 命令响应 → 交给协议处理器 --- - lup_process_frame(g_pkg_uart_2.pkg, g_pkg_uart_2.offset); - } // 调试打印 for(i = 0; i < g_pkg_uart_2.offset; i++){ @@ -185,7 +187,7 @@ void uart_srv(void) if(_report_flag){ // 传感器帧保留在 pkg 中供上层 (tcp_json_srv) 处理 - // 不 InitPkgUart — 由上层消费后再 InitPkgUart + // 不 InitPkgUart — 由 tcp_json_push_sensor 消费后清理 } } else { @@ -206,7 +208,7 @@ void uart_srv(void) } // 只有非 _report_flag 时才立即清空 - // _report_flag 的帧由 tcp_json 消费后清理 + // _report_flag 的帧由 tcp_json_push_sensor 消费后清理 if (!_report_flag) { InitPkgUart(&g_pkg_uart_2); }