Skip to content

Commit e6d6dee

Browse files
committed
Merge branch 'bugfix/btdm_fix_connect_fail_when_remote_addr_is_random' into 'master'
Component/bt: modify open API params See merge request idf/esp-idf!2116
2 parents 21099c1 + e626237 commit e6d6dee

File tree

31 files changed

+67
-45
lines changed

31 files changed

+67
-45
lines changed

components/bt/bluedroid/api/esp_gattc_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if)
6767
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
6868
}
6969

70-
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, bool is_direct)
70+
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct)
7171
{
7272
btc_msg_t msg;
7373
btc_ble_gattc_args_t arg;
@@ -79,6 +79,7 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, b
7979
msg.act = BTC_GATTC_ACT_OPEN;
8080
arg.open.gattc_if = gattc_if;
8181
memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
82+
arg.open.remote_addr_type = remote_addr_type;
8283
arg.open.is_direct = is_direct;
8384

8485
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);

components/bt/bluedroid/api/include/esp_gattc_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,15 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if);
283283
*
284284
* @param[in] gattc_if: Gatt client access interface.
285285
* @param[in] remote_bda: remote device bluetooth device address.
286+
* @param[in] remote_addr_type: remote device bluetooth device the address type.
286287
* @param[in] is_direct: direct connection or background auto connection
287288
*
288289
* @return
289290
* - ESP_OK: success
290291
* - other: failed
291292
*
292293
*/
293-
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, bool is_direct);
294+
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct);
294295

295296

296297
/**

components/bt/bluedroid/bta/dm/bta_dm_act.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5635,7 +5635,8 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr)
56355635
bta_sys_stop_timer(&bta_dm_search_cb.gatt_close_timer);
56365636
btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id);
56375637
} else {
5638-
BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, TRUE, BTA_GATT_TRANSPORT_LE);
5638+
//TODO need to add addr_type in future
5639+
BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE);
56395640
}
56405641
}
56415642
#endif /* #if (GATTC_INCLUDED == TRUE) */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
500500
found_app = gatt_find_specific_app_in_hold_link(p_tcb, p_clcb->p_rcb->client_if);
501501
}
502502
/* open/hold a connection */
503-
if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda,
503+
if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, p_data->api_conn.remote_addr_type,
504504
TRUE, p_data->api_conn.transport)) {
505505
APPL_TRACE_ERROR("Connection open failure");
506506

@@ -536,7 +536,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
536536

537537
if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, TRUE, FALSE)) {
538538
/* always call open to hold a connection */
539-
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, FALSE, p_data->transport)) {
539+
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, p_data->remote_addr_type, FALSE, p_data->transport)) {
540540
uint8_t *bda = (uint8_t *)p_data->remote_bda;
541541
status = BTA_GATT_ERROR;
542542
APPL_TRACE_ERROR("%s unable to connect to remote bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,14 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
135135
**
136136
** Parameters client_if: server interface.
137137
** remote_bda: remote device BD address.
138+
** remote_addr_type: remote device BD address type.
138139
** is_direct: direct connection or background auto connection
139140
** transport: Transport to be used for GATT connection (BREDR/LE)
140141
**
141142
** Returns void
142143
**
143144
*******************************************************************************/
144-
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
145+
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
145146
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport)
146147
{
147148
tBTA_GATTC_API_OPEN *p_buf;
@@ -152,6 +153,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
152153
p_buf->client_if = client_if;
153154
p_buf->is_direct = is_direct;
154155
p_buf->transport = transport;
156+
p_buf->remote_addr_type = remote_addr_type;
155157
memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
156158

157159

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
729729

730730
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL) {
731731
/* should always get the connection ID */
732-
if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda,
732+
if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda, BLE_ADDR_UNKNOWN_TYPE,
733733
p_msg->api_open.is_direct, p_msg->api_open.transport)) {
734734
status = BTA_GATT_OK;
735735

components/bt/bluedroid/bta/hh/bta_hh_le.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB *p_cb, BD_ADDR remote_bda)
334334
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index;
335335
p_cb->in_use = TRUE;
336336

337-
BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, TRUE, BTA_GATT_TRANSPORT_LE);
337+
BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE);
338338
}
339339

340340
/*******************************************************************************
@@ -2600,7 +2600,7 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond)
26002600
if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/
26012601
!p_cb->in_bg_conn && to_add) {
26022602
/* add device into BG connection to accept remote initiated connection */
2603-
BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, FALSE, BTA_GATT_TRANSPORT_LE);
2603+
BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE);
26042604
p_cb->in_bg_conn = TRUE;
26052605

26062606
BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL);

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ typedef UINT8 tBTA_GATTC_EVT;
188188

189189
typedef tGATT_IF tBTA_GATTC_IF;
190190

191+
typedef UINT8 tBTA_ADDR_TYPE;
192+
191193
typedef struct {
192194
UINT16 unit; /* as UUIUD defined by SIG */
193195
UINT16 descr; /* as UUID as defined by SIG */
@@ -740,13 +742,14 @@ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if);
740742
**
741743
** Parameters client_if: server interface.
742744
** remote_bda: remote device BD address.
745+
** remote_addr_type: remote device BD address type.
743746
** is_direct: direct connection or background auto connection
744747
**
745748
** Returns void
746749
**
747750
*******************************************************************************/
748-
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
749-
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport);
751+
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
752+
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport);
750753

751754
/*******************************************************************************
752755
**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;
116116
typedef struct {
117117
BT_HDR hdr;
118118
BD_ADDR remote_bda;
119+
tBTA_ADDR_TYPE remote_addr_type;
119120
tBTA_GATTC_IF client_if;
120121
BOOLEAN is_direct;
121122
tBTA_TRANSPORT transport;

components/bt/bluedroid/bta/jv/bta_jv_act.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2648,7 +2648,7 @@ void bta_jv_l2cap_connect_le(tBTA_JV_MSG *p_data)
26482648
id = t->id;
26492649
t->init_called = FALSE;
26502650

2651-
if (L2CA_ConnectFixedChnl(t->chan, t->remote_addr)) {
2651+
if (L2CA_ConnectFixedChnl(t->chan, t->remote_addr, BLE_ADDR_UNKNOWN_TYPE)) {
26522652

26532653
evt.l2c_cl_init.status = BTA_JV_SUCCESS;
26542654
evt.l2c_cl_init.handle = id;

0 commit comments

Comments
 (0)