mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 20:54:32 +02:00
Merge branch 'bugfix/fix_find_the_oldest_device_v5.1' into 'release/v5.1'
Bugfix/fix find the oldest device (v5.1) See merge request espressif/esp-idf!40834
This commit is contained in:
@@ -2409,8 +2409,7 @@ tBTM_STATUS btm_remove_acl (BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
||||
} else /* otherwise can disconnect right away */
|
||||
#endif
|
||||
{
|
||||
if (hci_handle != 0xFFFF && p_dev_rec &&
|
||||
p_dev_rec->sec_state != BTM_SEC_STATE_DISCONNECTING) {
|
||||
if (hci_handle != 0xFFFF && (( p_dev_rec && p_dev_rec->sec_state != BTM_SEC_STATE_DISCONNECTING) || (!p_dev_rec))) {
|
||||
if (!btsnd_hcic_disconnect (hci_handle, HCI_ERR_PEER_USER)) {
|
||||
status = BTM_NO_RESOURCES;
|
||||
}
|
||||
|
@@ -50,6 +50,9 @@
|
||||
#define BTM_BLE_META_READ_IRK_LEN 2
|
||||
#define BTM_BLE_META_ADD_WL_ATTR_LEN 9
|
||||
|
||||
#if CONTROLLER_RPA_LIST_ENABLE && BLE_SMP_ID_RESET_ENABLE
|
||||
static bool is_deleting_zero_addr;
|
||||
#endif // CONTROLLER_RPA_LIST_ENABLE && BLE_SMP_ID_RESET_ENABLE
|
||||
/*******************************************************************************
|
||||
** Functions implemented controller based privacy using Resolving List
|
||||
*******************************************************************************/
|
||||
@@ -343,8 +346,21 @@ void btm_ble_remove_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len)
|
||||
btm_cb.ble_ctr_cb.resolving_list_avail_size++;
|
||||
}
|
||||
} else {
|
||||
BTM_TRACE_ERROR("%s remove resolving list error 0x%x", __func__, status);
|
||||
#if CONTROLLER_RPA_LIST_ENABLE && BLE_SMP_ID_RESET_ENABLE
|
||||
if (!is_deleting_zero_addr)
|
||||
#endif // CONTROLLER_RPA_LIST_ENABLE && BLE_SMP_ID_RESET_ENABLE
|
||||
{
|
||||
/* It's expected for some controllers to return error when deleting {0,0,0,0,0,0}, ignore that case */
|
||||
BTM_TRACE_ERROR("%s remove resolving list error, status = 0x%02x", __func__, status);
|
||||
}
|
||||
}
|
||||
|
||||
#if CONTROLLER_RPA_LIST_ENABLE && BLE_SMP_ID_RESET_ENABLE
|
||||
/* Clear zero address deletion flag regardless of outcome */
|
||||
if (is_deleting_zero_addr) {
|
||||
is_deleting_zero_addr = false;
|
||||
}
|
||||
#endif // CONTROLLER_RPA_LIST_ENABLE && BLE_SMP_ID_RESET_ENABLE
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1135,6 +1151,7 @@ void btm_ble_resolving_list_cleanup(void)
|
||||
|
||||
}
|
||||
|
||||
#if (CONTROLLER_RPA_LIST_ENABLE == TRUE)
|
||||
void btm_ble_add_default_entry_to_resolving_list(void)
|
||||
{
|
||||
/*
|
||||
@@ -1147,9 +1164,17 @@ void btm_ble_add_default_entry_to_resolving_list(void)
|
||||
BD_ADDR peer_addr = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
||||
BT_OCTET16 peer_irk = {0x0};
|
||||
|
||||
#if (BLE_SMP_ID_RESET_ENABLE == TRUE)
|
||||
// Remove the existing entry in resolving list When resetting the device identity
|
||||
btsnd_hcic_ble_rm_device_resolving_list(BLE_ADDR_PUBLIC, peer_addr);
|
||||
|
||||
is_deleting_zero_addr = true;
|
||||
|
||||
btm_ble_enq_resolving_list_pending(peer_addr, BTM_BLE_META_REMOVE_IRK_ENTRY);
|
||||
#endif // (BLE_SMP_ID_RESET_ENABLE == TRUE)
|
||||
btsnd_hcic_ble_add_device_resolving_list (BLE_ADDR_PUBLIC, peer_addr, peer_irk, btm_cb.devcb.id_keys.irk);
|
||||
|
||||
btm_ble_enq_resolving_list_pending(peer_addr, BTM_BLE_META_ADD_IRK_ENTRY);
|
||||
}
|
||||
#endif // (CONTROLLER_RPA_LIST_ENABLE == TRUE)
|
||||
#endif
|
||||
|
@@ -367,6 +367,12 @@ tBTM_SEC_DEV_REC *btm_sec_alloc_dev (BD_ADDR bd_addr)
|
||||
}
|
||||
if (!new_entry_found) {
|
||||
p_dev_rec = btm_find_oldest_dev();
|
||||
#if (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE)
|
||||
// If device record exists and contains identity key, remove it from resolving list
|
||||
if (p_dev_rec && (p_dev_rec->ble.key_type & SMP_SEC_KEY_TYPE_ID)) {
|
||||
btm_ble_resolving_list_remove_dev(p_dev_rec);
|
||||
}
|
||||
#endif // (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE)
|
||||
} else {
|
||||
/* if the old device entry not present go with new entry */
|
||||
if (old_entry_found) {
|
||||
@@ -674,6 +680,7 @@ tBTM_SEC_DEV_REC *btm_find_oldest_dev (void)
|
||||
|
||||
/* All devices are paired; find the oldest */
|
||||
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
|
||||
p_dev_rec = list_node(p_node);
|
||||
if ((p_dev_rec->sec_flags & BTM_SEC_IN_USE) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -342,7 +342,12 @@ BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 *p_sec_flags)
|
||||
*p_sec_flags = (UINT8) p_dev_rec->sec_flags;
|
||||
return (TRUE);
|
||||
}
|
||||
BTM_TRACE_ERROR ("BTM_GetSecurityFlags false");
|
||||
|
||||
BTM_TRACE_ERROR("%s: BTM_GetSecurityFlags failed for device [%02X:%02X:%02X:%02X:%02X:%02X]",
|
||||
__func__,
|
||||
bd_addr[0], bd_addr[1], bd_addr[2],
|
||||
bd_addr[3], bd_addr[4], bd_addr[5]);
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@@ -369,7 +374,12 @@ BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr, UINT8 *p_sec_flags,
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
BTM_TRACE_ERROR ("BTM_GetSecurityFlags false\n");
|
||||
|
||||
BTM_TRACE_ERROR("%s: BTM_GetSecurityFlags failed for device [%02X:%02X:%02X:%02X:%02X:%02X]",
|
||||
__func__,
|
||||
bd_addr[0], bd_addr[1], bd_addr[2],
|
||||
bd_addr[3], bd_addr[4], bd_addr[5]);
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user