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
6 changes: 3 additions & 3 deletions doc/nrf-bm/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ Heart Rate Service

.. doxygengroup:: ble_hrs

.. _api_ble_hrs_central:
.. _api_ble_hrs_client:

Heart Rate Service Central
Heart Rate Service Client
==========================

.. doxygengroup:: ble_hrs_central
.. doxygengroup:: ble_hrs_client

.. _api_human_interface_device_service:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ The HRS Client retrieves information such as the sensor location from a device t
Configuration
*************

Set the :kconfig:option:`CONFIG_BLE_HRS_CENTRAL` Kconfig option to enable the service.
Set the :kconfig:option:`CONFIG_BLE_HRS_CLIENT` Kconfig option to enable the service.

Set the maximum number of RR intervals for each HRM notification using the :kconfig:option:`CONFIG_BLE_HRS_CENTRAL_RR_INTERVALS_MAX_COUNT` Kconfig option.
Set the maximum number of RR intervals for each HRM notification using the :kconfig:option:`CONFIG_BLE_HRS_CLIENT_RR_INTERVALS_MAX_COUNT` Kconfig option.

Initialization
==============

The service instance is declared using the :c:macro:`BLE_HRS_CENTRAL_DEF` macro, specifying the name of the instance.
To initialize the service, call the :c:func:`ble_hrs_central_init` function.
See the :c:struct:`ble_hrs_central_config` structure for configuration details, in addition to the HRS specification.
The service instance is declared using the :c:macro:`BLE_HRS_CLIENT_DEF` macro, specifying the name of the instance.
To initialize the service, call the :c:func:`ble_hrs_client_init` function.
See the :c:struct:`ble_hrs_client_config` structure for configuration details, in addition to the HRS specification.

Usage
*****
Expand All @@ -35,10 +35,10 @@ Applications can use the :ref:`lib_ble_scan` library for detecting advertising d

Upon connection, the application can use the :ref:`lib_ble_db_discovery` library to discover the peer's database.
Call the :c:func:`ble_hrs_on_db_disc_evt` function on callback events from the Database Discovery library.
This function sends the :c:enumerator:`BLE_HRS_CENTRAL_EVT_DISCOVERY_COMPLETE` event to the application if the Heart Rate Service is discovered in the peer's database.
The application must call the :c:func:`ble_hrs_central_handles_assign` function to associate the link with the HRS Client instance.
This function sends the :c:enumerator:`BLE_HRS_CLIENT_EVT_DISCOVERY_COMPLETE` event to the application if the Heart Rate Service is discovered in the peer's database.
The application must call the :c:func:`ble_hrs_client_handles_assign` function to associate the link with the HRS Client instance.

Upon Heart Rate Service discovery, the application can call the :c:func:`ble_hrs_central_hrm_notif_enable` function to request the peer to start sending Heart Rate Measurement notifications.
Upon Heart Rate Service discovery, the application can call the :c:func:`ble_hrs_client_hrm_notif_enable` function to request the peer to start sending Heart Rate Measurement notifications.

Dependencies
************
Expand All @@ -54,7 +54,7 @@ The library is expected to be used with the :ref:`lib_ble_scan` |BMshort| librar
API documentation
*****************

| Header file: :file:`include/bm/bluetooth/services/ble_hrs_central.h`
| Source files: :file:`subsys/bluetooth/services/ble_hrs_central/`
| Header file: :file:`include/bm/bluetooth/services/ble_hrs_client.h`
| Source files: :file:`subsys/bluetooth/services/ble_hrs_client/`

:ref:`Heart Rate Service API reference <api_ble_hrs_central>`
:ref:`Heart Rate Service API reference <api_ble_hrs_client>`
2 changes: 1 addition & 1 deletion doc/nrf-bm/release_notes/release_notes_changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ No changes since the latest nRF Connect SDK Bare Metal release.
Bluetooth LE Services
---------------------

No changes since the latest nRF Connect SDK Bare Metal release.
* Renamed the ``ble_hrs_central`` service to the :ref:`lib_ble_service_hrs_client` sample.

