Skip to content

Commit fb21110

Browse files
EndreEGhermabe
authored andcommitted
Bluetooth: path_loss_monitoring: Add path loss monitoring sample
Added a new sample demonstrating Bluetooth LE Path Loss Monitoring using three LEDs on the central DK. Signed-off-by: Endre Ekstang Grønevik <[email protected]>
1 parent ca33bb1 commit fb21110

File tree

18 files changed

+648
-1
lines changed

18 files changed

+648
-1
lines changed

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@
476476
/samples/bluetooth/peripheral_with_multiple_identities/ @nrfconnect/ncs-dragoon
477477
/samples/bluetooth/radio_coex_1wire/ @nrfconnect/ncs-dragoon
478478
/samples/bluetooth/radio_notification_cb/ @nrfconnect/ncs-dragoon
479+
/samples/bluetooth/path_loss_monitoring/ @nrfconnect/ncs-dragoon
479480
/samples/bluetooth/rpc_host/ @nrfconnect/ncs-si-muffin
480481
/samples/bluetooth/scanning_while_connecting/ @nrfconnect/ncs-dragoon
481482
/samples/bluetooth/shell_bt_nus/ @nrfconnect/ncs-si-muffin
@@ -591,6 +592,7 @@
591592
/samples/bluetooth/llpm/*.rst @nrfconnect/ncs-dragoon-doc
592593
/samples/bluetooth/multiple_adv_sets/*.rst @nrfconnect/ncs-si-muffin-doc
593594
/samples/bluetooth/nrf_dm/*.rst @nrfconnect/ncs-si-muffin-doc
595+
/samples/bluetooth/path_loss_monitoring/*.rst @nrfconnect/ncs-dragoon-doc
594596
/samples/bluetooth/peripheral_ams_client/*.rst @nrfconnect/ncs-si-muffin-doc
595597
/samples/bluetooth/peripheral_ancs_client/*.rst @nrfconnect/ncs-si-muffin-doc
596598
/samples/bluetooth/peripheral_bms/*.rst @nrfconnect/ncs-si-muffin-doc

doc/_extensions/page_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def page_filter_install(
199199
if visitor.found_filter_dropdown:
200200
app.add_css_file("page_filter.css")
201201
app.add_js_file("page_filter.mjs", type="module")
202-
script = app.builder.script_files[-1]
202+
script = app.builder.get_script_files()[-1]
203203

204204
page_depth = len(Path(pagename).parents) - 1
205205
body = f"import setupFiltering from './{page_depth * '../'}{script.filename}'; "

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ This section provides detailed lists of changes by :ref:`sample <samples>`.
326326
Bluetooth samples
327327
-----------------
328328

329+
* Added the :ref:`bluetooth_path_loss_monitoring` sample.
330+
329331
* Added the :ref:`samples_test_app` application to demonstrate how to use the Bluetooth LE Test GATT Server and test Bluetooth LE functionality in peripheral samples.
330332

331333
* Updated the network core image applications for the following samples from the :zephyr:code-sample:`bluetooth_hci_ipc` sample to the :ref:`ipc_radio` application for multicore builds:
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
.. _bluetooth_path_loss_monitoring:
2+
3+
Bluetooth: Path loss monitoring
4+
###############################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The Path loss monitoring sample demonstrates how to evaluate Bluetooth® LE signal quality using the path loss monitoring feature.
11+
It consists of a Central and a Peripheral device.
12+
The Central continuously monitors the signal strength and classifies the connection quality using onboard LEDs.
13+
14+
Requirements
15+
************
16+
17+
The sample supports the following development kits:
18+
19+
.. table-from-sample-yaml::
20+
21+
To run this sample, you must use two compatible development kits, one programmed with the Central application, and the other with the Peripheral application.
22+
23+
Overview
24+
********
25+
26+
This sample illustrates Bluetooth LE path loss monitoring by calculating the signal degradation between two connected devices.
27+
The Central application scans for a Peripheral named ``path_loss_peripheral`` and connects to it.
28+
After a successful connection, the Central measures path loss using the following formula:
29+
30+
.. code-block:: none
31+
32+
path loss = TX Power - RSSI
33+
34+
The application defines the following three signal quality zones based on the path loss value:
35+
36+
* Low path loss (strong signal) - **LED0** is lit.
37+
* Medium path loss - **LED1** is lit.
38+
* High path loss (weak signal) - **LED2** is lit.
39+
40+
The Peripheral advertises its presence and accepts connections.
41+
42+
User interface
43+
**************
44+
45+
Central
46+
=======
47+
48+
* **LED0:** Indicates **Low** path loss (good signal).
49+
* **LED1:** Indicates **Medium** path loss.
50+
* **LED2:** Indicates **High** path loss (weak signal).
51+
52+
No buttons are used.
53+
54+
Peripheral
55+
==========
56+
57+
No direct user interface.
58+
The device advertises under the name ``path_loss_peripheral``.
59+
60+
Configuration
61+
*************
62+
63+
|config|
64+
65+
Additional configuration
66+
========================
67+
68+
Check and configure the following Kconfig options:
69+
70+
* :kconfig:option:`CONFIG_BT_CENTRAL` - Enables the Bluetooth LE Central role (Central application).
71+
* :kconfig:option:`CONFIG_BT_PERIPHERAL` - Enables the Bluetooth LE Peripheral role (Peripheral application).
72+
* :kconfig:option:`CONFIG_BT_DEVICE_NAME` - Sets the advertising name of the Peripheral.
73+
* :kconfig:option:`CONFIG_BT_SCAN` - Enables scanning for Bluetooth LE advertisements (Central only).
74+
* :kconfig:option:`CONFIG_BT_SCAN_FILTER_ENABLE` - Enables name-based filtering for scan results (Central only).
75+
* :kconfig:option:`CONFIG_BT_PATH_LOSS_MONITORING` - Enables the Bluetooth LE path loss monitoring feature on both devices.
76+
* :kconfig:option:`CONFIG_DK_LIBRARY` - Enables the LEDs on the development kits.
77+
78+
Building and running
79+
********************
80+
81+
.. |sample path| replace:: :file:`samples/bluetooth/path_loss_monitoring`
82+
83+
.. include:: /includes/build_and_run.txt
84+
85+
.. |sample_or_app| replace:: sample
86+
87+
.. |ipc_radio_dir| replace:: :file:`sysbuild/ipc_radio`
88+
89+
.. include:: /includes/ipc_radio_conf.txt
90+
91+
Testing
92+
=======
93+
94+
|test_sample|
95+
96+
1. Program one DK with the :file:`samples/bluetooth/path_loss_monitoring/central` code.
97+
#. Program another DK with the :file:`samples/bluetooth/path_loss_monitoring/peripheral` code.
98+
#. Power on both devices.
99+
#. The Central will start scanning and connect automatically to the Peripheral.
100+
#. Once connected, observe the LEDs on the Central to evaluate signal strength:
101+
102+
* Bring the devices closer or move them farther apart to change the signal quality.
103+
* Optionally, place an obstruction between the devices to see how this affects signal quality.
104+
#. Monitor the virtual serial ports for logs showing connection status and real-time path loss.
105+
106+
Sample output
107+
=============
108+
109+
The following output is logged from the Central device:
110+
111+
.. code-block:: console
112+
113+
[00:00:01.000,000] <inf> central_unit: Starting path loss monitoring sample
114+
[00:00:01.500,000] <inf> central_unit: Scanning for peripherals...
115+
[00:00:03.020,000] <inf> central_unit: Found peripheral: FF:EE:DD:CC:BB:AA
116+
[00:00:03.050,000] <inf> central_unit: Connection to FF:EE:DD:CC:BB:AA
117+
[00:00:03.800,000] <inf> central_unit: Connected to FF:EE:DD:CC:BB:AA
118+
[00:00:03.810,000] <inf> central_unit: Path loss monitoring enabled
119+
[00:00:05.010,000] <inf> central_unit: Zone 0. Path loss: 30 dBm
120+
[00:00:06.010,000] <inf> central_unit: Zone 1. Path loss: 45 dBm
121+
[00:00:07.010,000] <inf> central_unit: Zone 2. Path loss: 63 dBm
122+
123+
Dependencies
124+
************
125+
126+
This sample uses the following |NCS| libraries:
127+
128+
* :ref:`nrf_bt_scan_readme`
129+
* :ref:`dk_buttons_and_leds_readme`
130+
131+
It uses the following Zephyr libraries:
132+
133+
* :file:`include/zephyr/bluetooth/bluetooth.h`
134+
* :file:`include/zephyr/bluetooth/conn.h`
135+
* :file:`include/zephyr/bluetooth/uuid.h`
136+
* :file:`include/zephyr/bluetooth/addr.h`
137+
* :file:`include/zephyr/bluetooth/gap.h`
138+
* :file:`include/zephyr/logging/log.h`
139+
* :file:`include/zephyr/kernel.h`
140+
* :file:`include/bluetooth/scan.h`
141+
* :file:`include/dk_buttons_and_leds.h`
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9+
project(central_path_loss_monitoring)
10+
11+
# NORDIC SDK APP START
12+
target_sources(app PRIVATE
13+
src/main.c
14+
)
15+
# NORDIC SDK APP END
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
source "share/sysbuild/Kconfig"
8+
9+
config NRF_DEFAULT_IPC_RADIO
10+
default y
11+
12+
config NETCORE_IPC_RADIO_BT_HCI_IPC
13+
default y
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_LOG=y
8+
9+
CONFIG_BT=y
10+
CONFIG_BT_CENTRAL=y
11+
12+
CONFIG_BT_SCAN=y
13+
CONFIG_BT_SCAN_FILTER_ENABLE=y
14+
CONFIG_BT_SCAN_NAME_CNT=1
15+
16+
CONFIG_BT_PATH_LOSS_MONITORING=y
17+
18+
CONFIG_DK_LIBRARY=y
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
sample:
8+
description: >
9+
Central device of a Bluetooth Low Energy Path Loss Monitor, where path loss
10+
zones are indicated by LED0, LED1, and LED2.
11+
name: Bluetooth LE Central Path Loss Monitoring Sample
12+
tests:
13+
sample.bluetooth.central_path_loss_monitoring:
14+
sysbuild: true
15+
build_only: true
16+
integration_platforms:
17+
- nrf52840dk/nrf52840
18+
- nrf5340dk/nrf5340/cpuapp
19+
- nrf54l15dk/nrf54l15/cpuapp
20+
- nrf54h20dk/nrf54h20/cpuapp
21+
platform_allow:
22+
- nrf52840dk/nrf52840
23+
- nrf5340dk/nrf5340/cpuapp
24+
- nrf54l15dk/nrf54l15/cpuapp
25+
- nrf54h20dk/nrf54h20/cpuapp
26+
tags:
27+
- bluetooth
28+
- ci_build
29+
- sysbuild

0 commit comments

Comments
 (0)