Skip to content

Commit 8fdc675

Browse files
committed
samples: bluetooth: Add Channel Sounding Initiator with RREQ sample
This sample can be used to set up a Channel Sounding Initiator with the GATT Ranging Requestor client. It can connect to Channel Sounding Reflector with Ranging Responder sample to request CS Ranging Data from. A simple distance estimation algorithm is included. This uses the same logic as the Zephyr Channel Sounding sample. Signed-off-by: Sean Madigan <[email protected]>
1 parent 3c94a8a commit 8fdc675

File tree

13 files changed

+1013
-3
lines changed

13 files changed

+1013
-3
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@
411411
/samples/bluetooth/central_nfc_pairing/ @nrfconnect/ncs-si-muffin
412412
/samples/bluetooth/central_smp_client/ @nrfconnect/ncs-si-muffin
413413
/samples/bluetooth/central_uart/ @nrfconnect/ncs-si-muffin
414+
/samples/bluetooth/channel_sounding_ras_initiator/ @nrfconnect/ncs-dragoon
414415
/samples/bluetooth/channel_sounding_ras_reflector/ @nrfconnect/ncs-dragoon
415416
/samples/bluetooth/conn_time_sync/ @nrfconnect/ncs-dragoon
416417
/samples/bluetooth/direction_finding_central/ @nrfconnect/ncs-dragoon

doc/nrf/links.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,9 @@
10131013
.. _`Auracast™`: https://www.bluetooth.com/auracast/how-it-works/
10141014
.. _`Basic Audio Profile specification`: https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/16212-BAP-html5/out/en/index-en.html#UUID-c9d31763-9ede-2270-6b9c-c042ae684cc3
10151015

1016+
.. _`Distance estimation based on phase and amplitude information`: https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-60/out/en/architecture,-change-history,-and-conventions/architecture.html#UUID-a8d03618-5fcf-3043-2198-559653272b1b
1017+
.. _`Distance estimation based on RTT packets`: https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-60/out/en/architecture,-change-history,-and-conventions/architecture.html#UUID-9d4969af-baa6-b7e4-03ca-70b340877adf
1018+
10161019
.. ### Source: openmobilealliance.org
10171020

10181021
.. _`SUPL context model`: https://www.openmobilealliance.org/release/SUPL/V1_0-20060127-C/OMA-AD-SUPL-V1_0-20060127-C.pdf#page=16

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ Bluetooth samples
249249
* Added:
250250

251251
* The :ref:`channel_sounding_ras_reflector` sample demonstrating how to implement a Channel Sounding Reflector that exposes the Ranging Responder GATT Service.
252+
* The :ref:`channel_sounding_ras_initiator` sample demonstrating basic distance estimation with Channel Sounding by setting up a Channel Sounding Initiator that acts as a Ranging Requestor GATT Client.
252253

