Skip to content

Commit 5b8148d

Browse files
olivier-le-sageeriksandgren
authored andcommitted
bluetooth: samples: Add samples showing basic channel sounding features
These samples demonstrate how to use the bluetooth 6.0 channel sounding APIs. A basic distance estimation algorithm is included. Signed-off-by: Olivier Lesage <[email protected]>
1 parent 7d33a1b commit 5b8148d

File tree

10 files changed

+1402
-0
lines changed

10 files changed

+1402
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.. zephyr:code-sample:: ble_cs
2+
:name: Channel Sounding
3+
:relevant-api: bt_gap bluetooth
4+
5+
Use Channel Sounding functionality.
6+
7+
8+
Bluetooth: Channel Sounding
9+
###########################
10+
11+
Overview
12+
********
13+
14+
These samples demonstrates how to use the Bluetooth Channel Sounding feature.
15+
16+
The CS Test sample shows how to us the CS test command to override randomization of certain channel
17+
sounding parameters, experiment with different configurations, or evaluate the RF medium. It can
18+
be found under :zephyr_file:`samples/bluetooth/channel_sounding/cs_test`.
19+
20+
The connected CS sample shows how to set up regular channel sounding procedures on a connection
21+
between two devices.
22+
It can be found under :zephyr_file:`samples/bluetooth/channel_sounding/connected_cs`
23+
24+
A basic distance estimation algorithm is included in both.
25+
The Channel Sounding feature does not mandate a specific algorithm for computing distance estimates,
26+
but the mathematical representation described in [#phase_and_amplitude]_ and [#rtt_packets]_ is used
27+
as a starting point for these samples.
28+
29+
Distance estimation using channel sounding requires data from two devices, and for that reason
30+
the channel sounding results in the sample are exchanged in a simple way using a GATT characteristic.
31+
This limits the amount of data that can be processed at once to about 512 bytes from each device,
32+
which is enough to estimate distance using a handful of RTT timings and PBR phase samples across
33+
about 35-40 channels, assuming a single antenna path.
34+
35+
Both samples will perform channel sounding procedures repeatedly and print regular distance estimates to
36+
the console. They are designed assuming a single subevent per procedure.
37+
38+
Requirements
39+
************
40+
41+
* A board with BLE support
42+
* A controller that supports the Channel Sounding feature
43+
44+
Building and Running
45+
********************
46+
47+
These samples can be found under :zephyr_file:`samples/bluetooth/channel_sounding` in
48+
the Zephyr tree.
49+
50+
See :zephyr:code-sample-category:`bluetooth` samples for details.
51+
52+
References
53+
**********
54+
55+
.. [#phase_and_amplitude] Bluetooth Core Specification v. 6.0: Vol. 1, Part A, 9.2
56+
.. [#rtt_packets] Bluetooth Core Specification v. 6.0: Vol. 1, Part A, 9.3
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(channel_sounding_test)
6+
7+
target_sources(app PRIVATE ../src/connected_cs.c ../src/distance_estimation.c)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CONFIG_CONSOLE=y
2+
CONFIG_CONSOLE_SUBSYS=y
3+
CONFIG_CONSOLE_HANDLER=y
4+
CONFIG_CONSOLE_GETCHAR=y
5+
6+
CONFIG_BT=y
7+
CONFIG_BT_SMP=y
8+
CONFIG_BT_CENTRAL=y
9+
CONFIG_BT_PERIPHERAL=y
10+
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
11+
CONFIG_BT_GATT_CLIENT=y
12+
CONFIG_BT_GATT_DYNAMIC_DB=y
13+
CONFIG_BT_ATT_PREPARE_COUNT=3
14+
CONFIG_BT_CHANNEL_SOUNDING=y
15+
CONFIG_LOG=y
16+
17+
CONFIG_BT_BUF_ACL_RX_SIZE=251
18+
CONFIG_BT_BUF_ACL_TX_SIZE=251
19+
CONFIG_BT_L2CAP_TX_MTU=247
20+
21+
CONFIG_MAIN_STACK_SIZE=4096
22+
23+
CONFIG_LOG_BUFFER_SIZE=2048
24+
CONFIG_CBPRINTF_FP_SUPPORT=y
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sample:
2+
name: Bluetooth Channel Sounding
3+
tests:
4+
sample.bluetooth.channel_sounding.connected_cs:
5+
harness: bluetooth
6+
platform_allow:
7+
- qemu_cortex_m3
8+
- qemu_x86
9+
tags: bluetooth
10+
integration_platforms:
11+
- qemu_cortex_m3
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(channel_sounding_test)
6+
7+
target_sources(app PRIVATE ../src/cs_test.c ../src/distance_estimation.c)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CONFIG_CONSOLE=y
2+
CONFIG_CONSOLE_SUBSYS=y
3+
CONFIG_CONSOLE_HANDLER=y
4+
CONFIG_CONSOLE_GETCHAR=y
5+
6+
CONFIG_BT=y
7+
CONFIG_BT_CENTRAL=y
8+
CONFIG_BT_PERIPHERAL=y
9+
CONFIG_BT_GATT_CLIENT=y
10+
CONFIG_BT_GATT_DYNAMIC_DB=y
11+
CONFIG_BT_ATT_PREPARE_COUNT=3
12+
CONFIG_BT_CHANNEL_SOUNDING=y
13+
CONFIG_BT_CHANNEL_SOUNDING_TEST=y
14+
CONFIG_LOG=y
15+
16+
CONFIG_BT_BUF_ACL_RX_SIZE=251
17+
CONFIG_BT_BUF_ACL_TX_SIZE=251
18+
CONFIG_BT_L2CAP_TX_MTU=247
19+
20+
CONFIG_MAIN_STACK_SIZE=4096
21+
22+
CONFIG_LOG_BUFFER_SIZE=2048
23+
CONFIG_CBPRINTF_FP_SUPPORT=y
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sample:
2+
name: Bluetooth Channel Sounding Test
3+
tests:
4+
sample.bluetooth.channel_sounding.cs_test:
5+
harness: bluetooth
6+
platform_allow:
7+
- qemu_cortex_m3
8+
- qemu_x86
9+
tags: bluetooth
10+
integration_platforms:
11+
- qemu_cortex_m3

0 commit comments

Comments
 (0)