* @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
AI_RESPONSE_CONTENT, //AI回应内容
AI_RESPONSE_ERROR,//AI 回应错误
AI_RESPONSE_END,//AI 回应结束
+ AI_BLE_ERROR,//蓝牙数据传入错误
};
static AiVoiceModel &GetInstance(void); // 获取单例实例
* @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"
#include "settings/include/SettingModel.h"
#include <unistd.h>
#include <sys/stat.h>
+#include "bleService.h"
namespace OHOS
{
// 声明定时器变量
// 获取APP蓝牙是否已连接
bool AiVoiceModel::GetAPPBluetoothIsConnect(void)
{
- return SettingModel::GetInstance().GetPhoneConnectStatus();
+ // return SettingModel::GetInstance().GetPhoneConnectStatus();
+ return get_ble_connect();
}
// 获取4G网络是否正常
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;
/*定时器到期时的处理*/
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--;
}
}
}
- else
+ else // 等待AI思考完成的定时器
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,Time = %d", Time);
Time -= 1;
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;
}