From 78437f48ae9cb8493359abc1e15cb37a0c56942d Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Wed, 4 Jan 2023 11:20:56 +0800 Subject: [PATCH 1/4] update bt-lib for ESP32 fix ble disconnect due to channel map update instant passed --- components/bt/controller/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index d4a224c5d6..f18eabd48c 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit d4a224c5d682d6b5a76542c6918b6a59dd0b2f8c +Subproject commit f18eabd48cb91d779e56e985512bf210741aa700 From a13b89a043c01388f114c9578cb050a83da6c60f Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Wed, 1 Feb 2023 12:08:05 +0800 Subject: [PATCH 2/4] 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 48edd89aed..2e179671f5 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 @@ -204,6 +204,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 ae1a0245b8..1fb3a08141 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 @@ -191,6 +191,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 ce5dcbf439..819615f6bd 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -742,7 +742,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); } } @@ -1688,6 +1689,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: From 58851cd5cd4c2cb3ba500a5eaa2a0d71339cef6e Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Mon, 9 Jan 2023 18:58:24 +0800 Subject: [PATCH 3/4] bluedroid: support ble privacy by controller --- .../bt/host/bluedroid/stack/btm/btm_ble.c | 18 ++++++++++++++++- .../host/bluedroid/stack/btm/btm_ble_5_gap.c | 5 +++++ .../host/bluedroid/stack/btm/btm_ble_addr.c | 2 +- .../bt/host/bluedroid/stack/btm/btm_ble_gap.c | 20 ++++++++++++++++++- .../bluedroid/stack/btm/btm_ble_privacy.c | 15 ++++++++++++++ .../bt/host/bluedroid/stack/btm/btm_sec.c | 5 +++++ .../bluedroid/stack/btm/include/btm_ble_int.h | 1 + 7 files changed, 63 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble.c b/components/bt/host/bluedroid/stack/btm/btm_ble.c index 962a3ef961..ae41206795 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble.c @@ -40,6 +40,7 @@ //#define LOG_TAG "bt_btm_ble" //#include "osi/include/log.h" #if BLE_INCLUDED == TRUE +extern void BTM_UpdateAddrInfor(uint8_t addr_type, BD_ADDR bda); #if SMP_INCLUDED == TRUE // The temp variable to pass parameter between functions when in the connected event callback. static BOOLEAN temp_enhanced = FALSE; @@ -1987,6 +1988,17 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced) if (enhanced) { STREAM_TO_BDADDR (local_rpa, p); STREAM_TO_BDADDR (peer_rpa, p); +#if (CONTROLLER_RPA_LIST_ENABLE == TRUE) + BD_ADDR dummy_bda = {0}; + /* For controller generates RPA, if resolving list contains no matching entry, it use identity address. + * So we should update own addr type in Host */ + if (memcmp(local_rpa, dummy_bda, BD_ADDR_LEN)) { + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type |= (BLE_ADDR_TYPE_ID_BIT); + BTM_UpdateAddrInfor(btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type, local_rpa); + } else { + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type &= (~BLE_ADDR_TYPE_ID_BIT); + } +#endif } #if (BLE_PRIVACY_SPT == TRUE ) peer_addr_type = bda_type; @@ -2566,7 +2578,11 @@ static void btm_ble_process_irk(tSMP_ENC *p) memcpy(btm_cb.devcb.id_keys.irk, p->param_buf, BT_OCTET16_LEN); btm_notify_new_key(BTM_BLE_KEY_TYPE_ID); -#if BLE_PRIVACY_SPT == TRUE +#if (CONTROLLER_RPA_LIST_ENABLE == TRUE) + btm_ble_add_default_entry_to_resolving_list(); +#endif + +#if (BLE_PRIVACY_SPT == TRUE) && (CONTROLLER_RPA_LIST_ENABLE == FALSE) /* if privacy is enabled, new RPA should be calculated */ if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) { btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low); diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index 266fe8d5f5..36e1dc00e1 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -367,6 +367,8 @@ tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PAR } else { extend_adv_cb.inst[instance].legacy_pdu = false; } + +#if (CONTROLLER_RPA_LIST_ENABLE == FALSE) // if own_addr_type == BLE_ADDR_PUBLIC_ID or BLE_ADDR_RANDOM_ID, if((params->own_addr_type == BLE_ADDR_PUBLIC_ID || params->own_addr_type == BLE_ADDR_RANDOM_ID) && BTM_GetLocalResolvablePrivateAddr(rand_addr)) { params->own_addr_type = BLE_ADDR_RANDOM; @@ -376,6 +378,9 @@ tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PAR } else if (params->own_addr_type == BLE_ADDR_RANDOM_ID) { params->own_addr_type = BLE_ADDR_RANDOM; } +#else + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = params->own_addr_type; +#endif if ((err = btsnd_hcic_ble_set_ext_adv_params(instance, params->type, params->interval_min, params->interval_max, params->channel_map, params->own_addr_type, params->peer_addr_type, diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_addr.c b/components/bt/host/bluedroid/stack/btm/btm_ble_addr.c index 036377c4a5..d7ed2095cd 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_addr.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_addr.c @@ -591,7 +591,7 @@ void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr, BD_ADDR dummy_bda = {0}; if (p != NULL) { - if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) { + if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type >= BLE_ADDR_RANDOM) { p->conn_addr_type = BLE_ADDR_RANDOM; if (memcmp(local_rpa, dummy_bda, BD_ADDR_LEN)) { memcpy(p->conn_addr, local_rpa, BD_ADDR_LEN); diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index f8624b3f1b..9c7b52aa9e 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -893,8 +893,16 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK // Disable RPA function btsnd_hcic_ble_set_addr_resolution_enable(FALSE); } else { /* privacy is turned on*/ +#if (CONTROLLER_RPA_LIST_ENABLE == FALSE) /* always set host random address, used when privacy 1.1 or priavcy 1.2 is disabled */ btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low); +#else + /* Controller generates RPA, Host don't need to set random address */ + if (random_cb && random_cb->set_local_privacy_cback){ + (*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_SUCCESS); + random_cb->set_local_privacy_cback = NULL; + } +#endif if (BTM_BleMaxMultiAdvInstanceCount() > 0) { btm_ble_multi_adv_enb_privacy(privacy_mode); @@ -910,7 +918,7 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK } else { /* 4.1/4.0 controller */ p_cb->privacy_mode = BTM_PRIVACY_1_1; } - // Disable RPA function + // Enable RPA function btsnd_hcic_ble_set_addr_resolution_enable(TRUE); } @@ -990,6 +998,7 @@ void BTM_BleSetStaticAddr(BD_ADDR rand_addr) btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit |= BTM_BLE_GAP_ADDR_BIT_RANDOM; } +#if (CONTROLLER_RPA_LIST_ENABLE == FALSE) uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK *cb) { if(*own_bda_type == BLE_ADDR_RANDOM) { @@ -1056,6 +1065,13 @@ uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK * return BTM_SUCCESS; } +#else +uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK *cb) +{ + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = *own_bda_type; + return BTM_SUCCESS; +} +#endif /******************************************************************************* @@ -4238,8 +4254,10 @@ void btm_ble_timeout(TIMER_LIST_ENT *p_tle) case BTU_TTYPE_BLE_RANDOM_ADDR: if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) { if (NULL == (void *)(p_tle->param)) { +#if (CONTROLLER_RPA_LIST_ENABLE == FALSE) /* refresh the random addr */ btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low); +#endif } else { if (BTM_BleMaxMultiAdvInstanceCount() > 0) { btm_ble_multi_adv_configure_rpa((tBTM_BLE_MULTI_ADV_INST *)p_tle->param); diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c index 0624727e7d..5477be2b1c 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c @@ -1021,4 +1021,19 @@ void btm_ble_resolving_list_cleanup(void) } } + +void btm_ble_add_default_entry_to_resolving_list(void) +{ + /* + * Add local IRK entry with 00:00:00:00:00:00 address. This entry will + * be used to generate RPA for non-directed advertising if own_addr_type + * is set to rpa_pub since we use all-zero address as peer addres in + * such case. Peer IRK should be left all-zero since this is not for an + * actual peer. + */ + BD_ADDR peer_addr = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + BT_OCTET16 peer_irk = {0x0}; + + btsnd_hcic_ble_add_device_resolving_list (BLE_ADDR_PUBLIC, peer_addr, peer_irk, btm_cb.devcb.id_keys.irk); +} #endif diff --git a/components/bt/host/bluedroid/stack/btm/btm_sec.c b/components/bt/host/bluedroid/stack/btm/btm_sec.c index bd3b0854b3..e84d523b20 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/host/bluedroid/stack/btm/btm_sec.c @@ -240,6 +240,11 @@ BOOLEAN BTM_SecRegister(tBTM_APPL_INFO *p_cb_info) if (memcmp(btm_cb.devcb.id_keys.ir, &temp_value, sizeof(BT_OCTET16)) == 0) { btm_ble_reset_id(); } +#if (CONTROLLER_RPA_LIST_ENABLE == TRUE) + else { + btm_ble_add_default_entry_to_resolving_list(); + } +#endif } else { BTM_TRACE_WARNING("%s p_cb_info->p_le_callback == NULL\n", __func__); } diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h index 12d95f97f3..f7fdbd1bb5 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h @@ -497,6 +497,7 @@ BOOLEAN btm_ble_disable_resolving_list(UINT8 rl_mask, BOOLEAN to_resume); void btm_ble_enable_resolving_list_for_platform (UINT8 rl_mask); void btm_ble_resolving_list_init(UINT8 max_irk_list_sz); void btm_ble_resolving_list_cleanup(void); +void btm_ble_add_default_entry_to_resolving_list(void); #endif void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst); From e6862798aae1f237717b595dd8c56c3719c1ab18 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Mon, 9 Jan 2023 19:28:23 +0800 Subject: [PATCH 4/4] examples: fix ble address type of adv and scan params --- examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c | 2 +- .../ble/gatt_security_client/main/example_ble_sec_gattc_demo.c | 2 +- .../ble/gatt_security_server/main/example_ble_sec_gatts_demo.c | 2 +- examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c index 1e0c0aa243..adc4d9822d 100644 --- a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c @@ -99,7 +99,7 @@ static esp_ble_adv_params_t adv_params = { .adv_int_min = 0x100, .adv_int_max = 0x100, .adv_type = ADV_TYPE_IND, - .own_addr_type = BLE_ADDR_TYPE_RANDOM, + .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, .channel_map = ADV_CHNL_ALL, .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, }; diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c index 013a69dc3a..b7759224f5 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c @@ -55,7 +55,7 @@ static const char remote_device_name[] = "ESP_BLE_SECURITY"; static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, - .own_addr_type = BLE_ADDR_TYPE_RANDOM, + .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, .scan_interval = 0x50, .scan_window = 0x30, diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c index 5eeac671d7..29c1f7c5a6 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c @@ -71,7 +71,7 @@ static esp_ble_adv_params_t heart_rate_adv_params = { .adv_int_min = 0x100, .adv_int_max = 0x100, .adv_type = ADV_TYPE_IND, - .own_addr_type = BLE_ADDR_TYPE_RANDOM, + .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, .channel_map = ADV_CHNL_ALL, .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, }; diff --git a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c index 81bf399f78..560b3269de 100644 --- a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c +++ b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c @@ -103,7 +103,7 @@ static esp_ble_adv_params_t adv_params = { .adv_int_min = 0x060, .adv_int_max = 0x060, .adv_type = ADV_TYPE_IND, - .own_addr_type = BLE_ADDR_TYPE_RANDOM, + .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, .channel_map = ADV_CHNL_ALL, .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, };