Skip to content

Commit 23d71fe

Browse files
committed
Merge branch 'feat/add_cte_iq_report_example' into 'master'
Add Bluetooth LE CTE connless example. See merge request espressif/esp-idf!39327
2 parents 4233552 + aa4489a commit 23d71fe

File tree

24 files changed

+1172
-0
lines changed

24 files changed

+1172
-0
lines changed

components/soc/esp32c5/include/soc/Kconfig.soc_caps.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,10 @@ config SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED
18111811
bool
18121812
default y
18131813

1814+
config SOC_BLE_CTE_SUPPORTED
1815+
bool
1816+
default y
1817+
18141818
config SOC_LP_CORE_SINGLE_INTERRUPT_VECTOR
18151819
bool
18161820
default y

components/soc/esp32c5/include/soc/soc_caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@
700700
#define SOC_BLE_POWER_CONTROL_SUPPORTED (1) /*!< Support Bluetooth Power Control */
701701
#define SOC_BLE_MULTI_CONN_OPTIMIZATION (1) /*!< Support multiple connections optimization */
702702
#define SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED (1) /*!< Support For BLE Periodic Adv Enhancements */
703+
#define SOC_BLE_CTE_SUPPORTED (1) /*!< Support Bluetooth LE Constant Tone Extension (CTE) */
703704

704705
/*------------------------------------- PHY CAPS -------------------------------------*/
705706
// #define SOC_PHY_COMBO_MODULE (1) /*!< Support Wi-Fi, BLE and 15.4*/

examples/bluetooth/.build-test-rules.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ examples/bluetooth/hci/controller_vhci_ble_adv:
180180

181181

