From f863a55aaba952e9ef5f42310a283330fefb6259 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Wed, 31 Jul 2024 16:47:08 +0800 Subject: [PATCH] =?utf8?q?=E5=AF=B9=E6=8E=A5=E6=96=B0=E7=9A=84AI=E5=8D=8F?= =?utf8?q?=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../service/ble_service/blemoder/bletest.cpp | 6 +++ .../service/ble_service/blemoder/bletest.h | 2 + .../service/ble_service/bleservice/bleEvent.c | 44 +++++++++++++++++-- .../service/ble_service/bleservice/bleEvent.h | 3 ++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 9edf53c47..30ad832b6 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -75,6 +75,12 @@ extern "C" { #include #include +//在此处实现,给UI回复消息。 +void ble_app_reply(bool data) +{ + +} + void ble_connect_ok(void) { diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index fb3f477f9..50ee072f7 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -265,6 +265,8 @@ void ble_set_ai_Answer_str(char *buf); char* ble_get_ai_audio_path_str(void); +void ble_app_reply(bool data); + /////////////////////////////MP3相关///////////////////////// typedef struct Tag_Trailer 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 34b67215f..6f20f3cca 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -471,9 +471,22 @@ void send_AI_is_ready(uint8_t type) printf("发送AI准备就绪\r\n"); send_big_data(0, (char *)&type, 1, 1, 1, 1, 0x05, 5); - +} +//查询AI 模型是否可用,结果通过2AE4返回 +/*使用模型: +0:文心一言 +1:ChatGPT +2:KIMI +3:豆包*/ +void inquire_AI_is_ready(uint8_t type) +{ + + printf("查询AI模型,是否准备就绪\r\n"); + send_big_data(0, (char *)&type, 1, 1, 1, 1, 0x06, 5); } + + //发送ble数据 uint8_t phone_mac[6];//手机下发的mac地址 第一次连接为空 uint8_t parie_mac[6];//配对完成之后的的mac地址 @@ -2230,6 +2243,23 @@ void SetAiResultCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u } } +void APP_reply_AI_is_ready(uint8_t *data,uint16_t len) +{ + if(data[0]) + { + if(len>1) + { + //更新chatgptKEY + FILE *fp= fopen("/user/userdata/chatGPTkey.bin","wb+"); + if(fp) + { + fwrite(data+1,1,len-1,fp); + fclose(fp); + } + } + } + ble_app_reply(data[0]); +} void SaveChatGPTCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue) { uint32_t tmp = 1; @@ -2244,6 +2274,7 @@ void SaveChatGPTCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u memcpy(sendBuf+11,&tmp,4); memcpy(sendBuf+15,&tmp_data,2); // printf("GetWeatherCmd:len:%d data:%s\r\n",len,data); + //"sk-proj-04ogvrZQqyaiv1OWw8OZT3BlbkFJG9Gyr8oFvRdmr3oXQNbX" if(Check_CRC(data,len,crcvalue)) { @@ -2258,7 +2289,6 @@ void SaveChatGPTCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u { sendBuf[17] = 2; } - sendBuf[18] = Calculate_CRC(sendBuf,18); sendBleData(sendBuf,19); } @@ -2556,7 +2586,10 @@ void type2AE4Data(ble_read_data *buffer_handle,uint8_t *buf_cmd,uint8_t *data,ui GetGPSCmd(typeID,data,datalen,totalData,crcvalue); break; case APP_SEND_CHATGPT_KEY_CMD: - + SaveChatGPTCmd(typeID,data,datalen,totalData,crcvalue); + break; + case APP_SEND_AI_KEY_IS_AVAILABLE_CMD: + APP_reply_AI_is_ready(data,datalen); break; default: @@ -3418,7 +3451,10 @@ static void GetWatchStatusCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *t memcpy(value+15,&tmp_data,2); //0空闲状态 9 usb状态 10 运动训练状态 - uint8_t watchStatus = 0; + uint8_t watchStatus = 0; + if(uapi_dev_runtime_get_train_status()) + watchStatus=10; + value[17] = 0; value[18] = Calculate_CRC(value,18); sendBleData(value,19); 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 3fc50357c..0c7316518 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -627,6 +627,7 @@ TYPE:02 #define SYN_BASIC_REAL_HEATR_CMD 0x024B //同步基础训练试试心率记录 #define APP_SEND_CHATGPT_KEY_CMD 0x0223 //APP发送chatGPT key #define SYN_TODAY_BASIC_TRAIN_TXT_CMD 0x024D //同步当天任意时间之后的基础训练记录 +#define APP_SEND_AI_KEY_IS_AVAILABLE_CMD 0x0601 //查询AI是否可用,APP 回复 #define SYN_APP_GET_GPS_DATA_CMD 0x024F //同步gps信息 @@ -792,6 +793,8 @@ void CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(void* data); void send_AI_is_ready(uint8_t type); +void inquire_AI_is_ready(uint8_t type); + void GetCurDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue); bool get_ctkd_flag(void); -- 2.17.1