Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion doc/nrf-bm/release_notes/release_notes_changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ Libraries
Bluetooth LE Services
---------------------

* :ref:`lib_ble_scan`
* :ref:`lib_ble_scan`:

* Changed :c:member:`ble_scan_filter_data.addr_filter.addr` and :c:member:`ble_scan_filter_data.name_filter.name` to ``const`` in the :c:struct:`ble_scan_filter_data` structure.

* :ref:`lib_ble_service_hrs_client`:

* Added the :c:enumerator:`BLE_HRS_CLIENT_EVT_BSL_UPDATE` event to the :c:enum:`ble_hrs_client_evt_type` enum.

Libraries for NFC
-----------------

Expand All @@ -110,6 +114,8 @@ Peripheral samples
Bluetooth LE samples
--------------------

* Added the :ref:`ble_hrs_peripheral_central_sample` sample.

* Updated the following samples and applications that do not support pairing to call the :c:func:`sd_ble_gatts_sys_attr_set` function only in response to the :c:macro:`BLE_GATTS_EVT_SYS_ATTR_MISSING` event and not as a response to a :c:macro:`BLE_GAP_EVT_CONNECTED` event:

* :ref:`ug_dfu_firmware_loader` (Bluetooth LE)
Expand Down
10 changes: 10 additions & 0 deletions include/bm/bluetooth/services/ble_hrs_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ enum ble_hrs_client_evt_type {
* received from the peer.
*/
BLE_HRS_CLIENT_EVT_HRM_NOTIFICATION,
/** Event indicating that the Body Sensor Location characteristic value was received from
* the peer.
*/
BLE_HRS_CLIENT_EVT_BSL_UPDATE,
/** Error. */
BLE_HRS_CLIENT_EVT_ERROR,
};
Expand All @@ -80,6 +84,8 @@ struct ble_hrs_handles {
uint16_t hrm_cccd_handle;
/** Handle of the Heart Rate Measurement characteristic, as provided by the SoftDevice. */
uint16_t hrm_handle;
/** Handle of the Body Sensor Location characteristic, as provided by the SoftDevice. */
uint16_t bsl_handle;
};

