Datasheet
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.
// Connect Callback Part 3
void connect_callback(uint16_t conn_handle)
{
.......
// Reaching here means we are ready to go, let's enable notification on measurement chr
if ( hrmc.enableNotify() )
{
Serial.println("Ready to receive HRM Measurement value");
}else
{
Serial.println("Couldn't enable notify for HRM Measurement. Increase DEBUG LEVEL for troubleshooting");
}
}
/**
* Hooked callback that triggered when a measurement value is sent from peripheral
* @param chr Pointer to client characteristic that even occurred,
* in this example it should be hrmc
* @param data Pointer to received data
* @param len Length of received data
*/
void hrm_notify_callback(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
{
// https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.heart_rate_measurement.xml
// Measurement contains of control byte0 and measurement (8 or 16 bit) + optional field
// if byte0's bit0 is 0 --> measurement is 8 bit, otherwise 16 bit.
Serial.print("HRM Measurement: ");
if ( data[0] & bit(0) )
{
uint16_t value;
memcpy(&value, data+1, 2);
Serial.println(value);
}
else
{
Serial.println(data[1]);
}
}
/*********************************************************************
This is an example for our nRF52 based Bluefruit LE modules
Pick one up today in the adafruit shop!
Adafruit invests time and resources providing this open source code,
© Adafruit Industries https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide Page 86 of 175