ancs修改
authorhcj <1224667075@qq.com>
Sat, 30 Aug 2025 10:09:12 +0000 (18:09 +0800)
committerhcj <1224667075@qq.com>
Sat, 30 Aug 2025 10:09:12 +0000 (18:09 +0800)
code/sdk/zhihui/services/ble_service/bleservice/bleANCS.c

index 830ccfe..9e8d0d4 100644 (file)
@@ -235,7 +235,7 @@ static uint8_t ble_ancs_client_at_cmd_get_notify_att(uint16_t conn_id,uint32_t n
 {
    
     /* 获取来电通知属性 */
-    ble_ancs_notification_attr_req_t *notify_attr_req = bt_os_new(
+    ble_ancs_notification_attr_req_t *notify_attr_req = bts_sample_mem_new(
         sizeof(ble_ancs_notification_attr_req_t) + (5 * sizeof(ble_ancs_attr_req_t)));
     notify_attr_req->att_num = 5;
     notify_attr_req->notification_uid = notify_uid;
@@ -257,7 +257,7 @@ static uint8_t ble_ancs_client_at_cmd_get_notify_att(uint16_t conn_id,uint32_t n
 
     //decode_att_req_from_str(argv[BT_INDEX_4], notify_attr_req->attr);
     errcode_t ret = ble_ancs_client_send_get_notify_att_cmd(g_client_id, conn_id, notify_attr_req);
-    bt_os_free(notify_attr_req);
+    bts_sample_mem_free(notify_attr_req);
     printf("ble ancs client notify att get ret:0x%x\r\n", ret);
     return 0;
 }
@@ -356,49 +356,53 @@ static void ble_ancs_client_notification_attr_rsp_cbk(uint8_t client_id, uint16_
         }  
 
         printf("[ANCSClientNotifyATTRSPCBK]conn_id:%d status:0x%x notify_uid:%lu\r\n",  
-            conn_id, status, notify_attr_rsp->notification_uid);  
+        conn_id, status, notify_attr_rsp->notification_uid);  
 
-        ble_ancs_attr_rsp_t *node = NULL ;//(ble_ancs_attr_rsp_t *)notify_attr_rsp->attr_rsp_lst.head;  
+        struct osal_list_head *list_head = &(notify_attr_rsp->attr_rsp_lst);
+        struct osal_list_head *node = list_head->next;
+
+        // ble_ancs_attr_rsp_t *node = (ble_ancs_attr_rsp_t *)notify_attr_rsp->attr_rsp_lst.head;  
         uint16_t att_num = 0;  
         time_t timestamp = 0;  
 
-        while (node != NULL) {  
-            if (node->att != NULL) {  
+        while (node != NULL && node != list_head) {  
+            ble_ancs_attr_rsp_t *attr_node = (ble_ancs_attr_rsp_t *)node;
+            if (attr_node->att != NULL) {  
                 printf("[ANCSClientNotifyATTRSPCBK]att id:%d length:%lu att_value:%s\r\n",  
-                    node->att_id, node->att_length, node->att);  
+                    attr_node->att_id, attr_node->att_length, attr_node->att);  
 
-                size_t att_length = strlen((char*)node->att);  
-                if (node->att_id == 1) {  
+                size_t att_length = strlen((char*)attr_node->att);  
+                if (attr_node->att_id == 1) {  
                     memset_s(title_buf, 300, 0, 300);  
                     if (att_length < 300) {  
-                        memcpy_s(title_buf, 300, node->att, att_length);  
+                        memcpy_s(title_buf, 300, attr_node->att, att_length);  
                     } else {  
-                        printf("标题缓冲区溢出: %s\r\n", node->att);  
+                        printf("标题缓冲区溢出: %s\r\n", attr_node->att);  
                     }  
-                } else if (node->att_id == 3) {  
+                } else if (attr_node->att_id == 3) {  
                     memset_s(msg_buf, 300, 0,300);  
                     if (att_length < 300) {  
-                        memcpy_s(msg_buf, 300, node->att, att_length);  
+                        memcpy_s(msg_buf, 300, attr_node->att, att_length);  
                     } else {  
-                        printf("消息缓冲区溢出: %s\r\n", node->att);  
+                        printf("消息缓冲区溢出: %s\r\n", attr_node->att);  
                     }  
-                } else if (node->att_id == 0) {  
+                } else if (attr_node->att_id == 0) {  
                     memset_s(app_buf, 70, 0, 70);  
                     if (att_length < 70) {  
-                        memcpy_s(app_buf,70, node->att, att_length);  
+                        memcpy_s(app_buf,70, attr_node->att, att_length);  
                     } else {  
-                        printf("应用缓冲区溢出: %s\r\n", node->att);  
+                        printf("应用缓冲区溢出: %s\r\n", attr_node->att);  
                     }  
-                } else if (node->att_id == 5) {  
+                } else if (attr_node->att_id == 5) {  
                     struct tm tm = {0};  
-                    if (strptime((const char *)node->att, "%Y%m%dT%H%M%S", &tm) != NULL) {  
+                    if (strptime((const char *)attr_node->att, "%Y%m%dT%H%M%S", &tm) != NULL) {  
                         timestamp = mktime(&tm);  
                     } else {  
-                        printf("时间字符串解析失败: %s\r\n", node->att);  
+                        printf("时间字符串解析失败: %s\r\n", attr_node->att);  
                     }  
                 }  
             }  
-            node = lnext(node);  
+            node = node->next;
             att_num++;  
             if (att_num >= notify_attr_rsp->att_num) {  
                 break;