nRF5 SDK v11.0.0
Data Structures | Macros | Typedefs | Enumerations | Functions
Heart Rate Service

Heart Rate Service module. More...

Data Structures

struct  ble_hrs_evt_t
 Heart Rate Service event. More...
 
struct  ble_hrs_init_t
 Heart Rate Service init structure. This contains all options and data needed for initialization of the service. More...
 
struct  ble_hrs_s
 Heart Rate Service structure. This contains various status information for the service. More...
 

Macros

#define BLE_HRS_BODY_SENSOR_LOCATION_OTHER   0
 
#define BLE_HRS_BODY_SENSOR_LOCATION_CHEST   1
 
#define BLE_HRS_BODY_SENSOR_LOCATION_WRIST   2
 
#define BLE_HRS_BODY_SENSOR_LOCATION_FINGER   3
 
#define BLE_HRS_BODY_SENSOR_LOCATION_HAND   4
 
#define BLE_HRS_BODY_SENSOR_LOCATION_EAR_LOBE   5
 
#define BLE_HRS_BODY_SENSOR_LOCATION_FOOT   6
 
#define BLE_HRS_MAX_BUFFERED_RR_INTERVALS   20
 

Typedefs

typedef struct ble_hrs_s ble_hrs_t
 
typedef void(* ble_hrs_evt_handler_t )(ble_hrs_t *p_hrs, ble_hrs_evt_t *p_evt)
 Heart Rate Service event handler type.
 

Enumerations

enum  ble_hrs_evt_type_t {
  BLE_HRS_EVT_NOTIFICATION_ENABLED,
  BLE_HRS_EVT_NOTIFICATION_DISABLED
}
 Heart Rate Service event type. More...
 

Functions

uint32_t ble_hrs_init (ble_hrs_t *p_hrs, const ble_hrs_init_t *p_hrs_init)
 Function for initializing the Heart Rate Service. More...
 
void ble_hrs_on_ble_evt (ble_hrs_t *p_hrs, ble_evt_t *p_ble_evt)
 Function for handling the Application's BLE Stack events. More...
 
uint32_t ble_hrs_heart_rate_measurement_send (ble_hrs_t *p_hrs, uint16_t heart_rate)
 Function for sending heart rate measurement if notification has been enabled. More...
 
void ble_hrs_rr_interval_add (ble_hrs_t *p_hrs, uint16_t rr_interval)
 Function for adding a RR Interval measurement to the RR Interval buffer. More...
 
bool ble_hrs_rr_interval_buffer_is_full (ble_hrs_t *p_hrs)
 Function for checking if RR Interval buffer is full. More...
 
uint32_t ble_hrs_sensor_contact_supported_set (ble_hrs_t *p_hrs, bool is_sensor_contact_supported)
 Function for setting the state of the Sensor Contact Supported bit. More...
 
void ble_hrs_sensor_contact_detected_update (ble_hrs_t *p_hrs, bool is_sensor_contact_detected)
 Function for setting the state of the Sensor Contact Detected bit. More...
 
uint32_t ble_hrs_body_sensor_location_set (ble_hrs_t *p_hrs, uint8_t body_sensor_location)
 Function for setting the Body Sensor Location. More...
 

Detailed Description

Heart Rate Service module.

This module implements the Heart Rate Service with the Heart Rate Measurement, Body Sensor Location and Heart Rate Control Point characteristics. During initialization it adds the Heart Rate Service and Heart Rate Measurement characteristic to the BLE stack database. Optionally it also adds the Body Sensor Location and Heart Rate Control Point characteristics.

If enabled, notification of the Heart Rate Measurement characteristic is performed when the application calls ble_hrs_heart_rate_measurement_send().

The Heart Rate Service also provides a set of functions for manipulating the various fields in the Heart Rate Measurement characteristic, as well as setting the Body Sensor Location characteristic value.

If an event handler is supplied by the application, the Heart Rate Service will generate Heart Rate Service events to the application.

