Skip to content

Commit f5d5814

Browse files
Component/bt: fix service change event params error
1 parent da27816 commit f5d5814

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

components/bt/bluedroid/bta/gatt/bta_gattc_act.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,10 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
18371837
}
18381838
/* notify applicationf or service change */
18391839
if (p_clrcb->p_cback != NULL) {
1840-
(* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)p_srcb->server_bda);
1840+
tBTA_GATTC_SERVICE_CHANGE srvc_chg= {0};
1841+
memcpy(srvc_chg.remote_bda, p_srcb->server_bda, sizeof(BD_ADDR));
1842+
srvc_chg.conn_id = conn_id;
1843+
(* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)&srvc_chg);
18411844
}
18421845

18431846
}

components/bt/bluedroid/bta/include/bta_gatt_api.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -387,27 +387,30 @@ typedef struct {
387387
BD_ADDR remote_bda;
388388
} tBTA_GATTC_DISCONNECT;
389389

390-
390+
typedef struct {
391+
UINT16 conn_id;
392+
BD_ADDR remote_bda;
393+
} tBTA_GATTC_SERVICE_CHANGE;
391394

392395
typedef union {
393396
tBTA_GATT_STATUS status;
394397

395-
tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */
396-
tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */
397-
tBTA_GATTC_REG reg_oper; /* registration data */
398+
tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */
399+
tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */
400+
tBTA_GATTC_REG reg_oper; /* registration data */
398401
tBTA_GATTC_OPEN open;
399402
tBTA_GATTC_CONNECT connect;
400403
tBTA_GATTC_CLOSE close;
401404
tBTA_GATTC_DISCONNECT disconnect;
402-
tBTA_GATTC_READ read; /* read attribute/descriptor data */
403-
tBTA_GATTC_WRITE write; /* write complete data */
404-
tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */
405-
tBTA_GATTC_NOTIFY notify; /* notification/indication event data */
405+
tBTA_GATTC_READ read; /* read attribute/descriptor data */
406+
tBTA_GATTC_WRITE write; /* write complete data */
407+
tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */
408+
tBTA_GATTC_NOTIFY notify; /* notification/indication event data */
406409
tBTA_GATTC_ENC_CMPL_CB enc_cmpl;
407-
BD_ADDR remote_bda; /* service change event */
408410
tBTA_GATTC_CFG_MTU cfg_mtu; /* configure MTU operation */
409411
tBTA_GATTC_CONGEST congest;
410412
tBTA_GATTC_QUEUE_FULL queue_full;
413+
tBTA_GATTC_SERVICE_CHANGE srvc_chg; /* service change event */
411414
} tBTA_GATTC;
412415

413416
/* GATTC enable callback function */

components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,10 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
913913
break;
914914
}
915915
case BTA_GATTC_SRVC_CHG_EVT: {
916-
memcpy(param.srvc_chg.remote_bda, arg->remote_bda, sizeof(esp_bd_addr_t));
917-
btc_gattc_cb_to_app(ESP_GATTC_SRVC_CHG_EVT, ESP_GATT_IF_NONE, &param);
916+
tBTA_GATTC_SERVICE_CHANGE *srvc_change = &arg->srvc_chg;
917+
gattc_if = BTC_GATT_GET_GATT_IF(srvc_change->conn_id);
918+
memcpy(param.srvc_chg.remote_bda, srvc_change->remote_bda, sizeof(esp_bd_addr_t));
919+
btc_gattc_cb_to_app(ESP_GATTC_SRVC_CHG_EVT, gattc_if, &param);
918920
break;
919921
}
920922
case BTA_GATTC_QUEUE_FULL_EVT: {

0 commit comments

Comments
 (0)