Skip to content

Commit 07f4ff8

Browse files
committed
Merge branch 'feature/add_vendor_ble_cmd_definitions_5.3' into 'release/v5.3'
Feature/add vendor ble cmd definitions (v5.3) See merge request espressif/esp-idf!37957
2 parents 8685219 + fe6e6b3 commit 07f4ff8

File tree

48 files changed

+2162
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2162
-42
lines changed

components/bt/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ if(CONFIG_BT_ENABLED)
100100
list(APPEND ldscripts "linker_rw_bt_controller.lf")
101101

102102
elseif(CONFIG_IDF_TARGET_ESP32C2)
103-
list(APPEND srcs "controller/esp32c2/bt.c")
103+
list(APPEND srcs "controller/esp32c2/bt.c"
104+
"controller/esp32c2/ble.c")
104105
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
105106
list(APPEND srcs "controller/esp32c2/dummy.c")
106107
endif()

components/bt/controller/esp32/Kconfig.in

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ config BTDM_CTRL_BLE_MAX_CONN
2323
BLE maximum connections of bluetooth controller.
2424
Each connection uses 1KB static DRAM whenever the BT controller is enabled.
2525

26+
config BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT
27+
int "BR/EDR default minimum size of encryption key"
28+
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
29+
default 7
30+
range 7 16
31+
help
32+
BR/EDR default minimum size of encryption key when start encryption.
33+
2634
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN
2735
int "BR/EDR ACL Max Connections"
2836
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
@@ -139,6 +147,11 @@ config BTDM_CTRL_BLE_MAX_CONN_EFF
139147
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
140148
default 0
141149

150+
config BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT_EFF
151+
int
152+
default BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
153+
default 0
154+
142155
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF
143156
int
144157
default BTDM_CTRL_BR_EDR_MAX_ACL_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
@@ -483,13 +496,6 @@ config BTDM_BLE_PING_EN
483496
If this option is disabled, The Controller will not start the LE authenticated payload timer.
484497
This option is used for some compatibility problems related to LE ping procedure.
485498

486-
config BTDM_BLE_VS_QA_SUPPORT
487-
bool "BLE vendor HCI QA support"
488-
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
489-
default n
490-
help
491-
This enables BLE vendor HCI command and event for QA.
492-
493499
config BTDM_CTRL_CONTROLLER_DEBUG_MODE_1
494500
visible if 0
495501
bool "Enable Bluetooth controller debugging mode 1 (for internal use only)"

components/bt/controller/esp32/bt.c

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,16 @@ extern uint32_t _bt_controller_data_end;
252252
extern void config_bt_funcs_reset(void);
253253
extern void config_ble_funcs_reset(void);
254254
extern void config_btdm_funcs_reset(void);
255-
extern void config_ble_vs_qa_funcs_reset(void);
255+
256+
#ifdef CONFIG_BT_BLUEDROID_ENABLED
257+
extern void bt_stack_enableSecCtrlVsCmd(bool en);
258+
#endif // CONFIG_BT_BLUEDROID_ENABLED
259+
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
260+
extern void bt_stack_enableCoexVsCmd(bool en);
261+
extern void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
262+
extern void adv_stack_enableClearLegacyAdvVsCmd(bool en);
263+
extern void advFilter_stack_enableDupExcListVsCmd(bool en);
264+
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
256265

