AI语音,添加两种情况判断: 1192/3
authorluozheng <1732036298@qq.com>
Tue, 15 Oct 2024 11:04:02 +0000 (19:04 +0800)
committerluozheng <1732036298@qq.com>
Tue, 15 Oct 2024 11:04:02 +0000 (19:04 +0800)
情况1,如果AI录音数据重传多次没成功,弹窗进入错误界面
情况2,如果AI思考中,手机蓝牙断开,弹窗进入错误界面

code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp

index d5b8dde..0ea1520 100644 (file)
@@ -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); // 获取单例实例
index 6230e28..3f7f047 100644 (file)
@@ -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 <unistd.h>
 #include <sys/stat.h>
+#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;
     }