Skip to content

Commit

Permalink
samples: bluetooth: Add Channel Sounding Initiator with RREQ sample
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sean-madigan committed Nov 15, 2024
1 parent b386295 commit d6bf442
Show file tree
Hide file tree
Showing 7 changed files with 1,081 additions and 0 deletions.
17 changes: 17 additions & 0 deletions samples/bluetooth/channel_sounding_ras_initiator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(NONE)

FILE(GLOB app_sources src/*.c)
# NORDIC SDK APP START
target_sources(app PRIVATE
${app_sources}
)
# NORDIC SDK APP END
98 changes: 98 additions & 0 deletions samples/bluetooth/channel_sounding_ras_initiator/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
.. _channel_sounding_ras_reflector:

Bluetooth: Channel Sounding Reflector with Ranging Responder
############################################################

.. contents::
:local:
:depth: 2

This sample demonstrates how to use the ranging service to request ranging data from a server.
It also provides a basic distance estimation algorithm to show how channel sounding can be used to estimate distance between two devices.

Requirements
************

The sample supports the following development kits:

.. table-from-sample-yaml::

The sample also requires a device running a Channel Sounding Reflector with Ranging Responder to connect to.

Overview
********

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.
Regular Channel Sounding procedures are set up, local subevent data is stored and peer ranging data is fetched.

A basic distance estimation algorithm is included in the sample.
The mathematical representations described in [#phase_and_amplitude]_ and [#rtt_packets]_ are used as the basis for this algorithm.

User interface
**************

The sample does not require user input and will scan for a device advertising with the GATT Ranging Service UUID.
The first LED on the development kit will be lit when a connection has been established.

Building and running
********************
.. |sample path| replace:: :file:`samples/bluetooth/channel_sounding_ras_initiator`

.. include:: /includes/build_and_run.txt

Testing
=======

After programming the sample to your development kit, you can test it by connecting to another development kit with a Channel Sounding Reflector role with Ranging Responder.

1. |connect_terminal_specific|
#. Reset the kit.
#. Program the other kit with the Channel Sounding Reflector with Ranging Responder sample.
#. Wait until the scanner detects the Peripheral.
In the terminal window, check for information similar to the following::

Filters matched. Address: XX:XX:XX:XX:XX:XX (random) connectable: 1
Connecting
Connected to XX:XX:XX:XX:XX:XX (random) (err 0x00)
Security changed: XX:XX:XX:XX:XX:XX (random) level 2
MTU exchange success (498)
The discovery procedure succeeded
CS capability exchange completed.
CS config creation complete. ID: 0
CS security enabled.
CS procedures enabled.
Subevent result callback 0
Ranging data ready 0
Ranging data get completed for ranging counter 0
Estimated distance to reflector:
- Round-Trip Timing method: X.XXXXX meters (derived from X samples)
- Phase-Based Ranging method: X.XXXXX meters (derived from X samples)

Dependencies
************

This sample uses the following |NCS| libraries:

* :ref:`dk_buttons_and_leds_readme`
* :file:`include/bluetooth/gatt_dm.h`
* :file:`include/bluetooth/services/ras.h`

This sample uses the following Zephyr libraries:

* :file:`include/sys/printk.h`
* :file:`include/zephyr/types.h`
* :ref:`zephyr:kernel_api`:

* :file:`include/kernel.h`

* :ref:`zephyr:bluetooth_api`:

* :file:`include/bluetooth/bluetooth.h`
* :file:`include/bluetooth/conn.h`
* :file:`include/bluetooth/cs.h`

References
**********

.. [#phase_and_amplitude] `Bluetooth Core Specification v. 6.0: Vol. 1, Part A, 9.2 <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>`_
.. [#rtt_packets] `Bluetooth Core Specification v. 6.0: Vol. 1, Part A, 9.3 <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>`_
38 changes: 38 additions & 0 deletions samples/bluetooth/channel_sounding_ras_initiator/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_DK_LIBRARY=y

CONFIG_BT=y
CONFIG_BT_SMP=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_MAX_CONN=1
CONFIG_BT_BONDABLE=n

CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DYNAMIC_DB=y

CONFIG_BT_CHANNEL_SOUNDING=y
CONFIG_BT_RAS=y
CONFIG_BT_RAS_RREQ=y

CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1

# The Ranging Profile recommends a MTU of at least 247 octets.
CONFIG_BT_L2CAP_TX_MTU=498
CONFIG_BT_BUF_ACL_TX_SIZE=502
CONFIG_BT_BUF_ACL_RX_SIZE=502
CONFIG_BT_ATT_PREPARE_COUNT=3

CONFIG_BT_CTLR_PHY_2M=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_CBPRINTF_FP_SUPPORT=y
12 changes: 12 additions & 0 deletions samples/bluetooth/channel_sounding_ras_initiator/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sample:
description: Bluetooth Low Energy Channel Sounding Initiator with Ranging Service Requestor
name: Bluetooth LE Channel Sounding Initiator with RREQ
tests:
sample.bluetooth.channel_sounding_ras_initiator:
sysbuild: true
build_only: true
integration_platforms:
- nrf54l15dk/nrf54l15/cpuapp
platform_allow:
- nrf54l15dk/nrf54l15/cpuapp
tags: bluetooth ci_build sysbuild
Loading

0 comments on commit d6bf442

Please sign in to comment.