From f5d581421ed4c99fe3c5633795ee9bc229d31596 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Thu, 29 Mar 2018 16:11:16 +0800 Subject: [PATCH] Component/bt: fix service change event params error --- .../bt/bluedroid/bta/gatt/bta_gattc_act.c | 5 ++++- .../bt/bluedroid/bta/include/bta_gatt_api.h | 21 +++++++++++-------- .../btc/profile/std/gatt/btc_gattc.c | 6 ++++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_act.c b/components/bt/bluedroid/bta/gatt/bta_gattc_act.c index c9189b20df..9a9f153870 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_act.c @@ -1837,7 +1837,10 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id, } /* notify applicationf or service change */ if (p_clrcb->p_cback != NULL) { - (* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)p_srcb->server_bda); + tBTA_GATTC_SERVICE_CHANGE srvc_chg= {0}; + memcpy(srvc_chg.remote_bda, p_srcb->server_bda, sizeof(BD_ADDR)); + srvc_chg.conn_id = conn_id; + (* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)&srvc_chg); } } diff --git a/components/bt/bluedroid/bta/include/bta_gatt_api.h b/components/bt/bluedroid/bta/include/bta_gatt_api.h index 95f6815216..4410cea58a 100644 --- a/components/bt/bluedroid/bta/include/bta_gatt_api.h +++ b/components/bt/bluedroid/bta/include/bta_gatt_api.h @@ -387,27 +387,30 @@ typedef struct { BD_ADDR remote_bda; } tBTA_GATTC_DISCONNECT; - +typedef struct { + UINT16 conn_id; + BD_ADDR remote_bda; +} tBTA_GATTC_SERVICE_CHANGE; typedef union { tBTA_GATT_STATUS status; - tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */ - tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */ - tBTA_GATTC_REG reg_oper; /* registration data */ + tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */ + tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */ + tBTA_GATTC_REG reg_oper; /* registration data */ tBTA_GATTC_OPEN open; tBTA_GATTC_CONNECT connect; tBTA_GATTC_CLOSE close; tBTA_GATTC_DISCONNECT disconnect; - tBTA_GATTC_READ read; /* read attribute/descriptor data */ - tBTA_GATTC_WRITE write; /* write complete data */ - tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */ - tBTA_GATTC_NOTIFY notify; /* notification/indication event data */ + tBTA_GATTC_READ read; /* read attribute/descriptor data */ + tBTA_GATTC_WRITE write; /* write complete data */ + tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */ + tBTA_GATTC_NOTIFY notify; /* notification/indication event data */ tBTA_GATTC_ENC_CMPL_CB enc_cmpl; - BD_ADDR remote_bda; /* service change event */ tBTA_GATTC_CFG_MTU cfg_mtu; /* configure MTU operation */ tBTA_GATTC_CONGEST congest; tBTA_GATTC_QUEUE_FULL queue_full; + tBTA_GATTC_SERVICE_CHANGE srvc_chg; /* service change event */ } tBTA_GATTC; /* GATTC enable callback function */ diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c index 3a66df1985..de22942679 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -913,8 +913,10 @@ void btc_gattc_cb_handler(btc_msg_t *msg) break; } case BTA_GATTC_SRVC_CHG_EVT: { - memcpy(param.srvc_chg.remote_bda, arg->remote_bda, sizeof(esp_bd_addr_t)); - btc_gattc_cb_to_app(ESP_GATTC_SRVC_CHG_EVT, ESP_GATT_IF_NONE, ¶m); + tBTA_GATTC_SERVICE_CHANGE *srvc_change = &arg->srvc_chg; + gattc_if = BTC_GATT_GET_GATT_IF(srvc_change->conn_id); + memcpy(param.srvc_chg.remote_bda, srvc_change->remote_bda, sizeof(esp_bd_addr_t)); + btc_gattc_cb_to_app(ESP_GATTC_SRVC_CHG_EVT, gattc_if, ¶m); break; } case BTA_GATTC_QUEUE_FULL_EVT: {