临时提交
author孙春阳 <snickersun@163.com>
Wed, 13 Aug 2025 16:23:23 +0000 (00:23 +0800)
committer孙春阳 <snickersun@163.com>
Wed, 13 Aug 2025 16:23:23 +0000 (00:23 +0800)
code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp
code/sdk/drivers/peripheral/slip/cat1Service/websocket_parser.cpp

index 4ff6237..7685fd3 100644 (file)
@@ -434,11 +434,13 @@ static int ws_queue_put(ws_message_queue_t* queue, const uint8_t* data, uint16_t
     
     /* 添加消息到队列 */
     ws_message_item_t* item = &queue->messages[queue->tail];
+    memset(item->data,0,WS_MESSAGE_MAX_SIZE);
     memcpy(item->data, data, length);
     item->length = length;
     item->type = type;
     item->timestamp = osKernelGetTickCount();
     item->in_use = true;
+    printf("ws_queue_put type %d , length %d , data %s\n",type,item->length,item->data);
     
     queue->tail = (queue->tail + 1) % WS_QUEUE_SIZE;
     queue->count++;
@@ -868,17 +870,27 @@ uint8_t get_bk_websocket_tts_tick(void)
 void asr_on_ws_packet_callback(uint8_t* data, size_t datalen, WebSocketMessageType type)
 {
     if(asr_client !=NULL && asr_client->msg_queue !=NULL)
-    ws_queue_put(asr_client->msg_queue,data,datalen,type);
+    {
+        // printf("asr_on_ws_packet_callback %d %s\n",datalen,data);
+        ws_queue_put(asr_client->msg_queue,data,datalen,type);
+    }
+    
 }
 void tts_on_ws_packet_callback(uint8_t* data, size_t datalen, WebSocketMessageType type)
 {
     if(tts_client !=NULL && tts_client->msg_queue !=NULL)
-    ws_queue_put(tts_client->msg_queue,data,datalen,type);
+    {
+        // printf("tts_on_ws_packet_callback %d %s\n",datalen,data);
+        ws_queue_put(tts_client->msg_queue,data,datalen,type);
+    }
 }
 void chat_on_ws_packet_callback(uint8_t* data, size_t datalen, WebSocketMessageType type)
 {
     if(chat_client !=NULL && chat_client->msg_queue !=NULL)
-    ws_queue_put(chat_client->msg_queue,data,datalen,type);
+    {
+        ws_queue_put(chat_client->msg_queue,data,datalen,type);
+    }
+    
 }
 
 
index d81b4a4..4057ee2 100644 (file)
@@ -718,34 +718,33 @@ int ws_process_received_data(WebSocketClient *client, const uint8_t *data, size_
     printf("\n=== WebSocket Raw Data Received ===\n");
     printf("Client: %s:%s\n", client->host, client->path);
     printf("Total bytes: %zu\n", len);
-    printf("Raw data (hex): ");
-    
-    // 打印所有数据的十六进制表示
-    for (size_t i = 0; i < len; i++) {
-        printf("%02X ", data[i]);
-        // 每16字节换行,提高可读性
-        if ((i + 1) % 16 == 0) {
-            printf("\n                    ");
-        }
-    }
-    printf("\n");
+    // printf("Raw data (hex): ");
+    // // 打印所有数据的十六进制表示
+    // for (size_t i = 0; i < len; i++) {
+    //     printf("%02X ", data[i]);
+    //     // 每16字节换行,提高可读性
+    //     if ((i + 1) % 16 == 0) {
+    //         printf("\n                    ");
+    //     }
+    // }
+    // printf("\n");
     
-    // 打印ASCII表示(可打印字符)
-    printf("Raw data (ASCII): ");
-    for (size_t i = 0; i < len; i++) {
-        if (data[i] >= 32 && data[i] <= 126) {
-            printf("%c", data[i]);
-        } else if (data[i] == '\r') {
-            printf("\\r");
-        } else if (data[i] == '\n') {
-            printf("\\n");
-        } else if (data[i] == '\t') {
-            printf("\\t");
-        } else {
-            printf(".");
-        }
-    }
-    printf("\n");
+    // // 打印ASCII表示(可打印字符)
+    // printf("Raw data (ASCII): ");
+    // for (size_t i = 0; i < len; i++) {
+    //     if (data[i] >= 32 && data[i] <= 126) {
+    //         printf("%c", data[i]);
+    //     } else if (data[i] == '\r') {
+    //         printf("\\r");
+    //     } else if (data[i] == '\n') {
+    //         printf("\\n");
+    //     } else if (data[i] == '\t') {
+    //         printf("\\t");
+    //     } else {
+    //         printf(".");
+    //     }
+    // }
+    // printf("\n");
     
     // 打印数据统计信息
     // printf("Data analysis:\n");
index 3bdaede..d695d81 100644 (file)
@@ -129,7 +129,7 @@ ws_parser_t* ws_parser_init() {
 void ws_parser_reset(ws_parser_t* parser) {
     if (!parser) return;
     
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "WS: Resetting parser state");
+    // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "WS: Resetting parser state");
     
     parser->state = WS_STATE_START;
     parser->buffer_pos = 0;
@@ -543,7 +543,7 @@ int ws_parse_stream(ws_parser_t* parser, const uint8_t* data, size_t len) {
             return i+1;
         } else if (result == -1) {
             // 解析错误,重置解析器
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WS: Parse error at byte %zu, resetting parser, byte: %02X", i, data[i]);
+            // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WS: Parse error at byte %zu, resetting parser, byte: %02X", i, data[i]);
             ws_parser_reset(parser);
             continue;
         }