Libraries for NFC
-----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @file
*
* @defgroup ble_hrs_central Heart Rate Service Client
* @defgroup ble_hrs_client Heart Rate Service Client
* @{
* @brief Heart Rate Service Client.
*
Expand All @@ -23,8 +23,8 @@
* the application.
*/

#ifndef BLE_HRS_CENTRAL_H__
#define BLE_HRS_CENTRAL_H__
#ifndef BLE_HRS_CLIENT_H__
#define BLE_HRS_CLIENT_H__

#include <stdint.h>
#include <ble.h>
Expand All @@ -37,27 +37,27 @@ extern "C" {
#endif

/**
* @brief Macro for defining a ble_hrs_central instance.
* @brief Macro for defining a ble_hrs_client instance.
*
* @param _name Name of the instance.
* @hideinitializer
*/
#define BLE_HRS_CENTRAL_DEF(_name) \
static struct ble_hrs_central _name; \
NRF_SDH_BLE_OBSERVER(_name##_obs, ble_hrs_central_on_ble_evt, &_name, USER_LOW)
#define BLE_HRS_CLIENT_DEF(_name) \
static struct ble_hrs_client _name; \
NRF_SDH_BLE_OBSERVER(_name##_obs, ble_hrs_client_on_ble_evt, &_name, USER_LOW)

/**
* @brief HRS Client event type.
*/
enum ble_hrs_central_evt_type {
enum ble_hrs_client_evt_type {
/** Event indicating that the Heart Rate Service was discovered at the peer. */
BLE_HRS_CENTRAL_EVT_DISCOVERY_COMPLETE,
BLE_HRS_CLIENT_EVT_DISCOVERY_COMPLETE,
/** Event indicating that a notification of the Heart Rate Measurement characteristic was
* received from the peer.
*/
BLE_HRS_CENTRAL_EVT_HRM_NOTIFICATION,
BLE_HRS_CLIENT_EVT_HRM_NOTIFICATION,
/** Error. */
BLE_HRS_CENTRAL_EVT_ERROR,
BLE_HRS_CLIENT_EVT_ERROR,
};

/**
Expand All @@ -69,7 +69,7 @@ struct ble_hrm {
/** Number of RR intervals. */
uint8_t rr_intervals_cnt;
/** RR intervals. */
uint16_t rr_intervals[CONFIG_BLE_HRS_CENTRAL_RR_INTERVALS_MAX_COUNT];
uint16_t rr_intervals[CONFIG_BLE_HRS_CLIENT_RR_INTERVALS_MAX_COUNT];
};

/**
Expand All @@ -85,22 +85,22 @@ struct hrs_db {
/**
* @brief Heart Rate Event.
*/
struct ble_hrs_central_evt {
struct ble_hrs_client_evt {
/** Type of the event. */
enum ble_hrs_central_evt_type evt_type;
enum ble_hrs_client_evt_type evt_type;
/** Connection handle on which the Heart Rate service was discovered on the peer device. */
uint16_t conn_handle;
union {
/** Handles related to the Heart Rate, found on the peer device.
* This is filled if the evt_type is @ref BLE_HRS_CENTRAL_EVT_DISCOVERY_COMPLETE.
* This is filled if the evt_type is @ref BLE_HRS_CLIENT_EVT_DISCOVERY_COMPLETE.
*/
struct hrs_db peer_db;
/** Heart Rate Measurement received. This is filled if the evt_type
* is @ref BLE_HRS_CENTRAL_EVT_HRM_NOTIFICATION.
* is @ref BLE_HRS_CLIENT_EVT_HRM_NOTIFICATION.
*/
struct ble_hrm hrm;
/** Error event. This is filled if the evt_type
* is @ref BLE_HRS_CENTRAL_EVT_ERROR.
* is @ref BLE_HRS_CLIENT_EVT_ERROR.
*/
struct {
/** Error reason */
Expand All @@ -110,41 +110,41 @@ struct ble_hrs_central_evt {
};

/** Forward declaration. */
struct ble_hrs_central;
struct ble_hrs_client;

/**
* @brief Event handler type.
*
* @details This is the type of the event handler that is to be provided by the application
* of this module to receive events.
*/
typedef void (*ble_hrs_central_evt_handler_t)(struct ble_hrs_central *ble_hrs_central,
struct ble_hrs_central_evt *evt);
typedef void (*ble_hrs_client_evt_handler_t)(struct ble_hrs_client *ble_hrs_client,
struct ble_hrs_client_evt *evt);

/**
* @brief Heart Rate Client.
*/
struct ble_hrs_central {
struct ble_hrs_client {
/** Connection handle, as provided by the SoftDevice. */
uint16_t conn_handle;
/** Handles related to HRS on the peer. */
struct hrs_db peer_hrs_db;
/** Application event handler to be called when there
* is an event related to the Heart Rate Service.
*/
ble_hrs_central_evt_handler_t evt_handler;
ble_hrs_client_evt_handler_t evt_handler;
/** Bluetooth LE GATT Queue instance. */
const struct ble_gq *gatt_queue;
};

/**
* @brief Heart Rate Client configuration structure.
*/
struct ble_hrs_central_config {
struct ble_hrs_client_config {
/** Event handler to be called by the Heart Rate Client module when
* there is an event related to the Heart Rate Service.
*/
ble_hrs_central_evt_handler_t evt_handler;
ble_hrs_client_evt_handler_t evt_handler;
/** Bluetooth LE GATT Queue instance. */
const struct ble_gq *gatt_queue;
/** Database discovery instance. */
Expand All @@ -158,15 +158,15 @@ struct ble_hrs_central_config {
* The module looks for the presence of a Heart Rate Service instance at the peer
* when a discovery is started.
*
* @param[in] ble_hrs_central Heart Rate Client structure.
* @param[in] ble_hrs_central_config Heart rate service central configuration.
* @param[in] ble_hrs_client Heart Rate Client structure.
* @param[in] ble_hrs_client_config Heart rate service client configuration.
*
* @retval NRF_SUCCESS On successful initialization.
* @return Otherwise, this function propagates the error code returned by the
* Database Discovery module API @ref ble_db_discovery_service_register.
*/
uint32_t ble_hrs_central_init(struct ble_hrs_central *ble_hrs_central,
struct ble_hrs_central_config *ble_hrs_central_config);
uint32_t ble_hrs_client_init(struct ble_hrs_client *ble_hrs_client,
struct ble_hrs_client_config *ble_hrs_client_config);

/**
* @brief Handle Bluetooth LE events from the SoftDevice.
Expand All @@ -179,20 +179,20 @@ uint32_t ble_hrs_central_init(struct ble_hrs_central *ble_hrs_central,
* @param[in] ble_evt Bluetooth LE event.
* @param[in] ctx Heart Rate Client structure.
*/
void ble_hrs_central_on_ble_evt(const ble_evt_t *ble_evt, void *ctx);
void ble_hrs_client_on_ble_evt(const ble_evt_t *ble_evt, void *ctx);

/**
* @brief Request the peer to start sending notification of Heart Rate Measurement.
*
* @details This function enables notification of the Heart Rate Measurement at the peer
* by writing to the CCCD of the Heart Rate Measurement characteristic.
*
* @param ble_hrs_central Heart Rate Client structure.
* @param ble_hrs_client Heart Rate Client structure.
*
* @retval NRF_SUCCESS If the SoftDevice is requested to write to the CCCD of the peer.
* @return Error code returned by the SoftDevice API @ref sd_ble_gattc_write.
*/
uint32_t ble_hrs_central_hrm_notif_enable(struct ble_hrs_central *ble_hrs_central);
uint32_t ble_hrs_client_hrm_notif_enable(struct ble_hrs_client *ble_hrs_client);

/**
* @brief Handle events from the Database Discovery module.
Expand All @@ -204,12 +204,12 @@ uint32_t ble_hrs_central_hrm_notif_enable(struct ble_hrs_central *ble_hrs_centra
* Service was discovered at the peer. The function also populates the event with
* service-related information before providing it to the application.
*
* @param[in] ble_hrs_central Heart Rate Client structure instance for
* @param[in] ble_hrs_client Heart Rate Client structure instance for
* associating the link.
* @param[in] evt Event received from the Database Discovery module.
*
*/
void ble_hrs_on_db_disc_evt(struct ble_hrs_central *ble_hrs_central,
void ble_hrs_on_db_disc_evt(struct ble_hrs_client *ble_hrs_client,
const struct ble_db_discovery_evt *evt);

/**
Expand All @@ -219,23 +219,23 @@ void ble_hrs_on_db_disc_evt(struct ble_hrs_central *ble_hrs_central,
* associate the link to this instance of the module. This association makes it
* possible to handle several links and associate each link to a particular
* instance of this module. The connection handle and attribute handles are
* provided from the discovery event @ref BLE_HRS_CENTRAL_EVT_DISCOVERY_COMPLETE.
* provided from the discovery event @ref BLE_HRS_CLIENT_EVT_DISCOVERY_COMPLETE.
*
* @param[in] ble_hrs_central Heart Rate Client structure instance for
* @param[in] ble_hrs_client Heart Rate Client structure instance for
* associating the link.
* @param[in] conn_handle Connection handle to associate with the given Heart Rate
* Client Instance.
* @param[in] peer_hrs_handles Attribute handles for the HRS server you want this HRS_C
* client to interact with.
*/
uint32_t ble_hrs_central_handles_assign(struct ble_hrs_central *ble_hrs_central,
uint32_t ble_hrs_client_handles_assign(struct ble_hrs_client *ble_hrs_client,
uint16_t conn_handle,
const struct hrs_db *peer_hrs_handles);

#ifdef __cplusplus
}
#endif

#endif /* BLE_HRS_CENTRAL_H__ */
#endif /* BLE_HRS_CLIENT_H__ */

/** @} */
2 changes: 1 addition & 1 deletion samples/bluetooth/ble_hrs_central/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bluetooth: Heart Rate Service Central
:local:
:depth: 2

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

Requirements
************
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/ble_hrs_central/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_PSA_WANT_GENERATE_RANDOM=y

# BLE Heart rate client
CONFIG_BLE_HRS_CENTRAL=y
CONFIG_BLE_HRS_CLIENT=y

# BLE connection parameter
CONFIG_BLE_CONN_PARAMS=y
Expand Down
Loading