{
/* 获取来电通知属性 */
- 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;
//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;
}
}
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;