From f20bccc1cc6a394d57561581eb4bdf952321c9ee Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 15 Oct 2024 19:04:02 +0800 Subject: [PATCH] =?utf8?q?AI=E8=AF=AD=E9=9F=B3=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?utf8?q?=E4=B8=A4=E7=A7=8D=E6=83=85=E5=86=B5=E5=88=A4=E6=96=AD=EF=BC=9A?= =?utf8?q?=20=E6=83=85=E5=86=B51=EF=BC=8C=E5=A6=82=E6=9E=9CAI=E5=BD=95?= =?utf8?q?=E9=9F=B3=E6=95=B0=E6=8D=AE=E9=87=8D=E4=BC=A0=E5=A4=9A=E6=AC=A1?= =?utf8?q?=E6=B2=A1=E6=88=90=E5=8A=9F=EF=BC=8C=E5=BC=B9=E7=AA=97=E8=BF=9B?= =?utf8?q?=E5=85=A5=E9=94=99=E8=AF=AF=E7=95=8C=E9=9D=A2=20=E6=83=85?= =?utf8?q?=E5=86=B52=EF=BC=8C=E5=A6=82=E6=9E=9CAI=E6=80=9D=E8=80=83?= =?utf8?q?=E4=B8=AD=EF=BC=8C=E6=89=8B=E6=9C=BA=E8=93=9D=E7=89=99=E6=96=AD?= =?utf8?q?=E5=BC=80=EF=BC=8C=E5=BC=B9=E7=AA=97=E8=BF=9B=E5=85=A5=E9=94=99?= =?utf8?q?=E8=AF=AF=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoiceModel.h | 3 ++- .../nativeui/aivoice/src/AiVoiceModel.cpp | 27 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h index d5b8ddec9..0ea15200c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-26 16:45:56 + * @LastEditTime: 2024-10-15 19:03:35 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h */ #ifndef AI_VOICE_MODEL_H @@ -33,6 +33,7 @@ namespace OHOS AI_RESPONSE_CONTENT, //AI回应内容 AI_RESPONSE_ERROR,//AI 回应错误 AI_RESPONSE_END,//AI 回应结束 + AI_BLE_ERROR,//蓝牙数据传入错误 }; static AiVoiceModel &GetInstance(void); // 获取单例实例 diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index 6230e2872..3f7f04716 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-28 10:30:19 + * @LastEditTime: 2024-10-15 19:02:09 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -26,6 +26,7 @@ #include "settings/include/SettingModel.h" #include #include +#include "bleService.h" namespace OHOS { // 声明定时器变量 @@ -173,7 +174,8 @@ namespace OHOS // 获取APP蓝牙是否已连接 bool AiVoiceModel::GetAPPBluetoothIsConnect(void) { - return SettingModel::GetInstance().GetPhoneConnectStatus(); + // return SettingModel::GetInstance().GetPhoneConnectStatus(); + return get_ble_connect(); } // 获取4G网络是否正常 @@ -514,8 +516,9 @@ namespace OHOS AIResponseType = type; errnote = str; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AIResponseType = %d,errnote = %s\n", AIResponseType, errnote.c_str()); - //如果是:AI录音解析错误或AI 回应错误 ->跳转AI回应错误界面 - if (AIResponseType == AiVoiceModel::AI_RECORDING_PARSING_ERROR || AIResponseType == AiVoiceModel::AI_RESPONSE_ERROR) + //如果是:AI录音解析错误或AI 回应错误 ,或者重传多次录音数据->跳转AI回应错误界面 + if (AIResponseType == AiVoiceModel::AI_RECORDING_PARSING_ERROR || AIResponseType == AiVoiceModel::AI_RESPONSE_ERROR + || AIResponseType == AiVoiceModel::AI_BLE_ERROR) { SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)errnote.c_str(), errnote.length()); return; @@ -663,7 +666,7 @@ namespace OHOS /*定时器到期时的处理*/ static void AIVoice_TimerCallbackProc(int data) { - if (!AiVoiceModel::GetInstance().GetAiVoiceConnectStatus()) + if (!AiVoiceModel::GetInstance().GetAiVoiceConnectStatus()) // 查询AI模型是否可用的定时器 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,AiModelConnectTimeout = %d", AiModelConnectTimeout); AiModelConnectTimeout--; @@ -682,7 +685,7 @@ namespace OHOS } } } - else + else // 等待AI思考完成的定时器 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,Time = %d", Time); Time -= 1; @@ -699,6 +702,18 @@ namespace OHOS std::string str = AiVoiceModel::GetInstance().GetErrnote(); SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); } + else + { + //4g中途断连待扩展 + + //蓝牙的连接状态判断,如果AI思考过程中途断连,直接弹窗提示,不在硬等 + if(get_ble_connect() == false) + { + AiVoiceModel::GetInstance().SetErrnote("ble is disconnected"); + std::string str = AiVoiceModel::GetInstance().GetErrnote(); + SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + } + } } return; } -- 2.17.1