Skip to content

Commit 0b8ca3d

Browse files
committed
Merge branch 'bugfix/bug_ble_max_device_record_v5.3' into 'release/v5.3'
fix(ble/bluedroid): Fixed BLE incorrect device record count issue (v5.3) See merge request espressif/esp-idf!43595
2 parents cbefff5 + cb9dc0d commit 0b8ca3d

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
@@ -1070,11 +1070,11 @@
10701070

10711071
/* The number of security records for peer devices. 15 AS Default*/
10721072
#ifndef BTM_SEC_MAX_DEVICE_RECORDS
1073-
#if (UC_BT_SMP_MAX_BONDS < UC_BT_ACL_CONNECTIONS)
1074-
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_ACL_CONNECTIONS
1075-
#else
1076-
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_SMP_MAX_BONDS
1073+
#define BTM_SEC_MAX_DEVICE_RECORDS (UC_BT_SMP_MAX_BONDS + UC_BT_ACL_CONNECTIONS)
10771074
#endif
1075+
1076+
#ifndef BTM_SEC_MAX_BONDS
1077+
#define BTM_SEC_MAX_BONDS UC_BT_SMP_MAX_BONDS
10781078
#endif
10791079

10801080
#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
@@ -1704,6 +1704,9 @@ tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk)
17041704
#if (SMP_INCLUDED == TRUE)
17051705
void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable)
17061706
{
1707+
#if BLE_INCLUDED == TRUE
1708+
l2cble_notify_le_connection(bd_addr);
1709+
#endif // BLE_INCLUDED == TRUE
17071710
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr);
17081711
BOOLEAN enc_cback;
17091712

0 commit comments

Comments
 (0)