Merge branch 'bugfix/fix_send_delete_link_key_cmd_1_v5.1' into 'release/v5.1'

Bugfix/fix send delete link key cmd 1 (v5.1)

See merge request espressif/esp-idf!39442
This commit is contained in:
Island
2025-05-29 11:17:48 +08:00
9 changed files with 22 additions and 7 deletions

View File

@@ -154,9 +154,9 @@ uint32_t btc_get_ble_status(void)
#if (SMP_INCLUDED == TRUE) #if (SMP_INCLUDED == TRUE)
// Number of recorded devices // Number of recorded devices
extern uint8_t btm_ble_sec_dev_active_count(void); extern uint8_t btm_ble_sec_dev_record_count(void);
if (btm_ble_sec_dev_active_count()) { if (btm_ble_sec_dev_record_count()) {
status |= BIT(BTC_BLE_STATUS_KEYS); status |= BIT(BTC_BLE_STATUS_DEVICE_REC);
} }
// Number of saved bonded devices // Number of saved bonded devices

View File

@@ -34,7 +34,7 @@ typedef enum {
BTC_BLE_STATUS_EXT_ADV, // Extended advertising exist BTC_BLE_STATUS_EXT_ADV, // Extended advertising exist
BTC_BLE_STATUS_SCAN, // Scanning exist BTC_BLE_STATUS_SCAN, // Scanning exist
BTC_BLE_STATUS_CONN, // Connection exist BTC_BLE_STATUS_CONN, // Connection exist
BTC_BLE_STATUS_KEYS, // Device keys record exist BTC_BLE_STATUS_DEVICE_REC, // Device record exist
BTC_BLE_STATUS_BOND, // Bond info exist BTC_BLE_STATUS_BOND, // Bond info exist
BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist
BTC_BLE_STATUS_GATTC_APP, // GATTC application exist BTC_BLE_STATUS_GATTC_APP, // GATTC application exist

View File

@@ -2941,7 +2941,7 @@ uint8_t btm_ble_scan_active_count(void)
} }
#if (SMP_INCLUDED == TRUE) #if (SMP_INCLUDED == TRUE)
uint8_t btm_ble_sec_dev_active_count(void) uint8_t btm_ble_sec_dev_record_count(void)
{ {
tBTM_SEC_DEV_REC *p_dev_rec = NULL; tBTM_SEC_DEV_REC *p_dev_rec = NULL;
list_node_t *p_node = NULL; list_node_t *p_node = NULL;
@@ -2957,6 +2957,12 @@ uint8_t btm_ble_sec_dev_active_count(void)
return count; return count;
} }
void btm_ble_clear_sec_dev_record(void)
{
/* only used when connection is closed */
if(btm_cb.p_sec_dev_rec_list) list_clear(btm_cb.p_sec_dev_rec_list);
}
#endif #endif
#if (BLE_PRIVACY_SPT == TRUE) #if (BLE_PRIVACY_SPT == TRUE)

View File

@@ -186,8 +186,10 @@ BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr, tBT_TRANSPORT transport)
} }
if ((p_dev_rec = btm_find_dev(bd_addr)) != NULL) { if ((p_dev_rec = btm_find_dev(bd_addr)) != NULL) {
#if (CLASSIC_BT_INCLUDED == TRUE)
/* Tell controller to get rid of the link key, if it has one stored */ /* Tell controller to get rid of the link key, if it has one stored */
BTM_DeleteStoredLinkKey (p_dev_rec->bd_addr, NULL); BTM_DeleteStoredLinkKey (p_dev_rec->bd_addr, NULL);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
btm_sec_free_dev(p_dev_rec, transport); btm_sec_free_dev(p_dev_rec, transport);
} }

View File

@@ -952,6 +952,7 @@ tBTM_STATUS BTM_EnableTestMode(void)
} }
} }
#if (CLASSIC_BT_INCLUDED == TRUE)
/******************************************************************************* /*******************************************************************************
** **
** Function BTM_DeleteStoredLinkKey ** Function BTM_DeleteStoredLinkKey
@@ -1026,6 +1027,7 @@ void btm_delete_stored_link_key_complete (UINT8 *p)
} }
} }
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/******************************************************************************* /*******************************************************************************
** **
** Function btm_report_device_status ** Function btm_report_device_status

View File

@@ -1001,12 +1001,12 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
return (BTM_SUCCESS); return (BTM_SUCCESS);
} }
#if (CLASSIC_BT_INCLUDED == TRUE)
/* Tell controller to get rid of the link key if it has one stored */ /* Tell controller to get rid of the link key if it has one stored */
if ((BTM_DeleteStoredLinkKey (bd_addr, NULL)) != BTM_SUCCESS) { if ((BTM_DeleteStoredLinkKey (bd_addr, NULL)) != BTM_SUCCESS) {
return (BTM_NO_RESOURCES); return (BTM_NO_RESOURCES);
} }
#if (CLASSIC_BT_INCLUDED == TRUE)
/* Save the PIN code if we got a valid one */ /* Save the PIN code if we got a valid one */
if (p_pin && (pin_len <= PIN_CODE_LEN) && (pin_len != 0)) { if (p_pin && (pin_len <= PIN_CODE_LEN) && (pin_len != 0)) {
btm_cb.pin_code_len = pin_len; btm_cb.pin_code_len = pin_len;

View File

@@ -1146,7 +1146,9 @@ void btm_vsc_complete (UINT8 *p, UINT16 cc_opcode, UINT16 evt_len,
tBTM_CMPL_CB *p_vsc_cplt_cback); tBTM_CMPL_CB *p_vsc_cplt_cback);
void btm_inq_db_reset (void); void btm_inq_db_reset (void);
void btm_vendor_specific_evt (UINT8 *p, UINT8 evt_len); void btm_vendor_specific_evt (UINT8 *p, UINT8 evt_len);
#if (CLASSIC_BT_INCLUDED == TRUE)
void btm_delete_stored_link_key_complete (UINT8 *p); void btm_delete_stored_link_key_complete (UINT8 *p);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
void btm_report_device_status (tBTM_DEV_STATUS status); void btm_report_device_status (tBTM_DEV_STATUS status);
void btm_set_afh_channels_complete (UINT8 *p); void btm_set_afh_channels_complete (UINT8 *p);
void btm_ble_set_channels_complete (UINT8 *p); void btm_ble_set_channels_complete (UINT8 *p);

View File

@@ -960,10 +960,11 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
case HCI_SET_EVENT_FILTER: case HCI_SET_EVENT_FILTER:
btm_event_filter_complete (p); btm_event_filter_complete (p);
break; break;
#if (CLASSIC_BT_INCLUDED == TRUE)
case HCI_DELETE_STORED_LINK_KEY: case HCI_DELETE_STORED_LINK_KEY:
btm_delete_stored_link_key_complete (p); btm_delete_stored_link_key_complete (p);
break; break;
#endif // (CLASSIC_BT_INCLUDED == TRUE)
case HCI_READ_LOCAL_NAME: case HCI_READ_LOCAL_NAME:
btm_read_local_name_complete (p, evt_len); btm_read_local_name_complete (p, evt_len);

View File

@@ -3942,6 +3942,7 @@ tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat,
//extern //extern
UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport); UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport);
#if (CLASSIC_BT_INCLUDED == TRUE)
/******************************************************************************* /*******************************************************************************
** **
** Function BTM_DeleteStoredLinkKey ** Function BTM_DeleteStoredLinkKey
@@ -3957,6 +3958,7 @@ UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport);
*******************************************************************************/ *******************************************************************************/
//extern //extern
tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb); tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb);
#endif // (CLASSIC_BT_INCLUDED == TRUE)
/******************************************************************************* /*******************************************************************************
** **