增加循环判断条件,避免断连后一直无法正确退出循环 2073/1 2073/head
authorhcj <1224667075@qq.com>
Wed, 13 Aug 2025 15:33:16 +0000 (23:33 +0800)
committerhcj <1224667075@qq.com>
Wed, 13 Aug 2025 15:33:16 +0000 (23:33 +0800)
code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp

index 4ff6237..312556e 100644 (file)
@@ -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;
                 }