mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(ble/bluedroid): Fixed BLE incorrect device record count issue
(cherry picked from commit 9bfd9c5340)
Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
#if (SMP_INCLUDED == TRUE)
|
#if (SMP_INCLUDED == TRUE)
|
||||||
|
|
||||||
//the maximum number of bonded devices
|
//the maximum number of bonded devices
|
||||||
#define BONED_DEVICES_MAX_COUNT (BTM_SEC_MAX_DEVICE_RECORDS)
|
#define BONED_DEVICES_MAX_COUNT (BTM_SEC_MAX_BONDS)
|
||||||
|
|
||||||
static void _btc_storage_save(void)
|
static void _btc_storage_save(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -40,7 +40,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
|||||||
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
|
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
|
||||||
|
|
||||||
/* device not in bond list and exceed the maximum number of bonded devices, delete the inactive bonded device */
|
/* device not in bond list and exceed the maximum number of bonded devices, delete the inactive bonded device */
|
||||||
if (btc_storage_get_num_all_bond_devices() >= BTM_SEC_MAX_DEVICE_RECORDS && !btc_config_has_section(bdstr)) {
|
if (btc_storage_get_num_all_bond_devices() >= BTM_SEC_MAX_BONDS && !btc_config_has_section(bdstr)) {
|
||||||
const btc_config_section_iter_t *iter = btc_config_section_begin();
|
const btc_config_section_iter_t *iter = btc_config_section_begin();
|
||||||
const btc_config_section_iter_t *remove_iter = iter;
|
const btc_config_section_iter_t *remove_iter = iter;
|
||||||
/* find the first device(the last node) */
|
/* 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,
|
|||||||
|
|
||||||
// delete config info
|
// delete config info
|
||||||
if (btc_config_remove_section(remove_section)) {
|
if (btc_config_remove_section(remove_section)) {
|
||||||
BTC_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the first device info : %02x:%02x:%02x:%02x:%02x:%02x",
|
BTC_TRACE_WARNING("exceeded the maximum number of bonded devices, delete the first device info : %02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
|
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,8 +141,8 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dev_cnt ++;
|
dev_cnt ++;
|
||||||
/* if the number of device stored in nvs not exceed to BTM_SEC_MAX_DEVICE_RECORDS, load it */
|
/* if the number of device stored in nvs not exceed to BTM_SEC_MAX_BONDS, load it */
|
||||||
if (dev_cnt <= BTM_SEC_MAX_DEVICE_RECORDS) {
|
if (dev_cnt <= BTM_SEC_MAX_BONDS) {
|
||||||
if (btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) && btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) &&
|
if (btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) && btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) &&
|
||||||
btc_config_exist(name, BTC_STORAGE_SC_SUPPORT) && btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
|
btc_config_exist(name, BTC_STORAGE_SC_SUPPORT) && btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
|
||||||
/* load bt device */
|
/* load bt device */
|
||||||
|
|||||||
@@ -1057,11 +1057,11 @@
|
|||||||
|
|
||||||
/* The number of security records for peer devices. 15 AS Default*/
|
/* The number of security records for peer devices. 15 AS Default*/
|
||||||
#ifndef BTM_SEC_MAX_DEVICE_RECORDS
|
#ifndef BTM_SEC_MAX_DEVICE_RECORDS
|
||||||
#if (UC_BT_SMP_MAX_BONDS < UC_BT_ACL_CONNECTIONS)
|
#define BTM_SEC_MAX_DEVICE_RECORDS (UC_BT_SMP_MAX_BONDS + UC_BT_ACL_CONNECTIONS)
|
||||||
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_ACL_CONNECTIONS
|
|
||||||
#else
|
|
||||||
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_SMP_MAX_BONDS
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BTM_SEC_MAX_BONDS
|
||||||
|
#define BTM_SEC_MAX_BONDS UC_BT_SMP_MAX_BONDS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BTA_SDP_INCLUDED
|
#if BTA_SDP_INCLUDED
|
||||||
|
|||||||
Reference in New Issue
Block a user