summaryrefslogtreecommitdiff
path: root/lib/bt/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2025-07-25 13:33:07 +1000
committerjacqueline <me@jacqueline.id.au>2025-07-25 13:33:07 +1000
commitc8e79a926620e48830778714cfe4b2ea2453fcaf (patch)
tree8c756e08e01b8e147cf72bec128026f46bd854c5 /lib/bt/include
parent237136f3e93cb6b5be24670d7520adb17cc0fa36 (diff)
downloadtangara-fw-c8e79a926620e48830778714cfe4b2ea2453fcaf.tar.gz
Update forked idf components
Diffstat (limited to 'lib/bt/include')
-rw-r--r--lib/bt/include/esp32/include/esp_bt.h708
-rw-r--r--lib/bt/include/esp32/include/esp_bt_vs.h252
-rw-r--r--lib/bt/include/esp32c2/include/esp_bt.h69
-rw-r--r--lib/bt/include/esp32c2/include/esp_bt_vs.h214
-rw-r--r--lib/bt/include/esp32c3/include/esp_bt.h820
-rw-r--r--lib/bt/include/esp32c3/include/esp_bt_vs.h175
-rw-r--r--lib/bt/include/esp32c5/include/esp_bt.h61
-rw-r--r--lib/bt/include/esp32c5/include/esp_bt_vs.h360
-rw-r--r--lib/bt/include/esp32c6/include/esp_bt.h122
-rw-r--r--lib/bt/include/esp32c6/include/esp_bt_vs.h360
-rw-r--r--lib/bt/include/esp32h2/include/esp_bt.h82
-rw-r--r--lib/bt/include/esp32h2/include/esp_bt_vs.h360
-rw-r--r--lib/bt/include/esp32h4/include/esp_bt_cfg.h20
13 files changed, 2989 insertions, 614 deletions
diff --git a/lib/bt/include/esp32/include/esp_bt.h b/lib/bt/include/esp32/include/esp_bt.h
index b31ce276..0e9b5fd1 100644
--- a/lib/bt/include/esp32/include/esp_bt.h
+++ b/lib/bt/include/esp32/include/esp_bt.h
@@ -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
*/
@@ -50,38 +50,44 @@ extern "C" {
#endif //CONFIG_BT_ENABLED
-#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240315
+/**
+* @brief Internal use only
+*
+* @note Please do not modify this value
+*/
+#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20250318
/**
- * @brief Bluetooth mode for controller enable/disable
+ * @brief Bluetooth Controller mode
*/
typedef enum {
- ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
- ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
- ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
- ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
+ ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not operating. */
+ ESP_BT_MODE_BLE = 0x01, /*!< Bluetooth is operating in BLE mode. */
+ ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Bluetooth is operating in Classic Bluetooth mode. */
+ ESP_BT_MODE_BTDM = 0x03, /*!< Bluetooth is operating in Dual mode. */
} esp_bt_mode_t;
/**
- * @brief BLE sleep clock accuracy(SCA), values for ble_sca field in esp_bt_controller_config_t,
- * currently only ESP_BLE_SCA_500PPM and ESP_BLE_SCA_250PPM are supported
+ * @brief BLE sleep clock accuracy (SCA)
+ *
+ * @note Currently only ESP_BLE_SCA_500PPM and ESP_BLE_SCA_250PPM are supported.
*/
-enum {
- ESP_BLE_SCA_500PPM = 0, /*!< BLE SCA at 500ppm */
- ESP_BLE_SCA_250PPM, /*!< BLE SCA at 250ppm */
- ESP_BLE_SCA_150PPM, /*!< BLE SCA at 150ppm */
- ESP_BLE_SCA_100PPM, /*!< BLE SCA at 100ppm */
- ESP_BLE_SCA_75PPM, /*!< BLE SCA at 75ppm */
- ESP_BLE_SCA_50PPM, /*!< BLE SCA at 50ppm */
- ESP_BLE_SCA_30PPM, /*!< BLE SCA at 30ppm */
- ESP_BLE_SCA_20PPM, /*!< BLE SCA at 20ppm */
-};
+typedef enum {
+ ESP_BLE_SCA_500PPM = 0, /*!< BLE SCA at 500 ppm */
+ ESP_BLE_SCA_250PPM, /*!< BLE SCA at 250 ppm */
+ ESP_BLE_SCA_150PPM, /*!< BLE SCA at 150 ppm */
+ ESP_BLE_SCA_100PPM, /*!< BLE SCA at 100 ppm */
+ ESP_BLE_SCA_75PPM, /*!< BLE SCA at 75 ppm */
+ ESP_BLE_SCA_50PPM, /*!< BLE SCA at 50 ppm */
+ ESP_BLE_SCA_30PPM, /*!< BLE SCA at 30 ppm */
+ ESP_BLE_SCA_20PPM, /*!< BLE SCA at 20 ppm */
+} esp_ble_sca_t;
#ifdef CONFIG_BT_ENABLED
/* While scanning, if the free memory value in controller is less than SCAN_SEND_ADV_RESERVED_SIZE,
-the adv packet will be discarded until the memory is restored. */
+the advertising packet will be discarded until the memory is restored. */
#define SCAN_SEND_ADV_RESERVED_SIZE 1000
-/* enable controller log debug when adv lost */
+/* enable controller log debug when the advertising packet gets lost */
#define CONTROLLER_ADV_LOST_DEBUG_BIT (0<<0)
#ifdef CONFIG_BTDM_CTRL_HCI_UART_NO
@@ -102,7 +108,7 @@ the adv packet will be discarded until the memory is restored. */
#define SCAN_DUPLICATE_TYPE_VALUE 0
#endif
-/* normal adv cache size */
+/* normal advertising cache size */
#ifdef CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE
#define NORMAL_SCAN_DUPLICATE_CACHE_SIZE CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE
#else
@@ -173,6 +179,51 @@ the adv packet will be discarded until the memory is restored. */
#define BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0
#endif
+#ifdef CONFIG_BTDM_BLE_LLCP_CONN_UPDATE
+#define BTDM_BLE_LLCP_CONN_UPDATE (1<<0)
+#else
+#define BTDM_BLE_LLCP_CONN_UPDATE (0<<0)
+#endif
+
+#ifdef CONFIG_BTDM_BLE_LLCP_CHAN_MAP_UPDATE
+#define BTDM_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
+#else
+#define BTDM_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
+#endif
+
+#define BTDM_BLE_LLCP_DISC_FLAG (BTDM_BLE_LLCP_CONN_UPDATE | BTDM_BLE_LLCP_CHAN_MAP_UPDATE)
+
+#ifdef CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
+#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
+#else
+#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED 0
+#endif
+
+#if defined(CONFIG_BTDM_BLE_CHAN_ASS_EN)
+#define BTDM_BLE_CHAN_ASS_EN (CONFIG_BTDM_BLE_CHAN_ASS_EN)
+#else
+#define BTDM_BLE_CHAN_ASS_EN (0)
+#endif
+
+#if CONFIG_BTDM_CTRL_CONTROLLER_DEBUG_MODE_1
+#define BTDM_CTRL_CONTROLLER_DEBUG_MODE_1 (1 << 1)
+#else
+#define BTDM_CTRL_CONTROLLER_DEBUG_MODE_1 0
+#endif
+
+#ifndef BTDM_CTRL_CONTROLLER_DEBUG_FLAG
+#define BTDM_CTRL_CONTROLLER_DEBUG_FLAG (BTDM_CTRL_CONTROLLER_DEBUG_MODE_1 | CONTROLLER_ADV_LOST_DEBUG_BIT)
+#endif
+
+#if defined(CONFIG_BTDM_BLE_PING_EN)
+#define BTDM_BLE_PING_EN (CONFIG_BTDM_BLE_PING_EN)
+#else
+#define BTDM_BLE_PING_EN (0)
+#endif
+
+/**
+* @brief Default Bluetooth Controller configuration
+*/
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
@@ -183,7 +234,7 @@ the adv packet will be discarded until the memory is restored. */
.normal_adv_size = NORMAL_SCAN_DUPLICATE_CACHE_SIZE, \
.mesh_adv_size = MESH_DUPLICATE_SCAN_CACHE_SIZE, \
.send_adv_reserved_size = SCAN_SEND_ADV_RESERVED_SIZE, \
- .controller_debug_flag = CONTROLLER_ADV_LOST_DEBUG_BIT, \
+ .controller_debug_flag = BTDM_CTRL_CONTROLLER_DEBUG_FLAG, \
.mode = BTDM_CONTROLLER_MODE_EFF, \
.ble_max_conn = CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF, \
.bt_max_acl_conn = CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF, \
@@ -194,112 +245,158 @@ the adv packet will be discarded until the memory is restored. */
.ble_sca = CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF, \
.pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \
.pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \
+ .pcm_fsyncshp = CONFIG_BTDM_CTRL_PCM_FSYNCSHP_EFF, \
.hli = BTDM_CTRL_HLI, \
+ .enc_key_sz_min = CONFIG_BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT_EFF, \
.dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \
.ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
+ .ble_llcp_disc_flag = BTDM_BLE_LLCP_DISC_FLAG, \
+ .ble_aa_check = BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED, \
+ .ble_chan_ass_en = BTDM_BLE_CHAN_ASS_EN, \
+ .ble_ping_en = BTDM_BLE_PING_EN, \
.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \
}
#else
+/**
+* @brief Default Bluetooth Controller configuration
+*/
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() {0}; ESP_STATIC_ASSERT(0, "please enable bluetooth in menuconfig to use esp_bt.h");
#endif
/**
- * @brief Controller config options, depend on config mask.
- * Config mask indicate which functions enabled, this means
- * some options or parameters of some functions enabled by config mask.
+ * @brief Bluetooth Controller config options
+ * @note
+ * 1. For parameters configurable through menuconfig, it is recommended to adjust them via the menuconfig interface. Please refer to menuconfig for details on the range and default values.
+ * 2. It is not recommended to modify the values for parameters which are not configurable through menuconfig.
*/
typedef struct {
- /*
- * Following parameters can be configured runtime, when call esp_bt_controller_init()
- */
- uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */
- uint8_t controller_task_prio; /*!< Bluetooth controller task priority */
- uint8_t hci_uart_no; /*!< If use UART1/2 as HCI IO interface, indicate UART number */
- uint32_t hci_uart_baudrate; /*!< If use UART1/2 as HCI IO interface, indicate UART baudrate */
- uint8_t scan_duplicate_mode; /*!< scan duplicate mode */
- uint8_t scan_duplicate_type; /*!< scan duplicate type */
- uint16_t normal_adv_size; /*!< Normal adv size for scan duplicate */
- uint16_t mesh_adv_size; /*!< Mesh adv size for scan duplicate */
- uint16_t send_adv_reserved_size; /*!< Controller minimum memory value */
- uint32_t controller_debug_flag; /*!< Controller debug log flag */
- uint8_t mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
- uint8_t ble_max_conn; /*!< BLE maximum connection numbers */
- uint8_t bt_max_acl_conn; /*!< BR/EDR maximum ACL connection numbers */
- uint8_t bt_sco_datapath; /*!< SCO data path, i.e. HCI or PCM module */
- bool auto_latency; /*!< BLE auto latency, used to enhance classic BT performance */
- bool bt_legacy_auth_vs_evt; /*!< BR/EDR Legacy auth complete event required to protect from BIAS attack */
- /*
- * Following parameters can not be configured runtime when call esp_bt_controller_init()
- * It will be overwrite with a constant value which in menuconfig or from a macro.
- * So, do not modify the value when esp_bt_controller_init()
- */
- uint8_t bt_max_sync_conn; /*!< BR/EDR maximum ACL connection numbers. Effective in menuconfig */
- uint8_t ble_sca; /*!< BLE low power crystal accuracy index */
- uint8_t pcm_role; /*!< PCM role (master & slave)*/
- uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge) */
- bool hli; /*!< Using high level interrupt or not */
- uint16_t dup_list_refresh_period; /*!< Duplicate scan list refresh period */
- bool ble_scan_backoff; /*!< BLE scan backoff */
+ uint16_t controller_task_stack_size; /*!< Bluetooth Controller task stack size in bytes */
+ uint8_t controller_task_prio; /*!< Bluetooth Controller task priority */
+ uint8_t hci_uart_no; /*!< UART number as HCI I/O interface. Configurable in menuconfig.
+ - 1 - URAT 1 (default)
+ - 2 - URAT 2 */
+ uint32_t hci_uart_baudrate; /*!< UART baudrate. Configurable in menuconfig.
+ - Range: 115200 - 921600
+ - Default: 921600 */
+ uint8_t scan_duplicate_mode; /*!< Scan duplicate filtering mode. Configurable in menuconfig.
+ - 0 - Normal scan duplicate filtering mode (default)
+ - 1 - Special scan duplicate filtering mode for BLE Mesh */
+ uint8_t scan_duplicate_type; /*!< Scan duplicate filtering type. If `scan_duplicate_mode` is set to 1, this parameter will be ignored. Configurable in menuconfig.
+ - 0 - Filter scan duplicates by device address only (default)
+ - 1 - Filter scan duplicates by advertising data only, even if they originate from different devices.
+ - 2 - Filter scan duplicated by device address and advertising data. */
+ uint16_t normal_adv_size; /*!< Maximum number of devices in scan duplicate filtering list. Configurable in menuconfig
+ - Range: 10 - 1000
+ - Default: 100 */
+ uint16_t mesh_adv_size; /*!< Maximum number of Mesh advertising packets in scan duplicate filtering list. Configurable in menuconfig
+ - Range: 10 - 1000
+ - Default: 100 */
+ uint16_t send_adv_reserved_size; /*!< Controller minimum memory value in bytes. Internal use only */
+ uint32_t controller_debug_flag; /*!< Controller debug log flag. Internal use only */
+ uint8_t mode; /*!< Controller mode. Configurable in menuconfig
+ - 1 - BLE mode
+ - 2 - Classic Bluetooth mode
+ - 3 - Dual mode
+ - 4 - Others: Invalid */
+ uint8_t ble_max_conn; /*!< Maximum number of BLE connections. Configurable in menuconfig
+ - Range: 1 - 9
+ - Default: 3 */
+ uint8_t bt_max_acl_conn; /*!< Maximum number of BR/EDR ACL connections. Configurable in menuconfig
+ - Range: 1 - 7
+ - Default: 2 */
+ uint8_t bt_sco_datapath; /*!< SCO data path. Configurable in menuconfig
+ - 0 - HCI module (default)
+ - 1 - PCM module */
+ bool auto_latency; /*!< True if BLE auto latency is enabled, used to enhance Classic Bluetooth performance in the Dual mode; false otherwise (default). Configurable in menuconfig */
+ bool bt_legacy_auth_vs_evt; /*!< True if BR/EDR Legacy Authentication Vendor Specific Event is enabled (default in the classic bluetooth or Dual mode), which is required to protect from BIAS attack; false otherwise. Configurable in menuconfig */
+ uint8_t bt_max_sync_conn; /*!< Maximum number of BR/EDR synchronous connections. Configurable in menuconfig
+ - Range: 0 - 3
+ - Default: 0 */
+ uint8_t ble_sca; /*!< BLE low power crystal accuracy index. Configurable in menuconfig
+ - 0 - `BTDM_BLE_DEFAULT_SCA_500PPM`
+ - 1 - `BTDM_BLE_DEFAULT_SCA_250PPM` (default) */
+ uint8_t pcm_role; /*!< PCM role. Configurable in menuconfig
+ - 0 - PCM master (default)
+ - 1 - PCM slave (default) */
+ uint8_t pcm_polar; /*!< PCM polarity (falling clk edge & rising clk edge). Configurable in menuconfig
+ - 0 - Falling Edge (default)
+ - 1 - Rising Edge */
+ uint8_t pcm_fsyncshp; /*!< Physical shape of the PCM Frame Synchronization signal. Configurable in menuconfig
+ - 0 - Stereo Mode (default)
+ - 1 - Mono Mode 1
+ - 2 - Mono Mode 2 */
+ bool hli; /*!< True if using high-level (level 4) interrupt (default); false otherwise. Configurable in menuconfig */
+ uint8_t enc_key_sz_min; /*!< Minimum size of the encryption key
+ - Range: 7 - 16
+ - Default: 7 */
+ uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig
+ - Range: 0 - 100 seconds
+ - Default: 0 second */
+ bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise (default). Configurable in menuconfig */
+ uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
+ - The Controller does not disconnect after Instant Passed (0x28) by default. */
+ bool ble_aa_check; /*!< True if adds a verification step for the Access Address within the `CONNECT_IND` PDU; false otherwise (default). Configurable in menuconfig */
+ uint8_t ble_chan_ass_en; /*!< True if BLE channel assessment is enabled (default), false otherwise. Configurable in menuconfig */
+ uint8_t ble_ping_en; /*!< True if BLE ping procedure is enabled (default), false otherwise. Configurable in menuconfig */
uint32_t magic; /*!< Magic number */
} esp_bt_controller_config_t;
/**
- * @brief Bluetooth controller enable/disable/initialised/de-initialised status
+ * @brief Bluetooth Controller status
*/
typedef enum {
- ESP_BT_CONTROLLER_STATUS_IDLE = 0,
- ESP_BT_CONTROLLER_STATUS_INITED,
- ESP_BT_CONTROLLER_STATUS_ENABLED,
- ESP_BT_CONTROLLER_STATUS_NUM,
+ ESP_BT_CONTROLLER_STATUS_IDLE = 0, /*!< The Controller is not initialized or has been de-initialized. */
+ ESP_BT_CONTROLLER_STATUS_INITED, /*!< The Controller has been initialized, but not enabled or has been disabled. */
+ ESP_BT_CONTROLLER_STATUS_ENABLED, /*!< The Controller has been initialized and enabled. */
+ ESP_BT_CONTROLLER_STATUS_NUM, /*!< Number of Controller statuses */
} esp_bt_controller_status_t;
/**
- * @brief BLE tx power type
- * ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed.
- * when disconnect, the correspond TX power is not effected.
- * ESP_BLE_PWR_TYPE_ADV : for advertising/scan response.
- * ESP_BLE_PWR_TYPE_SCAN : for scan.
- * ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value.
- * if neither in scan mode nor in adv mode, it will use this default value.
- * If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9.
+ * @brief BLE TX power type
+ * @note
+ * 1. The connection TX power can only be set after the connection is established.
+ * After disconnecting, the corresponding TX power will not be affected.
+ * 2. `ESP_BLE_PWR_TYPE_DEFAULT` can be used to set the TX power for power types that have not been set before.
+ * It will not affect the TX power values which have been set for the ADV/SCAN/CONN0-8 power types.
+ * 3. If none of power type is set, the system will use `ESP_PWR_LVL_P3` as default for all power types.
*/
typedef enum {
- ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
- ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
- ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
- ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */
- ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */
- ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */
- ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
- ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
- ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
- ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
- ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
- ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
- ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
+ ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< TX power for connection handle 0 */
+ ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< TX power for connection handle 1 */
+ ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< TX power for connection handle 2 */
+ ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< TX power for connection handle 3 */
+ ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< TX power for connection handle 4 */
+ ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< TX power for connection handle 5 */
+ ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< TX power for connection handle 6 */
+ ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< TX power for connection handle 7 */
+ ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< TX power for connection handle 8 */
+ ESP_BLE_PWR_TYPE_ADV = 9, /*!< TX power for advertising */
+ ESP_BLE_PWR_TYPE_SCAN = 10, /*!< TX power for scan */
+ ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< Default TX power type, which can be used to set the TX power for power types that have not been set before.*/
+ ESP_BLE_PWR_TYPE_NUM = 12, /*!< Number of types */
} esp_ble_power_type_t;
/**
- * @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
+ * @brief Bluetooth TX power level (index). Each index corresponds to a specific power value in dBm.
*/
typedef enum {
- ESP_PWR_LVL_N12 = 0, /*!< Corresponding to -12dbm */
- ESP_PWR_LVL_N9 = 1, /*!< Corresponding to -9dbm */
- ESP_PWR_LVL_N6 = 2, /*!< Corresponding to -6dbm */
- ESP_PWR_LVL_N3 = 3, /*!< Corresponding to -3dbm */
- ESP_PWR_LVL_N0 = 4, /*!< Corresponding to 0dbm */
- ESP_PWR_LVL_P3 = 5, /*!< Corresponding to +3dbm */
- ESP_PWR_LVL_P6 = 6, /*!< Corresponding to +6dbm */
- ESP_PWR_LVL_P9 = 7, /*!< Corresponding to +9dbm */
- ESP_PWR_LVL_N14 = ESP_PWR_LVL_N12, /*!< Backward compatibility! Setting to -14dbm will actually result to -12dbm */
- ESP_PWR_LVL_N11 = ESP_PWR_LVL_N9, /*!< Backward compatibility! Setting to -11dbm will actually result to -9dbm */
- ESP_PWR_LVL_N8 = ESP_PWR_LVL_N6, /*!< Backward compatibility! Setting to -8dbm will actually result to -6dbm */
- ESP_PWR_LVL_N5 = ESP_PWR_LVL_N3, /*!< Backward compatibility! Setting to -5dbm will actually result to -3dbm */
- ESP_PWR_LVL_N2 = ESP_PWR_LVL_N0, /*!< Backward compatibility! Setting to -2dbm will actually result to 0dbm */
- ESP_PWR_LVL_P1 = ESP_PWR_LVL_P3, /*!< Backward compatibility! Setting to +1dbm will actually result to +3dbm */
- ESP_PWR_LVL_P4 = ESP_PWR_LVL_P6, /*!< Backward compatibility! Setting to +4dbm will actually result to +6dbm */
- ESP_PWR_LVL_P7 = ESP_PWR_LVL_P9, /*!< Backward compatibility! Setting to +7dbm will actually result to +9dbm */
+ ESP_PWR_LVL_N12 = 0, /*!< Corresponding to -12 dBm */
+ ESP_PWR_LVL_N9 = 1, /*!< Corresponding to -9 dBm */
+ ESP_PWR_LVL_N6 = 2, /*!< Corresponding to -6 dBm */
+ ESP_PWR_LVL_N3 = 3, /*!< Corresponding to -3 dBm */
+ ESP_PWR_LVL_N0 = 4, /*!< Corresponding to 0 dBm */
+ ESP_PWR_LVL_P3 = 5, /*!< Corresponding to +3 dBm */
+ ESP_PWR_LVL_P6 = 6, /*!< Corresponding to +6 dBm */
+ ESP_PWR_LVL_P9 = 7, /*!< Corresponding to +9 dBm */
+ ESP_PWR_LVL_N14 = ESP_PWR_LVL_N12, /*!< Backward compatibility! Setting to -14 dBm will actually result in -12 dBm */
+ ESP_PWR_LVL_N11 = ESP_PWR_LVL_N9, /*!< Backward compatibility! Setting to -11 dBm will actually result in -9 dBm */
+ ESP_PWR_LVL_N8 = ESP_PWR_LVL_N6, /*!< Backward compatibility! Setting to -8 dBm will actually result in -6 dBm */
+ ESP_PWR_LVL_N5 = ESP_PWR_LVL_N3, /*!< Backward compatibility! Setting to -5 dBm will actually result in -3 dBm */
+ ESP_PWR_LVL_N2 = ESP_PWR_LVL_N0, /*!< Backward compatibility! Setting to -2 dBm will actually result in 0 dBm */
+ ESP_PWR_LVL_P1 = ESP_PWR_LVL_P3, /*!< Backward compatibility! Setting to +1 dBm will actually result in +3 dBm */
+ ESP_PWR_LVL_P4 = ESP_PWR_LVL_P6, /*!< Backward compatibility! Setting to +4 dBm will actually result in +6 dBm */
+ ESP_PWR_LVL_P7 = ESP_PWR_LVL_P9, /*!< Backward compatibility! Setting to +7 dBm will actually result in +9 dBm */
} esp_power_level_t;
/**
@@ -311,245 +408,334 @@ typedef enum {
} esp_sco_data_path_t;
/**
- * @brief Set BLE TX power
- * Connection Tx power should only be set after connection created.
- * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
- * @param power_level: Power level(index) corresponding to absolute value(dbm)
- * @return ESP_OK - success, other - failed
- */
-esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
-
-/**
- * @brief Get BLE TX power
- * Connection Tx power should only be get after connection created.
- * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
- * @return >= 0 - Power level, < 0 - Invalid
- */
-esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
-
-/**
- * @brief Set BR/EDR TX power
- * BR/EDR power control will use the power in range of minimum value and maximum value.
- * The power level will effect the global BR/EDR TX power, such inquire, page, connection and so on.
- * Please call the function after esp_bt_controller_enable and before any function which cause RF do TX.
- * So you can call the function before doing discovery, profile init and so on.
- * For example, if you want BR/EDR use the new TX power to do inquire, you should call
- * this function before inquire. Another word, If call this function when BR/EDR is in inquire(ING),
- * please do inquire again after call this function.
- * Default minimum power level is ESP_PWR_LVL_N0, and maximum power level is ESP_PWR_LVL_P3.
- * @param min_power_level: The minimum power level
- * @param max_power_level: The maximum power level
- * @return ESP_OK - success, other - failed
- */
-esp_err_t esp_bredr_tx_power_set(esp_power_level_t min_power_level, esp_power_level_t max_power_level);
-
-/**
- * @brief Get BR/EDR TX power
- * If the argument is not NULL, then store the corresponding value.
- * @param min_power_level: The minimum power level
- * @param max_power_level: The maximum power level
- * @return ESP_OK - success, other - failed
- */
-esp_err_t esp_bredr_tx_power_get(esp_power_level_t *min_power_level, esp_power_level_t *max_power_level);
-
-/**
- * @brief Set default SCO data path
- * Should be called after controller is enabled, and before (e)SCO link is established
- * @param data_path: SCO data path
- * @return ESP_OK - success, other - failed
+ * @brief Bluetooth sleep clock
*/
-esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path);
+typedef enum {
+ ESP_BT_SLEEP_CLOCK_NONE = 0, /*!< Sleep clock not configured */
+ ESP_BT_SLEEP_CLOCK_MAIN_XTAL = 1, /*!< SoC main crystal */
+ ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL = 2, /*!< External 32.768kHz crystal/oscillator */
+} esp_bt_sleep_clock_t;
/**
- * @brief Initialize BT controller to allocate task and other resource.
- * This function should be called only once, before any other BT functions are called.
- * @param cfg: Initial configuration of BT controller. Different from previous version, there's a mode and some
- * connection configuration in "cfg" to configure controller work mode and allocate the resource which is needed.
- * @return ESP_OK - success, other - failed
+ * @brief Initialize the Bluetooth Controller to allocate tasks and other resources
+ *
+ * @note This function should be called only once, before any other Bluetooth functions.
+ *
+ * @param[in] cfg Initial Bluetooth Controller configuration
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_INVALID_ARG: Invalid arguments
+ * - ESP_ERR_NO_MEM: Out of memory
*/
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
/**
- * @brief De-initialize BT controller to free resource and delete task.
- * You should stop advertising and scanning, as well as
- * disconnect all existing connections before de-initializing BT controller.
+ * @brief De-initialize Bluetooth Controller to free resources and delete tasks
*
- * This function should be called only once, after any other BT functions are called.
- * @return ESP_OK - success, other - failed
+ * @note
+ * 1. You should stop advertising and scanning, and disconnect all existing connections before de-initializing Bluetooth Controller.
+ * 2. This function should be called after `esp_bt_controller_disable` if the Controller was enabled before.
+ * 3. This function should be called only once, after any other Bluetooth functions.
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
*/
esp_err_t esp_bt_controller_deinit(void);
/**
- * @brief Enable BT controller.
- * Due to a known issue, you cannot call esp_bt_controller_enable() a second time
- * to change the controller mode dynamically. To change controller mode, call
- * esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
- * @param mode : the mode(BLE/BT/BTDM) to enable. For compatible of API, retain this argument. This mode must be
- * equal as the mode in "cfg" of esp_bt_controller_init().
- * @return ESP_OK - success, other - failed
+ * @brief Enable Bluetooth Controller
+ *
+ * @note
+ * 1. Bluetooth Controller cannot be enabled in `ESP_BT_CONTROLLER_STATUS_IDLE` status. It has to be initialized first.
+ * 2. Due to a known issue, you cannot call `esp_bt_controller_enable()` for the second time
+ * to change the Controller mode dynamically. To change the Controller mode, call
+ * `esp_bt_controller_disable()` and then call `esp_bt_controller_enable()` with the new mode.
+ *
+ * @param[in] mode The Bluetooth Controller mode (BLE/Classic Bluetooth/BTDM) to enable
+ *
+ * For API compatibility, retain this argument. This mode must match the mode specified in the `cfg` of `esp_bt_controller_init()`.
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_INVALID_ARG: Invalid arguments
*/
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
/**
- * @brief Disable BT controller
- * @return ESP_OK - success, other - failed
+ * @brief Disable Bluetooth Controller
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
*/
esp_err_t esp_bt_controller_disable(void);
/**
- * @brief Get BT controller is initialised/de-initialised/enabled/disabled
- * @return status value
+ * @brief Get Bluetooth Controller status
+ *
+ * @return
+ * - ESP_BT_CONTROLLER_STATUS_IDLE: The Controller is not initialized or has been de-initialized.
+ * - ESP_BT_CONTROLLER_STATUS_INITED: The Controller has been initialized, but not enabled or has been disabled.
+ * - ESP_BT_CONTROLLER_STATUS_ENABLED: The Controller has been initialized and enabled.
*/
esp_bt_controller_status_t esp_bt_controller_get_status(void);
-/** @brief esp_vhci_host_callback
- * used for vhci call host function to notify what host need to do
+/**
+ * @brief Release the Controller memory as per the mode
+ *
+ * This function releases the BSS, data and other sections of the Controller to heap. The total size is about 70 KB.
+ *
+ * @note
+ * 1. This function is optional and should be called only if you want to free up memory for other components.
+ * 2. This function should only be called when the Controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status.
+ * 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
+ * 4. If your firmware will upgrade the Bluetooth Controller mode later (such as switching from BLE to Classic Bluetooth or from disabled to enabled), then do not call this function.
+ *
+ * If you never intend to use Bluetooth in a current boot-up cycle, calling `esp_bt_controller_mem_release(ESP_BT_MODE_BTDM)` could release the BSS and data consumed by both Classic Bluetooth and BLE Controller to heap.
+ *
+ * If you intend to use BLE only, calling `esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)` could release the BSS and data consumed by Classic Bluetooth Controller. You can then continue using BLE.
+ *
+ * If you intend to use Classic Bluetooth only, calling `esp_bt_controller_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE Controller. You can then continue using Classic Bluetooth.
+ *
+ *
+ * @param[in] mode The Bluetooth Controller mode
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_FOUND: Requested resource not found
*/
-typedef struct esp_vhci_host_callback {
- void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */
- int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/
-} esp_vhci_host_callback_t;
+esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
-/** @brief esp_vhci_host_check_send_available
- * used for check actively if the host can send packet to controller or not.
- * @return true for ready to send, false means cannot send packet
+/** @brief Release the Controller memory, BSS and data section of the Classic Bluetooth/BLE Host stack as per the mode
+ *
+ * @note
+ * 1. This function is optional and should be called only if you want to free up memory for other components.
+ * 2. This function should only be called when the Controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status.
+ * 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
+ * 4. If your firmware will upgrade the Bluetooth Controller mode later (such as switching from BLE to Classic Bluetooth or from disabled to enabled), then do not call this function.
+ *
+ * This function first releases Controller memory by internally calling `esp_bt_controller_mem_release()`, then releases Host memory.
+ *
+ * If you never intend to use Bluetooth in a current boot-up cycle, calling `esp_bt_mem_release(ESP_BT_MODE_BTDM)` could release the BSS and data consumed by both Classic Bluetooth and BLE stack to heap.
+ *
+ * If you intend to use BLE only, calling `esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT)` could release the BSS and data consumed by Classic Bluetooth. You can then continue using BLE.
+ *
+ * If you intend to use Classic Bluetooth only, calling `esp_bt_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE. You can then continue using Classic Bluetooth.
+ *
+ * For example, if you only use Bluetooth for setting the Wi-Fi configuration, and do not use Bluetooth in the rest of the product operation,
+ * after receiving the Wi-Fi configuration, you can disable/de-init Bluetooth and release its memory.
+ * Below is the sequence of APIs to be called for such scenarios:
+ *
+ * esp_bluedroid_disable();
+ * esp_bluedroid_deinit();
+ * esp_bt_controller_disable();
+ * esp_bt_controller_deinit();
+ * esp_bt_mem_release(ESP_BT_MODE_BTDM);
+ *
+ * @param[in] mode The Bluetooth Controller mode
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_FOUND: Requested resource not found
*/
-bool esp_vhci_host_check_send_available(void);
+esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
-/** @brief esp_vhci_host_send_packet
- * host send packet to controller
+/**
+ * @brief Enable Bluetooth modem sleep
+ *
+ * There are currently two options for Bluetooth modem sleep: ORIG mode and EVED mode. The latter is intended for BLE only.
+ * The modem sleep mode could be configured in menuconfig.
*
- * Should not call this function from within a critical section
- * or when the scheduler is suspended.
+ * In ORIG mode, if there is no event to process, the Bluetooth Controller will periodically switch off some components and pause operation, then wake up according to the scheduled interval and resume work.
+ * It can also wakeup earlier upon external request using function `esp_bt_controller_wakeup_request()`.
*
- * @param data the packet point
- * @param len the packet length
+ * @note This function shall not be invoked before `esp_bt_controller_enable()`.
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_SUPPORTED: Operation or feature not supported
*/
-void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
+esp_err_t esp_bt_sleep_enable(void);
-/** @brief esp_vhci_host_register_callback
- * register the vhci reference callback
- * struct defined by vhci_host_callback structure.
- * @param callback esp_vhci_host_callback type variable
- * @return ESP_OK - success, ESP_FAIL - failed
+/**
+ * @brief Disable Bluetooth modem sleep
+ *
+ * @note
+ * 1. Bluetooth Controller will not be allowed to enter modem sleep after calling this function.
+ * 2. In ORIG modem sleep mode, calling this function may not immediately wake up the Controller if it is currently dormant.
+ * In this case, `esp_bt_controller_wakeup_request()` can be used to shorten the wake-up time.
+ * 3. This function shall not be invoked before `esp_bt_controller_enable()`.
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_SUPPORTED: The modem sleep mode is not supported
*/
-esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
+esp_err_t esp_bt_sleep_disable(void);
-/** @brief esp_bt_controller_mem_release
- * release the controller memory as per the mode
+/**
+ * @brief Set BLE TX power
*
- * This function releases the BSS, data and other sections of the controller to heap. The total size is about 70k bytes.
+ * @note Connection TX power should only be set after the connection is established.
*
- * esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init()
- * or after esp_bt_controller_deinit().
+ * @param[in] power_type The type of TX power. It could be Advertising, Connection, Default, etc.
+ * @param[in] power_level Power level (index) corresponding to the absolute value (dBm)
*
- * Note that once BT controller memory is released, the process cannot be reversed. It means you cannot use the bluetooth
- * mode which you have released by this function.
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_ARG: Invalid argument
+ */
+esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
+
+/**
+ * @brief Get BLE TX power
*
- * If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
- * then do not call this function.
+ * @note Connection TX power should only be retrieved after the connection is established.
*
- * If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call
- * esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialization time to free unused BT Classic memory.
+ * @param[in] power_type The type of TX power. It could be Advertising/Connection/Default and etc.
*
- * If the mode is ESP_BT_MODE_BTDM, then it may be useful to call API esp_bt_mem_release(ESP_BT_MODE_BTDM) instead,
- * which internally calls esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) and additionally releases the BSS and data
- * consumed by the BT/BLE host stack to heap. For more details about usage please refer to the documentation of
- * esp_bt_mem_release() function
+ * @return
+ * - Power level
*
- * @param mode : the mode want to release memory
- * @return ESP_OK - success, other - failed
*/
-esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
+esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
-/** @brief esp_bt_mem_release
- * release controller memory and BSS and data section of the BT/BLE host stack as per the mode
- *
- * This function first releases controller memory by internally calling esp_bt_controller_mem_release().
- * Additionally, if the mode is set to ESP_BT_MODE_BTDM, it also releases the BSS and data consumed by the BT/BLE host stack to heap
+/**
+ * @brief Manually clear the BLE scan duplicate list
*
- * Note that once BT memory is released, the process cannot be reversed. It means you cannot use the bluetooth
- * mode which you have released by this function.
+ * @note
+ * 1. This function name is incorrectly spelled, it will be fixed in release 5.x version.
+ * 2. The scan duplicate list will be automatically cleared when the maximum amount of devices in the filter is reached.
+ * The amount of devices in the filter can be configured in menuconfig.
*
- * If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
- * then do not call this function.
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ */
+esp_err_t esp_ble_scan_duplicate_list_flush(void);
+esp_err_t esp_ble_scan_dupilcate_list_flush(void);
+
+/**
+ * @brief Set BR/EDR TX power
*
- * If you never intend to use bluetooth in a current boot-up cycle, you can call esp_bt_mem_release(ESP_BT_MODE_BTDM)
- * before esp_bt_controller_init or after esp_bt_controller_deinit.
+ * BR/EDR power control will use the power within the range of minimum value and maximum value.
+ * The power level will affect the global BR/EDR TX power for operations such as inquiry, page, and connection.
*
- * For example, if a user only uses bluetooth for setting the WiFi configuration, and does not use bluetooth in the rest of the product operation".
- * In such cases, after receiving the WiFi configuration, you can disable/deinit bluetooth and release its memory.
- * Below is the sequence of APIs to be called for such scenarios:
+ * @note
+ * 1. Please call this function after `esp_bt_controller_enable()` and before any functions that cause RF transmission,
+ * such as performing discovery, profile initialization, and so on.
+ * 2. For BR/EDR to use the new TX power for inquiry, call this function before starting an inquiry.
+ * If BR/EDR is already inquiring, restart the inquiry after calling this function.
*
- * esp_bluedroid_disable();
- * esp_bluedroid_deinit();
- * esp_bt_controller_disable();
- * esp_bt_controller_deinit();
- * esp_bt_mem_release(ESP_BT_MODE_BTDM);
+ * @param[in] min_power_level The minimum power level. The default value is `ESP_PWR_LVL_N0`.
+ * @param[in] max_power_level The maximum power level. The default value is `ESP_PWR_LVL_P3`.
*
- * @note In case of NimBLE host, to release BSS and data memory to heap, the mode needs to be
- * set to ESP_BT_MODE_BTDM as controller is dual mode.
- * @param mode : the mode whose memory is to be released
- * @return ESP_OK - success, other - failed
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_ARG: Invalid argument
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
*/
-esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
+esp_err_t esp_bredr_tx_power_set(esp_power_level_t min_power_level, esp_power_level_t max_power_level);
/**
- * @brief enable bluetooth to enter modem sleep
+ * @brief Get BR/EDR TX power
*
- * Note that this function shall not be invoked before esp_bt_controller_enable()
+ * The corresponding power levels will be stored into the arguments.
*
- * There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only.
+ * @param[out] min_power_level Pointer to store the minimum power level
+ * @param[out] max_power_level The maximum power level
*
- * For ORIG mode:
- * Bluetooth modem sleep is enabled in controller start up by default if CONFIG_CTRL_BTDM_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request".
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_ARG: Invalid argument
+ */
+esp_err_t esp_bredr_tx_power_get(esp_power_level_t *min_power_level, esp_power_level_t *max_power_level);
+
+/**
+ * @brief Set BR/EDR default SCO data path
+ *
+ * @note This function should be called after the Controller is enabled, and before (e)SCO link is established.
+ *
+ * @param[in] data_path SCO data path
*
* @return
- * - ESP_OK : success
- * - other : failed
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
*/
-esp_err_t esp_bt_sleep_enable(void);
+esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path);
+/**
+ * @brief Virtual HCI (VHCI) callback functions to notify the Host on the next operation
+ */
+typedef struct esp_vhci_host_callback {
+ void (*notify_host_send_available)(void); /*!< Callback to notify the Host that the Controller is ready to receive the HCI data */
+ int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< Callback to notify the Host that the Controller has the HCI data to send */
+} esp_vhci_host_callback_t;
/**
- * @brief disable bluetooth modem sleep
- *
- * Note that this function shall not be invoked before esp_bt_controller_enable()
+ * @brief Check whether the Controller is ready to receive the HCI data from the Host
*
- * If esp_bt_sleep_disable() is called, bluetooth controller will not be allowed to enter modem sleep;
+ * If the return value is True, the Host can send the HCI data to the Controller.
*
- * If ORIG modem sleep mode is in use, if this function is called, bluetooth controller may not immediately wake up if it is dormant then.
- * In this case, esp_bt_controller_wakeup_request() can be used to shorten the time for wakeup.
+ * @note This function should be called before each `esp_vhci_host_send_packet()`.
*
* @return
- * - ESP_OK : success
- * - other : failed
+ * True if the Controller is ready to receive the HCI data; false otherwise
*/
-esp_err_t esp_bt_sleep_disable(void);
+bool esp_vhci_host_check_send_available(void);
/**
- * @brief Manually clear scan duplicate list
+ * @brief Send the HCI data to the Controller
*
- * Note that scan duplicate list will be automatically cleared when the maximum amount of device in the filter is reached
- * the amount of device in the filter can be configured in menuconfig.
+ * @note
+ * 1. This function shall not be called within a critical section or when the scheduler is suspended.
+ * 2. This function should be called only if `esp_vhci_host_check_send_available()` returns True.
+ *
+ * @param[in] data Pointer to the HCI data
+ * @param[in] len The HCI data length
+ */
+void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
+
+/**
+ * @brief Register the VHCI callback functions defined in `esp_vhci_host_callback` structure
*
- * @note This function name is incorrectly spelled, it will be fixed in release 5.x version.
+ * @param[in] callback `esp_vhci_host_callback` type variable
*
* @return
- * - ESP_OK : success
- * - other : failed
+ * - ESP_OK: Success
+ * - ESP_FAIL: Failure
*/
-esp_err_t esp_ble_scan_dupilcate_list_flush(void);
+esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
/**
- * @brief bt Wi-Fi power domain power on
+ * @brief Get the Bluetooth module sleep clock source.
+ *
+ * @note This function should be called after `esp_bt_controller_init()`
+ *
+ * @return
+ * - Clock source used in Bluetooth low power mode
*/
-void esp_wifi_bt_power_domain_on(void);
+esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void);
/**
- * @brief bt Wi-Fi power domain power off
+ * @brief Set the Bluetooth module sleep clock source.
+ *
+ * @note This function should be called before `esp_bt_controller_init()`
+ *
+ * @param[in] lpclk Bluetooth sleep clock source
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_ARG: Invalid argument
*/
-void esp_wifi_bt_power_domain_off(void);
+esp_err_t esp_bt_set_lpclk_src(esp_bt_sleep_clock_t lpclk);
#ifdef __cplusplus
}
diff --git a/lib/bt/include/esp32/include/esp_bt_vs.h b/lib/bt/include/esp32/include/esp_bt_vs.h
new file mode 100644
index 00000000..e8472ab5
--- /dev/null
+++ b/lib/bt/include/esp32/include/esp_bt_vs.h
@@ -0,0 +1,252 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include "sdkconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//
+// @brief HCI VS Commands for Espressif's Bluetooth Host
+//
+// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth Host (Bluedroid Host or NimBLE Host).
+// If you are using a different host or HCI UART, these commands will not be enabled, unless the init function is called from the application.
+// Note, these functions as well as these additional vendor-specific HCI commands are intended for Espressif's Bluetooth Host use only.
+// Application developers should not call the init functions in their applications.
+//
+
+/**
+ * @brief Test vendor HCI feature (OCF: 0x0081)
+ *
+ * The Controller return the value in command
+ *
+ * @note The init function is `bt_stack_enableEchoVsCmd(true)`
+ */
+#define ESP_BT_VS_COMMON_ECHO_OCF (0x0081)
+
+/**
+* @brief echo test cmd parameters
+*/
+struct bt_hci_vs_common_echo {
+ uint8_t echo; /*!< echo data */
+};
+
+/**
+ * @brief Set/Clear coexistence status (OCF: 0x0082)
+ *
+ * @note The init function is `bt_stack_enableCoexVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_COEX_STATUS_OCF (0x0082)
+/**
+* @brief Set/Clear coexistence status cmd parameters
+*/
+struct bt_hci_vs_set_coex_status {
+ uint8_t type; /*!< WIFI, BLE or BT */
+ uint8_t op; /*!< clear or set status */
+ uint8_t status; /*!< WIFI, BLE or BT status */
+};
+
+/**
+ * @brief Config scanning duplicate exceptional list (OCF: 0x0108)
+ *
+ * @note The init function is `advFilter_stack_enableDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF (0x0108)
+/**
+* @brief Update exception list cmd parameters
+*/
+struct bt_hci_vs_update_exc_list {
+ uint8_t subcode; /*!< Add, remove or clear exception list */
+ uint32_t type; /*!< device type */
+ uint8_t device_info[6]; /*!< device information */
+};
+
+/**
+ * @brief Enable/disable advertising report flow control (OCF: 0x0109)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
+
+/**
+* @brief Init ADV flow control cmd parameters
+*/
+struct bt_hci_vs_init_adv_flow_ctrl {
+ uint8_t enable; /*!< Enable ADV flow control */
+ uint16_t num; /*!< ADV buffer maximum value */
+ uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
+};
+
+/**
+ * @brief Update the number of advertising report flow control (OCF: 0x010A)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
+/**
+* @brief Update ADV flow control cmd parameters
+*/
+struct bt_hci_vs_update_adv_flow_ctrl {
+ uint16_t num; /*!< The number of ADV report processed */
+};
+
+/**
+ * @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
+ *
+ * @note The init function is `adv_stack_enableClearLegacyAdvVsCmd(true)`
+ */
+#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
+/**
+* @brief Clear legacy ADV cmd parameters
+*/
+struct bt_hci_vs_ble_clr_legacy_adv {
+ // no parameters
+};
+
+/**
+ * @brief Set Classic Bluetooth minimum encryption key size (OCF: 0x0182)
+ *
+ * @note The init function is `bt_stack_enableSecCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_MIN_ENC_KEY_SIZE_OCF (0x0182)
+/**
+* @brief Set bt minimum encryption key size cmd parameters
+*/
+struct bt_hci_vs_set_min_enc_key_size {
+ uint8_t size; /*!< the minimum encryption key size */
+};
+
+//
+// @brief HCI VS Events for Espressif's Bluetooth Host
+//
+// @note The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
+/**
+* @brief ADV lost event parameters
+*/
+struct bt_hci_vs_le_adv_lost_evt {
+ uint32_t nb_lost; /*!< The number of ADV report discarded */
+};
+
+/**
+ * @brief This event indicates legacy authentication is completed by remote device (EVTCODE: 0xFF, SUBCODE: 0x03)
+ *
+ * @note The init function is `bt_stack_enableSecCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_LEGACY_REM_AUTH_EVT_SUBCODE (0x03)
+/**
+* @brief legacy remote auth event parameters
+*/
+struct bt_hci_vs_legacy_rem_auth_evt {
+ uint16_t conhdl; /*!< connection handle */
+};
+
+//
+// @brief HCI VS Commands for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging commands are implemented in Bluetooth controller pre-compiled libraries.
+// These commands are not linked into the application binary, unless the specific enabling function is called from the application.
+// They are intended for Espressif's internal use only. Application developers **should not** call the specific enabling function in their applications.
+//
+
+//
+// @brief OCF for vendor specific BLE internal test command
+//
+// @note The init function is `esp_ble_internalTestFeaturesEnable(true)`
+//
+#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
+ #define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
+ #define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
+ #define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
+ #define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
+ #define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
+ #define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
+
+/**
+ * @note The init function is `bt_stack_enablePktCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_WR_DM1_ENABLE_OCF (0x0181)
+
+/**
+ * @note The init function is `bt_stack_enableClkCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_CLK_UPDATE_OCF (0x0183)
+
+/**
+ * @note The init function is `bt_stack_enableAfhVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_AFH_OCF (0x0187)
+
+/**
+ * @note The init function is `bt_stack_enableBasicVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_EVT_MASK_OCF (0x0188)
+
+/**
+ * @note The init function is `bt_stack_enableAfhVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_AFH_REPORTING_MODE_OCF (0x0189)
+
+/**
+ * @note The init function is `bt_stack_enableAfhVsCmd(true)`
+ */
+#define ESP_BT_VS_MASK_RMT_CHANNEL_CLASSIFICATION_OCF (0x018a)
+
+/**
+ * @note The init function is `bt_stack_enableRateCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_WR_AUTO_RATE_INIT_OCF (0x018b)
+
+//
+// @brief HCI VS Events for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging events are implemented in Bluetooth controller pre-compiled libraries.
+// These events are not linked into the application binary, unless the specific enabling function is called from the application.
+// Application developers **should not** call the specific enabling function in their applications.
+//
+
+/**
+ * @note The init function is `bt_stack_enableAfhVsCmd(true)`
+ */
+#define ESP_BT_VS_AFH_CHG_EVT_SUBCODE (0x05)
+
+/**
+ * @note The init function is `bt_stack_enableAfhVsCmd(true)`
+ */
+#define ESP_BT_VS_CH_CLASSIFICATION_EVT_SUBCODE (0x06)
+
+/**
+ * @note The init function is `bt_stack_enableAfhVsCmd(true)`
+ */
+#define ESP_BT_VS_CH_CLASSIFICATION_REPORTING_MODE_EVT_SUBCODE (0x07)
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/lib/bt/include/esp32c2/include/esp_bt.h b/lib/bt/include/esp32c2/include/esp_bt.h
index ee1bede7..de161b08 100644
--- a/lib/bt/include/esp32c2/include/esp_bt.h
+++ b/lib/bt/include/esp32c2/include/esp_bt.h
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,6 +16,7 @@
#include "nimble/nimble_npl.h"
#include "../../../../controller/esp32c2/esp_bt_cfg.h"
#include "hal/efuse_hal.h"
+#include "esp_private/esp_modem_clock.h"
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#include "driver/uart.h"
@@ -72,26 +73,26 @@ typedef enum {
} esp_ble_power_type_t;
/**
- * @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
+ * @brief Bluetooth TX power level(index), it's just a index corresponding to power(dBm).
*/
typedef enum {
- ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24dbm */
- ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21dbm */
- ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18dbm */
- ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15dbm */
- ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12dbm */
- ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9dbm */
- ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6dbm */
- ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3dbm */
- ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0dbm */
- ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3dbm */
- ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6dbm */
- ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9dbm */
- ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12dbm */
- ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15dbm */
- ESP_PWR_LVL_P18 = 14, /*!< Corresponding to +18dbm */
- ESP_PWR_LVL_P20 = 15, /*!< Corresponding to +20dbm */
- ESP_PWR_LVL_P21 = 15, /*!< Corresponding to +20dbm, this enum variable has been deprecated */
+ ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24 dBm */
+ ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21 dBm */
+ ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18 dBm */
+ ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15 dBm */
+ ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12 dBm */
+ ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9 dBm */
+ ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6 dBm */
+ ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3 dBm */
+ ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0 dBm */
+ ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3 dBm */
+ ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6 dBm */
+ ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9 dBm */
+ ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12 dBm */
+ ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15 dBm */
+ ESP_PWR_LVL_P18 = 14, /*!< Corresponding to +18 dBm */
+ ESP_PWR_LVL_P20 = 15, /*!< Corresponding to +20 dBm */
+ ESP_PWR_LVL_P21 = 15, /*!< Corresponding to +20 dBm, this enum variable has been deprecated */
ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
} esp_power_level_t;
@@ -127,7 +128,7 @@ typedef struct {
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
- * @param power_level: Power level(index) corresponding to absolute value(dbm)
+ * @param power_level: Power level(index) corresponding to absolute value(dBm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
@@ -145,7 +146,7 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
* Connection Tx power should only be set after connection created.
* @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types.
- * @param power_level: Power level(index) corresponding to absolute value(dbm)
+ * @param power_level: Power level(index) corresponding to absolute value(dBm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle, esp_power_level_t power_level);
@@ -166,7 +167,7 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
*/
uint8_t esp_ble_get_chip_rev_version(void);
-#define CONFIG_VERSION 0x20231124
+#define CONFIG_VERSION 0x20250310
#define CONFIG_MAGIC 0x5A5AA5A5
/**
@@ -226,6 +227,11 @@ typedef struct {
uint8_t version_num; /*!< Version number */
uint8_t ignore_wl_for_direct_adv; /*!< Ignore the white list for directed advertising */
uint8_t csa2_select; /*!< Select CSA#2 */
+ uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */
+ uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
+ - The Controller does not disconnect after Instant Passed (0x28) by default. */
+ uint16_t scan_backoff_upperlimitmax; /*!< The value of upperlimitmax is 2^n, The maximum value is 256 */
+ uint8_t vhci_enabled; /*!< VHCI mode is enabled */
uint32_t config_magic; /*!< Configuration magic value */
} esp_bt_controller_config_t;
@@ -262,13 +268,6 @@ typedef struct {
.controller_run_cpu = 0, \
.enable_qa_test = RUN_QA_TEST, \
.enable_bqb_test = RUN_BQB_TEST, \
- .enable_uart_hci = HCI_UART_EN, \
- .ble_hci_uart_port = DEFAULT_BT_LE_HCI_UART_PORT, \
- .ble_hci_uart_baud = DEFAULT_BT_LE_HCI_UART_BAUD, \
- .ble_hci_uart_data_bits = DEFAULT_BT_LE_HCI_UART_DATA_BITS, \
- .ble_hci_uart_stop_bits = DEFAULT_BT_LE_HCI_UART_STOP_BITS, \
- .ble_hci_uart_flow_ctrl = DEFAULT_BT_LE_HCI_UART_FLOW_CTRL, \
- .ble_hci_uart_uart_parity = DEFAULT_BT_LE_HCI_UART_PARITY, \
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
.sleep_en = NIMBLE_SLEEP_ENABLE, \
@@ -279,6 +278,10 @@ typedef struct {
.version_num = esp_ble_get_chip_rev_version(), \
.ignore_wl_for_direct_adv = 0, \
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
+ .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
+ .ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
+ .scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
+ .vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \
.config_magic = CONFIG_MAGIC, \
}
@@ -435,6 +438,14 @@ extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr);
void esp_ble_controller_log_dump_all(bool output);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
+modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void);
+
+void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src);
+
+uint32_t esp_bt_get_lpclk_freq(void);
+
+void esp_bt_set_lpclk_freq(uint32_t clk_freq);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/bt/include/esp32c2/include/esp_bt_vs.h b/lib/bt/include/esp32c2/include/esp_bt_vs.h
new file mode 100644
index 00000000..1010073b
--- /dev/null
+++ b/lib/bt/include/esp32c2/include/esp_bt_vs.h
@@ -0,0 +1,214 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include "sdkconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// @brief HCI VS Commands for Espressif's Bluetooth Host
+//
+// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these commands will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS commands are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief Enable/disable advertising report flow control (OCF: 0x0109)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
+/**
+* @brief Init ADV flow control cmd parameters
+*/
+struct bt_hci_vs_init_adv_flow_ctrl {
+ uint8_t enable; /*!< Enable ADV flow control */
+ uint16_t num; /*!< ADV buffer maximum value */
+ uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
+};
+
+/**
+ * @brief Update the number of advertising report in ADV flow control (OCF: 0x010A)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
+/**
+* @brief Update ADV flow control cmd parameters
+*/
+struct bt_hci_vs_update_adv_flow_ctrl {
+ uint16_t num; /*!< The number of ADV report processed */
+};
+
+/**
+ * @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
+ *
+ * @note The init function is `adv_stack_enableClearLegacyAdvVsCmd(true)`
+ */
+#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
+/**
+* @brief Clear legacy ADV cmd parameters
+*/
+struct bt_hci_vs_ble_clr_legacy_adv {
+ // no parameters
+};
+
+/**
+ * @brief Enable/disable channel selection algorithm #2 (OCF: 0x0112)
+ *
+ * @note The init function is `chanSel_stack_enableSetCsaVsCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_CSA2_OCF (0x0112)
+/**
+* @brief Enable/disable channel selection algorithm #2 cmd parameters
+*/
+struct bt_hci_vs_ble_csa_enable {
+ uint8_t csa2_select; /*!< Select CSA2 */
+};
+
+/**
+ * @brief Set BLE vendor events mask (OCF: 0x0116)
+ *
+ * @note The init function is `hci_stack_enableSetVsEvtMaskVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_LE_VENDOR_EVTS_MASK_OCF (0x0116)
+/**
+* @brief Set BLE vendor events mask cmd parameters
+*/
+struct bt_hci_vs_ble_set_vs_evts_mask {
+ uint32_t evt_masks; /*!< BLE vendor events Mask */
+};
+
+// @brief HCI VS Events for Espressif's Bluetooth Host
+//
+// @note The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief BLE Scan/Connect Request, Aux Connect Response received event (EVTCODE: 0xFF, SUBCODE: 0xC0)
+ *
+ * @note The init function is `adv_stack_enableScanReqRxdVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_CONN_SCAN_REQ_RXED_EVT_SUBCODE (0xC0)
+/**
+* @brief BLE Scan/Connect Request, Aux Connect Response received event parameters
+*/
+struct bt_hci_vs_le_conn_scan_req_rxed_evt {
+ uint8_t evt_type; /*!< Event type; 0: SCAN_REQ; 1: CONN_IND */
+ uint8_t handle; /*!< Advertisement handle */
+ uint8_t peer_addr_type; /*!< Peer address type */
+ uint8_t peer_addr[6]; /*!< Peer address */
+};
+
+/**
+ * @brief BLE Channel Map Update Completion event (EVTCODE: 0xFF, SUBCODE: 0xC1)
+ *
+ * @note The init function is `conn_stack_enableChanMapUpdCompVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_CHAN_UPDATE_COMP_EVT_SUBCODE (0xC1)
+/**
+* @brief BLE Channel Map Update Completion event parameters
+*/
+struct bt_hci_vs_le_chan_update_comp_evt {
+ uint8_t status; /*!< Controller error code */
+ uint16_t handle; /*!< Connection handle */
+ uint8_t ch_map[5]; /*!< Updated channel map */
+};
+
+/**
+ * @brief BLE Wakeup From Sleep event (EVTCODE: 0xFF, SUBCODE: 0xC3)
+ *
+ * @note The init function is `sleep_stack_enableWakeupVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_SLEEP_WAKEUP_EVT_SUBCODE (0xC3)
+/**
+* @brief BLE wakeup event parameters
+*/
+struct bt_hci_vs_le_sleep_wakeup_evt {
+ // no parameters
+};
+
+/**
+ * @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
+/**
+* @brief ADV lost event parameters
+*/
+struct bt_hci_vs_le_adv_lost_evt {
+ uint32_t nb_lost; /*!< The number of ADV report discarded */
+};
+
+//
+// @brief HCI VS Commands for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging commands are implemented in Bluetooth controller pre-compiled libraries.
+// These commands are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// They are intended for Espressif's internal use only. Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
+ #define ESP_BT_VS_CFG_TEST_SET_PREF_CODED_SUBCMD (0X02)
+ #define ESP_BT_VS_CFG_TEST_SET_DEFAULT_PRIV_MODE_SUBCMD (0X03)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
+ #define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
+ #define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_ENH_SUBCMD (0X0a)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_ENH_SUBCMD (0X0b)
+ #define ESP_BT_VS_CFG_TEST_IGNORE_WL_FOR_DIR_ADV_SUBCMD (0X0c)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_RXED_RSSI_SUBCMD (0X0d)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_CCA_SUBCMD (0X0e)
+ #define ESP_BT_VS_CFG_TEST_SET_CCA_WIN_SUBCMD (0X0f)
+ #define ESP_BT_VS_CFG_TEST_READ_CCA_DATA_SUBCM (0X10)
+ #define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
+ #define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
+ #define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
+ #define ESP_BT_VS_CFG_TEST_SKIP_LIGHT_SLEEP_CHECK_SUBCMD (0X17)
+ #define ESP_BT_VS_CFG_TEST_SET_WAKEUP_OVERHEAD_SUBCMD (0X18)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_MIN_ITVL_SUBCMD (0X19)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_RECODE_RX_STATE_SUBCMD (0X1f)
+ #define ESP_BT_VS_CFG_TEST_GET_RECODE_CNT_SUBCMD (0X20)
+ #define ESP_BT_VS_CFG_TEST_CLR_RECODE_CNT_SUBCMD (0X21)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
+ #define ESP_BT_VS_CFG_TEST_SET_AUX_ADV_OFFSET_SUBCMD (0X25)
+ #define ESP_BT_VS_CFG_TEST_GET_BACKOFF_UPLIMIT_SUBCMD (0X2d)
+ #define ESP_BT_VS_CFG_TEST_GET_RXED_ADV_ADI_SUBCMD (0X2f)
+ #define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31)
+ #define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39)
+ #define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
+
+//
+// @brief HCI VS Events for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging events are implemented in Bluetooth controller pre-compiled libraries.
+// These events are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/lib/bt/include/esp32c3/include/esp_bt.h b/lib/bt/include/esp32c3/include/esp_bt.h
index 8beb1d17..86c902fc 100644
--- a/lib/bt/include/esp32c3/include/esp_bt.h
+++ b/lib/bt/include/esp32c3/include/esp_bt.h
@@ -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
*/
@@ -18,50 +18,76 @@
extern "C" {
#endif
+/**
+* @brief Internal use only
+*
+* @note Please do not modify this value
+*/
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
-#define ESP_BT_CTRL_CONFIG_VERSION 0x02404010
+/**
+* @brief Internal use only
+*
+* @note Please do not modify this value
+*/
+#define ESP_BT_CTRL_CONFIG_VERSION 0x02505080
+
+/**
+* @brief Internal use only
+*
+* @note Please do not modify this value
+*/
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
+
+/**
+* @brief Internal use only
+*
+* @note Please do not modify this value
+*/
#define ESP_BT_HCI_TL_VERSION 0x00010000
/**
- * @brief Bluetooth mode for controller enable/disable
+ * @brief Bluetooth Controller mode
*/
typedef enum {
- ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
- ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
- ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
- ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
+ ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not operating. */
+ ESP_BT_MODE_BLE = 0x01, /*!< Bluetooth is operating in BLE mode. */
+ ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Unsupported mode */
+ ESP_BT_MODE_BTDM = 0x03, /*!< Unsupported mode */
} esp_bt_mode_t;
/**
- * @brief Type of controller HCI transport layer
+ * @brief BLE Controller HCI transport layer type
*/
typedef enum {
ESP_BT_CTRL_HCI_TL_UART = 0, /*!< HCI UART h4 transport layer */
- ESP_BT_CTRL_HCI_TL_VHCI = 1, /*!< VHCI interface */
+ ESP_BT_CTRL_HCI_TL_VHCI = 1, /*!< Virtual HCI interface */
} esp_bt_ctrl_hci_tl_t;
/**
- * @brief type of BLE connection event length computation
+ * @brief BLE connection event length computation type
*/
typedef enum {
ESP_BLE_CE_LEN_TYPE_ORIG = 0, /*!< original */
- ESP_BLE_CE_LEN_TYPE_CE = 1, /*!< use CE_LEN parameter from HCI commands */
+ ESP_BLE_CE_LEN_TYPE_CE = 1, /*!< use `CE_LEN` parameter from HCI commands */
ESP_BLE_CE_LEN_TYPE_SD = 1, /*!< Espressif vendor defined */
} esp_ble_ce_len_t;
/**
- * @brief Bluetooth sleep mode
+ * @brief Bluetooth modem sleep mode
*/
typedef enum {
- ESP_BT_SLEEP_MODE_NONE = 0, /*!< Bluetooth sleep mode disabled */
- ESP_BT_SLEEP_MODE_1 = 1, /*!< Bluetooth sleep mode 1 */
+ ESP_BT_SLEEP_MODE_NONE = 0, /*!< Disable modem sleep */
+ ESP_BT_SLEEP_MODE_1 = 1, /*!< Enable modem sleep */
} esp_bt_sleep_mode_t;
/**
- * @brief Bluetooth sleep clock
+ * @brief Bluetooth modem sleep clock source
+ *
+ * @note If the modem sleep mode is enabled, `ESP_BT_SLEEP_CLOCK_MAIN_XTAL` is the default option and
+ * `ESP_BT_SLEEP_CLOCK_NONE` will become an invalid option.
*/
+
typedef enum {
ESP_BT_SLEEP_CLOCK_NONE = 0, /*!< Sleep clock not configured */
ESP_BT_SLEEP_CLOCK_MAIN_XTAL = 1, /*!< SoC main crystal */
@@ -71,25 +97,25 @@ typedef enum {
} esp_bt_sleep_clock_t;
/**
- * @brief antenna index used for bluetooth
+ * @brief Bluetooth antenna index
*/
enum {
- ESP_BT_ANT_IDX_0 = 0, /*!< anntena NO 0 */
- ESP_BT_ANT_IDX_1 = 1, /*!< anntena NO 1 */
+ ESP_BT_ANT_IDX_0 = 0, /*!< Antenna NO 0 */
+ ESP_BT_ANT_IDX_1 = 1, /*!< Antenna NO 1 */
};
/**
- * @brief Maximum Tx/Rx time limit on Coded-PHY connection
+ * @brief Enable / disable the maximum TX/RX time limit for Coded-PHY connections in coexistence with Wi-Fi scenarios
*/
enum {
ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_DISABLE = 0, /*!< Disable the limit */
- ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_ENABLE, /*!< Always Enable the limit */
+ ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_ENABLE, /*!< Enable the limit */
};
-#define ESP_BT_HCI_TL_STATUS_OK (0) /*!< HCI_TL Tx/Rx operation status OK */
+#define ESP_BT_HCI_TL_STATUS_OK (0) /*!< HCI_TL TX/RX operation status OK */
/**
- * @brief callback function for HCI Transport Layer send/receive operations
+ * @brief Callback function for HCI Transport Layer send/receive operations
*/
typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
@@ -217,6 +243,93 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
#define BLE_HW_TARGET_CODE_CHIP_ECO0 (0x02010000)
#endif
+#ifdef CONFIG_BT_CTRL_BLE_LLCP_CONN_UPDATE
+#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0)
+#else
+#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0)
+#endif
+
+#ifdef CONFIG_BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE
+#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
+#else
+#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
+#endif
+
+#ifdef CONFIG_BT_CTRL_BLE_LLCP_PHY_UPDATE
+#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2)
+#else
+#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2)
+#endif
+
+#define BT_CTRL_BLE_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE)
+#if defined(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
+#define BT_CTRL_RUN_IN_FLASH_ONLY CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
+#else
+#define BT_CTRL_RUN_IN_FLASH_ONLY (0)
+#endif
+
+
+
+#if defined(CONFIG_BT_CTRL_DTM_ENABLE)
+#define BT_CTRL_DTM_ENABLE CONFIG_BT_CTRL_DTM_ENABLE
+#else
+#define BT_CTRL_DTM_ENABLE (0)
+#endif
+
+#if defined(CONFIG_BT_CTRL_BLE_MASTER)
+#define BT_CTRL_BLE_MASTER CONFIG_BT_CTRL_BLE_MASTER
+#else
+#define BT_CTRL_BLE_MASTER (0)
+#endif
+
+#if defined(CONFIG_BT_CTRL_BLE_TEST)
+#define BT_CTRL_BLE_TEST CONFIG_BT_CTRL_BLE_TEST
+#else
+#define BT_CTRL_BLE_TEST (0)
+#endif
+
+#if defined (CONFIG_BT_CTRL_BLE_SECURITY_ENABLE)
+#define BLE_SECURITY_ENABLE (CONFIG_BT_CTRL_BLE_SECURITY_ENABLE)
+#else
+#define BLE_SECURITY_ENABLE (0)
+#endif
+
+#if defined (CONFIG_BT_CTRL_BLE_SCAN)
+#define BT_CTRL_BLE_SCAN CONFIG_BT_CTRL_BLE_SCAN
+#else
+#define BT_CTRL_BLE_SCAN (0)
+#endif
+
+#if defined (CONFIG_BT_CTRL_BLE_ADV)
+#define BT_CTRL_BLE_ADV CONFIG_BT_CTRL_BLE_ADV
+#else
+#define BT_CTRL_BLE_ADV (0)
+#endif
+
+#ifdef CONFIG_BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
+#define BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED CONFIG_BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
+#else
+#define BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED 0
+#endif
+
+#if defined(CONFIG_BT_CTRL_LE_LOG_EN)
+#define BT_BLE_LOG_EN CONFIG_BT_CTRL_LE_LOG_EN
+#else
+#define BT_BLE_LOG_EN (0)
+#endif
+
+#if defined(CONFIG_BT_CTRL_LE_LOG_MODE_EN)
+#define BLE_LOG_MODE_EN CONFIG_BT_CTRL_LE_LOG_MODE_EN
+#else
+#define BLE_LOG_MODE_EN (0)
+#endif
+
+#if defined(CONFIG_BT_CTRL_LE_LOG_LEVEL)
+#define BLE_LOG_LEVEL CONFIG_BT_CTRL_LE_LOG_LEVEL
+#else
+#define BLE_LOG_LEVEL (0)
+#endif
+
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL, \
.version = ESP_BT_CTRL_CONFIG_VERSION, \
@@ -255,6 +368,17 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
.ble_data_lenth_zero_aux = BT_BLE_ADV_DATA_LENGTH_ZERO_AUX, \
.ble_chan_ass_en = BT_CTRL_CHAN_ASS_EN, \
.ble_ping_en = BT_CTRL_LE_PING_EN, \
+ .ble_llcp_disc_flag = BT_CTRL_BLE_LLCP_DISC_FLAG, \
+ .run_in_flash = BT_CTRL_RUN_IN_FLASH_ONLY, \
+ .dtm_en = BT_CTRL_DTM_ENABLE, \
+ .enc_en = BLE_SECURITY_ENABLE, \
+ .qa_test = BT_CTRL_BLE_TEST, \
+ .connect_en = BT_CTRL_BLE_MASTER, \
+ .scan_en = BT_CTRL_BLE_SCAN, \
+ .ble_aa_check = BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED, \
+ .ble_log_mode_en = BLE_LOG_MODE_EN, \
+ .ble_log_level = BLE_LOG_LEVEL, \
+ .adv_en = BT_CTRL_BLE_ADV, \
}
#else
@@ -263,7 +387,8 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
/**
* @brief Controller HCI transport layer function structure
- * This structure shall be registered when HCI transport layer is UART
+ *
+ * @note This structure must be registered when HCI transport layer is UART
*/
typedef struct {
uint32_t _magic; /*!< Magic number */
@@ -279,351 +404,528 @@ typedef struct {
} esp_bt_hci_tl_t;
/**
- * @brief Controller config options, depend on config mask.
- * Config mask indicate which functions enabled, this means
- * some options or parameters of some functions enabled by config mask.
+ * @brief Bluetooth Controller config options
+ * @note
+ * 1. For parameters configurable through menuconfig, it is recommended to adjust them via the menuconfig interface. Please refer to menuconfig for details on the range and default values.
+ * 2. It is not recommended to modify the values for parameters which are not configurable through menuconfig.
*/
typedef struct {
- /*
- * Following parameters can not be configured runtime when call esp_bt_controller_init()
- * They will be overwritten by constant values from menuconfig options or from macros.
- * So, do not modify the value when esp_bt_controller_init()
- */
uint32_t magic; /*!< Magic number */
uint32_t version; /*!< version number of the defined structure */
- /*
- * Following parameters can be configured runtime, when call esp_bt_controller_init()
- */
- uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */
- uint8_t controller_task_prio; /*!< Bluetooth controller task priority */
- uint8_t controller_task_run_cpu; /*!< CPU num that Bluetooth controller task runs on */
- uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
- uint8_t ble_max_act; /*!< BLE maximum number of air activities */
- uint8_t sleep_mode; /*!< controller sleep mode */
- uint8_t sleep_clock; /*!< controller sleep clock */
- uint8_t ble_st_acl_tx_buf_nb; /*!< controller static ACL TX BUFFER number */
- uint8_t ble_hw_cca_check; /*!< controller hardware triggered CCA check */
- uint16_t ble_adv_dup_filt_max; /*!< maximum number of duplicate scan filter */
- bool coex_param_en; /*!< deprecated */
- uint8_t ce_len_type; /*!< connection event length computation method */
- bool coex_use_hooks; /*!< deprecated */
- uint8_t hci_tl_type; /*!< HCI transport layer, UART, VHCI, etc */
- esp_bt_hci_tl_t *hci_tl_funcs; /*!< hci transport functions used, must be set when hci_tl_type is UART */
- uint8_t txant_dft; /*!< default Tx antenna */
- uint8_t rxant_dft; /*!< default Rx antenna */
- uint8_t txpwr_dft; /*!< default Tx power */
+ uint16_t controller_task_stack_size; /*!< Bluetooth Controller task stack size in bytes */
+ uint8_t controller_task_prio; /*!< Bluetooth Controller task priority */
+ uint8_t controller_task_run_cpu; /*!< CPU number that Bluetooth Controller task runs on. Configurable in menuconfig.
+ - 0 - CPU 0 (default)
+ - 1 - CPU 1 */
+ uint8_t bluetooth_mode; /*!< BLE mode */
+ uint8_t ble_max_act; /*!< The maximum number of BLE instance. Configurable in menuconfig.
+ - Range: 1 - 10
+ - Default: 6 */
+ uint8_t sleep_mode; /*!< Modem sleep mode. Configurable in menuconfig.
+ - 0 - Disable (default)
+ - 1 - Enable */
+ uint8_t sleep_clock; /*!< Modem sleep clock source. Configurable in menuconfig. */
+ uint8_t ble_st_acl_tx_buf_nb; /*!< Static ACL TX buffer numbers. Configurable in menuconfig.
+ - Range: 0 - 12
+ - Default: 0 */
+ uint8_t ble_hw_cca_check; /*!< Deprecated */
+ uint16_t ble_adv_dup_filt_max; /*!< The maximum number of extended duplicate scan filter. Configurable in menuconfig.
+ - Range: 1 - 500
+ - Default: 30 */
+ bool coex_param_en; /*!< Deprecated */
+ uint8_t ce_len_type; /*!< Connection event length determination method. Configurable in menuconfig.
+ - 0 - Original (default)
+ - 1 - use `CE_LEN` parameter from HCI commands
+ - 2 - Espressif vendor defined method */
+ bool coex_use_hooks; /*!< Deprecated */
+ uint8_t hci_tl_type; /*!< HCI transport layer type. Configurable in menuconfig.
+ - 0 - URAT
+ - 1 - Virtual HCI (default) */
+ esp_bt_hci_tl_t *hci_tl_funcs; /*!< HCI transport functions used. It must be set when `hci_tl_type` is UART. */
+ uint8_t txant_dft; /*!< Default TX antenna. Configurable in menuconfig.
+ - 0 - Antenna 0 (default)
+ - 1 - Antenna 1 */
+ uint8_t rxant_dft; /*!< Default RX antenna. Configurable in menuconfig.
+ - 0 - Antenna 0 (default)
+ - 1 - Antenna 1 */
+ uint8_t txpwr_dft; /*!< Default TX power. Please refer to `esp_power_level_t` for supported power level. Configurable in menuconfig.
+ - Default : `ESP_PWR_LVL_P9` +9 dBm. */
uint32_t cfg_mask; /*!< Configuration mask to set specific options */
- uint8_t scan_duplicate_mode; /*!< scan duplicate mode */
- uint8_t scan_duplicate_type; /*!< scan duplicate type */
- uint16_t normal_adv_size; /*!< Normal adv size for scan duplicate */
- uint16_t mesh_adv_size; /*!< Mesh adv size for scan duplicate */
- uint8_t coex_phy_coded_tx_rx_time_limit; /*!< limit on max tx/rx time in case of connection using CODED-PHY with Wi-Fi coexistence */
- uint32_t hw_target_code; /*!< hardware target */
- uint8_t slave_ce_len_min; /*!< slave minimum ce length*/
- uint8_t hw_recorrect_en; /*!< Hardware re-correction enabled */
- uint8_t cca_thresh; /*!< cca threshold*/
- uint16_t scan_backoff_upperlimitmax; /*!< scan backoff upperlimitmax value */
- uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */
- bool ble_50_feat_supp; /*!< BLE 5.0 feature support */
- uint8_t ble_cca_mode; /*!< BLE CCA mode */
- uint8_t ble_data_lenth_zero_aux; /*!< Config ext adv aux option */
- uint8_t ble_chan_ass_en; /*!< BLE channel assessment enable */
- uint8_t ble_ping_en; /*!< BLE ping procedure enable */
+ uint8_t scan_duplicate_mode; /*!< Scan duplicate filtering mode. Configurable in menuconfig.
+ - 0 - Normal scan duplicate filtering mode (default)
+ - 1 - Special scan duplicate filtering mode for BLE Mesh */
+ uint8_t scan_duplicate_type; /*!< Scan duplicate filtering type. If `scan_duplicate_mode` is set to 1, this parameter will be ignored. Configurable in menuconfig.
+ - 0 - Filter scan duplicates by device address only (default)
+ - 1 - Filter scan duplicates by advertising data only, even if they originate from different devices.
+ - 2 - Filter scan duplicated by device address and advertising data. */
+ uint16_t normal_adv_size; /*!< Maximum number of devices in scan duplicate filtering list. Configurable in menuconfig.
+ - Range: 10 - 1000
+ - Default: 100 */
+ uint16_t mesh_adv_size; /*!< Maximum number of Mesh advertising packets in scan duplicate filtering list. Configurable in menuconfig.
+ - Range: 10 - 1000
+ - Default: 100 */
+ uint8_t coex_phy_coded_tx_rx_time_limit; /*!< Enable / disable the maximum TX/RX time limit for Coded-PHY connections in coexistence with Wi-Fi scenarios. Configurable in menuconfig.
+ - 0 - Disable (default)
+ - 1 - Enable */
+ uint32_t hw_target_code; /*!< Hardware target. Internal use only. Please do not modify this value. */
+ uint8_t slave_ce_len_min; /*!< Slave minimum connection event length: 5 slots. Please do not modify this value. */
+ uint8_t hw_recorrect_en; /*!< Enable / disable uncoded phy / coded phy hardware re-correction. Configurable in menuconfig. */
+ uint8_t cca_thresh; /*!< Absolute value of hardware-triggered CCA threshold. The CCA threshold is always negative.
+ If the channel assessment result exceeds the CCA threshold (e.g. -75 dBm), indicating the channel is busy,
+ the hardware will not transmit packets on that channel. Configurable in menuconfig.
+ - Range: 20 dBm - 100 dBm
+ - Default: 75 dBm */
+ uint16_t scan_backoff_upperlimitmax; /*!< Enable / disable active scan backoff. Configurable in menuconfig.
+ - 0 - Disable (default)
+ - 1 - Enable */
+ uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig
+ - Range: 0 - 100 seconds
+ - Default: 0 second */
+ bool ble_50_feat_supp; /*!< True if BLE 5.0 features are enabled; false otherwise. This option depends on whether the Host enable the 5.0 features. */
+ uint8_t ble_cca_mode; /*!< BLE CCA mode. Configurable in menuconfig
+ - 0 - Disable (default)
+ - 1 - Hardware-triggered CCA
+ - 2 - Software-based CCA (experimental) */
+ uint8_t ble_data_lenth_zero_aux; /*!< Enable / disable auxiliary packets when the extended ADV data length is zero. Configurable in menuconfig.
+ - 0 - Disable (default)
+ - 1 - Enable */
+ uint8_t ble_chan_ass_en; /*!< Enable / disable BLE channel assessment. Configurable in menuconfig.
+ - 0 - Disable
+ - 1 - Enable (default) */
+ uint8_t ble_ping_en; /*!< Enable / disable BLE ping procedure. Configurable in menuconfig.
+ - 0 - Disable
+ - 1 - Enable (default) */
+ uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
+ - The Controller does not disconnect after Instant Passed (0x28) by default. */
+ bool run_in_flash; /*!< True if the Controller code is in flash (flash model); false otherwise (default). Configurable in menuconfig. */
+ bool dtm_en; /*!< True if the DTM feature is enabled; false otherwise (default). Configurable in menuconfig. */
+ bool enc_en; /*!< True if the encryption feature is enabled (default); false otherwise. Configurable in menuconfig. */
+ bool qa_test; /*!< True if the QA test feature is enabled; false otherwise (default). Configurable in menuconfig.*/
+ bool connect_en; /*!< True if the connection feature is enabled (default); false otherwise. Configurable in menuconfig.*/
+ bool scan_en; /*!< True if the scan feature is enabled (default); false otherwise. Configurable in menuconfig.*/
+ bool ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */
+ uint32_t ble_log_mode_en; /*!< BLE log mode enable */
+ uint8_t ble_log_level; /*!< BLE log level */
+ bool adv_en; /*!< True if the ADV feature is enabled (default); false otherwise. Configurable in menuconfig.*/
} esp_bt_controller_config_t;
/**
- * @brief Bluetooth controller enable/disable/initialised/de-initialised status
+ * @brief Bluetooth Controller status
*/
typedef enum {
- ESP_BT_CONTROLLER_STATUS_IDLE = 0,
- ESP_BT_CONTROLLER_STATUS_INITED,
- ESP_BT_CONTROLLER_STATUS_ENABLED,
- ESP_BT_CONTROLLER_STATUS_NUM,
+ ESP_BT_CONTROLLER_STATUS_IDLE = 0, /*!< The Controller is not initialized or has been de-initialized. */
+ ESP_BT_CONTROLLER_STATUS_INITED, /*!< The Controller has been initialized, but not enabled or has been disabled. */
+ ESP_BT_CONTROLLER_STATUS_ENABLED, /*!< The Controller has been initialized and enabled. */
+ ESP_BT_CONTROLLER_STATUS_NUM, /*!< Number of Controller statuses */
} esp_bt_controller_status_t;
/**
- * @brief BLE tx power type
- * ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed.
- * when disconnect, the correspond TX power is not effected.
- * ESP_BLE_PWR_TYPE_ADV : for advertising/scan response.
- * ESP_BLE_PWR_TYPE_SCAN : for scan.
- * ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value.
- * if neither in scan mode nor in adv mode, it will use this default value.
- * If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9.
+ * @brief BLE TX power type
+ *
+ * This TX power type is used for the API `esp_ble_tx_power_set()` and `esp_ble_tx_power_get()`.
+ *
+ * @note
+ * 1. The connection TX power can only be set after the connection is established.
+ * After disconnecting, the corresponding TX power will not be affected.
+ * 2. `ESP_BLE_PWR_TYPE_DEFAULT` can be used to set the TX power for power types that have not been set before.
+ * It will not affect the TX power values which have been set for the ADV/SCAN/CONN0-8 power types.
+ * 3. If none of power type is set, the system will use `ESP_PWR_LVL_P3` as default for all power types.
*/
typedef enum {
- ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
- ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
- ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
- ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */
- ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */
- ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */
- ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
- ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
- ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
- ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
- ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
- ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
- ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
+ ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< TX power for Connection state handle 0 */
+ ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< TX power for Connection state handle 1 */
+ ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< TX power for Connection state handle 2 */
+ ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< TX power for Connection state handle 3 */
+ ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< TX power for Connection state handle 4 */
+ ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< TX power for Connection state handle 5 */
+ ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< TX power for Connection state handle 6 */
+ ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< TX power for Connection state handle 7 */
+ ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< TX power for Connection state handle 8 */
+ ESP_BLE_PWR_TYPE_ADV = 9, /*!< TX power for Advertising state*/
+ ESP_BLE_PWR_TYPE_SCAN = 10, /*!< TX power for Scanning state */
+ ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< TX power for states that have not been set before */
+ ESP_BLE_PWR_TYPE_NUM = 12, /*!< Reserved */
} esp_ble_power_type_t;
/**
- * @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
+ * @brief The enhanced type of which TX power, could set Advertising/Connection/Default and etc.
+ *
+ * This TX power type is used for the API `esp_ble_tx_power_set_enhanced()` and `esp_ble_tx_power_get_enhanced()`.
+ *
+ * @note
+ * 1. The connection TX power can only be set after the connection is established.
+ * After disconnecting, the corresponding TX power will not be affected.
+ * 2. `ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT` can be used to set the TX power for power types that have not been set before.
+ * It will not affect the TX power values which have been set for the ADV/SCAN/INIT/CONN power types.
+ * 3. If none of power type is set, the system will use `ESP_PWR_LVL_P3` as default for all power types.
*/
typedef enum {
- ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24dbm */
- ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21dbm */
- ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18dbm */
- ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15dbm */
- ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12dbm */
- ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9dbm */
- ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6dbm */
- ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3dbm */
- ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0dbm */
- ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3dbm */
- ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6dbm */
- ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9dbm */
- ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12dbm */
- ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15dbm */
- ESP_PWR_LVL_P18 = 14, /*!< Corresponding to +18dbm */
- ESP_PWR_LVL_P21 = 15, /*!< Corresponding to +21dbm */
- ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
-} esp_power_level_t;
+ ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT = 0, /*!< TX power for states that have not been set before */
+ ESP_BLE_ENHANCED_PWR_TYPE_ADV, /*!< TX power for Advertising state */
+ ESP_BLE_ENHANCED_PWR_TYPE_SCAN, /*!< TX power for Scanning state */
+ ESP_BLE_ENHANCED_PWR_TYPE_INIT, /*!< TX power for Initiating state */
+ ESP_BLE_ENHANCED_PWR_TYPE_CONN, /*!< TX power for Connection state */
+ ESP_BLE_ENHANCED_PWR_TYPE_MAX, /*!< Reserved */
+} esp_ble_enhanced_power_type_t;
/**
- * @brief Set BLE TX power
- * Connection Tx power should only be set after connection created.
- * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
- * @param power_level: Power level(index) corresponding to absolute value(dbm)
- * @return ESP_OK - success, other - failed
+ * @brief Bluetooth TX power level (index). Each index corresponds to a specific power value in dBm.
*/
-esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
-
-/**
- * @brief Get BLE TX power
- * Connection Tx power should only be get after connection created.
- * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
- * @return >= 0 - Power level, < 0 - Invalid
- */
-esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
+typedef enum {
+ ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24 dBm */
+ ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21 dBm */
+ ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18 dBm */
+ ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15 dBm */
+ ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12 dBm */
+ ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9 dBm */
+ ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6 dBm */
+ ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3 dBm */
+ ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0 dBm */
+ ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3 dBm */
+ ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6 dBm */
+ ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9 dBm */
+ ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12 dBm */
+ ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15 dBm */
+ ESP_PWR_LVL_P18 = 14, /*!< Corresponding to +18 dBm */
+ ESP_PWR_LVL_P20 = 15, /*!< Corresponding to +20 dBm */
+ ESP_PWR_LVL_P21 = 15, /*!< Deprecated */
+ ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
+} esp_power_level_t;
/**
- * @brief Initialize BT controller to allocate task and other resource.
- * This function should be called only once, before any other BT functions are called.
- * @param cfg: Initial configuration of BT controller. Different from previous version, there's a mode and some
- * connection configuration in "cfg" to configure controller work mode and allocate the resource which is needed.
- * @return ESP_OK - success, other - failed
+ * @brief Initialize the Bluetooth Controller to allocate tasks and other resources
+ *
+ * @note This function should be called only once, before any other Bluetooth functions.
+ *
+ * @param[in] cfg Initial Bluetooth Controller configuration
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_SUPPORTED: Invalid Bluetooth Controller mode
+ * - ESP_ERR_INVALID_ARG: Invalid arguments
+ * - ESP_ERR_NO_MEM: Out of memory
+ * - ESP_FAIL: Failure due to other reasons
+ *
*/
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
/**
- * @brief De-initialize BT controller to free resource and delete task.
- * You should stop advertising and scanning, as well as
- * disconnect all existing connections before de-initializing BT controller.
+ * @brief De-initialize Bluetooth Controller to free resources and delete tasks
+ *
+ * @note
+ * 1. You should make sure that the Controller is in idle state before de-initializing it.
+ * 2. This function should be called only once, after any other Bluetooth functions.
*
- * This function should be called only once, after any other BT functions are called.
- * This function is not whole completed, esp_bt_controller_init cannot called after this function.
- * @return ESP_OK - success, other - failed
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_ARG: Invalid arguments
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NO_MEM: Out of memory
*/
esp_err_t esp_bt_controller_deinit(void);
/**
- * @brief Enable BT controller.
- * Due to a known issue, you cannot call esp_bt_controller_enable() a second time
- * to change the controller mode dynamically. To change controller mode, call
- * esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
- * @param mode : the mode(BLE/BT/BTDM) to enable. For compatible of API, retain this argument. This mode must be
- * equal as the mode in "cfg" of esp_bt_controller_init().
- * @return ESP_OK - success, other - failed
+ * @brief Enable Bluetooth Controller
+ *
+ * @note
+ * 1. Bluetooth Controller cannot be enabled in `ESP_BT_CONTROLLER_STATUS_IDLE` status. It has to be initialized first.
+ * 2. Due to a known issue, you cannot call `esp_bt_controller_enable()` for the second time
+ * to change the Controller mode dynamically. To change the Controller mode, call
+ * `esp_bt_controller_disable()` and then call `esp_bt_controller_enable()` with the new mode.
+ *
+ * @param[in] mode The Bluetooth Controller mode to enable
+ *
+ * For API compatibility, retain this argument. This mode must match the mode specified in the `cfg` of `esp_bt_controller_init()`.
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_INVALID_ARG: Invalid arguments
*/
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
/**
- * @brief Disable BT controller
- * @return ESP_OK - success, other - failed
+ * @brief Disable Bluetooth Controller
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
*/
esp_err_t esp_bt_controller_disable(void);
/**
- * @brief Get BT controller is initialised/de-initialised/enabled/disabled
- * @return status value
- */
-esp_bt_controller_status_t esp_bt_controller_get_status(void);
-
-uint16_t esp_bt_get_tx_buf_num(void);
-
-/** @brief esp_vhci_host_callback
- * used for vhci call host function to notify what host need to do
- */
-typedef struct esp_vhci_host_callback {
- void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */
- int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/
-} esp_vhci_host_callback_t;
-
-/** @brief esp_vhci_host_check_send_available
- * used for check actively if the host can send packet to controller or not.
- * @return true for ready to send, false means cannot send packet
- */
-bool esp_vhci_host_check_send_available(void);
-
-/** @brief esp_vhci_host_send_packet
- * host send packet to controller
+ * @brief Get Bluetooth Controller status
*
- * Should not call this function from within a critical section
- * or when the scheduler is suspended.
- *
- * @param data the packet point
- * @param len the packet length
- */
-void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
-
-/** @brief esp_vhci_host_register_callback
- * register the vhci reference callback
- * struct defined by vhci_host_callback structure.
- * @param callback esp_vhci_host_callback type variable
- * @return ESP_OK - success, ESP_FAIL - failed
+ * @return
+ * - ESP_BT_CONTROLLER_STATUS_IDLE: The Controller is not initialized or has been de-initialized.
+ * - ESP_BT_CONTROLLER_STATUS_INITED: The Controller has been initialized, but not enabled or has been disabled.
+ * - ESP_BT_CONTROLLER_STATUS_ENABLED: The Controller has been initialized and enabled.
*/
-esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
+esp_bt_controller_status_t esp_bt_controller_get_status(void);
-/** @brief esp_bt_controller_mem_release
- * release the controller memory as per the mode
- *
- * This function releases the BSS, data and other sections of the controller to heap. The total size is about 70k bytes.
+/**
+ * @brief Release the Controller memory as per the mode
*
- * esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init()
- * or after esp_bt_controller_deinit().
+ * This function releases the BSS, data and other sections of the Controller to heap. The total size is about 70 KB.
*
- * Note that once BT controller memory is released, the process cannot be reversed. It means you cannot use the bluetooth
- * mode which you have released by this function.
+ * @note
+ * 1. This function is optional and should be called only if you want to free up memory for other components.
+ * 2. This function should only be called when the Controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status.
+ * 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
+ * 4. If your firmware will upgrade the Bluetooth Controller mode later (such as from disabled to enabled), then do not call this function.
*
- * If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
- * then do not call this function.
+ * If you never intend to use Bluetooth in a current boot-up cycle, calling `esp_bt_controller_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE Controller to heap.
*
- * If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call
- * esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialization time to free unused BT Classic memory.
*
- * If the mode is ESP_BT_MODE_BTDM, then it may be useful to call API esp_bt_mem_release(ESP_BT_MODE_BTDM) instead,
- * which internally calls esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) and additionally releases the BSS and data
- * consumed by the BT/BLE host stack to heap. For more details about usage please refer to the documentation of
- * esp_bt_mem_release() function
+ * @param[in] mode The Bluetooth Controller mode
*
- * @param mode : the mode want to release memory
- * @return ESP_OK - success, other - failed
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_FOUND: Requested resource not found
*/
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
-/** @brief esp_bt_mem_release
- * release controller memory and BSS and data section of the BT/BLE host stack as per the mode
- *
- * This function first releases controller memory by internally calling esp_bt_controller_mem_release().
- * Additionally, if the mode is set to ESP_BT_MODE_BTDM, it also releases the BSS and data consumed by the BT/BLE host stack to heap
+/** @brief Release the Controller memory, BSS and data section of the BLE Host stack as per the mode
*
- * Note that once BT memory is released, the process cannot be reversed. It means you cannot use the bluetooth
- * mode which you have released by this function.
+ * @note
+ * 1. This function is optional and should be called only if you want to free up memory for other components.
+ * 2. This function should only be called when the Controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status.
+ * 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
+ * 4. If your firmware will upgrade the Bluetooth Controller mode later (such as from disabled to enabled), then do not call this function.
*
- * If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
- * then do not call this function.
+ * This function first releases Controller memory by internally calling `esp_bt_controller_mem_release()`, then releases Host memory.
*
- * If you never intend to use bluetooth in a current boot-up cycle, you can call esp_bt_mem_release(ESP_BT_MODE_BTDM)
- * before esp_bt_controller_init or after esp_bt_controller_deinit.
+ * If you never intend to use Bluetooth in a current boot-up cycle, calling `esp_bt_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE stack to heap.
*
- * For example, if a user only uses bluetooth for setting the WiFi configuration, and does not use bluetooth in the rest of the product operation".
- * In such cases, after receiving the WiFi configuration, you can disable/deinit bluetooth and release its memory.
+ * For example, if you only use Bluetooth for setting the Wi-Fi configuration, and do not use Bluetooth in the rest of the product operation,
+ * after receiving the Wi-Fi configuration, you can disable/de-init Bluetooth and release its memory.
* Below is the sequence of APIs to be called for such scenarios:
*
- * esp_bluedroid_disable();
- * esp_bluedroid_deinit();
- * esp_bt_controller_disable();
- * esp_bt_controller_deinit();
- * esp_bt_mem_release(ESP_BT_MODE_BTDM);
+ * esp_bluedroid_disable();
+ * esp_bluedroid_deinit();
+ * esp_bt_controller_disable();
+ * esp_bt_controller_deinit();
+ * esp_bt_mem_release(ESP_BT_MODE_BLE);
*
- * @param mode : the mode whose memory is to be released
- * @return ESP_OK - success, other - failed
+ * @param[in] mode The Bluetooth Controller mode
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_FOUND: Requested resource not found
*/
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
/**
- * @brief enable bluetooth to enter modem sleep
+ * @brief Enable Bluetooth modem sleep
*
- * Note that this function shall not be invoked before esp_bt_controller_enable()
+ * There are currently two options for Bluetooth modem sleep: ORIG mode and EVED mode. The latter is intended for BLE only.
+ * The modem sleep mode could be configured in menuconfig.
*
- * There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only.
+ * In ORIG mode, if there is no event to process, the Bluetooth Controller will periodically switch off some components and pause operation, then wake up according to the scheduled interval and resume work.
+ * It can also wakeup earlier upon external request using function `esp_bt_controller_wakeup_request()`.
*
- * For ORIG mode:
- * Bluetooth modem sleep is enabled in controller start up by default if CONFIG_BTDM_CONTROLLER_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request".
+ * @note This function shall not be invoked before `esp_bt_controller_enable()`.
*
* @return
- * - ESP_OK : success
- * - other : failed
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_SUPPORTED: Operation or feature not supported
*/
esp_err_t esp_bt_sleep_enable(void);
-
/**
- * @brief disable bluetooth modem sleep
+ * @brief Disable Bluetooth modem sleep
*
- * Note that this function shall not be invoked before esp_bt_controller_enable()
- *
- * If esp_bt_sleep_disable() is called, bluetooth controller will not be allowed to enter modem sleep;
- *
- * If ORIG modem sleep mode is in use, if this function is called, bluetooth controller may not immediately wake up if it is dormant then.
- * In this case, esp_bt_controller_wakeup_request() can be used to shorten the time for wakeup.
+ * @note
+ * 1. Bluetooth Controller will not be allowed to enter modem sleep after calling this function.
+ * 2. In ORIG modem sleep mode, calling this function may not immediately wake up the Controller if it is currently dormant.
+ * In this case, `esp_bt_controller_wakeup_request()` can be used to shorten the wake-up time.
+ * 3. This function shall not be invoked before `esp_bt_controller_enable()`.
*
* @return
- * - ESP_OK : success
- * - other : failed
+ * - ESP_OK: Success
+ * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state
+ * - ESP_ERR_NOT_SUPPORTED: Operation or feature not supported
*/
esp_err_t esp_bt_sleep_disable(void);
/**
- * @brief to check whether bluetooth controller is sleeping at the instant, if modem sleep is enabled
+ * @brief Get the Bluetooth sleep clock source.
*
- * Note that this function shall not be invoked before esp_bt_controller_enable()
- * This function is supposed to be used ORIG mode of modem sleep
+ * @note This function shall not be invoked before `esp_bt_controller_init()`.
*
- * @return true if in modem sleep state, false otherwise
+ * @return clock source used in Bluetooth low power mode
*/
-bool esp_bt_controller_is_sleeping(void);
+esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void);
/**
- * @brief request controller to wakeup from sleeping state during sleep mode
+ * @brief Check if the Bluetooth Controller is currently in sleep mode when modem sleep is enabled.
*
- * Note that this function shall not be invoked before esp_bt_controller_enable()
- * Note that this function is supposed to be used ORIG mode of modem sleep
- * Note that after this request, bluetooth controller may again enter sleep as long as the modem sleep is enabled
+ * @note
+ * 1. This function shall not be invoked before `esp_bt_controller_enable()`.
+ * 2. This function is supposed to be used ORIG mode of modem sleep.
+ *
+ * @return
+ * - True if the Controller is in modem sleep state; false otherwise.
+ */
+bool esp_bt_controller_is_sleeping(void);
+
+/**
+ * @brief Request the Controller to wakeup from sleeping state during sleep mode
*
* Profiling shows that it takes several milliseconds to wakeup from modem sleep after this request.
+ *
* Generally it takes longer if 32kHz XTAL is used than the main XTAL, due to the lower frequency of the former as the bluetooth low power clock source.
+ *
+ * @note
+ * 1. This function shall not be invoked before `esp_bt_controller_enable()`.
+ * 2. This function is supposed to be used ORIG mode of modem sleep.
+ * 3. After this request, the Bluetooth Controller can re-enter sleep as long as modem sleep remains enabled.
*/
void esp_bt_controller_wakeup_request(void);
/**
- * @brief notify bluetooth controller task to process the event upon Tx or Rx done
+ * @brief Set BLE TX power for the specified power type
+ *
+ * It is recommended to use `esp_ble_tx_power_set_enhanced` to set TX power for individual advertising and connection handle.
+ *
+ * @note Connection TX power should only be set after the connection is established.
+ *
+ * @param[in] power_type The type of TX power. It could be Advertising, Connection, or Default.
+ * @param[in] power_level Power level (index) corresponding to the absolute value (dBm)
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_NOT_SUPPORTED: Invalid TX power type
+ * - ESP_FAIL: Failure due to other reasons
+ */
+esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
+
+/**
+ * @brief Get BLE TX power of the specified power type
+ *
+ * It is recommended to use `esp_ble_tx_power_get_enhanced` to get TX power of individual advertising and connection handle.
+ *
+ * @note
+ * 1. Connection TX power should only be retrieved after the connection is established.
+ * 2. If an invalid power type is provided, this API returns `ESP_PWR_LVL_INVALID`.
+ *
+ * @param[in] power_type The type of TX power. It could be Advertising/Connection/Default and etc.
+ *
+ * @return
+ * - Power level
+ *
+ */
+esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
+
+/**
+ * @brief Set BLE TX power for the specified Advertising or Connection handle
+ *
+ * For the TX power type: `ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT`, `ESP_BLE_ENHANCED_PWR_TYPE_SCAN`, `ESP_BLE_ENHANCED_PWR_TYPE_INIT`,
+ * this API will ignore the input handle number, and set 0 internally.
+ *
+ * For the TX power type: `ESP_BLE_ENHANCED_PWR_TYPE_ADV` and `ESP_BLE_ENHANCED_PWR_TYPE_CONN`,
+ * this API will set the TX power for the target handle.
+ *
+ * @note
+ * 1. Connection TX power should only be set after connection created.
+ *
+ * @param[in] power_type The type of TX power
+ * @param[in] handle The handle of Advertising or Connection
+ * @param[in] power_level Power level (index) corresponding to absolute value (dBm)
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_ERR_NOT_SUPPORTED: Invalid TX power type
+ * - ESP_FAIL: Failure due to other reasons
+ */
+esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle, esp_power_level_t power_level);
+
+/**
+ * @brief Get BLE TX power of the specified Advertising or Connection handle
+ *
+ * For the TX power type: `ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT`, `ESP_BLE_ENHANCED_PWR_TYPE_SCAN`, `ESP_BLE_ENHANCED_PWR_TYPE_INIT`,
+ * this API will ignore the input handle number.
+ *
+ * For the TX power type: `ESP_BLE_ENHANCED_PWR_TYPE_ADV` and `ESP_BLE_ENHANCED_PWR_TYPE_CONN`,
+ * this API will return the TX power of the target handle.
*
- * Note that this function shall not be invoked before esp_bt_controller_enable()
- * This function can be called in both ISR and non-ISR context
+ * @note
+ * 1. Connection Tx power should only be get after connection created.
+ * 2. If an invalid power type is provided, this API returns `ESP_PWR_LVL_INVALID`.
+ *
+ * @param[in] power_type The type of TX power
+ * @param[in] handle The handle of Advertising or Connection and the value 0 for other enhanced power types
+ *
+ * @return Power level
+ */
+esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
+
+/**
+ * @brief Notify Bluetooth Controller task to process the event upon TX or RX done
*
+ * @note
+ * 1. This function shall not be invoked before `esp_bt_controller_enable()`.
+ * 2. This function can be called in both ISR and non-ISR context.
+ * 3. This function ignored the passed `event` value currently
*/
int esp_bt_h4tl_eif_io_event_notify(int event);
/**
- * @brief bt Wi-Fi power domain power on
+ * @brief Virtual HCI (VHCI) callback functions to notify the Host on the next operation
*/
-void esp_wifi_bt_power_domain_on(void);
+typedef struct esp_vhci_host_callback {
+ void (*notify_host_send_available)(void); /*!< callback used to notify that the Host can send the HCI data to Controller */
+ int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the Controller has the HCI data to send to the Host */
+} esp_vhci_host_callback_t;
/**
- * @brief bt Wi-Fi power domain power off
+ * @brief Check whether the Controller is ready to receive the HCI data
+ *
+ * If the return value is True, the Host can send the HCI data to the Controller.
+ *
+ * @note This function should be called before each `esp_vhci_host_send_packet()`.
+ *
+ * @return
+ * True if the Controller is ready to receive the HCI data; false otherwise.
*/
-void esp_wifi_bt_power_domain_off(void);
+bool esp_vhci_host_check_send_available(void);
/**
- * @brief Get the Bluetooth module sleep clock source.
+ * @brief Send the HCI data to the Controller
*
- * Note that this function shall not be invoked before esp_bt_controller_init()
+ * @note
+ * 1. This function shall not be called within a critical section or when the scheduler is suspended.
+ * 2. This function should be called only if `esp_vhci_host_check_send_available` returns True.
*
- * @return clock source used in Bluetooth low power mode
+ * @param[in] data Pointer to the HCI data
+ * @param[in] len The HCI data length
*/
-esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void);
+void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
+
+/**
+ * @brief Register the VHCI callback functions defined in `esp_vhci_host_callback` structure.
+ *
+ * @param[in] callback `esp_vhci_host_callback` type variable
+ *
+ * @return
+ * - ESP_OK: Success
+ * - ESP_FAIL: Failure
+ */
+esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
+
+/**
+ * @brief Select buffers
+*/
+typedef enum {
+ ESP_BLE_LOG_BUF_HCI = 0x02,
+ ESP_BLE_LOG_BUF_CONTROLLER = 0x05,
+} esp_ble_log_buf_t;
+
+void esp_ble_controller_log_dump_all(bool output);
#ifdef __cplusplus
}
diff --git a/lib/bt/include/esp32c3/include/esp_bt_vs.h b/lib/bt/include/esp32c3/include/esp_bt_vs.h
new file mode 100644
index 00000000..78d926eb
--- /dev/null
+++ b/lib/bt/include/esp32c3/include/esp_bt_vs.h
@@ -0,0 +1,175 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include "sdkconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// @brief HCI VS Commands for Espressif's Bluetooth Host
+//
+// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these commands will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS commands are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief Test vendor HCI feature (OCF: 0x0081)
+ *
+ * The Controller returns the value in command.
+ *
+ * @note The init function is `bt_stack_enableEchoVsCmd(true)`
+ */
+#define ESP_BT_VS_COMMON_ECHO_OCF (0x0081)
+/**
+* @brief echo test cmd parameters
+*/
+struct bt_hci_vs_common_echo {
+ uint8_t echo; /*!< echo data */
+};
+
+/**
+ * @brief Config scanning duplicate exceptional list (OCF: 0x0108)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF (0x0108)
+/**
+* @brief Update exception list cmd parameters
+*/
+struct bt_hci_vs_update_exc_list {
+ uint8_t subcode; /*!< Add, remove or clear exception list */
+ uint32_t type; /*!< device type */
+ uint8_t device_info[6]; /*!< device information */
+};
+
+/**
+ * @brief Enable/disable advertising report flow control (OCF: 0x0109)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
+/**
+* @brief Init ADV flow control cmd parameters
+*/
+struct bt_hci_vs_init_adv_flow_ctrl {
+ uint8_t enable; /*!< Enable ADV flow control */
+ uint16_t num; /*!< ADV buffer maximum value */
+ uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
+};
+
+/**
+ * @brief Update the number of advertising report in ADV flow control (OCF: 0x010A)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
+/**
+* @brief Update ADV flow control cmd parameters
+*/
+struct bt_hci_vs_update_adv_flow_ctrl {
+ uint16_t num; /*!< The number of ADV report processed */
+};
+
+/**
+ * @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
+ *
+ * @note The init function is `adv_stack_enableClearLegacyAdvVsCmd(true)`
+ */
+#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
+/**
+* @brief Clear legacy ADV cmd parameters
+*/
+struct bt_hci_vs_ble_clr_legacy_adv {
+ // no parameters
+};
+
+/**
+ * @brief Enable/disable channel selection algorithm #2 (OCF: 0x0112)
+ *
+ * @note The init function is `chanSel_stack_enableSetCsaVsCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_CSA2_OCF (0x0112)
+/**
+* @brief Enable/disable channel selection algorithm #2 cmd parameters
+*/
+struct bt_hci_vs_ble_csa_enable {
+ uint8_t csa2_select; /*!< Select CSA2 */
+};
+
+// @brief HCI VS Events for Espressif's Bluetooth Host
+//
+// @note The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
+/**
+* @brief ADV lost event parameters
+*/
+struct bt_hci_vs_le_adv_lost_evt {
+ uint32_t nb_lost; /*!< The number of ADV report discarded */
+};
+
+//
+// @brief HCI VS Commands for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging commands are implemented in Bluetooth controller pre-compiled libraries.
+// These commands are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// They are intended for Espressif's internal use only. Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
+ #define ESP_BT_VS_CFG_TEST_SET_PREF_CODED_SUBCMD (0X02)
+ #define ESP_BT_VS_CFG_TEST_SET_DEFAULT_PRIV_MODE_SUBCMD (0X03)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
+ #define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
+ #define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_ENH_SUBCMD (0X0a)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_ENH_SUBCMD (0X0b)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_CCA_SUBCMD (0X0e)
+ #define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
+ #define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
+ #define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
+ #define ESP_BT_VS_CFG_TEST_SET_AUX_ADV_OFFSET_SUBCMD (0X25)
+ #define ESP_BT_VS_CFG_TEST_SET_AUX_OFFSET_THRESHOLD_SUBCMD (0X2b)
+ #define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31)
+ #define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39)
+ #define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
+
+//
+// @brief HCI VS Events for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging events are implemented in Bluetooth controller pre-compiled libraries.
+// These events are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/lib/bt/include/esp32c5/include/esp_bt.h b/lib/bt/include/esp32c5/include/esp_bt.h
index 1a7cd646..91b1da30 100644
--- a/lib/bt/include/esp32c5/include/esp_bt.h
+++ b/lib/bt/include/esp32c5/include/esp_bt.h
@@ -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
*/
@@ -16,6 +16,7 @@
#include "nimble/nimble_npl.h"
#include "../../../../controller/esp32c5/esp_bt_cfg.h"
#include "hal/efuse_hal.h"
+#include "esp_private/esp_modem_clock.h"
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#include "driver/uart.h"
@@ -75,6 +76,9 @@ typedef enum {
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
*/
typedef enum {
+ ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24dbm */
+ ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21dbm */
+ ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18dbm */
ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15dbm */
ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12dbm */
ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9dbm */
@@ -155,7 +159,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
*/
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
-#define CONFIG_VERSION 0x20231124
+#define CONFIG_VERSION 0x20250526
#define CONFIG_MAGIC 0x5A5AA5A5
/**
@@ -196,13 +200,6 @@ typedef struct {
uint8_t controller_run_cpu; /*!< CPU core on which the controller runs */
uint8_t enable_qa_test; /*!< Enable quality assurance (QA) testing */
uint8_t enable_bqb_test; /*!< Enable Bluetooth Qualification Test (BQB) testing */
- uint8_t enable_uart_hci; /*!< Enable UART HCI (Host Controller Interface) */
- uint8_t ble_hci_uart_port; /*!< UART port number for Bluetooth HCI */
- uint32_t ble_hci_uart_baud; /*!< Baud rate for Bluetooth HCI UART */
- uint8_t ble_hci_uart_data_bits; /*!< Number of data bits for Bluetooth HCI UART */
- uint8_t ble_hci_uart_stop_bits; /*!< Number of stop bits for Bluetooth HCI UART */
- uint8_t ble_hci_uart_flow_ctrl; /*!< Flow control settings for Bluetooth HCI UART */
- uint8_t ble_hci_uart_uart_parity; /*!< Parity settings for Bluetooth HCI UART */
uint8_t enable_tx_cca; /*!< Enable Transmit Clear Channel Assessment (TX CCA) */
uint8_t cca_rssi_thresh; /*!< RSSI threshold for Transmit Clear Channel Assessment (CCA) */
uint8_t sleep_en; /*!< Enable sleep mode */
@@ -216,6 +213,25 @@ typedef struct {
uint8_t ignore_wl_for_direct_adv; /*!< Ignore the whitelist for direct advertising */
uint8_t enable_pcl; /*!< Enable power control */
uint8_t csa2_select; /*!< Select CSA#2*/
+ uint8_t enable_csr; /*!< Enable CSR */
+ uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */
+ uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
+ - The Controller does not disconnect after Instant Passed (0x28) by default. */
+ uint16_t scan_backoff_upperlimitmax; /*!< The value of upperlimitmax is 2^n, The maximum value is 256 */
+ uint8_t ble_chan_ass_en; /*!< Enable / disable BLE channel assessment. Configurable in menuconfig.
+ - 0 - Disable
+ - 1 - Enable (default) */
+ uint8_t ble_data_lenth_zero_aux; /*!< Enable / disable auxiliary packets when the extended ADV data length is zero. Configurable in menuconfig.
+ - 0 - Disable (default)
+ - 1 - Enable */
+ uint8_t vhci_enabled; /*!< VHCI mode is enabled */
+ uint8_t ptr_check_enabled; /*!< Enable boundary check for internal memory. */
+ uint8_t ble_adv_tx_options; /*!< The options for Extended advertising sending. */
+ uint8_t skip_unnecessary_checks_en; /*!< The option to skip non-fatal state checks and perform extra handling for fatal checks. */
+ uint8_t fast_conn_data_tx_en; /*!< The option for fast transmission of connection data
+ - 0 - Disable
+ - 1 - Enable (default) */
+ int8_t ch39_txpwr; /*!< BLE transmit power (in dBm) used for BLE advertising on channel 39. */
uint32_t config_magic; /*!< Magic number for configuration validation */
} esp_bt_controller_config_t;
@@ -252,13 +268,6 @@ typedef struct {
.controller_run_cpu = 0, \
.enable_qa_test = RUN_QA_TEST, \
.enable_bqb_test = RUN_BQB_TEST, \
- .enable_uart_hci = HCI_UART_EN, \
- .ble_hci_uart_port = DEFAULT_BT_LE_HCI_UART_PORT, \
- .ble_hci_uart_baud = DEFAULT_BT_LE_HCI_UART_BAUD, \
- .ble_hci_uart_data_bits = DEFAULT_BT_LE_HCI_UART_DATA_BITS, \
- .ble_hci_uart_stop_bits = DEFAULT_BT_LE_HCI_UART_STOP_BITS, \
- .ble_hci_uart_flow_ctrl = DEFAULT_BT_LE_HCI_UART_FLOW_CTRL, \
- .ble_hci_uart_uart_parity = DEFAULT_BT_LE_HCI_UART_PARITY, \
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
.sleep_en = NIMBLE_SLEEP_ENABLE, \
@@ -270,6 +279,18 @@ typedef struct {
.ignore_wl_for_direct_adv = 0, \
.enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED, \
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
+ .enable_csr = 0, \
+ .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
+ .ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
+ .scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
+ .ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
+ .ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
+ .vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \
+ .ptr_check_enabled = DEFAULT_BT_LE_PTR_CHECK_ENABLED, \
+ .ble_adv_tx_options = 0, \
+ .skip_unnecessary_checks_en = 0, \
+ .fast_conn_data_tx_en = DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN, \
+ .ch39_txpwr = BLE_LL_TX_PWR_DBM_N, \
.config_magic = CONFIG_MAGIC, \
}
@@ -426,6 +447,14 @@ extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr);
void esp_ble_controller_log_dump_all(bool output);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
+modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void);
+
+void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src);
+
+uint32_t esp_bt_get_lpclk_freq(void);
+
+void esp_bt_set_lpclk_freq(uint32_t clk_freq);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/bt/include/esp32c5/include/esp_bt_vs.h b/lib/bt/include/esp32c5/include/esp_bt_vs.h
new file mode 100644
index 00000000..3cbed925
--- /dev/null
+++ b/lib/bt/include/esp32c5/include/esp_bt_vs.h
@@ -0,0 +1,360 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include "sdkconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// @brief HCI VS Commands for Espressif's Bluetooth Host
+//
+// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these commands will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS commands are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief Config scanning duplicate exceptional list (OCF: 0x0108)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF (0x0108)
+/**
+* @brief Update exception list cmd parameters
+*/
+struct bt_hci_vs_update_exc_list {
+ uint8_t subcode; /*!< Add, remove or clear exception list */
+ uint32_t type; /*!< device type */
+ uint8_t device_info[6]; /*!< device information */
+};
+
+/**
+ * @brief Enable/disable advertising report flow control (OCF: 0x0109)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
+/**
+* @brief Init ADV flow control cmd parameters
+*/
+struct bt_hci_vs_init_adv_flow_ctrl {
+ uint8_t enable; /*!< Enable ADV flow control */
+ uint16_t num; /*!< ADV buffer maximum value */
+ uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
+};
+
+/**
+ * @brief Update the number of advertising report in ADV flow control (OCF: 0x010A)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
+/**
+* @brief Update ADV flow control cmd parameters
+*/
+struct bt_hci_vs_update_adv_flow_ctrl {
+ uint16_t num; /*!< The number of ADV report processed */
+};
+
+/**
+ * @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
+ *
+ * @note The init function is `adv_stack_enableClearLegacyAdvVsCmd(true)`
+ */
+#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
+/**
+* @brief Clear legacy ADV cmd parameters
+*/
+struct bt_hci_vs_ble_clr_legacy_adv {
+ // no parameters
+};
+
+/**
+ * @brief Set parameters of duplicate list (OCF: 0x010D)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_SET_DUP_LIST_PARAMS_OCF (0x010d)
+/**
+* @brief Set duplicate list cmd parameters
+*/
+struct bt_hci_vs_ble_set_dup_params {
+ uint8_t dup_mode; /*!< Duplicate mode */
+ uint8_t dup_ad_type; /*!< Duplicate data type */
+ uint16_t ring_list_max_num; /*!< Duplicate list size */
+};
+
+/**
+ * @brief Enable/disable duplicate and exception list (OCF: 0x010E)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_DUP_EXC_LIST_OCF (0x010e)
+/**
+* @brief Enable duplicate and exception list cmd parameters
+*/
+struct bt_hci_vs_ble_enable_dup_exc {
+ uint8_t enable; /*!< Enable or disable */
+ uint8_t ring_list_reset; /*!< Reset list */
+};
+
+/**
+ * @brief Enable optimization of multiple connections (OCF: 0x010F)
+ *
+ * @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_ARRANGEMENT_OCF (0x010f)
+/**
+* @brief Multiple connections optimization cmd parameters
+*/
+struct bt_hci_vs_ble_enable_arrangement {
+ uint32_t common_factor; /*!< The greatest common factor of connection interval */
+ uint8_t enable; /*!< Enable or disable */
+};
+
+/**
+ * @brief Set scheduling length for a certain role (OCF: 0x0110)
+ *
+ * @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_SCHED_ROLE_LEN_OCF (0x0110)
+/**
+* @brief Scheduling length cmd parameters
+*/
+struct bt_hci_vs_ble_set_sched_role_len {
+ uint8_t role; /*!< BLE role; 0: central; 1: peripheral */
+ uint32_t len; /*!< Length is us */
+};
+
+/**
+ * @brief Set RSSI threshold for automatic power control (OCF: 0x0111)
+ *
+ * @note The init function is `pcl_stack_enableSetRssiThreshVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_PCL_RSSI_THRESH_OCF (0x0111)
+/**
+* @brief PCL RSSI threshold cmd parameters
+*/
+struct bt_hci_vs_ble_set_pcl_rssi_thresh {
+ uint16_t conn_handle; /*!< Connection handle */
+ uint8_t rssi_thresh_min_1M; /*!< Lower limit for 1M */
+ uint8_t rssi_thresh_max_1M; /*!< Upper limit for 1M */
+ uint8_t rssi_thresh_min_2M; /*!< Lower limit for 2M */
+ uint8_t rssi_thresh_max_2M; /*!< Upper limit for 2M */
+ uint8_t rssi_thresh_min_s2coded; /*!< Lower limit for s2 coded */
+ uint8_t rssi_thresh_max_s2coded; /*!< Upper limit for s2 coded */
+ uint8_t rssi_thresh_min_s8coded; /*!< Lower limit for s8 coded */
+ uint8_t rssi_thresh_max_s8coded; /*!< Upper limit for s8 coded */
+};
+
+/**
+ * @brief Enable/disable channel selection algorithm #2 (OCF: 0x0112)
+ *
+ * @note The init function is `chanSel_stack_enableSetCsaVsCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_CSA2_OCF (0x0112)
+/**
+* @brief Enable/disable channel selection algorithm #2 cmd parameters
+*/
+struct bt_hci_vs_ble_csa_enable {
+ uint8_t csa2_select; /*!< Select CSA2 */
+};
+
+/**
+ * @brief Set parameters of controller logs (OCF: 0x0114)
+ *
+ * @note The init function is `log_stack_enableLogsRelatedVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_LOG_PARAMS_OCF (0x0114)
+/**
+* @brief Controller logs cmd parameters
+*/
+struct bt_hci_vs_ble_log_params {
+ uint8_t type; /*!< Operation type */
+ uint32_t output_enable; /*!< Enable/disable output */
+ uint8_t buffer_optoin /*!< Select log buffers */
+};
+
+/**
+ * @brief Set BLE vendor events mask (OCF: 0x0116)
+ *
+ * @note The init function is `hci_stack_enableSetVsEvtMaskVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_LE_VENDOR_EVTS_MASK_OCF (0x0116)
+/**
+* @brief Set BLE vendor events mask cmd parameters
+*/
+struct bt_hci_vs_ble_set_vs_evts_mask {
+ uint32_t evt_masks; /*!< BLE vendor events Mask */
+};
+
+/**
+ * @brief Set peer sleep clock accuracy to a constant value (OCF: 0x0118)
+ *
+ * @note The init function is `winWiden_stack_enableSetConstPeerScaVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_CONST_PEER_SCA_OCF (0x0118)
+/**
+* @brief Peer constant SCA cmd parameters
+*/
+struct bt_hci_vs_ble_set_const_peer_sca {
+ uint16_t peer_sca; /*!< Peer SCA */
+};
+
+// @brief HCI VS Events for Espressif's Bluetooth Host
+//
+// @note The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief BLE Scan/Connect Request, Aux Connect Response received event (EVTCODE: 0xFF, SUBCODE: 0xC0)
+ *
+ * @note The init function is `adv_stack_enableScanReqRxdVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_CONN_SCAN_REQ_RXED_EVT_SUBCODE (0xC0)
+/**
+* @brief BLE Scan/Connect Request, Aux Connect Response received event parameters
+*/
+struct bt_hci_vs_le_conn_scan_req_rxed_evt {
+ uint8_t evt_type; /*!< Event type; 0: SCAN_REQ; 1: CONN_IND */
+ uint8_t handle; /*!< Advertisement handle */
+ uint8_t peer_addr_type; /*!< Peer address type */
+ uint8_t peer_addr[6]; /*!< Peer address */
+};
+
+/**
+ * @brief BLE Channel Map Update Completion event (EVTCODE: 0xFF, SUBCODE: 0xC1)
+ *
+ * @note The init function is `conn_stack_enableChanMapUpdCompVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_CHAN_UPDATE_COMP_EVT_SUBCODE (0xC1)
+/**
+* @brief BLE Channel Map Update Completion event parameters
+*/
+struct bt_hci_vs_le_chan_update_comp_evt {
+ uint8_t status; /*!< Controller error code */
+ uint16_t handle; /*!< Connection handle */
+ uint8_t ch_map[5]; /*!< Updated channel map */
+};
+
+/**
+ * @brief BLE Wakeup From Sleep event (EVTCODE: 0xFF, SUBCODE: 0xC3)
+ *
+ * @note The init function is `sleep_stack_enableWakeupVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_SLEEP_WAKEUP_EVT_SUBCODE (0xC3)
+/**
+* @brief BLE wakeup event parameters
+*/
+struct bt_hci_vs_le_sleep_wakeup_evt {
+ // no parameters
+};
+
+/**
+ * @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
+/**
+* @brief ADV lost event parameters
+*/
+struct bt_hci_vs_le_adv_lost_evt {
+ uint32_t nb_lost; /*!< The number of ADV report discarded */
+};
+
+//
+// @brief HCI VS Commands for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging commands are implemented in Bluetooth controller pre-compiled libraries.
+// These commands are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// They are intended for Espressif's internal use only. Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
+ #define ESP_BT_VS_CFG_TEST_SET_PREF_CODED_SUBCMD (0X02)
+ #define ESP_BT_VS_CFG_TEST_SET_DEFAULT_PRIV_MODE_SUBCMD (0X03)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
+ #define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
+ #define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_ENH_SUBCMD (0X0a)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_ENH_SUBCMD (0X0b)
+ #define ESP_BT_VS_CFG_TEST_IGNORE_WL_FOR_DIR_ADV_SUBCMD (0X0c)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_RXED_RSSI_SUBCMD (0X0d)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_CCA_SUBCMD (0X0e)
+ #define ESP_BT_VS_CFG_TEST_SET_CCA_WIN_SUBCMD (0X0f)
+ #define ESP_BT_VS_CFG_TEST_READ_CCA_DATA_SUBCM (0X10)
+ #define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
+ #define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
+ #define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
+ #define ESP_BT_VS_CFG_TEST_SKIP_LIGHT_SLEEP_CHECK_SUBCMD (0X17)
+ #define ESP_BT_VS_CFG_TEST_SET_WAKEUP_OVERHEAD_SUBCMD (0X18)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_MIN_ITVL_SUBCMD (0X19)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
+ #define ESP_BT_VS_CFG_TEST_SET_CONN_PHY_TXPWR_SUBCMD (0X1b)
+ #define ESP_BT_VS_CFG_TEST_GET_CONN_PHY_TXPWR_SUBCMD (0X1c)
+ #define ESP_BT_VS_CFG_TEST_GET_RXBUF_EMPTY_CNT_SUBCMD (0X1d)
+ #define ESP_BT_VS_CFG_TEST_RESTART_SUBCMD (0X1e)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_RECODE_RX_STATE_SUBCMD (0X1f)
+ #define ESP_BT_VS_CFG_TEST_GET_RECODE_CNT_SUBCMD (0X20)
+ #define ESP_BT_VS_CFG_TEST_CLR_RECODE_CNT_SUBCMD (0X21)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
+ #define ESP_BT_VS_CFG_TEST_SET_AUX_ADV_OFFSET_SUBCMD (0X25)
+ #define ESP_BT_VS_CFG_TEST_INIT_FLEXIBLE_MODE_SUBCMD (0X26)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_FLEXIBLE_MODE_SUBCMD (0X27)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_CONN_ERR_SUBCMD (0X28)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_ADV_ERR_SUBCMD (0X29)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_SCAN_ERR_SUBCMD (0X2a)
+ #define ESP_BT_VS_CFG_TEST_GET_TXED_CRCERR_SUBCMD (0X2c)
+ #define ESP_BT_VS_CFG_TEST_GET_BACKOFF_UPLIMIT_SUBCMD (0X2d)
+ #define ESP_BT_VS_CFG_TEST_GET_RXED_ADV_ADI_SUBCMD (0X2f)
+ #define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_MODE_SUBCMD (0X30)
+ #define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31)
+ #define ESP_BT_VS_CFG_TEST_CHECK_MSYS_BUF_SUBCMD (0X32)
+ #define ESP_BT_VS_CFG_TEST_UPDATE_BLE_TIMER_SUBCMD (0X33)
+ #define ESP_BT_VS_CFG_TEST_UPDATE_BLE_RTC_SUBCMD (0X34)
+ #define ESP_BT_VS_CFG_TEST_SET_LOCKED_MEM_NUM_SUBCMD (0X35)
+ #define ESP_BT_VS_CFG_TEST_ALLOW_MEM_ALLOC_SUBCMD (0X36)
+ #define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_INFO_PTR_SUBCMD (0X37)
+ #define ESP_BT_VS_CFG_TEST_SET_DIAG_IO_SUBCMD (0X38)
+ #define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_CHAN_ASSESS_SUBCMD (0X40)
+ #define ESP_BT_VS_CFG_TEST_SET_BACKOFF_UPLIMIT_SUBCMD (0X41)
+ #define ESP_BT_VS_CFG_TEST_SET_CONN_TOP_PRIO_RESV_THRESH_SUBCMD (0X42)
+ #define ESP_BT_VS_CFG_TEST_SET_TEST_EVT_MSK_SUBCMD (0X43)
+ #define ESP_BT_VS_CFG_TEST_GET_WAKEUP_TIMEOUT_SUBCMD (0X45)
+ #define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
+
+//
+// @brief HCI VS Events for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging events are implemented in Bluetooth controller pre-compiled libraries.
+// These events are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#define ESP_BT_VS_LE_RUNNING_STATUS_EVT_SUBCODE (0xC3)
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/lib/bt/include/esp32c6/include/esp_bt.h b/lib/bt/include/esp32c6/include/esp_bt.h
index 210ead42..c035b4a6 100644
--- a/lib/bt/include/esp32c6/include/esp_bt.h
+++ b/lib/bt/include/esp32c6/include/esp_bt.h
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,6 +16,7 @@
#include "nimble/nimble_npl.h"
#include "../../../../controller/esp32c6/esp_bt_cfg.h"
#include "hal/efuse_hal.h"
+#include "esp_private/esp_modem_clock.h"
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#include "driver/uart.h"
@@ -155,7 +156,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
*/
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
-#define CONFIG_VERSION 0x20231124
+#define CONFIG_VERSION 0x20250526
#define CONFIG_MAGIC 0x5A5AA5A5
/**
@@ -196,13 +197,6 @@ typedef struct {
uint8_t controller_run_cpu; /*!< CPU core on which the controller runs */
uint8_t enable_qa_test; /*!< Enable quality assurance (QA) testing */
uint8_t enable_bqb_test; /*!< Enable Bluetooth Qualification Test (BQB) testing */
- uint8_t enable_uart_hci; /*!< Enable UART HCI (Host Controller Interface) */
- uint8_t ble_hci_uart_port; /*!< UART port number for Bluetooth HCI */
- uint32_t ble_hci_uart_baud; /*!< Baud rate for Bluetooth HCI UART */
- uint8_t ble_hci_uart_data_bits; /*!< Number of data bits for Bluetooth HCI UART */
- uint8_t ble_hci_uart_stop_bits; /*!< Number of stop bits for Bluetooth HCI UART */
- uint8_t ble_hci_uart_flow_ctrl; /*!< Flow control settings for Bluetooth HCI UART */
- uint8_t ble_hci_uart_uart_parity; /*!< Parity settings for Bluetooth HCI UART */
uint8_t enable_tx_cca; /*!< Enable Transmit Clear Channel Assessment (TX CCA) */
uint8_t cca_rssi_thresh; /*!< RSSI threshold for Transmit Clear Channel Assessment (CCA) */
uint8_t sleep_en; /*!< Enable sleep mode */
@@ -212,14 +206,37 @@ typedef struct {
uint8_t cca_drop_mode; /*!< CCA drop mode */
int8_t cca_low_tx_pwr; /*!< CCA low transmit power */
uint8_t main_xtal_freq; /*!< Main crystal frequency */
+#if CONFIG_IDF_TARGET_ESP32C6
uint32_t version_num; /*!< Controller configuration version number */
+#endif //CONFIG_IDF_TARGET_ESP32C6
uint8_t cpu_freq_mhz; /*!< CPU frequency in megahertz (MHz) */
uint8_t ignore_wl_for_direct_adv; /*!< Ignore the whitelist for direct advertising */
uint8_t enable_pcl; /*!< Enable power control */
uint8_t csa2_select; /*!< Select CSA#2*/
+ uint8_t enable_csr; /*!< Enable CSR */
+ uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */
+ uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
+ - The Controller does not disconnect after Instant Passed (0x28) by default. */
+ uint16_t scan_backoff_upperlimitmax; /*!< The value of upperlimitmax is 2^n, The maximum value is 256 */
+ uint8_t ble_chan_ass_en; /*!< Enable / disable BLE channel assessment. Configurable in menuconfig.
+ - 0 - Disable
+ - 1 - Enable (default) */
+ uint8_t ble_data_lenth_zero_aux; /*!< Enable / disable auxiliary packets when the extended ADV data length is zero. Configurable in menuconfig.
+ - 0 - Disable (default)
+ - 1 - Enable */
+ uint8_t vhci_enabled; /*!< VHCI mode is enabled */
+ uint8_t ptr_check_enabled; /*!< Enable boundary check for internal memory. */
+ uint8_t ble_adv_tx_options; /*!< The options for Extended advertising sending. */
+ uint8_t skip_unnecessary_checks_en; /*!< The option to skip non-fatal state checks and perform extra handling for fatal checks. */
+ uint8_t fast_conn_data_tx_en; /*!< The option for fast transmission of connection data
+ - 0 - Disable
+ - 1 - Enable (default) */
+ int8_t ch39_txpwr; /*!< BLE transmit power (in dBm) used for BLE advertising on channel 39. */
uint32_t config_magic; /*!< Magic number for configuration validation */
} esp_bt_controller_config_t;
+
+#if CONFIG_IDF_TARGET_ESP32C6
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.config_version = CONFIG_VERSION, \
.ble_ll_resolv_list_size = CONFIG_BT_LE_LL_RESOLV_LIST_SIZE, \
@@ -253,13 +270,6 @@ typedef struct {
.controller_run_cpu = 0, \
.enable_qa_test = RUN_QA_TEST, \
.enable_bqb_test = RUN_BQB_TEST, \
- .enable_uart_hci = HCI_UART_EN, \
- .ble_hci_uart_port = DEFAULT_BT_LE_HCI_UART_PORT, \
- .ble_hci_uart_baud = DEFAULT_BT_LE_HCI_UART_BAUD, \
- .ble_hci_uart_data_bits = DEFAULT_BT_LE_HCI_UART_DATA_BITS, \
- .ble_hci_uart_stop_bits = DEFAULT_BT_LE_HCI_UART_STOP_BITS, \
- .ble_hci_uart_flow_ctrl = DEFAULT_BT_LE_HCI_UART_FLOW_CTRL, \
- .ble_hci_uart_uart_parity = DEFAULT_BT_LE_HCI_UART_PARITY, \
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
.sleep_en = NIMBLE_SLEEP_ENABLE, \
@@ -272,8 +282,80 @@ typedef struct {
.ignore_wl_for_direct_adv = 0, \
.enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED, \
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
+ .enable_csr = DEFAULT_BT_LE_SUBRATE_ENABLED, \
+ .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
+ .ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
+ .scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
+ .ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
+ .ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
+ .vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \
+ .ptr_check_enabled = DEFAULT_BT_LE_PTR_CHECK_ENABLED, \
+ .ble_adv_tx_options = 0, \
+ .skip_unnecessary_checks_en = 0, \
+ .fast_conn_data_tx_en = DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN, \
+ .ch39_txpwr = BLE_LL_TX_PWR_DBM_N, \
+ .config_magic = CONFIG_MAGIC, \
+}
+#elif CONFIG_IDF_TARGET_ESP32C61
+#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
+ .config_version = CONFIG_VERSION, \
+ .ble_ll_resolv_list_size = CONFIG_BT_LE_LL_RESOLV_LIST_SIZE, \
+ .ble_hci_evt_hi_buf_count = DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT, \
+ .ble_hci_evt_lo_buf_count = DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT, \
+ .ble_ll_sync_list_cnt = DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST, \
+ .ble_ll_sync_cnt = DEFAULT_BT_LE_MAX_PERIODIC_SYNCS, \
+ .ble_ll_rsp_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
+ .ble_ll_adv_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
+ .ble_ll_tx_pwr_dbm = BLE_LL_TX_PWR_DBM_N, \
+ .rtc_freq = RTC_FREQ_N, \
+ .ble_ll_sca = CONFIG_BT_LE_LL_SCA, \
+ .ble_ll_scan_phy_number = BLE_LL_SCAN_PHY_NUMBER_N, \
+ .ble_ll_conn_def_auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N, \
+ .ble_ll_jitter_usecs = BLE_LL_JITTER_USECS_N, \
+ .ble_ll_sched_max_adv_pdu_usecs = BLE_LL_SCHED_MAX_ADV_PDU_USECS_N, \
+ .ble_ll_sched_direct_adv_max_usecs = BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N, \
+ .ble_ll_sched_adv_max_usecs = BLE_LL_SCHED_ADV_MAX_USECS_N, \
+ .ble_scan_rsp_data_max_len = DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N, \
+ .ble_ll_cfg_num_hci_cmd_pkts = BLE_LL_CFG_NUM_HCI_CMD_PKTS_N, \
+ .ble_ll_ctrl_proc_timeout_ms = BLE_LL_CTRL_PROC_TIMEOUT_MS_N, \
+ .nimble_max_connections = DEFAULT_BT_LE_MAX_CONNECTIONS, \
+ .ble_whitelist_size = DEFAULT_BT_NIMBLE_WHITELIST_SIZE, \
+ .ble_acl_buf_size = DEFAULT_BT_LE_ACL_BUF_SIZE, \
+ .ble_acl_buf_count = DEFAULT_BT_LE_ACL_BUF_COUNT, \
+ .ble_hci_evt_buf_size = DEFAULT_BT_LE_HCI_EVT_BUF_SIZE, \
+ .ble_multi_adv_instances = DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES, \
+ .ble_ext_adv_max_size = DEFAULT_BT_LE_EXT_ADV_MAX_SIZE, \
+ .controller_task_stack_size = NIMBLE_LL_STACK_SIZE, \
+ .controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
+ .controller_run_cpu = 0, \
+ .enable_qa_test = RUN_QA_TEST, \
+ .enable_bqb_test = RUN_BQB_TEST, \
+ .enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
+ .cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
+ .sleep_en = NIMBLE_SLEEP_ENABLE, \
+ .coex_phy_coded_tx_rx_time_limit = DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF, \
+ .dis_scan_backoff = NIMBLE_DISABLE_SCAN_BACKOFF, \
+ .ble_scan_classify_filter_enable = 1, \
+ .main_xtal_freq = CONFIG_XTAL_FREQ, \
+ .cpu_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ, \
+ .ignore_wl_for_direct_adv = 0, \
+ .enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED, \
+ .csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
+ .enable_csr = 0, \
+ .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
+ .ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
+ .scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
+ .ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
+ .ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
+ .vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \
+ .ptr_check_enabled = DEFAULT_BT_LE_PTR_CHECK_ENABLED, \
+ .ble_adv_tx_options = 0, \
+ .skip_unnecessary_checks_en = 0, \
+ .fast_conn_data_tx_en = DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN, \
+ .ch39_txpwr = BLE_LL_TX_PWR_DBM_N, \
.config_magic = CONFIG_MAGIC, \
}
+#endif
/**
* @brief Initialize BT controller to allocate task and other resource.
@@ -428,6 +510,14 @@ extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr);
void esp_ble_controller_log_dump_all(bool output);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
+modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void);
+
+void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src);
+
+uint32_t esp_bt_get_lpclk_freq(void);
+
+void esp_bt_set_lpclk_freq(uint32_t clk_freq);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/bt/include/esp32c6/include/esp_bt_vs.h b/lib/bt/include/esp32c6/include/esp_bt_vs.h
new file mode 100644
index 00000000..3cbed925
--- /dev/null
+++ b/lib/bt/include/esp32c6/include/esp_bt_vs.h
@@ -0,0 +1,360 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include "sdkconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// @brief HCI VS Commands for Espressif's Bluetooth Host
+//
+// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these commands will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS commands are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief Config scanning duplicate exceptional list (OCF: 0x0108)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF (0x0108)
+/**
+* @brief Update exception list cmd parameters
+*/
+struct bt_hci_vs_update_exc_list {
+ uint8_t subcode; /*!< Add, remove or clear exception list */
+ uint32_t type; /*!< device type */
+ uint8_t device_info[6]; /*!< device information */
+};
+
+/**
+ * @brief Enable/disable advertising report flow control (OCF: 0x0109)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
+/**
+* @brief Init ADV flow control cmd parameters
+*/
+struct bt_hci_vs_init_adv_flow_ctrl {
+ uint8_t enable; /*!< Enable ADV flow control */
+ uint16_t num; /*!< ADV buffer maximum value */
+ uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
+};
+
+/**
+ * @brief Update the number of advertising report in ADV flow control (OCF: 0x010A)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
+/**
+* @brief Update ADV flow control cmd parameters
+*/
+struct bt_hci_vs_update_adv_flow_ctrl {
+ uint16_t num; /*!< The number of ADV report processed */
+};
+
+/**
+ * @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
+ *
+ * @note The init function is `adv_stack_enableClearLegacyAdvVsCmd(true)`
+ */
+#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
+/**
+* @brief Clear legacy ADV cmd parameters
+*/
+struct bt_hci_vs_ble_clr_legacy_adv {
+ // no parameters
+};
+
+/**
+ * @brief Set parameters of duplicate list (OCF: 0x010D)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_SET_DUP_LIST_PARAMS_OCF (0x010d)
+/**
+* @brief Set duplicate list cmd parameters
+*/
+struct bt_hci_vs_ble_set_dup_params {
+ uint8_t dup_mode; /*!< Duplicate mode */
+ uint8_t dup_ad_type; /*!< Duplicate data type */
+ uint16_t ring_list_max_num; /*!< Duplicate list size */
+};
+
+/**
+ * @brief Enable/disable duplicate and exception list (OCF: 0x010E)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_DUP_EXC_LIST_OCF (0x010e)
+/**
+* @brief Enable duplicate and exception list cmd parameters
+*/
+struct bt_hci_vs_ble_enable_dup_exc {
+ uint8_t enable; /*!< Enable or disable */
+ uint8_t ring_list_reset; /*!< Reset list */
+};
+
+/**
+ * @brief Enable optimization of multiple connections (OCF: 0x010F)
+ *
+ * @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_ARRANGEMENT_OCF (0x010f)
+/**
+* @brief Multiple connections optimization cmd parameters
+*/
+struct bt_hci_vs_ble_enable_arrangement {
+ uint32_t common_factor; /*!< The greatest common factor of connection interval */
+ uint8_t enable; /*!< Enable or disable */
+};
+
+/**
+ * @brief Set scheduling length for a certain role (OCF: 0x0110)
+ *
+ * @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_SCHED_ROLE_LEN_OCF (0x0110)
+/**
+* @brief Scheduling length cmd parameters
+*/
+struct bt_hci_vs_ble_set_sched_role_len {
+ uint8_t role; /*!< BLE role; 0: central; 1: peripheral */
+ uint32_t len; /*!< Length is us */
+};
+
+/**
+ * @brief Set RSSI threshold for automatic power control (OCF: 0x0111)
+ *
+ * @note The init function is `pcl_stack_enableSetRssiThreshVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_PCL_RSSI_THRESH_OCF (0x0111)
+/**
+* @brief PCL RSSI threshold cmd parameters
+*/
+struct bt_hci_vs_ble_set_pcl_rssi_thresh {
+ uint16_t conn_handle; /*!< Connection handle */
+ uint8_t rssi_thresh_min_1M; /*!< Lower limit for 1M */
+ uint8_t rssi_thresh_max_1M; /*!< Upper limit for 1M */
+ uint8_t rssi_thresh_min_2M; /*!< Lower limit for 2M */
+ uint8_t rssi_thresh_max_2M; /*!< Upper limit for 2M */
+ uint8_t rssi_thresh_min_s2coded; /*!< Lower limit for s2 coded */
+ uint8_t rssi_thresh_max_s2coded; /*!< Upper limit for s2 coded */
+ uint8_t rssi_thresh_min_s8coded; /*!< Lower limit for s8 coded */
+ uint8_t rssi_thresh_max_s8coded; /*!< Upper limit for s8 coded */
+};
+
+/**
+ * @brief Enable/disable channel selection algorithm #2 (OCF: 0x0112)
+ *
+ * @note The init function is `chanSel_stack_enableSetCsaVsCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_CSA2_OCF (0x0112)
+/**
+* @brief Enable/disable channel selection algorithm #2 cmd parameters
+*/
+struct bt_hci_vs_ble_csa_enable {
+ uint8_t csa2_select; /*!< Select CSA2 */
+};
+
+/**
+ * @brief Set parameters of controller logs (OCF: 0x0114)
+ *
+ * @note The init function is `log_stack_enableLogsRelatedVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_LOG_PARAMS_OCF (0x0114)
+/**
+* @brief Controller logs cmd parameters
+*/
+struct bt_hci_vs_ble_log_params {
+ uint8_t type; /*!< Operation type */
+ uint32_t output_enable; /*!< Enable/disable output */
+ uint8_t buffer_optoin /*!< Select log buffers */
+};
+
+/**
+ * @brief Set BLE vendor events mask (OCF: 0x0116)
+ *
+ * @note The init function is `hci_stack_enableSetVsEvtMaskVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_LE_VENDOR_EVTS_MASK_OCF (0x0116)
+/**
+* @brief Set BLE vendor events mask cmd parameters
+*/
+struct bt_hci_vs_ble_set_vs_evts_mask {
+ uint32_t evt_masks; /*!< BLE vendor events Mask */
+};
+
+/**
+ * @brief Set peer sleep clock accuracy to a constant value (OCF: 0x0118)
+ *
+ * @note The init function is `winWiden_stack_enableSetConstPeerScaVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_CONST_PEER_SCA_OCF (0x0118)
+/**
+* @brief Peer constant SCA cmd parameters
+*/
+struct bt_hci_vs_ble_set_const_peer_sca {
+ uint16_t peer_sca; /*!< Peer SCA */
+};
+
+// @brief HCI VS Events for Espressif's Bluetooth Host
+//
+// @note The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief BLE Scan/Connect Request, Aux Connect Response received event (EVTCODE: 0xFF, SUBCODE: 0xC0)
+ *
+ * @note The init function is `adv_stack_enableScanReqRxdVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_CONN_SCAN_REQ_RXED_EVT_SUBCODE (0xC0)
+/**
+* @brief BLE Scan/Connect Request, Aux Connect Response received event parameters
+*/
+struct bt_hci_vs_le_conn_scan_req_rxed_evt {
+ uint8_t evt_type; /*!< Event type; 0: SCAN_REQ; 1: CONN_IND */
+ uint8_t handle; /*!< Advertisement handle */
+ uint8_t peer_addr_type; /*!< Peer address type */
+ uint8_t peer_addr[6]; /*!< Peer address */
+};
+
+/**
+ * @brief BLE Channel Map Update Completion event (EVTCODE: 0xFF, SUBCODE: 0xC1)
+ *
+ * @note The init function is `conn_stack_enableChanMapUpdCompVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_CHAN_UPDATE_COMP_EVT_SUBCODE (0xC1)
+/**
+* @brief BLE Channel Map Update Completion event parameters
+*/
+struct bt_hci_vs_le_chan_update_comp_evt {
+ uint8_t status; /*!< Controller error code */
+ uint16_t handle; /*!< Connection handle */
+ uint8_t ch_map[5]; /*!< Updated channel map */
+};
+
+/**
+ * @brief BLE Wakeup From Sleep event (EVTCODE: 0xFF, SUBCODE: 0xC3)
+ *
+ * @note The init function is `sleep_stack_enableWakeupVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_SLEEP_WAKEUP_EVT_SUBCODE (0xC3)
+/**
+* @brief BLE wakeup event parameters
+*/
+struct bt_hci_vs_le_sleep_wakeup_evt {
+ // no parameters
+};
+
+/**
+ * @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
+/**
+* @brief ADV lost event parameters
+*/
+struct bt_hci_vs_le_adv_lost_evt {
+ uint32_t nb_lost; /*!< The number of ADV report discarded */
+};
+
+//
+// @brief HCI VS Commands for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging commands are implemented in Bluetooth controller pre-compiled libraries.
+// These commands are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// They are intended for Espressif's internal use only. Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
+ #define ESP_BT_VS_CFG_TEST_SET_PREF_CODED_SUBCMD (0X02)
+ #define ESP_BT_VS_CFG_TEST_SET_DEFAULT_PRIV_MODE_SUBCMD (0X03)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
+ #define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
+ #define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_ENH_SUBCMD (0X0a)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_ENH_SUBCMD (0X0b)
+ #define ESP_BT_VS_CFG_TEST_IGNORE_WL_FOR_DIR_ADV_SUBCMD (0X0c)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_RXED_RSSI_SUBCMD (0X0d)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_CCA_SUBCMD (0X0e)
+ #define ESP_BT_VS_CFG_TEST_SET_CCA_WIN_SUBCMD (0X0f)
+ #define ESP_BT_VS_CFG_TEST_READ_CCA_DATA_SUBCM (0X10)
+ #define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
+ #define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
+ #define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
+ #define ESP_BT_VS_CFG_TEST_SKIP_LIGHT_SLEEP_CHECK_SUBCMD (0X17)
+ #define ESP_BT_VS_CFG_TEST_SET_WAKEUP_OVERHEAD_SUBCMD (0X18)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_MIN_ITVL_SUBCMD (0X19)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
+ #define ESP_BT_VS_CFG_TEST_SET_CONN_PHY_TXPWR_SUBCMD (0X1b)
+ #define ESP_BT_VS_CFG_TEST_GET_CONN_PHY_TXPWR_SUBCMD (0X1c)
+ #define ESP_BT_VS_CFG_TEST_GET_RXBUF_EMPTY_CNT_SUBCMD (0X1d)
+ #define ESP_BT_VS_CFG_TEST_RESTART_SUBCMD (0X1e)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_RECODE_RX_STATE_SUBCMD (0X1f)
+ #define ESP_BT_VS_CFG_TEST_GET_RECODE_CNT_SUBCMD (0X20)
+ #define ESP_BT_VS_CFG_TEST_CLR_RECODE_CNT_SUBCMD (0X21)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
+ #define ESP_BT_VS_CFG_TEST_SET_AUX_ADV_OFFSET_SUBCMD (0X25)
+ #define ESP_BT_VS_CFG_TEST_INIT_FLEXIBLE_MODE_SUBCMD (0X26)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_FLEXIBLE_MODE_SUBCMD (0X27)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_CONN_ERR_SUBCMD (0X28)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_ADV_ERR_SUBCMD (0X29)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_SCAN_ERR_SUBCMD (0X2a)
+ #define ESP_BT_VS_CFG_TEST_GET_TXED_CRCERR_SUBCMD (0X2c)
+ #define ESP_BT_VS_CFG_TEST_GET_BACKOFF_UPLIMIT_SUBCMD (0X2d)
+ #define ESP_BT_VS_CFG_TEST_GET_RXED_ADV_ADI_SUBCMD (0X2f)
+ #define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_MODE_SUBCMD (0X30)
+ #define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31)
+ #define ESP_BT_VS_CFG_TEST_CHECK_MSYS_BUF_SUBCMD (0X32)
+ #define ESP_BT_VS_CFG_TEST_UPDATE_BLE_TIMER_SUBCMD (0X33)
+ #define ESP_BT_VS_CFG_TEST_UPDATE_BLE_RTC_SUBCMD (0X34)
+ #define ESP_BT_VS_CFG_TEST_SET_LOCKED_MEM_NUM_SUBCMD (0X35)
+ #define ESP_BT_VS_CFG_TEST_ALLOW_MEM_ALLOC_SUBCMD (0X36)
+ #define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_INFO_PTR_SUBCMD (0X37)
+ #define ESP_BT_VS_CFG_TEST_SET_DIAG_IO_SUBCMD (0X38)
+ #define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_CHAN_ASSESS_SUBCMD (0X40)
+ #define ESP_BT_VS_CFG_TEST_SET_BACKOFF_UPLIMIT_SUBCMD (0X41)
+ #define ESP_BT_VS_CFG_TEST_SET_CONN_TOP_PRIO_RESV_THRESH_SUBCMD (0X42)
+ #define ESP_BT_VS_CFG_TEST_SET_TEST_EVT_MSK_SUBCMD (0X43)
+ #define ESP_BT_VS_CFG_TEST_GET_WAKEUP_TIMEOUT_SUBCMD (0X45)
+ #define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
+
+//
+// @brief HCI VS Events for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging events are implemented in Bluetooth controller pre-compiled libraries.
+// These events are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#define ESP_BT_VS_LE_RUNNING_STATUS_EVT_SUBCODE (0xC3)
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/lib/bt/include/esp32h2/include/esp_bt.h b/lib/bt/include/esp32h2/include/esp_bt.h
index a1c7aed8..0aafa744 100644
--- a/lib/bt/include/esp32h2/include/esp_bt.h
+++ b/lib/bt/include/esp32h2/include/esp_bt.h
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -15,6 +15,7 @@
#include "nimble/nimble_npl.h"
#include "../../../../controller/esp32h2/esp_bt_cfg.h"
+#include "esp_private/esp_modem_clock.h"
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#include "driver/uart.h"
@@ -109,14 +110,6 @@ typedef enum {
} esp_ble_enhanced_power_type_t;
/**
- * @brief Address type and address value.
- */
-typedef struct {
- uint8_t type; /*!< Type of the Bluetooth address (public, random, etc.) */
- uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */
-} esp_ble_addr_t;
-
-/**
* @brief Select buffers
*/
typedef enum {
@@ -125,6 +118,14 @@ typedef enum {
} esp_ble_log_buf_t;
/**
+ * @brief Address type and address value.
+ */
+typedef struct {
+ uint8_t type; /*!< Type of the Bluetooth address (public, random, etc.) */
+ uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */
+} esp_ble_addr_t;
+
+/**
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
@@ -160,7 +161,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
*/
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
-#define CONFIG_VERSION 0x20231124
+#define CONFIG_VERSION 0x20250526
#define CONFIG_MAGIC 0x5A5AA5A5
/**
@@ -201,13 +202,6 @@ typedef struct {
uint8_t controller_run_cpu; /*!< CPU number on which the Bluetooth controller task runs */
uint8_t enable_qa_test; /*!< Enable for QA test */
uint8_t enable_bqb_test; /*!< Enable for BQB test */
- uint8_t enable_uart_hci; /*!< Enable UART for HCI (Host Controller Interface) */
- uint8_t ble_hci_uart_port; /*!< Port of UART for HCI */
- uint32_t ble_hci_uart_baud; /*!< Baudrate of UART for HCI */
- uint8_t ble_hci_uart_data_bits; /*!< Data bits of UART for HCI */
- uint8_t ble_hci_uart_stop_bits; /*!< Stop bits of UART for HCI */
- uint8_t ble_hci_uart_flow_ctrl; /*!< Flow control of UART for HCI */
- uint8_t ble_hci_uart_uart_parity; /*!< UART parity */
uint8_t enable_tx_cca; /*!< Enable Clear Channel Assessment (CCA) when transmitting */
uint8_t cca_rssi_thresh; /*!< RSSI threshold for CCA */
uint8_t sleep_en; /*!< Enable sleep functionality */
@@ -220,8 +214,27 @@ typedef struct {
uint8_t cpu_freq_mhz; /*!< CPU frequency in megahertz */
uint8_t ignore_wl_for_direct_adv; /*!< Ignore the white list for directed advertising */
uint8_t enable_pcl; /*!< Enable power control */
- uint8_t csa2_select; /*!< Select CSA#2*/
- uint32_t config_magic; /*!< Configuration magic value */
+ uint8_t csa2_select; /*!< Select CSA#2*/
+ uint8_t enable_csr; /*!< Enable CSR */
+ uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */
+ uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
+ - The Controller does not disconnect after Instant Passed (0x28) by default. */
+ uint16_t scan_backoff_upperlimitmax; /*!< The value of upperlimitmax is 2^n, The maximum value is 256 */
+ uint8_t ble_chan_ass_en; /*!< Enable / disable BLE channel assessment. Configurable in menuconfig.
+ - 0 - Disable
+ - 1 - Enable (default) */
+ uint8_t ble_data_lenth_zero_aux; /*!< Enable / disable auxiliary packets when the extended ADV data length is zero. Configurable in menuconfig.
+ - 0 - Disable (default)
+ - 1 - Enable */
+ uint8_t vhci_enabled; /*!< VHCI is enabled */
+ uint8_t ptr_check_enabled; /*!< Enable boundary check for internal memory. */
+ uint8_t ble_adv_tx_options; /*!< The options for Extended advertising sending. */
+ uint8_t skip_unnecessary_checks_en; /*!< The option to skip non-fatal state checks and perform extra handling for fatal checks. */
+ uint8_t fast_conn_data_tx_en; /*!< The option for fast transmission of connection data
+ - 0 - Disable
+ - 1 - Enable (default) */
+ int8_t ch39_txpwr; /*!< BLE transmit power (in dBm) used for BLE advertising on channel 39. */
+ uint32_t config_magic; /*!< Configuration magic value */
} esp_bt_controller_config_t;
@@ -258,13 +271,6 @@ typedef struct {
.controller_run_cpu = 0, \
.enable_qa_test = RUN_QA_TEST, \
.enable_bqb_test = RUN_BQB_TEST, \
- .enable_uart_hci = HCI_UART_EN, \
- .ble_hci_uart_port = DEFAULT_BT_LE_HCI_UART_PORT, \
- .ble_hci_uart_baud = DEFAULT_BT_LE_HCI_UART_BAUD, \
- .ble_hci_uart_data_bits = DEFAULT_BT_LE_HCI_UART_DATA_BITS, \
- .ble_hci_uart_stop_bits = DEFAULT_BT_LE_HCI_UART_STOP_BITS, \
- .ble_hci_uart_flow_ctrl = DEFAULT_BT_LE_HCI_UART_FLOW_CTRL, \
- .ble_hci_uart_uart_parity = DEFAULT_BT_LE_HCI_UART_PARITY, \
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
.sleep_en = NIMBLE_SLEEP_ENABLE, \
@@ -274,8 +280,20 @@ typedef struct {
.main_xtal_freq = CONFIG_XTAL_FREQ, \
.cpu_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ, \
.ignore_wl_for_direct_adv = 0, \
- .enable_pcl = 0, \
- .csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
+ .enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED, \
+ .csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
+ .enable_csr = 0, \
+ .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
+ .ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
+ .scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
+ .ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
+ .ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
+ .vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \
+ .ptr_check_enabled = DEFAULT_BT_LE_PTR_CHECK_ENABLED, \
+ .ble_adv_tx_options = 0, \
+ .skip_unnecessary_checks_en = 0, \
+ .fast_conn_data_tx_en = DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN, \
+ .ch39_txpwr = BLE_LL_TX_PWR_DBM_N, \
.config_magic = CONFIG_MAGIC, \
}
@@ -432,6 +450,14 @@ extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr);
void esp_ble_controller_log_dump_all(bool output);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
+modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void);
+
+void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src);
+
+uint32_t esp_bt_get_lpclk_freq(void);
+
+void esp_bt_set_lpclk_freq(uint32_t clk_freq);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/bt/include/esp32h2/include/esp_bt_vs.h b/lib/bt/include/esp32h2/include/esp_bt_vs.h
new file mode 100644
index 00000000..3cbed925
--- /dev/null
+++ b/lib/bt/include/esp32h2/include/esp_bt_vs.h
@@ -0,0 +1,360 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+#include "sdkconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// @brief HCI VS Commands for Espressif's Bluetooth Host
+//
+// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these commands will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS commands are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief Config scanning duplicate exceptional list (OCF: 0x0108)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF (0x0108)
+/**
+* @brief Update exception list cmd parameters
+*/
+struct bt_hci_vs_update_exc_list {
+ uint8_t subcode; /*!< Add, remove or clear exception list */
+ uint32_t type; /*!< device type */
+ uint8_t device_info[6]; /*!< device information */
+};
+
+/**
+ * @brief Enable/disable advertising report flow control (OCF: 0x0109)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
+/**
+* @brief Init ADV flow control cmd parameters
+*/
+struct bt_hci_vs_init_adv_flow_ctrl {
+ uint8_t enable; /*!< Enable ADV flow control */
+ uint16_t num; /*!< ADV buffer maximum value */
+ uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
+};
+
+/**
+ * @brief Update the number of advertising report in ADV flow control (OCF: 0x010A)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
+/**
+* @brief Update ADV flow control cmd parameters
+*/
+struct bt_hci_vs_update_adv_flow_ctrl {
+ uint16_t num; /*!< The number of ADV report processed */
+};
+
+/**
+ * @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
+ *
+ * @note The init function is `adv_stack_enableClearLegacyAdvVsCmd(true)`
+ */
+#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
+/**
+* @brief Clear legacy ADV cmd parameters
+*/
+struct bt_hci_vs_ble_clr_legacy_adv {
+ // no parameters
+};
+
+/**
+ * @brief Set parameters of duplicate list (OCF: 0x010D)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_SET_DUP_LIST_PARAMS_OCF (0x010d)
+/**
+* @brief Set duplicate list cmd parameters
+*/
+struct bt_hci_vs_ble_set_dup_params {
+ uint8_t dup_mode; /*!< Duplicate mode */
+ uint8_t dup_ad_type; /*!< Duplicate data type */
+ uint16_t ring_list_max_num; /*!< Duplicate list size */
+};
+
+/**
+ * @brief Enable/disable duplicate and exception list (OCF: 0x010E)
+ *
+ * @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_DUP_EXC_LIST_OCF (0x010e)
+/**
+* @brief Enable duplicate and exception list cmd parameters
+*/
+struct bt_hci_vs_ble_enable_dup_exc {
+ uint8_t enable; /*!< Enable or disable */
+ uint8_t ring_list_reset; /*!< Reset list */
+};
+
+/**
+ * @brief Enable optimization of multiple connections (OCF: 0x010F)
+ *
+ * @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_ARRANGEMENT_OCF (0x010f)
+/**
+* @brief Multiple connections optimization cmd parameters
+*/
+struct bt_hci_vs_ble_enable_arrangement {
+ uint32_t common_factor; /*!< The greatest common factor of connection interval */
+ uint8_t enable; /*!< Enable or disable */
+};
+
+/**
+ * @brief Set scheduling length for a certain role (OCF: 0x0110)
+ *
+ * @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_SCHED_ROLE_LEN_OCF (0x0110)
+/**
+* @brief Scheduling length cmd parameters
+*/
+struct bt_hci_vs_ble_set_sched_role_len {
+ uint8_t role; /*!< BLE role; 0: central; 1: peripheral */
+ uint32_t len; /*!< Length is us */
+};
+
+/**
+ * @brief Set RSSI threshold for automatic power control (OCF: 0x0111)
+ *
+ * @note The init function is `pcl_stack_enableSetRssiThreshVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_PCL_RSSI_THRESH_OCF (0x0111)
+/**
+* @brief PCL RSSI threshold cmd parameters
+*/
+struct bt_hci_vs_ble_set_pcl_rssi_thresh {
+ uint16_t conn_handle; /*!< Connection handle */
+ uint8_t rssi_thresh_min_1M; /*!< Lower limit for 1M */
+ uint8_t rssi_thresh_max_1M; /*!< Upper limit for 1M */
+ uint8_t rssi_thresh_min_2M; /*!< Lower limit for 2M */
+ uint8_t rssi_thresh_max_2M; /*!< Upper limit for 2M */
+ uint8_t rssi_thresh_min_s2coded; /*!< Lower limit for s2 coded */
+ uint8_t rssi_thresh_max_s2coded; /*!< Upper limit for s2 coded */
+ uint8_t rssi_thresh_min_s8coded; /*!< Lower limit for s8 coded */
+ uint8_t rssi_thresh_max_s8coded; /*!< Upper limit for s8 coded */
+};
+
+/**
+ * @brief Enable/disable channel selection algorithm #2 (OCF: 0x0112)
+ *
+ * @note The init function is `chanSel_stack_enableSetCsaVsCmd(true)`
+ */
+#define ESP_BT_VS_ENABLE_CSA2_OCF (0x0112)
+/**
+* @brief Enable/disable channel selection algorithm #2 cmd parameters
+*/
+struct bt_hci_vs_ble_csa_enable {
+ uint8_t csa2_select; /*!< Select CSA2 */
+};
+
+/**
+ * @brief Set parameters of controller logs (OCF: 0x0114)
+ *
+ * @note The init function is `log_stack_enableLogsRelatedVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_LOG_PARAMS_OCF (0x0114)
+/**
+* @brief Controller logs cmd parameters
+*/
+struct bt_hci_vs_ble_log_params {
+ uint8_t type; /*!< Operation type */
+ uint32_t output_enable; /*!< Enable/disable output */
+ uint8_t buffer_optoin /*!< Select log buffers */
+};
+
+/**
+ * @brief Set BLE vendor events mask (OCF: 0x0116)
+ *
+ * @note The init function is `hci_stack_enableSetVsEvtMaskVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_LE_VENDOR_EVTS_MASK_OCF (0x0116)
+/**
+* @brief Set BLE vendor events mask cmd parameters
+*/
+struct bt_hci_vs_ble_set_vs_evts_mask {
+ uint32_t evt_masks; /*!< BLE vendor events Mask */
+};
+
+/**
+ * @brief Set peer sleep clock accuracy to a constant value (OCF: 0x0118)
+ *
+ * @note The init function is `winWiden_stack_enableSetConstPeerScaVsCmd(true)`
+ */
+#define ESP_BT_VS_SET_CONST_PEER_SCA_OCF (0x0118)
+/**
+* @brief Peer constant SCA cmd parameters
+*/
+struct bt_hci_vs_ble_set_const_peer_sca {
+ uint16_t peer_sca; /*!< Peer SCA */
+};
+
+// @brief HCI VS Events for Espressif's Bluetooth Host
+//
+// @note The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
+// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
+// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
+// Application developers **should not** call the init functions in their applications.
+//
+
+/**
+ * @brief BLE Scan/Connect Request, Aux Connect Response received event (EVTCODE: 0xFF, SUBCODE: 0xC0)
+ *
+ * @note The init function is `adv_stack_enableScanReqRxdVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_CONN_SCAN_REQ_RXED_EVT_SUBCODE (0xC0)
+/**
+* @brief BLE Scan/Connect Request, Aux Connect Response received event parameters
+*/
+struct bt_hci_vs_le_conn_scan_req_rxed_evt {
+ uint8_t evt_type; /*!< Event type; 0: SCAN_REQ; 1: CONN_IND */
+ uint8_t handle; /*!< Advertisement handle */
+ uint8_t peer_addr_type; /*!< Peer address type */
+ uint8_t peer_addr[6]; /*!< Peer address */
+};
+
+/**
+ * @brief BLE Channel Map Update Completion event (EVTCODE: 0xFF, SUBCODE: 0xC1)
+ *
+ * @note The init function is `conn_stack_enableChanMapUpdCompVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_CHAN_UPDATE_COMP_EVT_SUBCODE (0xC1)
+/**
+* @brief BLE Channel Map Update Completion event parameters
+*/
+struct bt_hci_vs_le_chan_update_comp_evt {
+ uint8_t status; /*!< Controller error code */
+ uint16_t handle; /*!< Connection handle */
+ uint8_t ch_map[5]; /*!< Updated channel map */
+};
+
+/**
+ * @brief BLE Wakeup From Sleep event (EVTCODE: 0xFF, SUBCODE: 0xC3)
+ *
+ * @note The init function is `sleep_stack_enableWakeupVsEvent(true)`
+ */
+#define ESP_BT_VS_LE_SLEEP_WAKEUP_EVT_SUBCODE (0xC3)
+/**
+* @brief BLE wakeup event parameters
+*/
+struct bt_hci_vs_le_sleep_wakeup_evt {
+ // no parameters
+};
+
+/**
+ * @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
+ *
+ * @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
+ */
+#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
+/**
+* @brief ADV lost event parameters
+*/
+struct bt_hci_vs_le_adv_lost_evt {
+ uint32_t nb_lost; /*!< The number of ADV report discarded */
+};
+
+//
+// @brief HCI VS Commands for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging commands are implemented in Bluetooth controller pre-compiled libraries.
+// These commands are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// They are intended for Espressif's internal use only. Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
+ #define ESP_BT_VS_CFG_TEST_SET_PREF_CODED_SUBCMD (0X02)
+ #define ESP_BT_VS_CFG_TEST_SET_DEFAULT_PRIV_MODE_SUBCMD (0X03)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
+ #define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
+ #define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
+ #define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_ENH_SUBCMD (0X0a)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_ENH_SUBCMD (0X0b)
+ #define ESP_BT_VS_CFG_TEST_IGNORE_WL_FOR_DIR_ADV_SUBCMD (0X0c)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_RXED_RSSI_SUBCMD (0X0d)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_CCA_SUBCMD (0X0e)
+ #define ESP_BT_VS_CFG_TEST_SET_CCA_WIN_SUBCMD (0X0f)
+ #define ESP_BT_VS_CFG_TEST_READ_CCA_DATA_SUBCM (0X10)
+ #define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
+ #define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
+ #define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
+ #define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
+ #define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
+ #define ESP_BT_VS_CFG_TEST_SKIP_LIGHT_SLEEP_CHECK_SUBCMD (0X17)
+ #define ESP_BT_VS_CFG_TEST_SET_WAKEUP_OVERHEAD_SUBCMD (0X18)
+ #define ESP_BT_VS_CFG_TEST_GET_ADV_MIN_ITVL_SUBCMD (0X19)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
+ #define ESP_BT_VS_CFG_TEST_SET_CONN_PHY_TXPWR_SUBCMD (0X1b)
+ #define ESP_BT_VS_CFG_TEST_GET_CONN_PHY_TXPWR_SUBCMD (0X1c)
+ #define ESP_BT_VS_CFG_TEST_GET_RXBUF_EMPTY_CNT_SUBCMD (0X1d)
+ #define ESP_BT_VS_CFG_TEST_RESTART_SUBCMD (0X1e)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_RECODE_RX_STATE_SUBCMD (0X1f)
+ #define ESP_BT_VS_CFG_TEST_GET_RECODE_CNT_SUBCMD (0X20)
+ #define ESP_BT_VS_CFG_TEST_CLR_RECODE_CNT_SUBCMD (0X21)
+ #define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
+ #define ESP_BT_VS_CFG_TEST_SET_AUX_ADV_OFFSET_SUBCMD (0X25)
+ #define ESP_BT_VS_CFG_TEST_INIT_FLEXIBLE_MODE_SUBCMD (0X26)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_FLEXIBLE_MODE_SUBCMD (0X27)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_CONN_ERR_SUBCMD (0X28)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_ADV_ERR_SUBCMD (0X29)
+ #define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_SCAN_ERR_SUBCMD (0X2a)
+ #define ESP_BT_VS_CFG_TEST_GET_TXED_CRCERR_SUBCMD (0X2c)
+ #define ESP_BT_VS_CFG_TEST_GET_BACKOFF_UPLIMIT_SUBCMD (0X2d)
+ #define ESP_BT_VS_CFG_TEST_GET_RXED_ADV_ADI_SUBCMD (0X2f)
+ #define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_MODE_SUBCMD (0X30)
+ #define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31)
+ #define ESP_BT_VS_CFG_TEST_CHECK_MSYS_BUF_SUBCMD (0X32)
+ #define ESP_BT_VS_CFG_TEST_UPDATE_BLE_TIMER_SUBCMD (0X33)
+ #define ESP_BT_VS_CFG_TEST_UPDATE_BLE_RTC_SUBCMD (0X34)
+ #define ESP_BT_VS_CFG_TEST_SET_LOCKED_MEM_NUM_SUBCMD (0X35)
+ #define ESP_BT_VS_CFG_TEST_ALLOW_MEM_ALLOC_SUBCMD (0X36)
+ #define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_INFO_PTR_SUBCMD (0X37)
+ #define ESP_BT_VS_CFG_TEST_SET_DIAG_IO_SUBCMD (0X38)
+ #define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39)
+ #define ESP_BT_VS_CFG_TEST_ENABLE_CHAN_ASSESS_SUBCMD (0X40)
+ #define ESP_BT_VS_CFG_TEST_SET_BACKOFF_UPLIMIT_SUBCMD (0X41)
+ #define ESP_BT_VS_CFG_TEST_SET_CONN_TOP_PRIO_RESV_THRESH_SUBCMD (0X42)
+ #define ESP_BT_VS_CFG_TEST_SET_TEST_EVT_MSK_SUBCMD (0X43)
+ #define ESP_BT_VS_CFG_TEST_GET_WAKEUP_TIMEOUT_SUBCMD (0X45)
+ #define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
+
+//
+// @brief HCI VS Events for Espressif's Internal-Use Debugging
+//
+// @note The following HCI VS debugging events are implemented in Bluetooth controller pre-compiled libraries.
+// These events are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
+// Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
+//
+
+#define ESP_BT_VS_LE_RUNNING_STATUS_EVT_SUBCODE (0xC3)
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/lib/bt/include/esp32h4/include/esp_bt_cfg.h b/lib/bt/include/esp32h4/include/esp_bt_cfg.h
index 768a0c6c..1f8caaec 100644
--- a/lib/bt/include/esp32h4/include/esp_bt_cfg.h
+++ b/lib/bt/include/esp32h4/include/esp_bt_cfg.h
@@ -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
*/
@@ -116,6 +116,20 @@ extern "C" {
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8)
#endif
+ #if defined (CONFIG_BT_LE_HCI_UART_FLOWCTRL)
+ #define DEFAULT_BT_LE_HCI_UART_FLOW_CTRL (CONFIG_BT_LE_HCI_UART_FLOWCTRL)
+ #if DEFAULT_BT_LE_HCI_UART_FLOW_CTRL
+ #define DEFAULT_BT_LE_HCI_UART_CTS_PIN (CONFIG_BT_LE_HCI_UART_CTS_PIN)
+ #define DEFAULT_BT_LE_HCI_UART_RTS_PIN (CONFIG_BT_LE_HCI_UART_RTS_PIN)
+ #else
+ #define DEFAULT_BT_LE_HCI_UART_CTS_PIN (-1)
+ #define DEFAULT_BT_LE_HCI_UART_RTS_PIN (-1)
+ #endif
+ #else
+ #define DEFAULT_BT_LE_HCI_UART_FLOW_CTRL (0)
+ #define DEFAULT_BT_LE_HCI_UART_CTS_PIN (-1)
+ #define DEFAULT_BT_LE_HCI_UART_RTS_PIN (-1)
+ #endif
#endif
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
@@ -156,8 +170,6 @@ extern "C" {
#define DEFAULT_BT_LE_HCI_UART_DATA_BITS (UART_DATA_8_BITS)
#define DEFAULT_BT_LE_HCI_UART_STOP_BITS (UART_STOP_BITS_1)
#define DEFAULT_BT_LE_HCI_UART_PARITY (0)
- #define DEFAULT_BT_LE_HCI_UART_TASK_STACK_SIZE (CONFIG_BT_LE_HCI_UART_TASK_STACK_SIZE)
- #define DEFAULT_BT_LE_HCI_UART_FLOW_CTRL (0)
#else
#define DEFAULT_BT_LE_HCI_UART_TX_PIN (0)
#define DEFAULT_BT_LE_HCI_UART_RX_PIN (0)
@@ -166,8 +178,6 @@ extern "C" {
#define DEFAULT_BT_LE_HCI_UART_DATA_BITS (0)
#define DEFAULT_BT_LE_HCI_UART_STOP_BITS (0)
#define DEFAULT_BT_LE_HCI_UART_PARITY (0)
- #define DEFAULT_BT_LE_HCI_UART_TASK_STACK_SIZE (0)
- #define DEFAULT_BT_LE_HCI_UART_FLOW_CTRL (0)
#endif
/* Unchanged configuration */