182182
# config BT_NIMBLE_ENABLED does not depends on any soc cap
183+
examples/bluetooth/nimble/ble_cte:
184+
<<: *bt_default_depends
185+
enable:
186+
- if: SOC_BLE_CTE_SUPPORTED == 1
187+
depends_filepatterns:
188+
- examples/bluetooth/nimble/ble_cte/common_components/*
189+
183190
examples/bluetooth/nimble/ble_enc_adv_data:
184191
<<: *bt_default_depends
185192
enable:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following lines of boilerplate have to be in your project's
2+
# CMakeLists in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6+
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
7+
idf_build_set_property(MINIMAL_BUILD ON)
8+
project(ble_periodic_adv_cte)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
| Supported Targets | ESP32-C5 | ESP32-H2 |
2+
| ----------------- | -------- | -------- |
3+
4+
# Bluetooth LE Direction Finding Example (Periodic Advertiser With CTE)
5+
6+
(See the README.md file in the upper level 'examples' directory for more information about examples.)
7+
8+
This example starts periodic advertising with a non-resolvable private address and includes Constant Tone Extension (CTE) signals.
9+
10+
It uses Bluetooth controller and NimBLE stack based BLE host.
11+
12+
This example aims at understanding how to use direction finding features use periodic advertisement and related NimBLE APIs.
13+
14+
To test this demo, BLE Periodic Sync With CTE app can be used as a locator.
15+
16+
## How to Use Example
17+
18+
Before project configuration and build, be sure to set the correct chip target using:
19+
20+
```bash
21+
idf.py set-target <chip_name>
22+
```
23+
24+
### Configure the project (Optional)
25+
26+
If you need to change the Direction Finding mode or configure antenna control GPIOs, run the configuration menu:
27+
28+
```bash
29+
idf.py menuconfig
30+
```
31+
32+
Navigate to the `Example Configuration` menu where you can:
33+
34+
* Change the `Direction Finding Mode` if needed.
35+
* Set the GPIO pin configuration for antenna switching when using the `AoD (Antenna Switching with GPIO Encoding)` mode.
36+
37+
> Note: These configurations are optional. Only modify them if you need to adjust the default behavior.
38+
39+
40+
### Build and Flash
41+
42+
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
43+
44+
(To exit the serial monitor, type ``Ctrl-]``.)
45+
46+
See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.
47+
48+
## Example Output
49+
50+
There is this console output when periodic_adv is started:
51+
52+
```
53+
I (364) main_task: Started on CPU0
54+
I (364) main_task: Calling app_main()
55+
I (374) BLE_INIT: Using main XTAL as clock source
56+
I (374) BLE_INIT: ble controller commit:[c223b2b]
57+
I (384) BLE_INIT: Bluetooth MAC: 74:4d:bd:60:1b:bb
58+
I (394) phy: phy_version: 322,2, 823e7f8, Mar 3 2025, 16:09:11
59+
I (414) phy: libbtbb version: e9c8b26, Mar 3 2025, 16:09:24
60+
I (414) CTE_ADV_EXAMPLE:
61+
███████╗███████╗██████╗ ██████╗ ██╗ ███████╗
62+
██╔════╝██╔════╝██╔══██╗ ██╔══██╗██║ ██╔════╝
63+
█████╗ ███████╗██████╔╝ ██████╔╝██║ █████╗
64+
██╔══╝ ╚════██║██╔═══╝ ██╔══██╗██║ ██╔══╝
65+
███████╗███████║██║ ██████╔╝███████╗███████╗
66+
╚══════╝╚══════╝╚═╝ ╚═════╝ ╚══════╝╚══════╝
67+
68+
██████╗ ██╗██████╗ ███████╗ ██████╗████████╗██╗ ██████╗ ███╗ ██╗ ███████╗██╗███╗ ██╗██████╗ ██╗███╗ ██╗ ██████╗
69+
██╔══██╗██║██╔══██╗██╔════╝██╔════╝╚══██╔══╝██║██╔═══██╗████╗ ██║ ██╔════╝██║████╗ ██║██╔══██╗██║████╗ ██║██╔════╝
70+
██║ ██║██║██████╔╝█████╗ ██║ ██║ ██║██║ ██║██╔██╗ ██║ █████╗ ██║██╔██╗ ██║██║ ██║██║██╔██╗ ██║██║ ███╗
71+
██║ ██║██║██╔══██╗██╔══╝ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██╔══╝ ██║██║╚██╗██║██║ ██║██║██║╚██╗██║██║ ██║
72+
██████╔╝██║██║ ██║███████╗╚██████╗ ██║ ██║╚██████╔╝██║ ╚████║ ██║ ██║██║ ╚████║██████╔╝██║██║ ╚████║╚██████╔╝
73+
╚═════╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
74+
75+
76+
I (704) CTE_ADV_EXAMPLE: DIRECTION_FINDING Example Periodic Adv AOA Mode
77+
I (714) CTE_ADV_EXAMPLE: BLE Host Task Started
78+
I (714) NimBLE: Failed to restore IRKs from store; status=8
79+
80+
I (724) CTE_ADV_EXAMPLE: Device Address:
81+
I (724) CTE_ADV_EXAMPLE: 10:21:34:8d:5a:c4
82+
I (734) NimBLE: GAP procedure initiated: extended advertise; instance=1
83+
84+
I (734) CTE_ADV_EXAMPLE: Instance 1 started (periodic)
85+
I (744) main_task: Returned from app_main()
86+
87+
```
88+
89+
## Troubleshooting
90+
91+
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
idf_component_register(SRCS "main.c"
2+
INCLUDE_DIRS ".")
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
menu "Example Configuration"
2+
3+
choice
4+
prompt "Direction Finding Mode"
5+
default EXAMPLE_ADV_DIRECTION_FINDING_AOA
6+
help
7+
Select the direction finding technology for periodic advertising.
8+
9+
config EXAMPLE_ADV_DIRECTION_FINDING_AOA
10+
bool "AoA (Constant Tone Only)"
11+
help
12+
Select this option for Angle of Arrival (AoA) mode.
13+
The advertiser will send CTE with constant tone only,
14+
no antenna switching required on the advertiser side.
15+
16+
config EXAMPLE_ADV_DIRECTION_FINDING_AOD
17+
bool "AoD (Antenna Switching with GPIO Encoding)"
18+
help
19+
Select this option for Angle of Departure (AoD) mode.
20+
The advertiser will send CTE with antenna switching pattern.
21+
GPIOs are used as encoded bits to control multiple antennas.
22+
For example: 2 GPIOs can control 4 antennas (00, 01, 10, 11).
23+
24+
endchoice
25+
26+
if EXAMPLE_ADV_DIRECTION_FINDING_AOD
27+
28+
config EXAMPLE_ANT_GPIO_BIT_COUNT
29+
int "Number of GPIO bits for antenna encoding"
30+
range 1 4
31+
default 2
32+
help
33+
Select the number of GPIO pins used as encoded bits for antenna switching.
34+
Each additional GPIO bit doubles the number of controllable antennas.
35+
Example:
36+
1 bit -> 2 antennas (0, 1)
37+
2 bits -> 4 antennas (00, 01, 10, 11)
38+
3 bits -> 8 antennas
39+
4 bits -> 16 antennas
40+
41+
config EXAMPLE_ANT_GPIO_0
42+
int "GPIO Bit 0 (LSB)"
43+
range 0 39
44+
default 0
45+
help
46+
GPIO pin number for the least significant bit (LSB) of antenna encoding.
47+
48+
config EXAMPLE_ANT_GPIO_1
49+
int "GPIO Bit 1"
50+
range 0 39
51+
default 1
52+
depends on EXAMPLE_ANT_GPIO_BIT_COUNT > 1
53+
help
54+
GPIO pin number for bit 1 of antenna encoding.
55+
56+
config EXAMPLE_ANT_GPIO_2
57+
int "GPIO Bit 2"
58+
range 0 39
59+
default 2
60+
depends on EXAMPLE_ANT_GPIO_BIT_COUNT > 2
61+
help
62+
GPIO pin number for bit 2 of antenna encoding.
63+
64+
config EXAMPLE_ANT_GPIO_3
65+
int "GPIO Bit 3 (MSB)"
66+
range 0 39
67+
default 3
68+
depends on EXAMPLE_ANT_GPIO_BIT_COUNT > 3
69+
help
70+
GPIO pin number for the most significant bit (MSB) of antenna encoding.
71+
72+
endif # EXAMPLE_DIRECTION_FINDING_CTE
73+
74+
config EXAMPLE_RANDOM_ADDR
75+
bool
76+
prompt "Advertise RANDOM Address"
77+
help
78+
Use this option to advertise a random address instead of public address
79+
80+
endmenu
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies:
2+
cte_config:
3+
path: ${IDF_PATH}/examples/bluetooth/nimble/ble_cte/common_components/cte_config

0 commit comments

Comments
 (0)