/**
Expand All @@ -98,6 +104,10 @@ struct ble_hrs_client_evt {
} discovery_complete;
/** @ref BLE_HRS_CLIENT_EVT_HRM_NOTIFICATION event data. */
struct ble_hrs_measurement hrm_notification;
/** @ref BLE_HRS_CLIENT_EVT_BSL_UPDATE event data. */
struct {
uint8_t body_sensor_location;
} bsl_update;
/** @ref BLE_HRS_CLIENT_EVT_ERROR event data. */
struct {
/** Error reason */
Expand Down
12 changes: 12 additions & 0 deletions samples/bluetooth/ble_hrs_peripheral_central/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2026 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

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

target_sources(app PRIVATE src/main.c)
43 changes: 43 additions & 0 deletions samples/bluetooth/ble_hrs_peripheral_central/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# Copyright (c) 2026 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

menu "Bluetooth LE HRS peripheral central sample"

config SAMPLE_BLE_DEVICE_NAME
string "Device name"
default "nRF_BM_HRS_bridge"

config SAMPLE_USE_TARGET_PERIPHERAL_NAME
bool "Use target peripheral name"
default y

if SAMPLE_USE_TARGET_PERIPHERAL_NAME

config SAMPLE_TARGET_PERIPHERAL_NAME
string "Target peripheral name"
default "nRF_BM_HRS"

endif # SAMPLE_USE_TARGET_PERIPHERAL_NAME

config SAMPLE_USE_TARGET_PERIPHERAL_ADDR
bool "Use target peripheral address"

if SAMPLE_USE_TARGET_PERIPHERAL_ADDR

config SAMPLE_TARGET_PERIPHERAL_ADDR
hex "Target peripheral address"
range 0x0 0xffffffffffff
default 0xD627FDA7AE54

endif # SAMPLE_USE_TARGET_PERIPHERAL_ADDR

module=SAMPLE_BLE_HRS_PERIPHERAL_CENTRAL
module-str=BLE Heart Rate Peripheral Central Service Sample
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

endmenu # "Bluetooth LE HRS peripheral central sample"

source "Kconfig.zephyr"
135 changes: 135 additions & 0 deletions samples/bluetooth/ble_hrs_peripheral_central/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
.. _ble_hrs_peripheral_central_sample:

Bluetooth: Heart Rate Service Peripheral Central
################################################

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

The Heart Rate Service Peripheral Central sample demonstrates how you can implement the Heart Rate profile as a server and client using |BMlong|.

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

The sample supports the following development kits:

.. tabs::

Comment thread
anhmolt marked this conversation as resolved.
.. group-tab:: Simple board variants

The following board variants do **not** have DFU capabilities:

.. include:: /includes/supported_boards_all_non-mcuboot_variants_s145.txt

.. group-tab:: MCUboot board variants

The following board variants have DFU capabilities:

.. include:: /includes/supported_boards_all_mcuboot_variants_s145.txt

Overview
********

This sample acts simultaneously as both a peripheral and a central device.

* As a peripheral it advertises with the :ref:`lib_ble_service_hrs` UUID (0x180D).
A central can connect to this device and subscribe to the Heart Rate Measurement characteristic to receive heart rate notifications.
* As a central the sample scans for other devices that advertise with the :ref:`lib_ble_service_hrs` UUID (0x180D).
When a device is found, it connects and starts service discovery.
If the heart rate service is found, it subscribes to receive heart rate notifications that will be forwarded to a connected central device.

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

Button 0:
Press to disable allow list.

When pairing with authentication, press this button to confirm the passkey shown in the COM listener and complete pairing with the other device.

Button 1:
Press to disconnect from the connected peripheral device.

Keep the button pressed while resetting the board to delete bonding information for all peers stored on the device.

When pairing with authentication, press this button to reject the passkey shown in the COM listener to prevent pairing with the other device.

Button 2:
Press to disconnect from the connected central device.

LED 0:
Lit when the device is initialized.

LED 1:
Lit when connected to a peripheral device.

LED 2:
Lit when connected to a central device.

.. _ble_hrs_peripheral_central_sample_testing:

Building and running
********************

This sample can be found under :file:`samples/bluetooth/ble_hrs_peripheral_central/` in the |BMshort| folder structure.

For details on how to create, configure, and program a sample, see :ref:`getting_started_with_the_samples`.

Comment thread
PizzaAllTheWay marked this conversation as resolved.
Scan filtering options
======================

The sample always scans for devices advertising the Heart Rate Service UUID (``0x180D``).
Two optional filters can narrow this down further:

.. list-table::
:header-rows: 1

* - Kconfig option
- Matches on
* - :kconfig:option:`CONFIG_SAMPLE_USE_TARGET_PERIPHERAL_NAME`
- Advertised device name (e.g. ``"MyDeviceName"``)
* - :kconfig:option:`CONFIG_SAMPLE_USE_TARGET_PERIPHERAL_ADDR`
- Exact 48-bit Bluetooth address

.. note::

Use of ``peripheral`` in the option name refers to the *remote* device being scanned for, not this device's role.

Testing
=======

This sample can be tested with three devices:

* A device running this sample.
* A device running the :ref:`ble_hrs_sample` sample.
* A central device, for example, a phone or a tablet with `nRF Connect for Mobile`_ or `nRF Toolbox`_.

Complete the following steps to test the sample:

1. Compile and program the application.
#. Observe that the ``BLE HRS Peripheral Central sample initialized`` message is printed.
#. In the Serial Terminal, observe that the ``Advertising as nRF_BM_HRS_bridge`` message is printed.
You can configure the advertising name using the :kconfig:option:`CONFIG_SAMPLE_BLE_DEVICE_NAME` Kconfig option.
For information on how to do this, see `Configuring Kconfig`_.
#. Program the second development kit with the :ref:`ble_hrs_sample` sample.
#. Observe that the ``Scan filter match`` message is printed, followed by ``Connecting to target`` and ``Connected``, when connecting to the peripheral device.
#. Observe that the ``Heart rate service discovered`` message is printed.
#. Connect to the device from nRF Connect (the device is advertising as "nRF_BM_HRS_bridge").
#. Observe that the ``Connecting to target`` and ``Connected`` messages are printed when connecting to the central device.
#. Observe that the device starts receiving heart rate measurement notifications and forwarding them to the central.
Comment thread
PizzaAllTheWay marked this conversation as resolved.
#. Note the address printed in the log when connecting, e.g:

.. code-block:: console

Connecting to target AA:BB:CC:DD:EE:FF

#. Enable the address filter in Kconfig with:

.. code-block:: cfg

CONFIG_SAMPLE_USE_TARGET_PERIPHERAL_ADDR=y
CONFIG_SAMPLE_TARGET_PERIPHERAL_ADDR=0xAABBCCDDEEFF

Rebuild and flash. Confirm the sample still connects to the same peripheral.
#. Change the address to a wrong value, rebuild and flash. Confirm the sample no
longer connects to any peripheral.
67 changes: 67 additions & 0 deletions samples/bluetooth/ble_hrs_peripheral_central/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Logging
CONFIG_LOG=y
CONFIG_LOG_BACKEND_BM_UARTE=y

# SoftDevice
CONFIG_SOFTDEVICE=y

# SoftDevice handler link counts
CONFIG_NRF_SDH_BLE_TOTAL_LINK_COUNT=2
CONFIG_NRF_SDH_BLE_CENTRAL_LINK_COUNT=1

# Enable RNG
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_PSA_WANT_GENERATE_RANDOM=y
Comment thread
PizzaAllTheWay marked this conversation as resolved.

# Enable Crypto functionality required by LE Secure Connections pairing (ECDH over NIST P-256)
CONFIG_PSA_WANT_ALG_ECDH=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT=y
CONFIG_PSA_WANT_ECC_SECP_R1_256=y
# PSA key storage: one slot per concurrent pairing
CONFIG_MBEDTLS_PSA_STATIC_KEY_SLOTS=y
CONFIG_MBEDTLS_PSA_KEY_SLOT_COUNT=2

# Button and timer
CONFIG_BM_BUTTONS=y
CONFIG_BM_GPIOTE=y
CONFIG_BM_TIMER=y

# BLE Heart rate client
CONFIG_BLE_HRS_CLIENT=y

# BLE Heart rate server
CONFIG_BLE_HRS=y

# BLE BAS client
CONFIG_BLE_BAS_CLIENT=y

# BLE BAS server
CONFIG_BLE_BAS=y

# BLE connection parameter
CONFIG_BLE_CONN_PARAMS=y

# BLE database discovery
CONFIG_BLE_DB_DISCOVERY=y
CONFIG_BLE_GATT_QUEUE=y

# BLE scan
CONFIG_BLE_SCAN=y
CONFIG_BLE_SCAN_UUID_COUNT=2
CONFIG_BLE_SCAN_ADDRESS_COUNT=1
CONFIG_BLE_ADV_DATA=y

# Advertising library
CONFIG_BLE_ADV=y
CONFIG_BLE_ADV_RESTART_ON_DISCONNECT=n

# Peer manager
CONFIG_PEER_MANAGER=y
CONFIG_PM_LESC=y
CONFIG_BM_ZMS=y

# GATT queue: one queue per concurrent connection
CONFIG_BLE_GQ_MAX_CONNECTIONS=2
Comment thread
PizzaAllTheWay marked this conversation as resolved.
22 changes: 22 additions & 0 deletions samples/bluetooth/ble_hrs_peripheral_central/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
sample:
name: Bluetooth LE Heart Rate Peripheral Central Service Sample
tests:
sample.ble_hrs_peripheral_central:
build_only: true
integration_platforms:
- bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice
- bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice/mcuboot
platform_allow:
- bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice
- bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice/mcuboot
- bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice
- bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice/mcuboot
- bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice
- bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice/mcuboot
- bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice
- bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice/mcuboot
- bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice
- bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice/mcuboot
- bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice
Comment thread
anhmolt marked this conversation as resolved.
- bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice/mcuboot
tags: ci_build
Loading
Loading