253254
* Updated:
254255

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(NONE)
11+
12+
FILE(GLOB app_sources src/*.c)
13+
# NORDIC SDK APP START
14+
target_sources(app PRIVATE
15+
${app_sources}
16+
)
17+
# NORDIC SDK APP END
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
.. _channel_sounding_ras_initiator:
2+
3+
Bluetooth: Channel Sounding Initiator with Ranging Requestor
4+
############################################################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
This sample demonstrates how to use the ranging service to request ranging data from a server.
11+
It also provides a basic distance estimation algorithm to show how channel sounding can be used to estimate distance between two devices.
12+
13+
Requirements
14+
************
15+
16+
The sample supports the following development kits:
17+
18+
.. table-from-sample-yaml::
19+
20+
The sample also requires a device running a Channel Sounding Reflector with Ranging Responder to connect to, such as the :ref:`channel_sounding_ras_reflector` sample.
21+
22+
Overview
23+
********
24+
25+
The sample demonstrates a basic Bluetooth® Low Energy Central role functionality that acts as a GATT Ranging Requestor client and configures the Channel Sounding initiator role.
26+
Regular Channel Sounding procedures are set up, local subevent data is stored, and peer ranging data is fetched.
27+
28+
A basic distance estimation algorithm is included in the sample.
29+
The mathematical representations described in `Distance estimation based on phase and amplitude information`_ and `Distance estimation based on RTT packets`_ are used as the basis for this algorithm.
30+
31+
User interface
32+
**************
33+
34+
The sample does not require user input and will scan for a device advertising with the GATT Ranging Service UUID.
35+
The first LED on the development kit will be lit when a connection has been established.
36+
37+
Building and running
38+
********************
39+
.. |sample path| replace:: :file:`samples/bluetooth/channel_sounding_ras_initiator`
40+
41+
.. include:: /includes/build_and_run.txt
42+
43+
Testing
44+
=======
45+
46+
After programming the sample to your development kit, you can test it by connecting to another device programmed with a Channel Sounding Reflector role with Ranging Responder, such as the :ref:`channel_sounding_ras_reflector` sample.
47+
48+
1. |connect_terminal_specific|
49+
#. Reset both kits.
50+
#. Wait until the scanner detects the Peripheral.
51+
In the terminal window, check for information similar to the following::
52+
53+
I: Filters matched. Address: XX:XX:XX:XX:XX:XX (random) connectable: 1
54+
I: Connecting
55+
I: Connected to XX:XX:XX:XX:XX:XX (random) (err 0x00)
56+
I: Security changed: XX:XX:XX:XX:XX:XX (random) level 2
57+
I: MTU exchange success (498)
58+
I: The discovery procedure succeeded
59+
I: CS capability exchange completed.
60+
I: CS config creation complete. ID: 0
61+
I: CS security enabled.
62+
I: CS procedures enabled.
63+
I: Subevent result callback 0
64+
I: Ranging data ready 0
65+
I: Ranging data get completed for ranging counter 0
66+
I: Estimated distance to reflector:
67+
I: - Round-Trip Timing method: X.XXXXX meters (derived from X samples)
68+
I: - Phase-Based Ranging method: X.XXXXX meters (derived from X samples)
69+
70+
Dependencies
71+
************
72+
73+
This sample uses the following |NCS| libraries:
74+
75+
* :ref:`dk_buttons_and_leds_readme`
76+
* :file:`include/bluetooth/gatt_dm.h`
77+
* :file:`include/bluetooth/services/ras.h`
78+
79+
This sample uses the following Zephyr libraries:
80+
81+
* :file:`include/sys/printk.h`
82+
* :file:`include/zephyr/types.h`
83+
* :ref:`zephyr:kernel_api`:
84+
85+
* :file:`include/kernel.h`
86+
87+
* :ref:`zephyr:bluetooth_api`:
88+
89+
* :file:`include/bluetooth/bluetooth.h`
90+
* :file:`include/bluetooth/conn.h`
91+
* :file:`include/bluetooth/cs.h`
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_NCS_SAMPLES_DEFAULTS=y
8+
CONFIG_DK_LIBRARY=y
9+
10+
CONFIG_BT=y
11+
CONFIG_BT_SMP=y
12+
CONFIG_BT_CENTRAL=y
13+
CONFIG_BT_MAX_CONN=1
14+
CONFIG_BT_BONDABLE=n
15+
16+
CONFIG_BT_GATT_CLIENT=y
17+
CONFIG_BT_GATT_DYNAMIC_DB=y
18+
19+
CONFIG_BT_CHANNEL_SOUNDING=y
20+
CONFIG_BT_RAS=y
21+
CONFIG_BT_RAS_RREQ=y
22+
23+
CONFIG_BT_SCAN=y
24+
CONFIG_BT_SCAN_FILTER_ENABLE=y
25+
CONFIG_BT_SCAN_UUID_CNT=1
26+
27+
# The Ranging Profile recommends a MTU of at least 247 octets.
28+
CONFIG_BT_L2CAP_TX_MTU=498
29+
CONFIG_BT_BUF_ACL_TX_SIZE=502
30+
CONFIG_BT_BUF_ACL_RX_SIZE=502
31+
CONFIG_BT_ATT_PREPARE_COUNT=3
32+
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
33+
34+
# This allows CS and ACL to use different PHYs
35+
CONFIG_BT_TRANSMIT_POWER_CONTROL=y
36+
37+
CONFIG_CBPRINTF_FP_SUPPORT=y
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
sample:
2+
description: Bluetooth Low Energy Channel Sounding Initiator with Ranging Service Requestor
3+
name: Bluetooth LE Channel Sounding Initiator with RREQ
4+
tests:
5+
sample.bluetooth.channel_sounding_ras_initiator:
6+
sysbuild: true
7+
build_only: true
8+
integration_platforms:
9+
- nrf54l15dk/nrf54l15/cpuapp
10+
platform_allow:
11+
- nrf54l15dk/nrf54l15/cpuapp
12+
tags: bluetooth ci_build sysbuild

0 commit comments

Comments
 (0)