From b4a88f0f993f732c71a57b4b970ae4b0dd4e91ba Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Fri, 12 Jul 2024 10:00:30 +0800 Subject: [PATCH] =?utf8?q?ANCS=E8=8E=B7=E5=8F=96=E6=9C=8D=E5=8A=A1?= =?utf8?q?=E4=BD=8D=E7=BD=AE=E6=94=B9=E5=8F=98=EF=BC=8C=E5=8F=8A=E6=B6=88?= =?utf8?q?=E6=81=AF=E5=A4=84=E7=90=86=E6=9C=BA=E5=88=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../service/ble_service/bleservice/bleANCS.c | 6 +-- .../service/ble_service/bleservice/bleEvent.c | 38 +++++++------------ .../service/ble_service/bleservice/bleEvent.h | 2 +- code/sdk/drivers/peripheral/utils/pdu.c | 3 +- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleANCS.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleANCS.c index d6f946845..0457b0c39 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleANCS.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleANCS.c @@ -162,7 +162,7 @@ static void ble_ancs_client_notify_source_cbk(uint8_t client_id, uint16_t conn_i uint32_t creationTime=0; int ret = uapi_get_timestampe_ss(&creationTime); //当前时间戳减去订阅通知时间戳3s以上的通知,才要求数据(过滤ios将所有未查看消息发过来) - if(creationTime!=subscribe_notify_creationTime) + if(creationTime-subscribe_notify_creationTime>3) ble_ancs_client_at_cmd_get_notify_att(conn_id, notify_src->notification_uid); // @@ -220,8 +220,8 @@ static void ble_ancs_client_notification_attr_rsp_cbk(uint8_t client_id, uint16_ // memset(old_time_buf,0,64); // memcpy_s(old_time_buf,64,new_msg_buf,64); // printf("ble_ancs_client_notification_attr_rsp_cbk test 2\r\n"); - ancs_msg_index = message_data(notify_attr_rsp->notification_uid,0,title_buf,msg_buf,0); - CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(ancs_msg_index); + message_data(notify_attr_rsp->notification_uid,0,title_buf,msg_buf,0); + //} 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 37e6f38e2..879b667db 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -5095,7 +5095,7 @@ char *get_message_dir_path(void)//获取信息的文件夹路径 return ANCS_DATA_CONFIG_DIR; } -void* message_data(int uid,int appid,char *title,char *msg,int hasCode) +void message_data(int uid,int appid,char *title,char *msg,int hasCode) { uint32_t timestampe = 0; @@ -5103,23 +5103,20 @@ void* message_data(int uid,int appid,char *title,char *msg,int hasCode) { timestampe = 0; } - ancs_data_info_t *data= (ancs_data_info_t *)malloc(sizeof(ancs_data_info_t)); - if(data==NULL) - return NULL; - memset_s(data,sizeof(ancs_data_info_t),0,sizeof(ancs_data_info_t)); + ancs_data_info_t data; + memset_s(&data,sizeof(ancs_data_info_t),0,sizeof(ancs_data_info_t)); - data->appid=appid; - memcpy_s(data->title,TITLE_BUF_LEN+1,title,strlen(title)); - memcpy_s(data->msg,MSG_BUF_LEN+1,msg,strlen(msg)); - data->uid=uid; - data->time=timestampe; - data->read=0; - data->hasCode=hasCode; + data.appid=appid; + memcpy_s(data.title,TITLE_BUF_LEN+1,title,strlen(title)); + memcpy_s(data.msg,MSG_BUF_LEN+1,msg,strlen(msg)); + data.uid=uid; + data.time=timestampe; + data.read=0; + data.hasCode=hasCode; - printf("messagedata make ok\r\n"); - return data; + CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(&data); + return ; - //read_message_data(); } int uft8_check(char *chinese_string,int length) { @@ -5152,7 +5149,6 @@ int uft8_check(char *chinese_string,int length) return i; } - void* ancs_msg_data =NULL; //安卓消息接收解析数据 //ANCS 2AE1 uint8_t jscheck_ancs(uint8_t *data) @@ -5233,7 +5229,7 @@ uint8_t jscheck_ancs(uint8_t *data) // } printf("send message\r\n"); - ancs_msg_data = message_data(uid_t,appid_t,titleBuf,msgBuf,hasCode_t); + message_data(uid_t,appid_t,titleBuf,msgBuf,hasCode_t); printf("send message ok\r\n"); if(titleBuf != NULL){ @@ -5268,8 +5264,6 @@ void ancsDataShowCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData, value[17] = 1; value[18] = Calculate_CRC(value,18); sendBleData(value,19); - if(ancs_msg_data) - CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(ancs_msg_data); }else{ value[17] = 0; value[18] = Calculate_CRC(value,18); @@ -5280,12 +5274,6 @@ void ancsDataShowCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData, void CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(void *data) { CustomEventPublish(TOPIC_EVENT_MESSAGE_UPDATA,(uint8_t*)data,sizeof(ancs_data_info_t)); - if(data) - { - free(data); - data=NULL; - } - } void type2AE1Data(uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue) 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 38fa11453..bd065d119 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -774,7 +774,7 @@ uint8_t get_crc_from_lrc(uint8_t lrcValue); uint8_t calculate_lrc_file(char *file_path); -void* message_data(int uid,int appid,char *title,char *msg,int hasCode); +void message_data(int uid,int appid,char *title,char *msg,int hasCode); void CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(void* data); diff --git a/code/sdk/drivers/peripheral/utils/pdu.c b/code/sdk/drivers/peripheral/utils/pdu.c index 3ffb327c5..6315b759d 100644 --- a/code/sdk/drivers/peripheral/utils/pdu.c +++ b/code/sdk/drivers/peripheral/utils/pdu.c @@ -323,8 +323,7 @@ int pdu_decode_example(const char *inpdustr ) timenow->tm_min, timenow->tm_sec); - void *data= message_data(0,0,phone_number,text,0); - CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(data); + message_data(0,0,phone_number,text,0); } return ret; -- 2.17.1