Skip to content

Conversation

@eivindj-nordic
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the doc-required PR must not be merged without tech writer approval. label Nov 26, 2025
@github-actions
Copy link

You can find the documentation preview for this PR here.

@eivindj-nordic eivindj-nordic added this to the v1.0.0 milestone Nov 27, 2025
@anhmolt anhmolt force-pushed the hrs_central branch 2 times, most recently from f1b6f15 to 345c14e Compare November 28, 2025 11:11
@eivindj-nordic eivindj-nordic force-pushed the hrs_central branch 4 times, most recently from def7c1f to ff5b64e Compare November 28, 2025 13:38
@eivindj-nordic eivindj-nordic marked this pull request as ready for review November 28, 2025 13:58
@eivindj-nordic eivindj-nordic requested review from a team as code owners November 28, 2025 13:58
Comment on lines 3 to 4
Bluetooth: Database Discovery library
##############################
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Bluetooth: Database Discovery library
##############################
Bluetooth: Database discovery library
#####################################

:local:
:depth: 2

This module contains the APIs and types exposed by the Database Discovery module. These APIs and types can be used by the application to perform discovery of a service and its characteristics at the peer server. This module can also be used to discover the desired services in multiple remote devices.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This module contains the APIs and types exposed by the Database Discovery module. These APIs and types can be used by the application to perform discovery of a service and its characteristics at the peer server. This module can also be used to discover the desired services in multiple remote devices.
This module contains the APIs and types exposed by the Database discovery module.
These APIs and types can be used by the application to discover a service and its characteristics at the peer server.
This module can also be used to discover the desired services in multiple remote devices.

Configuration
*************

The library is enabled and configured using the Kconfig system:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The library is enabled and configured using the Kconfig system:
To enable and configure the library use the following Kconfig options:

==============

The library is initialized by calling the :c:func:`ble_db_discovery_init` function.
See the :c:struct:`ble_db_discovery_config` struct for configuration details.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
See the :c:struct:`ble_db_discovery_config` struct for configuration details.
See the :c:struct:`ble_db_discovery_config` structure for configuration details.

Comment on lines 39 to 41
After initialization, use :c:func:`ble_db_discovery_service_register` to register a callback that triggers when a service is discovered with a specific UUID.
To start discovering from a peer, you must use :c:func:`ble_db_discovery_start` with the connection handle of the peer device.
For example, you can call :c:func:`ble_db_discovery_start` when the ble event :c:enum:`BLE_GAP_EVT_CONNECTED` is triggered and use the connection handle from the event as the second argument in :c:func:`ble_db_discovery_start`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After initialization, use :c:func:`ble_db_discovery_service_register` to register a callback that triggers when a service is discovered with a specific UUID.
To start discovering from a peer, you must use :c:func:`ble_db_discovery_start` with the connection handle of the peer device.
For example, you can call :c:func:`ble_db_discovery_start` when the ble event :c:enum:`BLE_GAP_EVT_CONNECTED` is triggered and use the connection handle from the event as the second argument in :c:func:`ble_db_discovery_start`.
After initialization, use the :c:func:`ble_db_discovery_service_register` function to register a callback that triggers when a service is discovered with a specific UUID.
To start discovering from a peer, use the :c:func:`ble_db_discovery_start` function with the connection handle of the peer device.
For example, you can call the :c:func:`ble_db_discovery_start` function when the :c:enum:`BLE_GAP_EVT_CONNECTED` event is triggered and use the connection handle from the event as the second argument in the :c:func:`ble_db_discovery_start` function.

If the device is not advertising, you might need to use the :guilabel:`Reset Board` option in |VSC|.
#. :guilabel:`Connect` to your device.
The terminal output in |VSC| indicates ``Peer connected``.
#. Observe that the services are shown in the connected device and that you can start receiving values for the Heart Rate and the Battery Service by clicking the Play button.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#. Observe that the services are shown in the connected device and that you can start receiving values for the Heart Rate and the Battery Service by clicking the Play button.
#. Observe that the services are shown in the connected device and you can start receiving values for the Heart Rate and the Battery Service when you click the :guilabel:`Play` button.

#. In nRF Connect for Desktop, scan for advertising devices.
Your device should be advertising as ``nRF_BM_HRS``.
If the device is not advertising, you might need to use the :guilabel:`Reset Board` option in |VSC|.
#. :guilabel:`Connect` to your device.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#. :guilabel:`Connect` to your device.
#. Click :guilabel:`Connect` to connect your device.

#. :guilabel:`Connect` to your device.
The terminal output in |VSC| indicates ``Peer connected``.
#. Observe that the services are shown in the connected device and that you can start receiving values for the Heart Rate and the Battery Service by clicking the Play button.
Heart Rate notifications are received every second, and Battery Level notifications are received every two seconds.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Heart Rate notifications are received every second, and Battery Level notifications are received every two seconds.
Heart Rate notifications are received every second, and Battery Level notifications every two seconds.

