From 3efe85f324e5ee0a43d959c885c90bcfc4f62797 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Thu, 29 Aug 2024 10:11:25 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0AI=E5=AF=B9=E8=AF=9D=E5=8F=96?= =?utf8?q?=E6=B6=88=E5=AF=B9=E8=AF=9D=E5=9C=A8=E8=93=9D=E7=89=99=E5=B1=82?= =?utf8?q?=E7=BA=A7=E4=BF=9D=E6=8A=A4=EF=BC=8C=E9=81=BF=E5=85=8D=E5=87=BA?= =?utf8?q?=E7=8E=B0=E8=AF=AF=E5=8F=96=E6=B6=88=EF=BC=8C=E4=BB=A5=E5=8F=8A?= =?utf8?q?=E6=9C=AA=E7=BB=93=E6=9D=9F=E7=BB=A7=E7=BB=AD=E5=AF=B9=E8=AF=9D?= =?utf8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../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