Mistake on this page?
Report an issue in GitHub or email us
Data Structures | Public Types | Public Member Functions | Protected Member Functions
HeartRateService Class Reference

BLE Heart Rate Service. More...

#include <HeartRateService.h>

Data Structures

struct  HeartRateValueBytes
 

Public Types

Public Member Functions

 HeartRateService (BLE &_ble, uint16_t hrmCounter, BodySensorLocation location)
 Construct and initialize a heart rate service. More...
 
void updateHeartRate (uint16_t hrmCounter)
 Update the heart rate that the service exposes. More...
 

Protected Member Functions

void setupService (void)
 Construct and add to the GattServer the heart rate service. More...
 

Detailed Description

BLE Heart Rate Service.

purpose

Fitness applications use the heart rate service to expose the heart beat per minute measured by a heart rate sensor.

Clients can read the intended location of the sensor and the last heart rate value measured. Additionally, clients can subscribe to server initiated updates of the heart rate value measured by the sensor. The service delivers these updates to the subscribed client in a notification packet.

The subscription mechanism is useful to save power; it avoids unecessary data traffic between the client and the server, which may be induced by polling the value of the heart rate measurement characteristic.

usage

When this class is instantiated, it adds a heart rate service in the GattServer. The service contains the location of the sensor and the initial value measured by the sensor.

Application code can invoke updateHeartRate() when a new heart rate measurement is acquired; this function updates the value of the heart rate measurement characteristic and notifies the new value to subscribed clients.

Note
You can find specification of the heart rate service here: https://www.bluetooth.com/specifications/gatt
Attention
The service does not expose information related to the sensor contact, the accumulated energy expanded or the interbeat intervals.
The heart rate profile limits the number of instantiations of the heart rate services to one.

Definition at line 60 of file HeartRateService.h.

Member Enumeration Documentation

Intended location of the heart rate sensor.

Enumerator
LOCATION_OTHER 

Other location.

LOCATION_CHEST 

Chest.

LOCATION_WRIST 

Wrist.

LOCATION_FINGER 

Finger.

LOCATION_HAND 

Hand.

LOCATION_EAR_LOBE 

Earlobe.

LOCATION_FOOT 

Foot.

Definition at line 65 of file HeartRateService.h.

Constructor & Destructor Documentation

HeartRateService ( BLE _ble,
uint16_t  hrmCounter,
BodySensorLocation  location 
)

Construct and initialize a heart rate service.

The construction process adds a GATT heart rate service in _ble GattServer, sets the value of the heart rate measurement characteristic to hrmCounter and the value of the body sensor location characteristic to location.

Parameters
[in]_bleBLE device that hosts the heart rate service.
[in]hrmCounterHeart beats per minute measured by the heart rate sensor.
[in]locationIntended location of the heart rate sensor.

Definition at line 116 of file HeartRateService.h.

Member Function Documentation

void setupService ( void  )
protected

Construct and add to the GattServer the heart rate service.

Definition at line 160 of file HeartRateService.h.

void updateHeartRate ( uint16_t  hrmCounter)

Update the heart rate that the service exposes.

The server sends a notification of the new value to clients that have subscribed to updates of the heart rate measurement characteristic; clients reading the heart rate measurement characteristic after the update obtain the updated value.

Parameters
[in]hrmCounterHeart rate measured in BPM.
Attention
This function must be called in the execution context of the BLE stack.

Definition at line 147 of file HeartRateService.h.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.