Datasheet
4. Repeat the same procedure for any other BLECharacteristics in your service.
Full Sample Code
The full sample code for this example can be seen below, but this maybe be out of sync with the latest code available
on Github. Please consult the Github code (https://adafru.it/vaP) if you have any problems with the code below.
void cccd_callback(BLECharacteristic& chr, uint16_t cccd_value)
{
// Display the raw request packet
Serial.print("CCCD Updated: ");
Serial.print(cccd_value);
Serial.println("");
// Check the characteristic this CCCD update is associated with in case
// this handler is used for multiple CCCD records.
if (chr.uuid == hrmc.uuid) {
if (chr.notifyEnabled()) {
Serial.println("Heart Rate Measurement 'Notify' enabled");
} else {
Serial.println("Heart Rate Measurement 'Notify' disabled");
}
}
}
#include <bluefruit.h>
#define STATUS_LED (17)
#define BLINKY_MS (2000)
/* HRM Service Definitions
* Heart Rate Monitor Service: 0x180D
* Heart Rate Measurement Char: 0x2A37
* Body Sensor Location Char: 0x2A38
*/
BLEService hrms = BLEService(UUID16_SVC_HEART_RATE);
BLECharacteristic hrmc = BLECharacteristic(UUID16_CHR_HEART_RATE_MEASUREMENT);
BLECharacteristic bslc = BLECharacteristic(UUID16_CHR_BODY_SENSOR_LOCATION);
BLEDis bledis; // DIS (Device Information Service) helper class instance
BLEBas blebas; // BAS (Battery Service) helper class instance
uint32_t blinkyms;
uint8_t bps = 0;
// Advanced function prototypes
void setupAdv(void);
void setupHRM(void);
void connect_callback(void);
void disconnect_callback(uint8_t reason);
void cccd_callback(BLECharacteristic& chr, ble_gatts_evt_write_t* request);
void setup()
{
Serial.begin(115200);
Serial.println("Bluefruit52 HRM Example");
Serial.println("-----------------------");
© Adafruit Industries https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide Page 48 of 175