Datasheet

Custom: Central HRM
The BLEClientService and BLEClientCharacteristic classes can be used to implement any custom or officially adopted
BLE service of characteristic on the client side (most often is Central) using a set of basic properties and callback
handlers.
The example below shows how to use these classes to implement the Heart Rate Monitor (https://adafru.it/vaO)
service, as defined by the Bluetooth SIG. To run this example, you will need an extra nRF52 running peripheral HRM
sketch (https://adafru.it/Cnf)
HRM Service Definition
UUID: 0x180D (https://adafru.it/vaO)
Only the first characteristic is mandatory, but we will also implement the optional Body Sensor Location characteristic.
Heart Rate Control Point won't be used in this example to keep things simple.
Implementing the HRM Service and Characteristics
The core service and the first two characteristics can be implemented with the following code:
First, define the BLEService and BLECharacteristic variables that will be used in your project:
Then you need to initialize those variables by calling their begin().
Client Service + Characteristic Code Analysis
1. The first thing to do is to call .begin() on the BLEClientService (hrms above). Since the UUID is set in the object
declaration at the top of the sketch, there is normally nothing else to do with the BLEClientService instance.
/* HRM Service Definitions
* Heart Rate Monitor Service: 0x180D
* Heart Rate Measurement Char: 0x2A37 (Mandatory)
* Body Sensor Location Char: 0x2A38 (Optional)
*/
BLEClientService hrms(UUID16_SVC_HEART_RATE);
BLEClientCharacteristic hrmc(UUID16_CHR_HEART_RATE_MEASUREMENT);
BLEClientCharacteristic bslc(UUID16_CHR_BODY_SENSOR_LOCATION);
// Initialize HRM client
hrms.begin();
// Initialize client characteristics of HRM.
// Note: Client Char will be added to the last service that is begin()ed.
bslc.begin();
// set up callback for receiving measurement
hrmc.setNotifyCallback(hrm_notify_callback);
hrmc.begin();
© Adafruit Industries https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide Page 83 of 175