Note
The application must propagate BLE stack events to the Heart Rate Service module by calling ble_hrs_on_ble_evt() from the SoftDevice Event Handler callback.
Attention! To maintain compliance with Nordic Semiconductor ASA Bluetooth profile qualification listings, this section of source code must not be modified.

Macro Definition Documentation

#define BLE_HRS_MAX_BUFFERED_RR_INTERVALS   20

Size of RR Interval buffer inside service.

Enumeration Type Documentation

Heart Rate Service event type.

Enumerator
BLE_HRS_EVT_NOTIFICATION_ENABLED 

Heart Rate value notification enabled event.

BLE_HRS_EVT_NOTIFICATION_DISABLED 

Heart Rate value notification disabled event.

Function Documentation

uint32_t ble_hrs_body_sensor_location_set ( ble_hrs_t p_hrs,
uint8_t  body_sensor_location 
)

Function for setting the Body Sensor Location.

Sets a new value of the Body Sensor Location characteristic. The new value will be sent to the client the next time the client reads the Body Sensor Location characteristic.

Parameters
[in]p_hrsHeart Rate Service structure.
[in]body_sensor_locationNew Body Sensor Location.
Returns
NRF_SUCCESS on success, otherwise an error code.
uint32_t ble_hrs_heart_rate_measurement_send ( ble_hrs_t p_hrs,
uint16_t  heart_rate 
)

Function for sending heart rate measurement if notification has been enabled.

The application calls this function after having performed a heart rate measurement. If notification has been enabled, the heart rate measurement data is encoded and sent to the client.

Parameters
[in]p_hrsHeart Rate Service structure.
[in]heart_rateNew heart rate measurement.
Returns
NRF_SUCCESS on success, otherwise an error code.
uint32_t ble_hrs_init ( ble_hrs_t p_hrs,
const ble_hrs_init_t p_hrs_init 
)

Function for initializing the Heart Rate Service.

Parameters
[out]p_hrsHeart Rate Service structure. This structure will have to be supplied by the application. It will be initialized by this function, and will later be used to identify this particular service instance.
[in]p_hrs_initInformation needed to initialize the service.
Returns
NRF_SUCCESS on successful initialization of service, otherwise an error code.
void ble_hrs_on_ble_evt ( ble_hrs_t p_hrs,
ble_evt_t p_ble_evt 
)

Function for handling the Application's BLE Stack events.

Handles all events from the BLE stack of interest to the Heart Rate Service.

Parameters
[in]p_hrsHeart Rate Service structure.
[in]p_ble_evtEvent received from the BLE stack.
void ble_hrs_rr_interval_add ( ble_hrs_t p_hrs,
uint16_t  rr_interval 
)

Function for adding a RR Interval measurement to the RR Interval buffer.

All buffered RR Interval measurements will be included in the next heart rate measurement message, up to the maximum number of measurements that will fit into the message. If the buffer is full, the oldest measurement in the buffer will be deleted.

Parameters
[in]p_hrsHeart Rate Service structure.
[in]rr_intervalNew RR Interval measurement (will be buffered until the next transmission of Heart Rate Measurement).
bool ble_hrs_rr_interval_buffer_is_full ( ble_hrs_t p_hrs)

Function for checking if RR Interval buffer is full.

Parameters
[in]p_hrsHeart Rate Service structure.
Returns
true if RR Interval buffer is full, false otherwise.
void ble_hrs_sensor_contact_detected_update ( ble_hrs_t p_hrs,
bool  is_sensor_contact_detected 
)

Function for setting the state of the Sensor Contact Detected bit.

Parameters
[in]p_hrsHeart Rate Service structure.
[in]is_sensor_contact_detectedTRUE if sensor contact is detected, FALSE otherwise.
uint32_t ble_hrs_sensor_contact_supported_set ( ble_hrs_t p_hrs,
bool  is_sensor_contact_supported 
)

Function for setting the state of the Sensor Contact Supported bit.

Parameters
[in]p_hrsHeart Rate Service structure.
[in]is_sensor_contact_supportedNew state of the Sensor Contact Supported bit.
Returns
NRF_SUCCESS on success, otherwise an error code.

Documentation feedback | Developer Zone | Updated