/* 添加消息到队列 */
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++;
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);
+ }
+
}
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");
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;
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;
}