From 7eaab849bf1cd76fbce1dadcdd0fd25116521672 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Thu, 29 Aug 2024 02:14:34 +0000 Subject: [PATCH] Merge #816 into sdk602patch0626 from refs/changes/816/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 胡传军 * refs/changes/816/head: (2 commits squashed) - 增加AI对话取消对话在蓝牙层级保护,避免出现误取消,以及未结束继续对话的情况 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/816 --- .../service/ble_service/bleservice/bleEvent.c | 48 +++++++++++++++---- .../service/ble_service/bleservice/bleEvent.h | 2 +- 2 files changed, 40 insertions(+), 10 deletions(-) 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); -- 2.17.1