fix: improve field diagnostics and mirror logs to USB CDC

This commit is contained in:
chenjintao
2026-10-20 14:46:08 +08:00
parent 8bff1f569e
commit 07094d4a4e
20 changed files with 1036 additions and 200 deletions
@@ -5,6 +5,7 @@
#include "app_inc.h"
#include "talkingq_wss.h"
#include "net_diag.h"
#include "net_diag_voice.h"
#include "ql_rtos.h"
#include "ql_application.h"
#include "ql_audio.h"
@@ -102,6 +103,7 @@ void conversation_record_begin(void)
conversation_lock();
if (!g_mic_working) conversation_begin_round();
g_mic_working = 1;
net_diag_voice_begin(conversation_round);
conversation_unlock();
}
@@ -118,7 +120,8 @@ void conversation_no_speech(void)
{
conversation_lock();
wait_round = conversation_round;
conversation_wait = WAIT_NO_SPEECH;
conversation_wait = WAIT_NO_SPEECH;
net_diag_event("VAD未确认用户语音,本轮等待超时提示;不是AI回复耗时", 0);
conversation_unlock();
}
static volatile int player_mq_couter = 0;
@@ -504,7 +507,8 @@ static void onmessage_text_locked(rws_socket socket, const char *text, const uns
char url_buff_bak[128]={0x00};
if(strstr(text, "_START")){
printf("TTS_START\r\n");
printf("TTS_START\r\n");
if (active_session_valid) net_diag_voice_mark(active_session_round, VOICE_TTS_START);
//语音交互音频开始
tts_playing = 1;
tts_play_status = 1;
@@ -514,7 +518,9 @@ static void onmessage_text_locked(rws_socket socket, const char *text, const uns
//语音交互音频结束
// tts_playing = 0;
tts_play_status = 2;
}else if(strstr(text, "END_ACK")||strstr(text, "START_ACK")){
}else if(strstr(text, "END_ACK")||strstr(text, "START_ACK")){
if (active_session_valid && strstr(text, "END_ACK"))
net_diag_voice_mark(active_session_round, VOICE_END_ACK);
}else{//TTS_URL:audio_url
char *ret_str1 = strstr(text, "https://");
@@ -584,6 +590,9 @@ static void onmessage_text_locked(rws_socket socket, const char *text, const uns
/* 对话超时提示使用 type=3,云端播放失败时由播放线程切换到本地兜底。 */
if (active_session_valid && !is_tts_error_url && !is_message_ok_url &&
strstr(url_buff_bak, sessionId) != NULL)
net_diag_voice_url(active_session_round, url_buff);
add_file_to_play_player_queue(url_buff, is_tts_error_url == 1 ? 3 : 0);
}
}
@@ -1056,7 +1065,9 @@ void sendEndPacket(void) {
conversation_lock();
if (sender_round == conversation_round) {
int end_ret = sendRecordingAudioPacket(&endPacket);
int end_ret = sendRecordingAudioPacket(&endPacket);
if (end_ret == 0) net_diag_voice_mark(sender_round, VOICE_END_QUEUED);
else net_diag_event("结束包入队失败;不能按等待AI回复解释", end_ret);
if (!round_response_received) {
wait_round = sender_round;
reply_wait_start_ms = hal_os_up_time_ms();