257266
/* Local Function Declare
258267
*********************************************************************
@@ -1703,6 +1712,16 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
17031712
goto error;
17041713
}
17051714

1715+
#ifdef CONFIG_BT_BLUEDROID_ENABLED
1716+
bt_stack_enableSecCtrlVsCmd(true);
1717+
#endif // CONFIG_BT_BLUEDROID_ENABLED
1718+
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
1719+
bt_stack_enableCoexVsCmd(true);
1720+
scan_stack_enableAdvFlowCtrlVsCmd(true);
1721+
adv_stack_enableClearLegacyAdvVsCmd(true);
1722+
advFilter_stack_enableDupExcListVsCmd(true);
1723+
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
1724+
17061725
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
17071726

17081727
return ESP_OK;
@@ -1728,6 +1747,16 @@ esp_err_t esp_bt_controller_deinit(void)
17281747

17291748
bt_controller_deinit_internal();
17301749

1750+
#ifdef CONFIG_BT_BLUEDROID_ENABLED
1751+
bt_stack_enableSecCtrlVsCmd(false);
1752+
#endif // CONFIG_BT_BLUEDROID_ENABLED
1753+
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
1754+
bt_stack_enableCoexVsCmd(false);
1755+
scan_stack_enableAdvFlowCtrlVsCmd(false);
1756+
adv_stack_enableClearLegacyAdvVsCmd(false);
1757+
advFilter_stack_enableDupExcListVsCmd(false);
1758+
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
1759+
17311760
return ESP_OK;
17321761
}
17331762

@@ -1812,10 +1841,6 @@ static void patch_apply(void)
18121841
#ifndef CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY
18131842
config_ble_funcs_reset();
18141843
#endif
1815-
1816-
#ifdef CONFIG_BTDM_BLE_VS_QA_SUPPORT
1817-
config_ble_vs_qa_funcs_reset();
1818-
#endif
18191844
}
18201845

18211846
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <stdlib.h>
7+
8+
#include "sdkconfig.h"
9+
#include "esp_bt_cfg.h"
10+
11+
/* External functions or variables
12+
************************************************************************
13+
*/
14+
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
15+
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
16+
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
17+
void chanSel_stack_enableSetCsaVsCmd(bool en);
18+
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
19+
20+
/* Local functions definition
21+
***************************************************************************
22+
*/
23+
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
24+
void ble_stack_enableVsCmds(bool en)
25+
{
26+
#if DEFAULT_BT_LE_ROLE_BROADCASTER
27+
adv_stack_enableClearLegacyAdvVsCmd(en);
28+
#endif // DEFAULT_BT_LE_ROLE_BROADCASTER
29+
30+
#if DEFAULT_BT_LE_ROLE_OBSERVER
31+
scan_stack_enableAdvFlowCtrlVsCmd(en);
32+
#endif // DEFAULT_BT_LE_ROLE_OBSERVER
33+
34+
chanSel_stack_enableSetCsaVsCmd(en);
35+
}
36+
37+
void ble_stack_enableVsEvents(bool en)
38+
{
39+
}
40+
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
41+
42+
int ble_stack_enable(void)
43+
{
44+
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
45+
ble_stack_enableVsCmds(true);
46+
ble_stack_enableVsEvents(true);
47+
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
48+
49+
return 0;
50+
}
51+
52+
void ble_stack_disable(void)
53+
{
54+
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
55+
ble_stack_enableVsEvents(false);
56+
ble_stack_enableVsCmds(false);
57+
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
58+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#ifndef _BLE_PRIV_H_
7+
#define _BLE_PRIV_H_
8+
9+
int ble_stack_enable(void);
10+
11+
void ble_stack_disable(void);
12+
13+
#endif // _BLE_PRIV_H_

components/bt/controller/esp32c2/bt.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "os/endian.h"
3636

3737
#include "esp_bt.h"
38+
#include "ble_priv.h"
3839
#include "esp_intr_alloc.h"
3940
#include "esp_sleep.h"
4041
#include "esp_pm.h"
@@ -999,6 +1000,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
9991000
#if CONFIG_SW_COEXIST_ENABLE
10001001
coex_enable();
10011002
#endif
1003+
1004+
if (ble_stack_enable() != 0) {
1005+
ret = ESP_FAIL;
1006+
goto error;
1007+
}
1008+
10021009
if (ble_controller_enable(mode) != 0) {
10031010
ret = ESP_FAIL;
10041011
goto error;
@@ -1008,6 +1015,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
10081015
return ESP_OK;
10091016

10101017
error:
1018+
ble_stack_disable();
10111019
#if CONFIG_SW_COEXIST_ENABLE
10121020
coex_disable();
10131021
#endif
@@ -1030,7 +1038,7 @@ esp_err_t esp_bt_controller_disable(void)
10301038
if (ble_controller_disable() != 0) {
10311039
return ESP_FAIL;
10321040
}
1033-
1041+
ble_stack_disable();
10341042
if (s_ble_active) {
10351043
esp_phy_disable(PHY_MODEM_BT);
10361044
#if CONFIG_PM_ENABLE

components/bt/controller/esp32c2/esp_bt_cfg.h

Lines changed: 7 additions & 1 deletion
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
*/
@@ -232,6 +232,12 @@ extern "C" {
232232
#define HCI_UART_EN 0 // hci ram mode
233233
#endif
234234

235+
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_RAM
236+
#define DEFAULT_BT_LE_VHCI_ENABLED (CONFIG_BT_LE_HCI_INTERFACE_USE_RAM)
237+
#else
238+
#define DEFAULT_BT_LE_VHCI_ENABLED (0)
239+
#endif
240+
235241
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
236242
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
237243
#else

components/bt/controller/esp32c3/Kconfig.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ endchoice
6666
config BT_CTRL_HCI_TL
6767
int
6868
default 0 if BT_CTRL_HCI_MODE_UART_H4
69-
default 1 if BT_CTRL_HCI_M0DE_VHCI
69+
default 1 if BT_CTRL_HCI_MODE_VHCI
7070
default 1
7171
help
7272
HCI mode as VHCI or UART(H4)
@@ -445,7 +445,7 @@ config BT_CTRL_SLEEP_CLOCK_EFF
445445
config BT_CTRL_HCI_TL_EFF
446446
int
447447
default 0 if BT_CTRL_HCI_MODE_UART_H4
448-
default 1 if BT_CTRL_HCI_M0DE_VHCI
448+
default 1 if BT_CTRL_HCI_MODE_VHCI
449449
default 1
450450

451451
config BT_CTRL_AGC_RECORRECT_EN

components/bt/controller/esp32c3/bt.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
304304
extern void r_ble_log_async_output_dump_all(bool output);
305305
extern void esp_panic_handler_feed_wdts(void);
306306
#endif // CONFIG_BT_CTRL_LE_LOG_EN
307+
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
308+
extern void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
309+
extern void adv_stack_enableClearLegacyAdvVsCmd(bool en);
310+
extern void advFilter_stack_enableDupExcListVsCmd(bool en);
311+
extern void chanSel_stack_enableSetCsaVsCmd(bool en);
312+
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
307313

308314
extern uint32_t _bt_bss_start;
309315
extern uint32_t _bt_bss_end;
@@ -1771,6 +1777,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
17711777
goto error;
17721778
}
17731779

1780+
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
1781+
scan_stack_enableAdvFlowCtrlVsCmd(true);
1782+
adv_stack_enableClearLegacyAdvVsCmd(true);
1783+
advFilter_stack_enableDupExcListVsCmd(true);
1784+
chanSel_stack_enableSetCsaVsCmd(true);
1785+
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
1786+
17741787
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
17751788

17761789
return ESP_OK;
@@ -1792,6 +1805,13 @@ esp_err_t esp_bt_controller_deinit(void)
17921805
ble_log_spi_out_deinit();
17931806
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
17941807

1808+
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
1809+
scan_stack_enableAdvFlowCtrlVsCmd(false);
1810+
adv_stack_enableClearLegacyAdvVsCmd(false);
1811+
advFilter_stack_enableDupExcListVsCmd(false);
1812+
chanSel_stack_enableSetCsaVsCmd(false);
1813+
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
1814+
17951815
btdm_controller_deinit();
17961816

17971817
bt_controller_deinit_internal();

components/bt/controller/esp32c6/ble.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "sdkconfig.h"
99
#include "esp_bt_cfg.h"
10+
#include "esp_bit_defs.h"
1011

1112
/* External functions or variables
1213
************************************************************************
@@ -28,9 +29,43 @@ int conn_errorSim_enable(void);
2829
void conn_errorSim_disable(void);
2930
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
3031

32+
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
33+
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
34+
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
35+
void advFilter_stack_enableDupExcListVsCmd(bool en);
36+
void arr_stack_enableMultiConnVsCmd(bool en);
37+
void pcl_stack_enableSetRssiThreshVsCmd(bool en);
38+
void chanSel_stack_enableSetCsaVsCmd(bool en);
39+
void log_stack_enableLogsRelatedVsCmd(bool en);
40+
void hci_stack_enableSetVsEvtMaskVsCmd(bool en);
41+
42+
void adv_stack_enableScanReqRxdVsEvent(bool en);
43+
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
44+
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
45+
3146
/* Local functions definition
3247
***************************************************************************
3348
*/
49+
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
50+
void ble_stack_enableVsCmds(bool en)
51+
{
52+
adv_stack_enableClearLegacyAdvVsCmd(en);
53+
advFilter_stack_enableDupExcListVsCmd(en);
54+
scan_stack_enableAdvFlowCtrlVsCmd(en);
55+
arr_stack_enableMultiConnVsCmd(en);
56+
pcl_stack_enableSetRssiThreshVsCmd(en);
57+
chanSel_stack_enableSetCsaVsCmd(en);
58+
log_stack_enableLogsRelatedVsCmd(en);
59+
hci_stack_enableSetVsEvtMaskVsCmd(en);
60+
}
61+
62+
void ble_stack_enableVsEvents(bool en)
63+
{
64+
adv_stack_enableScanReqRxdVsEvent(en);
65+
conn_stack_enableChanMapUpdCompVsEvent(en);
66+
}
67+
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
68+
3469
int ble_stack_initEnv(void)
3570
{
3671
int rc;
@@ -90,11 +125,21 @@ int ble_stack_enable(void)
90125
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
91126
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
92127

128+
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
129+
ble_stack_enableVsCmds(true);
130+
ble_stack_enableVsEvents(true);
131+
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
132+
93133
return 0;
94134
}
95135

96136
void ble_stack_disable(void)
97137
{
138+
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
139+
ble_stack_enableVsEvents(false);
140+
ble_stack_enableVsCmds(false);
141+
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
142+
98143
#if DEFAULT_BT_LE_MAX_CONNECTIONS
99144
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
100145
conn_errorSim_disable();

components/bt/controller/esp32c6/esp_bt_cfg.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ extern "C" {
198198
#define HCI_UART_EN 0 // hci ram mode
199199
#endif
200200

201+
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_RAM
202+
#define DEFAULT_BT_LE_VHCI_ENABLED (CONFIG_BT_LE_HCI_INTERFACE_USE_RAM)
203+
#else
204+
#define DEFAULT_BT_LE_VHCI_ENABLED (0)
205+
#endif
206+
201207
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
202208
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
203209
#else

0 commit comments

Comments
 (0)