From: cheng.chen Date: Mon, 8 Jun 2026 03:09:01 +0000 (+0800) Subject: 毛小七开机慢问题和强制关机复位问题 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=HEAD;p=mirrors%2FFX01.git 毛小七开机慢问题和强制关机复位问题 --- diff --git a/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c b/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c index d07bd33..3c233c4 100644 --- a/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c +++ b/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.c @@ -120,10 +120,14 @@ WebSocketClient *AI_client_IOT = NULL; static u8 issend_start_up=0; +static u8 random_mt_test=0; + static u32 close_timerout = 0; static u32 sleep_chumo_timerout = 0; +static u32 tts_start_timerout = 0; + static u32 VC_pingping_timerout = 0; static u32 VC_END_play_timerout = 0; static char *AI_TTS_str = NULL; @@ -319,6 +323,7 @@ int save_VC_cfg(void) aic_free(vc_cfg_tmp); return 0; } + void reset_VC_cfg(void) { vc_cfg.start_flag = 0xaaaa; @@ -327,24 +332,26 @@ void reset_VC_cfg(void) //vc_cfg.dev_type = DEV_ADS;//奥德赛 vc_cfg.dev_type = DEV_JSWM;//金山完美 //vc_cfg.dev_type = DEV_ALY;//阿里云 - // strcpy(vc_cfg.server_ip,"amp.raisound.com");//服务器地址 - // strcpy(vc_cfg.server_ip,"115.190.94.208:22080");//服务器地址 + strcpy(vc_cfg.server_ip,"amp.raisound.com");//服务器地址 + + // strcpy(vc_cfg.server_ip,"115.190.94.208:22080");//服务器地址 - strcpy(vc_cfg.server_ip,"118.145.158.207:22080");//服务器地址 + // strcpy(vc_cfg.server_ip,"118.145.158.207:22080");//服务器地址 - vc_cfg.VC_mode =2;//对话模式 + vc_cfg.VC_mode =2; //对话模式 strcpy(vc_cfg.power_on_tone,"你好,请问您有什么需要我帮忙的吗?");//开机提示词 vc_cfg.VC_record_TYPE = VC_record_TYPE_PCM;//录音格式 vc_cfg.VC_play_TYPE = VC_play_TYPE_PCM;//播放格式 vc_cfg.VC_record_samplerate = 16000;//录音采样率 vc_cfg.VC_play_samplerate = 16000;//播放采样率 - vc_cfg.is_VAD = IS_VAD;//=1打开vad打断 - vc_cfg.is_KWS = IS_KWS;//=1打开本地语言打断 - vc_cfg.speech_rate = 0;//语速配置 - vc_cfg.vad_silence = 800;//vad断句时间 ms 500 - vc_cfg.VC_TTS_volume = 80;//音量 + vc_cfg.is_VAD = IS_VAD; //=1打开vad打断 + vc_cfg.is_KWS = IS_KWS; //=1打开本地语言打断 + vc_cfg.speech_rate = 0; //语速配置 + vc_cfg.vad_silence = 800; //vad断句时间 ms 500 + vc_cfg.VC_TTS_volume = 80; //音量 } + int init_VC_cfg(void) { FILE *fp = NULL; @@ -384,6 +391,7 @@ int init_VC_cfg(void) vc_cfg.VC_mode =2;//对话模式 + reset_VC_cfg(); return 0; } @@ -425,6 +433,8 @@ u8 *save_temp_tts=NULL; int is_guanji=0; +int ddh_is_close_dialog=0; + void aic_https_demotest(); int check_text(char *text,int ret_str_len) @@ -444,72 +454,81 @@ int check_text(char *text,int ret_str_len) } } - if(strstr(text,"音量") || strstr(text,"声音")) - { - if(strstr(text,"加")||(strstr(text,"大")&&!strstr(text,"太")) || (strstr(text,"太小"))) - { - vc_cfg.VC_TTS_volume +=10; - if(vc_cfg.VC_TTS_volume > 100) - { - vc_cfg.VC_TTS_volume = 100; - AI_AMP_MSG_put("音量已最大。",strlen("音量已最大。"),VC_TTS_PLAY); - //AI_TTS_str - }else{ - - tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"配置成功,当前音量%d。",vc_cfg.VC_TTS_volume); - AI_AMP_MSG_put(tmp_data,tmp_data_len,VC_TTS_PLAY); - } - // if(vc_cfg.VC_mode != 0) - app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); - // else{ - - // if(vc_cfg.VC_TTS_volume > 80) - // { - // app_audio_set_master_volume(15*50/100); - // }else{ + if(strstr(text,"音量查询") || strstr(text,"查询音量")) + { - // app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); - // } - // } + tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"查询成功,当前音量%d。",vc_cfg.VC_TTS_volume); + AI_AMP_MSG_put(tmp_data,tmp_data_len,VC_TTS_PLAY); + ret = 0; + goto RET; + } + // if(strstr(text,"加")||(strstr(text,"大")&&!strstr(text,"太")) || (strstr(text,"太小"))) + // { + // vc_cfg.VC_TTS_volume +=10; + // if(vc_cfg.VC_TTS_volume > 100) + // { + // vc_cfg.VC_TTS_volume = 100; + // AI_AMP_MSG_put("音量已最大。",strlen("音量已最大。"),VC_TTS_PLAY); + // //AI_TTS_str + // }else{ + + // tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"配置成功,当前音量%d。",vc_cfg.VC_TTS_volume); + // AI_AMP_MSG_put(tmp_data,tmp_data_len,VC_TTS_PLAY); + // } + // // if(vc_cfg.VC_mode != 0) + // app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); + // // else{ + + // // if(vc_cfg.VC_TTS_volume > 80) + // // { + + // // app_audio_set_master_volume(15*50/100); + // // }else{ + + // // app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); + // // } + // // } - is_save_VC_cfg = 1; - ret = 0; - goto RET; - }else if(strstr(text,"减")||(strstr(text,"小")&&!strstr(text,"太")) || (strstr(text,"太大"))) - { - vc_cfg.VC_TTS_volume -=10; - if(vc_cfg.VC_TTS_volume < 0) - { - vc_cfg.VC_TTS_volume = 0; - AI_AMP_MSG_put("音量已最小。",strlen("音量已最小。"),VC_TTS_PLAY); - //AI_TTS_str - }else{ - - tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"配置成功,当前音量%d。",vc_cfg.VC_TTS_volume); - AI_AMP_MSG_put(tmp_data,tmp_data_len,VC_TTS_PLAY); - } - - // if(vc_cfg.VC_mode != 0) - app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); - // else{ - - // if(vc_cfg.VC_TTS_volume > 80) - // { - - // app_audio_set_master_volume(15*50/100); - // }else{ + // is_save_VC_cfg = 1; + // ret = 0; + // goto RET; + // }else if(strstr(text,"减")||(strstr(text,"小")&&!strstr(text,"太")) || (strstr(text,"太大"))) + // { + // vc_cfg.VC_TTS_volume -=10; + // if(vc_cfg.VC_TTS_volume < 0) + // { + // vc_cfg.VC_TTS_volume = 0; + // AI_AMP_MSG_put("音量已最小。",strlen("音量已最小。"),VC_TTS_PLAY); + // //AI_TTS_str + // }else{ + + // tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"配置成功,当前音量%d。",vc_cfg.VC_TTS_volume); + // AI_AMP_MSG_put(tmp_data,tmp_data_len,VC_TTS_PLAY); + // } + + // // if(vc_cfg.VC_mode != 0) + // app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); + // // else{ + + // // if(vc_cfg.VC_TTS_volume > 80) + // // { + + // // app_audio_set_master_volume(15*50/100); + // // }else{ + + // // app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); + // // } + // // } + + // is_save_VC_cfg = 1; + // ret = 0; + // goto RET; + // } + // } - // app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); - // } - // } - is_save_VC_cfg = 1; - ret = 0; - goto RET; - } - } if(strstr(text,"切换")) { if(strstr(text,"对话模式") || strstr(text,"兑换模式")) @@ -526,14 +545,14 @@ int check_text(char *text,int ret_str_len) }else if(vc_cfg.VC_mode == 1) { - AI_AMP_MSG_put("已切换到单对话模式。长按按钮说话,说完松开即可。",strlen("已切换到单对话模式。长按按钮说话,说完松开即可。"),VC_TTS_PLAY); + AI_AMP_MSG_put("已切换到单对话模式。长按按钮说话,说完松开即可。",strlen("已切换到单对话模式。长按按钮说话,说完松开即可。"),VC_TTS_PLAY); app_audio_set_master_volume(15*80/100); }else { - app_audio_set_master_volume(15*80/100); - AI_AMP_MSG_put("已切换到按键打断模式。我说话的时候需要短按按钮打断。",strlen("已切换到按键打断模式。我说话的时候需要短按按钮打断。"),VC_TTS_PLAY); + app_audio_set_master_volume(15*80/100); + AI_AMP_MSG_put("已切换到按键打断模式。我说话的时候需要短按按钮打断。",strlen("已切换到按键打断模式。我说话的时候需要短按按钮打断。"),VC_TTS_PLAY); } is_save_VC_cfg = 1; ret = 0; @@ -586,6 +605,8 @@ int check_text(char *text,int ret_str_len) is_dialog_status=1; + ddh_is_close_dialog=1; + // AI_AMP_MSG_put(0,0,VC_CLOSE); // ret = 0; @@ -1142,8 +1163,10 @@ int check_text(char *text,int ret_str_len) } if(ret_str_len<16 && (strstr(text,"再见") || strstr(text,"拜拜") || strstr(text,"关闭对话"))) { - tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"再见了,我会想你的。"); - AI_AMP_MSG_put(tmp_data,tmp_data_len,VC_TTS_PLAY_CLOSE); + // tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"再见了,我会想你的。"); + // AI_AMP_MSG_put(tmp_data,tmp_data_len,VC_TTS_PLAY_CLOSE); + is_dialog_status=1; + ddh_is_close_dialog=1; } if(ret_str_len<16 && (strstr(text,"关机") )) @@ -1867,7 +1890,7 @@ long getFileSize(char* filename) { } - if(type==1&&mode==1){ + if(type==1&&mode==1){ #if SUPPORT_MOT mot_nod_exp(12,2); @@ -1924,7 +1947,7 @@ long getFileSize(char* filename) { - uart_write(ui_uart_handle,cmd_ui, 7); + uart_write(ui_uart_handle,cmd_ui, 7); } void back_middle_statu_mot(){ @@ -1934,6 +1957,32 @@ void back_middle_statu_mot(){ } +void random_statu_mot(){ + + //aos_sleep(1000); + u32 count_tmp = 0; + aos_get_queue_used_count(AI_VC_play_queue,&count_tmp); + + bk_printf("random_statu_mot....\n"); + + if(count_tmp<=0) + return ; + //VC_END_play_timerout = 1; + + if(random_mt_test%3==0) + mot_nod_exp(8,2); + + if(random_mt_test%3==1) + mot_nod_exp(15,2); + + if(random_mt_test%3==2) + mot_nod_exp(16,2); + + random_mt_test++; + + +} + void send_express_str_xinxinmao(char *exp_str){ @@ -2236,7 +2285,7 @@ void send_express_str(char *exp_str){ { #if SUPPORT_MOT - mot_nod_exp(7,2); + mot_nod_exp(5,2); // mot_nod_exp(7,2); #endif cmd_ui[4]=0x02; @@ -2427,12 +2476,23 @@ static void AI_VC_read_task(void *thread_input)//websocket 读线程 { - close_timerout = 300; + close_timerout = 305; if(is_dialog_status==0){ - sleep_chumo_timerout=180; + sleep_chumo_timerout=300; + + }else{ + + if(vc_cfg.VC_mode==1){ + + if(ddh_is_close_dialog==0) + close_timerout=5; + // else{ + // } + + } } if(code == WS_TEXT)//字符串 @@ -2442,6 +2502,7 @@ static void AI_VC_read_task(void *thread_input)//websocket 读线程 if(strstr(recv_buff,"\"started\""))//开始 { + tts_start_timerout=0; if(issend_start_up==0){ issend_start_up=1; @@ -2573,7 +2634,7 @@ static void AI_VC_read_task(void *thread_input)//websocket 读线程 } - bk_printf("002AI_ASR_str%s AI_ASR_str_tmp %s",AI_ASR_str,AI_ASR_str_tmp); + bk_printf("002AI_ASR_str%s AI_ASR_str_tmp %s",AI_ASR_str,AI_ASR_str_tmp); bk_printf("play_file_stream_data:%d",VC_Play_flag); if(has_tmp_result==0) @@ -2688,6 +2749,17 @@ static void AI_VC_read_task(void *thread_input)//websocket 读线程 else if(strstr(recv_buff,"\"completed\""))//结束 { VC_state = VC_State_End;// + + if(vc_cfg.VC_mode==0&&strlen(AI_ASR_str_tmp)==0){ + + u32 count_tmp = 0; + aos_get_queue_used_count(AI_VC_play_queue,&count_tmp); + + bk_printf("连续对话模式没有语音....\n"); + if(count_tmp<=0) + VC_END_play_timerout = 1; + + } //AI_AMP_MSG_put(0,0,VC_RECORD_START);//打开录音 }else if(strstr(recv_buff,"\"event\":\"failed\""))//接口报错了 @@ -2933,7 +3005,7 @@ static void AI_VC_record_task(void *thread_input)//录音线程 bk_printf("!!!!!!!!!!!!!!!!!!!!!!离线语音识别打断了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n"); kws_clear(); - AI_AMP_MSG_put("我来了。",strlen("我来了。"),VC_TTS_PLAY); + AI_AMP_MSG_put("我来了。",strlen("我来了。"),VC_TTS_PLAY); } } continue; @@ -3048,9 +3120,10 @@ static void AI_VC_record_task(void *thread_input)//录音线程 } - AI_VC_put_record_data(vrecord_buf,ret); + AI_VC_put_record_data(vrecord_buf,ret); + + audio_data(vrecord_buf,ret,21); - audio_data(vrecord_buf,ret,21); // if(vc_cfg.is_KWS) // { // int KWS_time = aos_get_tickcount(); @@ -3066,6 +3139,7 @@ static void AI_VC_record_task(void *thread_input)//录音线程 // } // } //bk_printf("VAD:检测到说话了"); + }else if(vad_status_t == 0 )//m没有说话 { @@ -3120,7 +3194,7 @@ static void AI_VC_record_task(void *thread_input)//录音线程 } VC_state = VC_State_None; - bk_printf("VAD:vad_status_t:%d",vad_status_t); + bk_printf("VAD:vad_status_t:%d",vad_status_t); bk_printf("VAD:发送打断对话"); AI_AMP_MSG_put(0,0,VC_Cancel);//发送打断 @@ -3152,19 +3226,20 @@ static void AI_VC_record_task(void *thread_input)//录音线程 }else { - if(VC_state > VC_State_SpeechStart){ + if(VC_state > VC_State_SpeechStart) + { bk_printf("VAD:有数据还没发:VC_state:%d\r\n\r\n",VC_state); - AI_AMP_MSG_put("没听清,请再说一遍",strlen("没听清,请再说一遍"),VC_CONNECT_ERROR); + // AI_AMP_MSG_put("没听清,请再说一遍",strlen("没听清,请再说一遍"),VC_CONNECT_ERROR); } - // AI_VC_send_audio_create();//发送开始音频 - // bk_printf("VAD:发送开始音频"); - - // char count_tmp = 200; + // AI_VC_send_audio_create();//发送开始音频 + // bk_printf("VAD:发送开始音频"); + // char count_tmp = 200; } vad_end_flag = 1; - }else//没录音数据 + } + else//没录音数据 { if(VAD_status) { @@ -3434,6 +3509,7 @@ void deal_iot_receive(char *json_data) if(strstr(json_data,"action")){ + tts_start_timerout=0; bk_printf("action"); char *str_tmp = NULL; @@ -3465,10 +3541,73 @@ void deal_iot_receive(char *json_data) } + if(strstr(json_data,"set_vol")){ + + + char *str_tmp = NULL; + + char action_str[500]={0}; + + str_tmp = strstr(json_data,"\"data\":\""); + + if(str_tmp)//解析password + { + + str_tmp += strlen("\"data\":\""); + int count = str_count(str_tmp,'\"'); + bk_printf("count:%d",count); + if(count < sizeof(action_str)) + { + + + memcpy(action_str,str_tmp,count); + action_str[count] = 0; + bk_printf("set_vol:%s",action_str); + + if(strstr(action_str,"+10")){ + + if(vc_cfg.VC_TTS_volume<=90){ + vc_cfg.VC_TTS_volume+=10; + + app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); + } + + }else if(strstr(action_str,"-10")){ + + if(vc_cfg.VC_TTS_volume>10){ + vc_cfg.VC_TTS_volume-=10; + app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); + } + + }else{ + + int temp_vol=atoi(action_str); + + if(temp_vol>0&&temp_vol<=100){ + + bk_printf("temp_vol:%d",temp_vol); + vc_cfg.VC_TTS_volume=temp_vol; + + app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); + + + } + + } + // if(is_guanji==0) + // send_express_str(action_str); + } + + } + + } + if(strstr(json_data,"emotion")){ bk_printf("emotion"); + tts_start_timerout=0; + char *str_tmp = NULL; char emotion_str[500]={0}; @@ -3923,7 +4062,7 @@ static int websocket_connect_VC(void) // wss://wsiot.raisound.com/iot-api/ws-hub/dev/v1?bz-dt=xxx // ws(s)://wsiot-nocdn.raisound.com/ws-hub/dev/v1?bz-dt= -#if 0 +#if 1 sprintf(url_iot,"ws://wsiot-nocdn.raisound.com/ws-hub/dev/v1?bz-dt=%s",get_token()); #else @@ -4457,6 +4596,22 @@ static void AI_VC_1S_timeout(void *param) AI_AMP_MSG_put(0,0,VC_CLOSE); AI_AMP_MSG_put(0,0,CLOSE_IOT); } + + if(VC_state>=VC_State_TTSStart&&VC_state0) @@ -4468,8 +4623,16 @@ static void AI_VC_1S_timeout(void *param) is_dialog_status=1; // VC_state = VC_State_End; + if(vc_cfg.VC_mode==0||vc_cfg.VC_mode==2) + AI_client_VC_synthesis("你好,我要去休息了,唤醒请说你好小七"); + else{ + + AI_AMP_MSG_put(0,0,VC_CLOSE); + // AI_AMP_MSG_put(0,0,CLOSE_IOT); - AI_client_VC_synthesis("你好,我要去休息了,唤醒请说你好小七"); + close_timerout=2; + } + // if() } } @@ -4510,14 +4673,24 @@ static void AI_VC_1S_timeout(void *param) } else{ - VAD_status = 0; - // AI_AMP_MSG_put(0,0,VC_CLOSE); + if (VC_TTS_PLAY_EVENT == VC_TTS_PLAY_POWER_OFF) + { + AI_AMP_MSG_put(0,0,POWER_OFF); + }else if (VC_TTS_PLAY_EVENT == VC_TTS_PLAY_RESET) + { + AI_AMP_MSG_put(0,0,POWER_RESET); + } + VAD_status = 0; + + ddh_is_close_dialog=0; + + // AI_AMP_MSG_put(0,0,VC_CLOSE); } //AI_AMP_MSG_put(0,0,VC_RECORD_START);//开启录音 // AI_AMP_MSG_put(0,0,AI_MOT_BACK_MID); - bk_msg_printf("VC_END_play_timerout=%d",VC_END_play_timerout); + bk_msg_printf("VC_END_play_timerout=%d",VC_END_play_timerout); AI_AMP_MSG_put(0,0,AI_MOT_BACK_MID); } @@ -4831,10 +5004,15 @@ AI_VC_start_RET: net_status_count++; play_audio_file("C:/xinhaoruo1.mp3"); - if(net_status_count>=3) - play_audio_file("C:/khye.mp3"); + if(net_status_count>=3){ + + play_audio_file("C:/khye.mp3"); + AI_AMP_MSG_put(0,0,POWER_RESET); + + } }else AI_VC_stata = 1; + return ret; } char AI_VC_Close_lock = 0; @@ -4851,8 +5029,8 @@ void AI_VC_Close(void) // aic_gpio_output(MOT_EN_REV,GPIO_OUTPUT_LVL_LOW); // aic_gpio_output(GPIO_20,GPIO_OUTPUT_LVL_LOW ); #if SUPPORT_MOT - // MTO_stop(); + // MTO_stop(); // MTO_restert(); // MTO_restert_tb(); @@ -5028,6 +5206,8 @@ void AI_VC_Close(void) AI_ASR_str =NULL; } //app_logi("app_audio_stop2"); + + VC_state = VC_State_None; AI_VC_stata = 0; AI_VC_Close_lock = 0; @@ -5150,16 +5330,16 @@ static void sys_10S_timeout_even(void) is_Low_power_warning =0; } chg_status_tmp = psy_info.bat_chg_status; - // bk_printf("电量查询:psy_name:%s bat_vol:%d bat_cap:%d chg_status%d chg_type:%d bat_min_voltage:%d bat_max_voltage:%d\n", - - // psy_info.psy_name, - // psy_info.bat_current_voltage, - // psy_info.bat_capacity, - // psy_info.bat_chg_status, - // psy_info.bat_chg_type, - // psy_info.bat_min_voltage, - // psy_info.bat_max_voltage); - //tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"当前电量为百分之%d。",psy_info.bat_capacity); + bk_printf("电量查询:psy_name:%s bat_vol:%d bat_cap:%d chg_status%d chg_type:%d bat_min_voltage:%d bat_max_voltage:%d\n", + + psy_info.psy_name, + psy_info.bat_current_voltage, + psy_info.bat_capacity, + psy_info.bat_chg_status, + psy_info.bat_chg_type, + psy_info.bat_min_voltage, + psy_info.bat_max_voltage); + // tmp_data_len = snprintf(tmp_data,sizeof(tmp_data),"当前电量为百分之%d。",psy_info.bat_capacity); } // extern char *ota_url; @@ -5234,7 +5414,8 @@ void random_chumo(int type,int mode){ // ||is_dialog_status==1 - if((VC_state==VC_State_Listening&&VAD_status==0)||VC_state==VC_State_End||VC_state==VC_State_None){ + //if((VC_state==VC_State_Listening&&VAD_status==0)||VC_state==VC_State_End) //||VC_state==VC_State_None + // { bk_printf("VC_state11 %d.....\n",VC_state); @@ -5248,8 +5429,11 @@ void random_chumo(int type,int mode){ if(index_temp<5) { - AI_AMP_MSG_put(str_huashu[type][mode][index_temp],strlen(str_huashu[type][mode][index_temp]),VC_TTS_PLAY); + app_audio_set_master_volume(15*vc_cfg.VC_TTS_volume/100); + + AI_AMP_MSG_put(str_huashu[type][mode][index_temp],strlen(str_huashu[type][mode][index_temp]),VC_TTS_PLAY); + is_dialog_status=0; } // AI_client_VC_synthesis(str_huashu[type][mode][index_temp]); @@ -5265,12 +5449,12 @@ void random_chumo(int type,int mode){ // play_audio_file("C:/chumo.mp3"); // return ; - }else{ + // }else{ - bk_printf("VC_state22 %d.....\n",VC_state); + // bk_printf("VC_state22 %d.....\n",VC_state); - return ; - } + // return ; + // } // if(VC_Play_flag!=1){ @@ -5350,6 +5534,8 @@ extern imsl_nn_printf_func imsl_nn_printf; int auth_vad_status=0; +int auth_kws_status=0; + static void uart_recv_UI_handel(void *thread_input) { size_t read; @@ -5405,7 +5591,7 @@ static void uart_recv_UI_handel(void *thread_input) static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 { - char count = 30; + char count = 20; boolean pdp_activated ; AI_AMP_MSG_queue_t AI_AMP_msg = {0}; @@ -5433,9 +5619,9 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 // http://dmp-ota.tos-cn-guangzhou.volces.com/ota/2025_07_24/1948312805093978114gx306l_h3.diff - bk_printf("FXH01_Version:%s",FXH01_Version); - bk_printf("FXH01_Version:%s",FXH01_Version); - bk_printf("FXH01_Version:%s",FXH01_Version); + bk_printf("FXH01_Version:%s",FXH01_Version); + bk_printf("FXH01_Version:%s",FXH01_Version); + bk_printf("FXH01_Version:%s",FXH01_Version); //slp_register_sleep_hook(bk_task_suspend, AIC_NULL, // bk_task_resume, AIC_NULL); @@ -5444,7 +5630,37 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 // snd_soc_component_write(codec, ES8311_ADC_REG17, es8311->adc_volume); // snd_soc_component_write(codec, ES8311_DAC_REG32, es8311->dac_volume); + // aos_sleep(1000); + + while(count --) + { + pdp_activated = aic_is_default_pdp_activated(); + if(pdp_activated == TRUE) + break; + bk_printf("AI_AMP_2_5_init 等待注网..... \n"); + + // audio_play_tone(count%15,500);//播放提示音,测试用 + // audio_play_tone(3,500);//播放提示音,测试用 + + aos_sleep(1000); + } + + + if(pdp_activated){ + + bk_printf("AI_AMP_2_5_init 入网成功..... \n"); + + }else{ + + bk_printf("AI_AMP_2_5_init 第一次入网失败..... \n"); + aic_send_cfun_cmd(0); + aos_sleep(500); + + aic_send_cfun_cmd(1); + + aos_sleep(500); + count=20; while(count --) { @@ -5453,10 +5669,12 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 break; bk_printf("AI_AMP_2_5_init 等待注网..... \n"); - //audio_play_tone(count%15,500);//播放提示音,测试用 - //audio_play_tone(3,500);//播放提示音,测试用 + // audio_play_tone(count%15,500);//播放提示音,测试用 + // audio_play_tone(3,500);//播放提示音,测试用 aos_sleep(1000); + } + } bk_websocket_demo(); @@ -5522,7 +5740,7 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 } - // AI_VC_60S_timer + // AI_VC_60S_timer // if(AI_VC_60S_timer == NULL) // { // AI_VC_60S_timer = aos_create_timer("AI_VC_60S_timer", @@ -5535,43 +5753,82 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 bk_printf("auth_vad token0: %s..... \n",get_token()); struct AuthInfo auth_info; - // dmp_log_level = 10086; + // dmp_log_level = 10086; - auth_info.server_addr=2; + // auth_info.server_addr=2; strcpy(auth_info.dmp_token, get_token()); if(strlen(auth_info.dmp_token)>0){ - for(int i=0;i<3;i++){ + for(int i=0;i<40;i++){ + int ret=auth_vad(&auth_info); if(ret==0){ - bk_printf("auth_vad fail token: %s..... \n",get_token()); + bk_printf("auth_vad fail token: %s..... \n",get_token()); - }else{ + } + else + { - bk_printf("auth_vad success token: %s..... \n",get_token()); + bk_printf("auth_vad success token: %s..... \n",get_token()); - auth_vad_status=1; - break; + auth_vad_status=1; + + break; + + } + + aos_sleep(100); } + for(int i=0;i<40;i++){ + + int ret=auth_kws(&auth_info); + + if(ret==0){ + + bk_printf("auth_kws fail token: %s..... \n",get_token()); + + } + else + { + + bk_printf("auth_kws success token: %s..... \n",get_token()); + + auth_kws_status=1; + + break; + + } + + aos_sleep(100); + } - }else{ - play_audio_file_event("C:/xinhaoruo1.mp3"); - } - if(auth_vad_status==0){ + bk_printf("auth_vad_status: %d auth_kws_status %d..... \n",auth_vad_status,auth_kws_status); - play_audio_file_event("C:/xinhaoruo1.mp3"); + if(auth_vad_status==0||auth_kws_status==0) + { - aos_sleep(2000); + // play_audio_file_event("C:/xinhaoruo1.mp3"); + // aos_sleep(500); + + } + + } + else + { + + // play_audio_file_event("C:/xinhaoruo1.mp3"); } + + #ifdef exptest aos_sleep(500); @@ -5691,6 +5948,11 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 // AI_client_IOT } + break; + case RANDOM_MT: + + random_statu_mot(); + break; case VC_START: AI_VC_start(0); @@ -5845,7 +6107,7 @@ static void AI_AMP_2_5_task(void *thread_input)//做逻辑线程 aic_free(AI_AMP_msg.data); }else { - aos_sleep(10); + aos_sleep(10); } diff --git a/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.h b/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.h index e74e506..1d08871 100644 --- a/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.h +++ b/2.code/aicos/app/AI_AMP_2_5/AI_AMP_2_5.h @@ -97,6 +97,7 @@ typedef enum AI_AMP_MSG AI_TIMER_EVENT_IOT,//定时器事件 AI_MOT_BACK_MID, CLOSE_IOT, + RANDOM_MT, } AI_AMP_MSG_Type; typedef struct { diff --git a/2.code/aicos/app/AI_AMP_2_5/bk_key.c b/2.code/aicos/app/AI_AMP_2_5/bk_key.c index ec1d176..9552a8a 100644 --- a/2.code/aicos/app/AI_AMP_2_5/bk_key.c +++ b/2.code/aicos/app/AI_AMP_2_5/bk_key.c @@ -160,6 +160,8 @@ void bk_to_ups_sync(void *ptr) { // gx_ups_phy_from_rtc(); AI_AMP_MSG_put(0, 0, VC_CLOSE); + //aos_sleep(1000); + AI_AMP_MSG_put(0,0,AI_MOT_BACK_MID); // gx_ups_phy_cnt_clr(); play_audio_file("C:/zhengzaiguanji.mp3"); bk_msg_printf("bk_to_ups_sync"); @@ -170,6 +172,9 @@ void bk_key_init(void) { // bk_printf("开始初始化按键模块\n"); 不注释掉就卡住没日志 aic_gpo_output(TP_POWER_EN,GPO_OUTPUT_HIGH );//tp电源 + + // aic_gpo_output(GPO_13,GPO_OUTPUT_LOW);//tp电源 + int32_t handle = aic_srv_kpc_register("app", bk_kpc_callback); if (handle < 0) { alog_error("Failed to register KPC callback\n"); // 使用 alog_error 输出错误信息 diff --git a/2.code/aicos/app/AI_AMP_2_5/bk_opus_coder.c b/2.code/aicos/app/AI_AMP_2_5/bk_opus_coder.c index 77e1006..26f663c 100644 --- a/2.code/aicos/app/AI_AMP_2_5/bk_opus_coder.c +++ b/2.code/aicos/app/AI_AMP_2_5/bk_opus_coder.c @@ -462,7 +462,7 @@ int my_opus_decode_data(char *in_ogg_data,int in_ogg_data_len) dec_inparam.outbuffer_size = 1920; ret = aic_opus_decode(&dec_inparam); - // bk_printf("opus解码 输入大小:%d,输出大小:%d", in_ogg_data_len,dec_inparam.outputfrms_size); + // bk_printf("opus解码 输入大小:%d,输出大小:%d", in_ogg_data_len,dec_inparam.outputfrms_size); opus_encode_len++; diff --git a/2.code/aicos/app/AI_AMP_2_5/dev_authentication.c b/2.code/aicos/app/AI_AMP_2_5/dev_authentication.c index 4511b17..fe8a2da 100644 --- a/2.code/aicos/app/AI_AMP_2_5/dev_authentication.c +++ b/2.code/aicos/app/AI_AMP_2_5/dev_authentication.c @@ -25,7 +25,7 @@ #include "aic_fota.h" - #define DMPTEST + // #define DMPTEST #define bk_malloc aic_malloc #define bk_free aic_free diff --git a/2.code/aicos/app/AI_AMP_2_5/mot_dev.c b/2.code/aicos/app/AI_AMP_2_5/mot_dev.c index 929263b..6044209 100644 --- a/2.code/aicos/app/AI_AMP_2_5/mot_dev.c +++ b/2.code/aicos/app/AI_AMP_2_5/mot_dev.c @@ -494,7 +494,7 @@ static void mot_nod3(void)//点头处理 int count = 255; while(count--) { - count = 10000; + count = 2000; while (count--) { if(EIPU_GetIndata(NOSEC_MODE, EIPU_DBNC, 4) == 0)//到顶部 @@ -517,7 +517,7 @@ static void mot_nod2(void) int count = 255; while(count--) { - count = 10000; + count = 2000; while (count--) { if(aic_gpio_level_get(MOT_LR_TOP_SITE_IO) == 0)//到顶部