From: hcj <1224667075@qq.com> Date: Wed, 13 Aug 2025 15:33:16 +0000 (+0800) Subject: 增加循环判断条件,避免断连后一直无法正确退出循环 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F2073%2Fhead;p=mirrors%2FFD230.git 增加循环判断条件,避免断连后一直无法正确退出循环 --- 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 4ff62376d..312556ec0 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp @@ -1060,6 +1060,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(); @@ -1593,7 +1600,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; @@ -2044,6 +2056,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; }