Otherwise, the :c:macro:`NRF_BLE_SCAN_EVT_NOT_FOUND` event is generated.

You can enable filters by calling the :c:func:`ble_scan_filters_enable` function after initialization.
You can activate filters for one filter type, or for a combination of several filter types.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can activate filters for one filter type, or for a combination of several filter types.
You can activate filters for one filter type, or for a combination of several filter types.
Example code:

=======================

The advanced initialization provides a larger configuration set for the library.
It is required when using scan filters or the whitelist.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It is required when using scan filters or the whitelist.
It is required when using scan filters or the whitelist.
Example code:


PREDEFINED = __DOXYGEN__ \
CONFIG_BLE_QWR_MAX_ATTR=1 \
CONFIG_BLE_SCAN_FILTER=1 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? We don't do this in zephyr and we don't do this in NCS, so why is this required in BM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is required until we have #401 I think. After that doc generation will be the same as in NCS.

* :kconfig:option:`CONFIG_BLE_SCAN_INTERVAL` - Determines the scan interval in units of 0.625 ms.
* :kconfig:option:`CONFIG_BLE_SCAN_DURATION` - Duration of a scanning session in units of 10 ms, if set to 0, the scanning continues until it is explicitly disabled.
* :kconfig:option:`CONFIG_BLE_SCAN_WINDOW` - Determines the scanning window in units of 0.625 ms.
* :kconfig:option:`CONFIG_BLE_SCAN_SLAVE_LATENCY` - Determines the slave latency in counts of connection events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

peripheral latency, as per BT SIG, update Kconfigs and names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hermabe The SoftDevice uses slave latency, I assume that is for legacy reasons (avoid breaking API)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the SoftDevice still refers to pre-5.3 naming in many places. We decided early on to not rename everything to not break the API.

You can call the Kconfig whatever you want. I am more concerned with why these are kconfigs at all, shouldnt the connection parameters be runtime configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were part of the sdk_config.h in nRF5. The ble_gap_scan_params_t provided are still configurable through ble_scan_params_set().


.. note::

When using the whitelist, filters are inactive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as other PR, allow list

@eivindj-nordic eivindj-nordic mentioned this pull request Dec 1, 2025
@eivindj-nordic eivindj-nordic changed the title DB discovery library and hrs c sample. Scan, DB discovery library and hrs c sample. Dec 1, 2025
@eivindj-nordic eivindj-nordic force-pushed the hrs_central branch 2 times, most recently from 1427e26 to 28eb23a Compare December 1, 2025 09:30
Copy link
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"HRS_C" Kconfig name is awful and non descriptive, use full word "HRS_CENTRAL"

Comment on lines 102 to 103
.filter_policy = BLE_GAP_SCAN_FP_WHITELIST,
.timeout = SCAN_DURATION_WHITELIST,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these need updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top one is from SoftDevice, cannot be changed.

Determines the scanning window in units of 0.625 milliseconds.

config BLE_SCAN_PERIPHERAL_LATENCY
int "Scan slave latency"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs update

range 1 6
default 6
help
The maximum number of database characteristics.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indent for all these

depends on BLE_GATT_QUEUE
select EXPERIMENTAL
help
database discovery.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is going to be the help text, might as well remove it. Either that or expand it here properly, with capital first letter

help
The total number of services that can be discovered by this module.

config SRV_DISC_START_HANDLE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing prefix

SVCALL_AS_NORMAL_FUNCTION=1
NRF54L15_XXAA)

