From: hcj <1224667075@qq.com> Date: Fri, 19 Sep 2025 12:31:56 +0000 (+0800) Subject: 修改ws 的stop调用 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~13^2~7 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=ee61d1960d5ebf99530b6443056e971ba8d3c0c2;p=mirrors%2FFD230.git 修改ws 的stop调用 --- diff --git a/code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c b/code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c index aaed755b6..f00f1c168 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c @@ -650,7 +650,7 @@ static uint32_t ln_ws_stop_at(uint8_t *para, uint32_t paraLen, char *strCommonCm { VAD_UNUSED(para); VAD_UNUSED(paraLen); VAD_UNUSED(strCommonCmd); printf("[LN][WS_STOP]\n"); - int ret = ln_ws_stop(); + int ret = ln_ws_stop_async(); if (ret != 0) { printf("[LN][WS_STOP] failed: %d\n", ret); diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c index 555a11158..cb1c3e8e7 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c @@ -124,7 +124,7 @@ static void ln_ws_on_error(int client, struct WebSocketErrorResult error) static void ln_ws_on_close(int client) { (void)client; - printf("WebSocketClientConstructor [LN][WS] ln_ws_on_close"); + printf("WebSocketClientConstructor [LN][WS] ln_ws_on_close %d\r\n",client); g_ws_connected = WS_STATE_DISCONNECTED; printf("[LN][WS] 连接状态: 未连接\n"); if(g_ws_client_fd>=0) @@ -274,6 +274,27 @@ static void ln_ws_main_thread(void *arg) /* 1秒间隔 */ usleep(1000 * 1000); } + + if (g_ws_client_fd >= 0) { + WebSocketClientClose(g_ws_client_fd); + g_ws_client_fd = -1; + } + g_ws_connected = WS_STATE_DISCONNECTED; + + // 删除消息队列 + if (g_ws_msg_queue != NULL) { + + ws_msg_info_t msg; + while (osMessageQueueGet(g_ws_msg_queue, &msg, NULL, 0) == osOK) { + if(msg.data.raw_json) + { + free(msg.data.raw_json); + } + + } + osMessageQueueDelete(g_ws_msg_queue); + g_ws_msg_queue = NULL; + } } /* @@ -411,7 +432,7 @@ int ln_ws_force_reconnect(void) ws_msg_info_t msg; msg.msg_type = WS_MSG_TYPE_FORCE_RECONNECT; msg.data_len = 0; - // msg.data = NULL; + msg.data.raw_json = NULL; osStatus_t ret = osMessageQueuePut(g_ws_msg_queue, &msg, 0, 0); return (ret == osOK) ? 0 : -1; @@ -425,6 +446,7 @@ int ln_ws_stop_async(void) ws_msg_info_t msg; msg.msg_type = WS_MSG_TYPE_STOP; msg.data_len = 0; + msg.data.raw_json = NULL; // msg.data = NULL; osStatus_t ret = osMessageQueuePut(g_ws_msg_queue, &msg, 0, 0);