From 6fb303e0bbc1ca275951d2ef382d7c964c11154c Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Thu, 6 Mar 2025 12:25:58 +0800 Subject: [PATCH] =?utf8?q?AI=E7=BB=84=E5=90=88=E6=95=B0=E6=8D=AE=E5=8C=85?= =?utf8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../ble_service/bleservice/bleService.c | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 012e13640..b8e760e5b 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -2351,6 +2351,7 @@ static void blesrvAi_send_service_task(void const *arg) fwrite(fp,1,mail.msg_len,mail.msg_data); #endif // if(get_ble_connect()) + if(mail.msg_data && mail.msg_len!=0) send_Ai_record(mail.msg_len,mail.msg_data); if(mail.msg_data) @@ -2457,23 +2458,27 @@ int send_msg_data_into_Ai_msg_queue(void *buff,uint16_t len,uint8_t type) blesrv_custom_cmd_t blesrv_mail_end={0}; - blesrv_mail_end.msg_len=g_blesrv_mail.msg_len; - blesrv_mail_end.msg_data=malloc(g_blesrv_mail.msg_len); - if(blesrv_mail_end.msg_data==NULL) + if(g_blesrv_mail.msg_len!=0 && g_blesrv_mail.msg_data!=NULL) { - return ERRCODE_FAIL; - } + blesrv_mail_end.msg_len=g_blesrv_mail.msg_len; + blesrv_mail_end.msg_data=malloc(g_blesrv_mail.msg_len); + if(blesrv_mail_end.msg_data==NULL) + { + return ERRCODE_FAIL; + } - memcpy_s( blesrv_mail_end.msg_data,singlebuflen,g_blesrv_mail.msg_data,g_blesrv_mail.msg_len); - free(g_blesrv_mail.msg_data); - g_blesrv_mail.msg_data=NULL; - g_blesrv_mail.msg_len=0; + memcpy_s( blesrv_mail_end.msg_data,singlebuflen,g_blesrv_mail.msg_data,g_blesrv_mail.msg_len); + free(g_blesrv_mail.msg_data); + g_blesrv_mail.msg_data=NULL; + g_blesrv_mail.msg_len=0; - ret = osal_msg_queue_write_copy(g_ble_Ai_record_queue, (void *)&blesrv_mail_end, sendlen , 0); - if (ret != OSAL_SUCCESS) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"len<=singlebuflen Error blesrv Check send failed! err=0x%X %d! \r\n", ret,send_msg_data_into_Ai_msg_queue_count); + ret = osal_msg_queue_write_copy(g_ble_Ai_record_queue, (void *)&blesrv_mail_end, sendlen , 0); + if (ret != OSAL_SUCCESS) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"len<=singlebuflen Error blesrv Check send failed! err=0x%X %d! \r\n", ret,send_msg_data_into_Ai_msg_queue_count); + } } + blesrv_mail.service_handle = 0; blesrv_mail.msg_len = len; @@ -2554,9 +2559,13 @@ int send_msg_data_into_Ai_msg_queue(void *buff,uint16_t len,uint8_t type) { return ERRCODE_FAIL; } - memcpy_s( blesrv_mail.msg_data,singlebuflen,g_blesrv_mail.msg_data,g_blesrv_mail.msg_len); - free(g_blesrv_mail.msg_data); + if(g_blesrv_mail.msg_len!=0 && g_blesrv_mail.msg_data!=NULL) + { + memcpy_s( blesrv_mail.msg_data,singlebuflen,g_blesrv_mail.msg_data,g_blesrv_mail.msg_len); + free(g_blesrv_mail.msg_data); + } + g_blesrv_mail.msg_len=len; g_blesrv_mail.msg_data=malloc(len); memcpy_s( blesrv_mail.msg_data,singlebuflen,buff,len); -- 2.17.1