Rtos API example
HeartRateService Class Reference
BLE Heart Rate Service. More...
#include <HeartRateService.h>
Public Types | |
enum | BodySensorLocation { LOCATION_OTHER = 0, LOCATION_CHEST = 1, LOCATION_WRIST = 2, LOCATION_FINGER, LOCATION_HAND, LOCATION_EAR_LOBE, LOCATION_FOOT } |
Intended location of the heart rate sensor. More... | |
Public Member Functions | |
HeartRateService (BLE &_ble, uint16_t hrmCounter, BodySensorLocation location) | |
Construct and initialize a heart rate service. | |
void | updateHeartRate (uint16_t hrmCounter) |
Update the heart rate that the service exposes. | |
Protected Member Functions | |
void | setupService (void) |
Construct and add to the GattServer the heart rate service. |
Detailed Description
BLE Heart Rate Service.
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
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 58 of file HeartRateService.h.
Member Enumeration Documentation
enum BodySensorLocation |
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 63 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] _ble BLE device that hosts the heart rate service. [in] hrmCounter Heart beats per minute measured by the heart rate sensor. [in] location Intended location of the heart rate sensor.
Definition at line 114 of file HeartRateService.h.
Member Function Documentation
void setupService | ( | void | ) | [protected] |
Construct and add to the GattServer the heart rate service.
Definition at line 158 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] hrmCounter Heart rate measured in BPM.
This function must be called in the execution context of the BLE stack.
Definition at line 145 of file HeartRateService.h.
Generated on Sun Jul 17 2022 08:25:40 by 1.7.2