Datasheet

Serial.println("Connected");
}
void disconnect_callback(uint8_t reason)
{
(void) reason;
Serial.println("Disconnected");
Serial.println("Advertising!");
}
void cccd_callback(BLECharacteristic& chr, uint16_t cccd_value)
{
// Display the raw request packet
Serial.print("CCCD Updated: ");
//Serial.printBuffer(request->data, request->len);
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");
}
}
}
void loop()
{
// Blinky!
if (blinkyms+BLINKY_MS < millis()) {
blinkyms = millis();
digitalToggle(STATUS_LED);
if (Bluefruit.connected()) {
uint8_t hrmdata[2] = { 0b00000110, bps++ }; // Sensor connected, increment BPS value
err_t resp = hrmc.notify(hrmdata, sizeof(hrmdata)); // Note: We use .notify instead of .write!
// This isn't strictly necessary, but you can check the result
// of the .notify() attempt to see if it was successful or not
switch (resp) {
case ERROR_NONE:
// Value was written correctly!
Serial.print("Heart Rate Measurement updated to: "); Serial.println(bps);
break;
case NRF_ERROR_INVALID_PARAM:
// Characteristic property not set to 'Notify'
Serial.println("ERROR: Characteristic 'Property' not set to Notify!");
break;
case NRF_ERROR_INVALID_STATE:
// Notify bit not set in the CCCD or not connected
Serial.println("ERROR: Notify not set in the CCCD or not connected!");
break;
default:
// Unhandled error code
Serial.print("ERROR: Ox"); Serial.println(resp, HEX);
break;
© Adafruit Industries https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide Page 51 of 175