From 38b7938c902456c437198068947e23973d3afba9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Thu, 1 Aug 2024 02:26:24 +0000 Subject: [PATCH] Merge #622 into sdk602patch0626 from refs/changes/622/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 胡传军 * refs/changes/622/head: (6 commits squashed) - 先屏蔽MP3获取作者和时长保证APP可以正常显示 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 - 对接新的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/622 --- .../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 ++ .../fd230/fs/user/res/makephone/Ellipse 4.bin | 3 -- 5 files changed, 51 insertions(+), 7 deletions(-) delete mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/makephone/Ellipse 4.bin 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 414bf0c68..db2cccbec 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); diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/makephone/Ellipse 4.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/makephone/Ellipse 4.bin deleted file mode 100644 index 219c8d709..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/makephone/Ellipse 4.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:288c01fbc20c96cbf6adf3eaeff643eba6ffae7d500ae04e6d63e9c504c1d0c7 -size 40 -- 2.17.1