target_compile_definitions( app PRIVATE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the old way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updated locally.


menu "BLE HRS Central sample"

config APP_USE_TARGET_PERIPH_NAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*PERIPHERAL, these Kconfig names are not long, they can use full words

endif # APP_USE_TARGET_PERIPH_ADDR

module=APP_BLE_HRS_C_SAMPLE
module-dep=LOG
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
module-dep=LOG

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

endmenu # "BLE HRS sample"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mismatch

# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

menu "BLE HRS Central sample"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*central

.active = 0x01,
.interval = NRF_BLE_SCAN_INTERVAL,
.window = NRF_BLE_SCAN_WINDOW,
.filter_policy = BLE_GAP_SCAN_FP_WHITELIST,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLE_GAP_SCAN_FP_WHITELIST is still not updated, this name is not acceptable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot be updated here. This is part of the SoftDevice deliverables.

#define BLE_GAP_SCAN_FP_WHITELIST 0x01 /**< Accept advertising packets from devices in the whitelist except directed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration
*************

To enable and configure the library use the following Kconfig options:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To enable and configure the library use the following Kconfig options:
To enable and configure the library, use the following Kconfig options:

Sorry, my bad forgetting the comma.


The allow list (formerly known as whitelist) stores information about all the device connections and bonding.
If you enable the allow list, the application receives advertising packets only from the devices that are on the allow list.
An advertising package from a allow listed device generates an :c:macro:`BLE_SCAN_EVT_ALLOW_LIST_ADV_REPORT` event.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An advertising package from a allow listed device generates an :c:macro:`BLE_SCAN_EVT_ALLOW_LIST_ADV_REPORT` event.
An advertising package from an allow-listed device generates an :c:macro:`BLE_SCAN_EVT_ALLOW_LIST_ADV_REPORT` event.

Comment on lines 183 to 185
* Multifilter - At least one filter from each filter type you set must be matched to generate an event.
For UUID filters, all specified UUIDs must match in this mode.
To enabled multifilter, set the :c:macro:`match_all` argument to true when calling the :c:func:`ble_scan_filters_enable` function.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Multifilter - At least one filter from each filter type you set must be matched to generate an event.
For UUID filters, all specified UUIDs must match in this mode.
To enabled multifilter, set the :c:macro:`match_all` argument to true when calling the :c:func:`ble_scan_filters_enable` function.
* Multifilter - At least one filter from each filter type you set must be matched to generate an event.
For UUID filters, all specified UUIDs must match in this mode.
To enabled multifilter, set the :c:macro:`match_all` argument to true when calling the :c:func:`ble_scan_filters_enable` function.

uint32_t ble_hrs_c_init(struct ble_hrs_c *ble_hrs_c, struct ble_hrs_c_config *ble_hrs_c_init);

/**
* @brief Handle BLE events from the SoftDevice.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @brief Handle BLE events from the SoftDevice.
* @brief Handle Bluetooth LE events from the SoftDevice.

Comment on lines 171 to 172
* @details This function handles the BLE events received from the SoftDevice. If a BLE
* event is relevant to the Heart Rate Client module, the function uses the
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @details This function handles the BLE events received from the SoftDevice. If a BLE
* event is relevant to the Heart Rate Client module, the function uses the
* @details This function handles the Bluetooth LE events received from the SoftDevice. If an
* event is relevant to the Heart Rate Client module, the function uses the

* event's data to update interval variables and, if necessary, send events to the
* application.
*
* @param[in] ble_evt Pointer to the BLE event.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in] ble_evt Pointer to the BLE event.
* @param[in] ble_evt Pointer to the Bluetooth LE event.

#

menuconfig BLE_SCAN
bool "BLE Scan [EXPERIMENTAL]"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool "BLE Scan [EXPERIMENTAL]"
bool "Bluetooth LE Scan [EXPERIMENTAL]"

#

menuconfig BLE_HRS_CENTRAL
bool "BLE Heart rate service central [EXPERIMENTAL]"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool "BLE Heart rate service central [EXPERIMENTAL]"
bool "Bluetooth LE Heart rate service central [EXPERIMENTAL]"

@eivindj-nordic eivindj-nordic force-pushed the hrs_central branch 2 times, most recently from c153d9c to 9acf427 Compare December 1, 2025 12:11
@carlescufi
Copy link
Contributor

"HRS_C" Kconfig name is awful and non descriptive, use full word "HRS_CENTRAL"

Agreed, and I think we should use hrs_central_* everywhere IMHO.

@eivindj-nordic
Copy link
Contributor Author

"HRS_C" Kconfig name is awful and non descriptive, use full word "HRS_CENTRAL"

Agreed, and I think we should use hrs_central_* everywhere IMHO.

Ok, I'll make the changes.

@eivindj-nordic eivindj-nordic force-pushed the hrs_central branch 2 times, most recently from 5e6dae8 to fd67120 Compare December 1, 2025 13:57
* has been reached.
*/
uint32_t ble_db_discovery_service_register(struct ble_db_discovery *db_discovery,
const ble_uuid_t *const uuid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. alignment is off

@@ -0,0 +1,242 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit title is wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated locally.

/**
* @brief Heart Rate Measurement received from the peer.
*/
struct ble_hrm {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this conflict if you include the peripheral and central files in a .c file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only defined in ble_hrs_central.h.
ble_hrs.h defines heart rate service (hrs), not heart rate measurement (hrm).

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ble_hrs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
project(ble_hrs)
project(ble_hrs_central)

eivindj-nordic and others added 2 commits December 1, 2025 15:06
Add scan library.

Co-authored-by: Sondre Pettersen <[email protected]>
Co-authored-by: Asil Zogby <[email protected]>
Signed-off-by: Eivind Jølsgard <[email protected]>
Add db_discovery library.

Co-authored-by: Sondre Pettersen <[email protected]>
Co-authored-by: Asil Zogby <[email protected]>
Signed-off-by: Eivind Jølsgard <[email protected]>
@eivindj-nordic eivindj-nordic force-pushed the hrs_central branch 2 times, most recently from bfc6b15 to 909a78f Compare December 1, 2025 14:08
Add BLE heart rate service central and sample.

Co-authored-by: Asil Zogby <[email protected]>
Signed-off-by: Sondre Pettersen <[email protected]>
Signed-off-by: Eivind Jølsgard <[email protected]>
@eivindj-nordic eivindj-nordic merged commit b251cd5 into nrfconnect:main Dec 1, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-required PR must not be merged without tech writer approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants