mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Merge branch 'feat/support_bleqabr24_1539_v5.4' into 'release/v5.4'
feat(bt/bluedroid): Added config for saving BLE bonding keys to NVS (v5.4) See merge request espressif/esp-idf!35604
This commit is contained in:
@ -358,6 +358,13 @@ config BT_BLE_SMP_ID_RESET_ENABLE
|
|||||||
of a previously paired peer to be used to determine whether a device
|
of a previously paired peer to be used to determine whether a device
|
||||||
with which it previously shared an IRK is within range.
|
with which it previously shared an IRK is within range.
|
||||||
|
|
||||||
|
config BT_BLE_SMP_BOND_NVS_FLASH
|
||||||
|
bool "Save SMP bonding keys to nvs flash"
|
||||||
|
depends on BT_BLE_SMP_ENABLE
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
This select can save SMP bonding keys to nvs flash
|
||||||
|
|
||||||
config BT_STACK_NO_LOG
|
config BT_STACK_NO_LOG
|
||||||
bool "Disable BT debug logs (minimize bin size)"
|
bool "Disable BT debug logs (minimize bin size)"
|
||||||
depends on BT_BLUEDROID_ENABLED
|
depends on BT_BLUEDROID_ENABLED
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -182,11 +182,12 @@ static void btc_dm_remove_ble_bonding_keys(void)
|
|||||||
btc_storage_remove_ble_bonding_keys(&bd_addr);
|
btc_storage_remove_ble_bonding_keys(&bd_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BLE_SMP_BOND_NVS_FLASH
|
||||||
static void btc_dm_save_ble_bonding_keys(void)
|
static void btc_dm_save_ble_bonding_keys(void)
|
||||||
{
|
{
|
||||||
if (!(btc_dm_cb.pairing_cb.ble.is_penc_key_rcvd || btc_dm_cb.pairing_cb.ble.is_pid_key_rcvd || btc_dm_cb.pairing_cb.ble.is_pcsrk_key_rcvd ||
|
if (!(btc_dm_cb.pairing_cb.ble.is_penc_key_rcvd || btc_dm_cb.pairing_cb.ble.is_pid_key_rcvd || btc_dm_cb.pairing_cb.ble.is_pcsrk_key_rcvd ||
|
||||||
btc_dm_cb.pairing_cb.ble.is_lenc_key_rcvd || btc_dm_cb.pairing_cb.ble.is_lcsrk_key_rcvd || btc_dm_cb.pairing_cb.ble.is_lidk_key_rcvd)) {
|
btc_dm_cb.pairing_cb.ble.is_lenc_key_rcvd || btc_dm_cb.pairing_cb.ble.is_lcsrk_key_rcvd || btc_dm_cb.pairing_cb.ble.is_lidk_key_rcvd)) {
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
bt_bdaddr_t bd_addr;
|
bt_bdaddr_t bd_addr;
|
||||||
|
|
||||||
@ -244,13 +245,13 @@ static void btc_dm_save_ble_bonding_keys(void)
|
|||||||
btc_dm_cb.pairing_cb.ble.is_lidk_key_rcvd = false;
|
btc_dm_cb.pairing_cb.ble.is_lidk_key_rcvd = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||||
{
|
{
|
||||||
/* Save link key, if not temporary */
|
/* Save link key, if not temporary */
|
||||||
BTC_TRACE_DEBUG("%s, status = %d", __func__, p_auth_cmpl->success);
|
BTC_TRACE_DEBUG("%s, status = %d", __func__, p_auth_cmpl->success);
|
||||||
bt_status_t status = BT_STATUS_FAIL;
|
bt_status_t status = BT_STATUS_FAIL;
|
||||||
int addr_type;
|
|
||||||
bt_bdaddr_t bdaddr;
|
bt_bdaddr_t bdaddr;
|
||||||
bdcpy(bdaddr.address, p_auth_cmpl->bd_addr);
|
bdcpy(bdaddr.address, p_auth_cmpl->bd_addr);
|
||||||
bdcpy(btc_dm_cb.pairing_cb.bd_addr, p_auth_cmpl->bd_addr);
|
bdcpy(btc_dm_cb.pairing_cb.bd_addr, p_auth_cmpl->bd_addr);
|
||||||
@ -266,6 +267,9 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BLE_SMP_BOND_NVS_FLASH
|
||||||
|
int addr_type;
|
||||||
|
|
||||||
if (btc_dm_cb.pairing_cb.ble.is_pid_key_rcvd) {
|
if (btc_dm_cb.pairing_cb.ble.is_pid_key_rcvd) {
|
||||||
// delete unused section in NVS
|
// delete unused section in NVS
|
||||||
btc_storage_remove_unused_sections(p_auth_cmpl->bd_addr, &btc_dm_cb.pairing_cb.ble.pid_key);
|
btc_storage_remove_unused_sections(p_auth_cmpl->bd_addr, &btc_dm_cb.pairing_cb.ble.pid_key);
|
||||||
@ -276,6 +280,7 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
|||||||
}
|
}
|
||||||
btc_storage_set_ble_dev_auth_mode(&bdaddr, p_auth_cmpl->auth_mode, true);
|
btc_storage_set_ble_dev_auth_mode(&bdaddr, p_auth_cmpl->auth_mode, true);
|
||||||
btc_dm_save_ble_bonding_keys();
|
btc_dm_save_ble_bonding_keys();
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/*Map the HCI fail reason to bt status */
|
/*Map the HCI fail reason to bt status */
|
||||||
switch (p_auth_cmpl->fail_reason) {
|
switch (p_auth_cmpl->fail_reason) {
|
||||||
|
@ -122,6 +122,11 @@ uint32_t btc_get_ble_status(void)
|
|||||||
{
|
{
|
||||||
uint32_t status = BTC_BLE_STATUS_IDLE;
|
uint32_t status = BTC_BLE_STATUS_IDLE;
|
||||||
|
|
||||||
|
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||||
|
BTC_TRACE_ERROR("%s Bluedroid not enabled", __func__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
#if (BLE_INCLUDED == TRUE)
|
#if (BLE_INCLUDED == TRUE)
|
||||||
// Number of active advertising
|
// Number of active advertising
|
||||||
extern uint8_t btm_ble_adv_active_count(void);
|
extern uint8_t btm_ble_adv_active_count(void);
|
||||||
|
@ -251,6 +251,12 @@
|
|||||||
#define UC_BT_BLE_SMP_ID_RESET_ENABLE FALSE
|
#define UC_BT_BLE_SMP_ID_RESET_ENABLE FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_BT_BLE_SMP_BOND_NVS_FLASH
|
||||||
|
#define UC_BT_BLE_SMP_BOND_NVS_FLASH CONFIG_BT_BLE_SMP_BOND_NVS_FLASH
|
||||||
|
#else
|
||||||
|
#define UC_BT_BLE_SMP_BOND_NVS_FLASH FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
//Device Name Maximum Length
|
//Device Name Maximum Length
|
||||||
#ifdef CONFIG_BT_MAX_DEVICE_NAME_LEN
|
#ifdef CONFIG_BT_MAX_DEVICE_NAME_LEN
|
||||||
#define UC_MAX_LOC_BD_NAME_LEN CONFIG_BT_MAX_DEVICE_NAME_LEN
|
#define UC_MAX_LOC_BD_NAME_LEN CONFIG_BT_MAX_DEVICE_NAME_LEN
|
||||||
|
@ -316,6 +316,12 @@
|
|||||||
#define BLE_SMP_ID_RESET_ENABLE FALSE
|
#define BLE_SMP_ID_RESET_ENABLE FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (UC_BT_BLE_SMP_BOND_NVS_FLASH)
|
||||||
|
#define BLE_SMP_BOND_NVS_FLASH TRUE
|
||||||
|
#else
|
||||||
|
#define BLE_SMP_BOND_NVS_FLASH FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
#ifdef UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||||
#define BLE_ADV_REPORT_FLOW_CONTROL (UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP && BLE_INCLUDED)
|
#define BLE_ADV_REPORT_FLOW_CONTROL (UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP && BLE_INCLUDED)
|
||||||
#endif /* UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP */
|
#endif /* UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP */
|
||||||
|
Reference in New Issue
Block a user