From 29a097504d994a0788689c470b1d6ea4dbf6c5b4 Mon Sep 17 00:00:00 2001 From: xiewenxiang Date: Thu, 9 Sep 2021 14:30:30 +0800 Subject: [PATCH 1/2] component/bt: set ext adv param failed when stop ext adv --- components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index e6df9b0761..44de14065d 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -523,10 +523,6 @@ tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_ end: if (!enable && status == BTM_SUCCESS) { - // Reset the configure parameters when stop extend adv. - for (int i = 0; i < MAX_BLE_ADV_INSTANCE; i++) { - extend_adv_cb.inst[i].configured = false; - } // disable all ext adv if(num == 0) { From 5e217882835e9aff1594383f8a997d2842e31c21 Mon Sep 17 00:00:00 2001 From: xiewenxiang Date: Wed, 20 Oct 2021 16:19:28 +0800 Subject: [PATCH 2/2] component/bt: Modify the bluetooth device name length limits --- components/bt/host/bluedroid/Kconfig.in | 10 +++++ .../bt/host/bluedroid/api/esp_bt_device.c | 25 ++++++------ .../bt/host/bluedroid/btc/core/btc_dev.c | 39 ++++++++++++------- .../host/bluedroid/btc/include/btc/btc_dev.h | 21 +++------- .../include/common/bluedroid_user_config.h | 8 ++++ .../common/include/common/bt_target.h | 6 ++- tools/ci/check_copyright_ignore.txt | 3 -- 7 files changed, 66 insertions(+), 46 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 0b41479221..a1ed479b7f 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -1040,6 +1040,16 @@ config BT_BLE_ESTAB_LINK_CONN_TOUT Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered. +config BT_MAX_DEVICE_NAME_LEN + int "length of bluetooth device name" + depends on BT_BLUEDROID_ENABLED + range 32 248 + default 32 + help + Bluetooth Device name length shall be no larger than 248 octets, If the broadcast data cannot contain + the complete device name, then only the shortname will be displayed, the rest parts that can't fit in + will be truncated. + config BT_BLE_RPA_SUPPORTED bool "Update RPA to Controller" depends on BT_BLUEDROID_ENABLED diff --git a/components/bt/host/bluedroid/api/esp_bt_device.c b/components/bt/host/bluedroid/api/esp_bt_device.c index 212157e06d..6fdd99d66e 100644 --- a/components/bt/host/bluedroid/api/esp_bt_device.c +++ b/components/bt/host/bluedroid/api/esp_bt_device.c @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include @@ -39,13 +31,18 @@ esp_err_t esp_bt_dev_set_device_name(const char *name) if (!name){ return ESP_ERR_INVALID_ARG; } - if (strlen(name) > ESP_DEV_DEVICE_NAME_MAX) { + if (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN) { return ESP_ERR_INVALID_ARG; } msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_DEV; msg.act = BTC_DEV_ACT_SET_DEVICE_NAME; + arg.set_dev_name.device_name = (char *)malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char)); + if (!arg.set_dev_name.device_name) { + return ESP_ERR_NO_MEM; + } + strcpy(arg.set_dev_name.device_name, name); return (btc_transfer_context(&msg, &arg, sizeof(btc_dev_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); diff --git a/components/bt/host/bluedroid/btc/core/btc_dev.c b/components/bt/host/bluedroid/btc/core/btc_dev.c index b5c85b9651..88d15c8584 100644 --- a/components/bt/host/bluedroid/btc/core/btc_dev.c +++ b/components/bt/host/bluedroid/btc/core/btc_dev.c @@ -1,23 +1,34 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include +#include "osi/allocator.h" #include "bta/bta_api.h" #include "btc/btc_task.h" #include "btc/btc_manage.h" #include "btc/btc_dev.h" +void btc_dev_arg_deep_free(btc_msg_t *msg) +{ + BTC_TRACE_DEBUG("%s \n", __func__); + + switch (msg->act) { + case BTC_DEV_ACT_SET_DEVICE_NAME:{ + char *device_name = ((btc_dev_args_t *)msg->arg)->set_dev_name.device_name; + if (device_name) { + osi_free(device_name); + } + break; + } + default: + BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act); + break; + } +} + void btc_dev_call_handler(btc_msg_t *msg) { btc_dev_args_t *arg = (btc_dev_args_t *)msg->arg; @@ -31,4 +42,6 @@ void btc_dev_call_handler(btc_msg_t *msg) default: break; } + + btc_dev_arg_deep_free(msg); } diff --git a/components/bt/host/bluedroid/btc/include/btc/btc_dev.h b/components/bt/host/bluedroid/btc/include/btc/btc_dev.h index 480b0fa57d..e87766b9dc 100644 --- a/components/bt/host/bluedroid/btc/include/btc/btc_dev.h +++ b/components/bt/host/bluedroid/btc/include/btc/btc_dev.h @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __BTC_DEV_H__ #define __BTC_DEV_H__ @@ -27,8 +19,7 @@ typedef enum { typedef union { // BTC_BT_GAP_ACT_SET_DEV_NAME struct set_bt_dev_name_args { -#define ESP_DEV_DEVICE_NAME_MAX (32) - char device_name[ESP_DEV_DEVICE_NAME_MAX + 1]; + char *device_name; } set_dev_name; } btc_dev_args_t; diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index 5e94a03403..193546c6b1 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -163,6 +163,14 @@ #endif #if CONFIG_IDF_TARGET_ESP32 + +//Device Nane Maximum Length +#ifdef CONFIG_BT_MAX_DEVICE_NAME_LEN +#define UC_MAX_LOC_BD_NAME_LEN CONFIG_BT_MAX_DEVICE_NAME_LEN +#else +#define UC_MAX_LOC_BD_NAME_LEN 64 +#endif + //BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP #ifdef CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP #define UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index 4afb853e6e..c16e4d5be8 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -850,8 +850,12 @@ /* Maximum local device name length stored btm database. '0' disables storage of the local name in BTM */ -#ifndef BTM_MAX_LOC_BD_NAME_LEN +#if UC_MAX_LOC_BD_NAME_LEN +#define BTM_MAX_LOC_BD_NAME_LEN UC_MAX_LOC_BD_NAME_LEN +#define BTC_MAX_LOC_BD_NAME_LEN BTM_MAX_LOC_BD_NAME_LEN +#else #define BTM_MAX_LOC_BD_NAME_LEN 64 +#define BTC_MAX_LOC_BD_NAME_LEN BTM_MAX_LOC_BD_NAME_LEN #endif /* Fixed Default String. When this is defined as null string, the device's diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index ea4ccf7ebf..b6e86f0917 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -255,7 +255,6 @@ components/bt/esp_ble_mesh/mesh_models/server/state_transition.c components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c components/bt/host/bluedroid/api/esp_a2dp_api.c components/bt/host/bluedroid/api/esp_avrc_api.c -components/bt/host/bluedroid/api/esp_bt_device.c components/bt/host/bluedroid/api/esp_bt_main.c components/bt/host/bluedroid/api/esp_gap_ble_api.c components/bt/host/bluedroid/api/esp_gap_bt_api.c @@ -395,7 +394,6 @@ components/bt/host/bluedroid/bta/sys/include/bta_sys_int.h components/bt/host/bluedroid/bta/sys/utl.c components/bt/host/bluedroid/btc/core/btc_ble_storage.c components/bt/host/bluedroid/btc/core/btc_config.c -components/bt/host/bluedroid/btc/core/btc_dev.c components/bt/host/bluedroid/btc/core/btc_dm.c components/bt/host/bluedroid/btc/core/btc_main.c components/bt/host/bluedroid/btc/core/btc_profile_queue.c @@ -405,7 +403,6 @@ components/bt/host/bluedroid/btc/core/btc_util.c components/bt/host/bluedroid/btc/include/btc/btc_ble_storage.h components/bt/host/bluedroid/btc/include/btc/btc_common.h components/bt/host/bluedroid/btc/include/btc/btc_config.h -components/bt/host/bluedroid/btc/include/btc/btc_dev.h components/bt/host/bluedroid/btc/include/btc/btc_dm.h components/bt/host/bluedroid/btc/include/btc/btc_main.h components/bt/host/bluedroid/btc/include/btc/btc_profile_queue.h