mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(bt/bluedroid): Optimize ble remove all bonded devices function
This commit is contained in:
parent
e9c1d5c4b6
commit
951e3b2b8c
@ -246,6 +246,10 @@ static const esp_gatts_attr_db_t gatt_db[HRS_IDX_NB] =
|
|||||||
static void show_bonded_devices(void)
|
static void show_bonded_devices(void)
|
||||||
{
|
{
|
||||||
int dev_num = esp_ble_get_bond_device_num();
|
int dev_num = esp_ble_get_bond_device_num();
|
||||||
|
if (dev_num == 0) {
|
||||||
|
ESP_LOGI(EXAMPLE_TAG, "Bonded devices number zero\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
||||||
if (!dev_list) {
|
if (!dev_list) {
|
||||||
@ -268,6 +272,10 @@ static void show_bonded_devices(void)
|
|||||||
static void __attribute__((unused)) remove_all_bonded_devices(void)
|
static void __attribute__((unused)) remove_all_bonded_devices(void)
|
||||||
{
|
{
|
||||||
int dev_num = esp_ble_get_bond_device_num();
|
int dev_num = esp_ble_get_bond_device_num();
|
||||||
|
if (dev_num == 0) {
|
||||||
|
ESP_LOGI(EXAMPLE_TAG, "Bonded devices number zero\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
||||||
if (!dev_list) {
|
if (!dev_list) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -256,6 +256,10 @@ static char *esp_auth_req_to_str(esp_ble_auth_req_t auth_req)
|
|||||||
static void show_bonded_devices(void)
|
static void show_bonded_devices(void)
|
||||||
{
|
{
|
||||||
int dev_num = esp_ble_get_bond_device_num();
|
int dev_num = esp_ble_get_bond_device_num();
|
||||||
|
if (dev_num == 0) {
|
||||||
|
ESP_LOGI(GATTS_TABLE_TAG, "Bonded devices number zero\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
||||||
if (!dev_list) {
|
if (!dev_list) {
|
||||||
@ -276,6 +280,10 @@ static void show_bonded_devices(void)
|
|||||||
static void __attribute__((unused)) remove_all_bonded_devices(void)
|
static void __attribute__((unused)) remove_all_bonded_devices(void)
|
||||||
{
|
{
|
||||||
int dev_num = esp_ble_get_bond_device_num();
|
int dev_num = esp_ble_get_bond_device_num();
|
||||||
|
if (dev_num == 0) {
|
||||||
|
ESP_LOGI(GATTS_TABLE_TAG, "Bonded devices number zero\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
||||||
if (!dev_list) {
|
if (!dev_list) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -228,6 +228,10 @@ static char *esp_auth_req_to_str(esp_ble_auth_req_t auth_req)
|
|||||||
static void show_bonded_devices(void)
|
static void show_bonded_devices(void)
|
||||||
{
|
{
|
||||||
int dev_num = esp_ble_get_bond_device_num();
|
int dev_num = esp_ble_get_bond_device_num();
|
||||||
|
if (dev_num == 0) {
|
||||||
|
ESP_LOGI(GATTS_TABLE_TAG, "Bonded devices number zero\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
||||||
if (!dev_list) {
|
if (!dev_list) {
|
||||||
@ -246,6 +250,10 @@ static void show_bonded_devices(void)
|
|||||||
static void __attribute__((unused)) remove_all_bonded_devices(void)
|
static void __attribute__((unused)) remove_all_bonded_devices(void)
|
||||||
{
|
{
|
||||||
int dev_num = esp_ble_get_bond_device_num();
|
int dev_num = esp_ble_get_bond_device_num();
|
||||||
|
if (dev_num == 0) {
|
||||||
|
ESP_LOGI(GATTS_TABLE_TAG, "Bonded devices number zero\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
|
||||||
if (!dev_list) {
|
if (!dev_list) {
|
||||||
|
Loading…
Reference in New Issue
Block a user