From: hcj <1224667075@qq.com> Date: Thu, 29 Aug 2024 02:11:25 +0000 (+0800) Subject: 增加AI对话取消对话在蓝牙层级保护,避免出现误取消,以及未结束继续对话的情况 X-Git-Tag: release_V1.2.70_20241020_135402~550^2~2^2~12 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=3efe85f324e5ee0a43d959c885c90bcfc4f62797;p=mirrors%2FFD230.git 增加AI对话取消对话在蓝牙层级保护,避免出现误取消,以及未结束继续对话的情况 --- diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 36dd7ad5b..67178c082 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -467,18 +467,34 @@ void sendtraningdata(msg_get_train_data_info_t *data) cJSON_free(jsonString); } + +static uint8_t AI_is_end_state=0; //发送AI录音准备就绪国内/ /*使用模型: 0:文心一言 1:ChatGPT 2:KIMI 3:豆包*/ -void send_AI_is_ready(uint8_t type) +bool send_AI_is_ready(uint8_t type) { + + if(AI_is_end_state==0) + { + printf("发送AI准备就绪\r\n"); + ble_data_type type_={0x05,0x05,1,1,1}; + send_big_data(type_,(char *)&type,1); + AI_is_end_state=1; + return true; + + } + else + { + printf("发送AI准备就绪失败,没有正确回复结束\r\n"); + return false; + } - printf("发送AI准备就绪\r\n"); - ble_data_type type_={0x05,0x05,1,1,1}; - send_big_data(type_,(char *)&type,1); + + //send_big_data(0, (char *)&type, 1, 1, 1, 1, 0x05, 5); } @@ -499,11 +515,20 @@ void inquire_AI_is_ready(uint8_t type) void cancel_AI_cur_chat(void) { - - printf("取消当前AI对话\r\n"); - uint8_t data=1; - ble_data_type type_={0x05,0x07,data_len,1,1}; - send_big_data(type_,(char *)&data,data_len); + if(AI_is_end_state) + { + printf("取消当前AI对话\r\n"); + uint8_t data=1; + ble_data_type type_={0x05,0x07,data_len,1,1}; + send_big_data(type_,(char *)&data,data_len); + AI_is_end_state=0; + + } + else + { + printf("已经取消当前AI对话无需再次取消\r\n"); + } + //send_big_data(0, (char *)&data, 1, 1, 1, 1, 0x07, 5); } @@ -2351,6 +2376,11 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 if(buf[offset]==4) { + printf("AI 结束\r\n"); + if(AI_is_end_state) + { + AI_is_end_state=0; + } offset++; if(offset>=len) { diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index 16a251459..c6220ebea 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -806,7 +806,7 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode); void CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(void* data); -void send_AI_is_ready(uint8_t type); +bool send_AI_is_ready(uint8_t type); void inquire_AI_is_ready(uint8_t type);