From 8790931bab7b69481cea356c278f830eb27ef86f Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Wed, 1 Feb 2023 12:08:05 +0800 Subject: [PATCH] bluedroid: add params in GATT connect event --- .../bt/host/bluedroid/api/include/api/esp_gattc_api.h | 2 ++ .../bt/host/bluedroid/api/include/api/esp_gatts_api.h | 2 ++ components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c | 8 +++++++- components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c | 5 ++++- components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c | 4 ++++ .../bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h | 5 ++++- .../bt/host/bluedroid/bta/include/bta/bta_gatt_api.h | 4 ++++ .../bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c | 2 ++ .../bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c | 2 ++ 9 files changed, 31 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h b/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h index 4071909634..22563a432c 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h @@ -212,6 +212,8 @@ typedef union { uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ esp_gatt_conn_params_t conn_params; /*!< current connection parameters */ + esp_ble_addr_type_t ble_addr_type; /*!< Remote BLE device address type */ + uint16_t conn_handle; /*!< HCI connection handle */ } connect; /*!< Gatt client callback param of ESP_GATTC_CONNECT_EVT */ /** diff --git a/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h b/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h index 9d3142331c..dc8534ab5d 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h @@ -199,6 +199,8 @@ typedef union { uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ esp_gatt_conn_params_t conn_params; /*!< current Connection parameters */ + esp_ble_addr_type_t ble_addr_type; /*!< Remote BLE device address type */ + uint16_t conn_handle; /*!< HCI connection handle */ } connect; /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */ /** diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c index cc882f61c2..98407cb181 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -738,7 +738,8 @@ void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data) if (p_rcb) { bta_gattc_send_connect_cback(p_rcb, p_data->int_conn.remote_bda, - p_data->int_conn.hdr.layer_specific, p_data->int_conn.conn_params, p_data->int_conn.role); + p_data->int_conn.hdr.layer_specific, p_data->int_conn.conn_params, p_data->int_conn.role, + p_data->int_conn.ble_addr_type, p_data->int_conn.conn_handle); } } @@ -1684,6 +1685,11 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id, p_buf->int_conn.conn_params.interval = p_lcb->current_used_conn_interval; p_buf->int_conn.conn_params.latency = p_lcb->current_used_conn_latency; p_buf->int_conn.conn_params.timeout = p_lcb->current_used_conn_timeout; + #if (BLE_INCLUDED == TRUE) + p_buf->int_conn.ble_addr_type = p_lcb->ble_addr_type; + #endif + p_buf->int_conn.conn_handle = p_lcb->handle; + } else { APPL_TRACE_WARNING("gattc_conn_cb: conn params not found"); } diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c index bdb712cb32..6959526c83 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c @@ -765,7 +765,8 @@ void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status ** Returns ** *******************************************************************************/ -void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id, tBTA_GATT_CONN_PARAMS conn_params, UINT8 link_role) +void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id, + tBTA_GATT_CONN_PARAMS conn_params, UINT8 link_role, UINT8 ble_addr_type, UINT16 conn_handle) { tBTA_GATTC cb_data; @@ -779,6 +780,8 @@ void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, cb_data.connect.conn_params.latency = conn_params.latency; cb_data.connect.conn_params.timeout = conn_params.timeout; bdcpy(cb_data.connect.remote_bda, remote_bda); + cb_data.connect.ble_addr_type = ble_addr_type; + cb_data.connect.conn_handle = conn_handle; (*p_clreg->p_cback)(BTA_GATTC_CONNECT_EVT, &cb_data); } diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c index adcb2830db..5320f66711 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c @@ -1003,6 +1003,10 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, cb_data.conn.conn_params.latency = p_lcb->current_used_conn_latency; cb_data.conn.conn_params.timeout = p_lcb->current_used_conn_timeout; cb_data.conn.link_role = p_lcb->link_role; + #if (BLE_INCLUDED == TRUE) + cb_data.conn.ble_addr_type = p_lcb->ble_addr_type; + #endif + cb_data.conn.conn_handle = p_lcb->handle; }else { APPL_TRACE_WARNING("%s not found connection parameters of the device ", __func__); } diff --git a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h index db1408ea4f..874315028c 100644 --- a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h +++ b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h @@ -223,6 +223,8 @@ typedef struct { tGATT_DISCONN_REASON reason; BOOLEAN already_connect; tBTA_GATT_CONN_PARAMS conn_params; + UINT8 ble_addr_type; + UINT16 conn_handle; } tBTA_GATTC_INT_CONN; typedef struct { @@ -474,7 +476,8 @@ extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB * extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data); extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status, BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport, UINT16 mtu); -extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id, tBTA_GATT_CONN_PARAMS conn_params, UINT8 link_role); +extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id, + tBTA_GATT_CONN_PARAMS conn_params, UINT8 link_role, UINT8 ble_addr_type, UINT16 conn_handle); extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tGATT_DISCONN_REASON reason, BD_ADDR remote_bda, UINT16 conn_id); extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h index 03e22ca20f..1739f19c0b 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h @@ -410,6 +410,8 @@ typedef struct { tBTA_GATTC_IF client_if; BD_ADDR remote_bda; tBTA_GATT_CONN_PARAMS conn_params; + UINT8 ble_addr_type; + UINT16 conn_handle; } tBTA_GATTC_CONNECT; typedef struct { @@ -621,6 +623,8 @@ typedef struct { tBTA_GATT_REASON reason; /* report disconnect reason */ tBTA_GATT_TRANSPORT transport; tBTA_GATT_CONN_PARAMS conn_params; + UINT8 ble_addr_type; + UINT16 conn_handle; } tBTA_GATTS_CONN; typedef struct { diff --git a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c index b6ac9a4584..731eae692e 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -914,6 +914,8 @@ void btc_gattc_cb_handler(btc_msg_t *msg) param.connect.conn_params.interval = connect->conn_params.interval; param.connect.conn_params.latency = connect->conn_params.latency; param.connect.conn_params.timeout = connect->conn_params.timeout; + param.connect.ble_addr_type = connect->ble_addr_type; + param.connect.conn_handle = connect->conn_handle; btc_gattc_cb_to_app(ESP_GATTC_CONNECT_EVT, gattc_if, ¶m); break; } diff --git a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c index 9c88081bb8..5badf5f45b 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c @@ -898,6 +898,8 @@ void btc_gatts_cb_handler(btc_msg_t *msg) param.connect.conn_params.interval = p_data->conn.conn_params.interval; param.connect.conn_params.latency = p_data->conn.conn_params.latency; param.connect.conn_params.timeout = p_data->conn.conn_params.timeout; + param.connect.ble_addr_type = p_data->conn.ble_addr_type; + param.connect.conn_handle = p_data->conn.conn_handle; btc_gatts_cb_to_app(ESP_GATTS_CONNECT_EVT, gatts_if, ¶m); break; case BTA_GATTS_DISCONNECT_EVT: