Skip to content

Commit 2798c89

Browse files
committed
Merge branch 'bugfix/bug_ble_max_device_record_v5.4' into 'release/v5.4'
fix(ble/bluedroid): Fixed BLE incorrect device record count issue (v5.4) See merge request espressif/esp-idf!43596
2 parents 6d8a856 + 354e6c1 commit 2798c89

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

components/bt/host/bluedroid/btc/core/btc_ble_storage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#if (SMP_INCLUDED == TRUE)
1717

1818
//the maximum number of bonded devices
19-
#define BONED_DEVICES_MAX_COUNT (BTM_SEC_MAX_DEVICE_RECORDS)
19+
#define BONED_DEVICES_MAX_COUNT (BTM_SEC_MAX_BONDS)
2020

2121
static void _btc_storage_save(void)
2222
{

components/bt/host/bluedroid/btc/core/btc_storage.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -40,7 +40,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
4040
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
4141

4242
/* device not in bond list and exceed the maximum number of bonded devices, delete the inactive bonded device */
43-
if (btc_storage_get_num_all_bond_devices() >= BTM_SEC_MAX_DEVICE_RECORDS && !btc_config_has_section(bdstr)) {
43+
if (btc_storage_get_num_all_bond_devices() >= BTM_SEC_MAX_BONDS && !btc_config_has_section(bdstr)) {
4444
const btc_config_section_iter_t *iter = btc_config_section_begin();
4545
const btc_config_section_iter_t *remove_iter = iter;
4646
/* find the first device(the last node) */
@@ -57,7 +57,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
5757

5858
// delete config info
5959
if (btc_config_remove_section(remove_section)) {
60-
BTC_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the first device info : %02x:%02x:%02x:%02x:%02x:%02x",
60+
BTC_TRACE_WARNING("exceeded the maximum number of bonded devices, delete the first device info : %02x:%02x:%02x:%02x:%02x:%02x",
6161
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
6262
}
6363
}
@@ -141,8 +141,8 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
141141
continue;
142142
}
143143
dev_cnt ++;
144-
/* if the number of device stored in nvs not exceed to BTM_SEC_MAX_DEVICE_RECORDS, load it */
145-
if (dev_cnt <= BTM_SEC_MAX_DEVICE_RECORDS) {
144+
/* if the number of device stored in nvs not exceed to BTM_SEC_MAX_BONDS, load it */
145+
if (dev_cnt <= BTM_SEC_MAX_BONDS) {
146146
if (btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) && btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) &&
147147
btc_config_exist(name, BTC_STORAGE_SC_SUPPORT) && btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
148148
/* load bt device */

components/bt/host/bluedroid/common/include/common/bt_target.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,11 +1093,11 @@
10931093

10941094
/* The number of security records for peer devices. 15 AS Default*/
10951095
#ifndef BTM_SEC_MAX_DEVICE_RECORDS
1096-
#if (UC_BT_SMP_MAX_BONDS < UC_BT_ACL_CONNECTIONS)
1097-
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_ACL_CONNECTIONS
1098-
#else
1099-
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_SMP_MAX_BONDS
1096+
#define BTM_SEC_MAX_DEVICE_RECORDS (UC_BT_SMP_MAX_BONDS + UC_BT_ACL_CONNECTIONS)
11001097
#endif
1098+
1099+
#ifndef BTM_SEC_MAX_BONDS
1100+
#define BTM_SEC_MAX_BONDS UC_BT_SMP_MAX_BONDS
11011101
#endif
11021102

11031103
#if BTA_SDP_INCLUDED

components/bt/host/bluedroid/stack/btm/btm_ble.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,9 @@ tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk)
17001700
#if (SMP_INCLUDED == TRUE)
17011701
void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable)
17021702
{
1703+
#if BLE_INCLUDED == TRUE
1704+
l2cble_notify_le_connection(bd_addr);
1705+
#endif // BLE_INCLUDED == TRUE
17031706
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
17041707
BOOLEAN enc_cback;
17051708

0 commit comments

Comments
 (0)