From a129d32b5ae9c26e962355b555300ea8fabd5c48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Wed, 13 Aug 2025 23:49:25 +0000 Subject: [PATCH] Merge #2073 into sdk602patch0911 from refs/changes/2073/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 增加循环判断条件,避免断连后一直无法正确退出循环 * refs/changes/2073/head: (1 commits squashed) - 增加循环判断条件,避免断连后一直无法正确退出循环 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: Caisking <3449750381@qq.com> Reviewed-by: 罗正 <1732036298@qq.com> Reviewed-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Reviewed-by: aliyun6865282430 <1624952103@qq.com> Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/2073 --- .../slip/cat1Service/cat1_ai_server.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp index 4ba5118cc..ea8cb7c6a 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp @@ -1088,6 +1088,13 @@ void bk_websocket_demo(void *data) { // 检查超时 if ((uint32_t)osKernelGetTickCount() - last_activity > AI_RECEIVE_TIMEOUT_MS) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Receive timeout, reconnecting..."); + + tcp_connection_state_t current_state = tcp_get_connection_state(chat_client->tcp_handle); + if(current_state!=TCP_STATE_CONNECTED) + { + break; + } + if(disconnect_server == 0) { last_activity = (uint32_t)osKernelGetTickCount(); @@ -1633,7 +1640,12 @@ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "等待ASR WebSocket握手完成... (%d m if ((uint32_t)osKernelGetTickCount() - last_activity > AI_RECEIVE_TIMEOUT_MS) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ASR receive timeout, reconnecting..."); - if(disconnect_server == 0 ) + tcp_connection_state_t current_state = tcp_get_connection_state(asr_client->tcp_handle); + if(current_state!=TCP_STATE_CONNECTED) + { + break; + } + if(disconnect_server == 0) { last_activity = (uint32_t)osKernelGetTickCount(); continue; @@ -2089,6 +2101,11 @@ void bk_websocket_tts(void *data) { if(disconnect_server == 0) { + tcp_connection_state_t current_state = tcp_get_connection_state(tts_client->tcp_handle); + if(current_state!=TCP_STATE_CONNECTED) + { + break; + } last_activity = (uint32_t)osKernelGetTickCount(); continue; } -- 2.17.1