Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Diff: services/HeartRateService.h
- Revision:
- 526:caa67c3187a0
- Parent:
- 524:6e97ab392e2a
- Child:
- 527:493185cebc03
--- a/services/HeartRateService.h Fri Jun 19 15:52:06 2015 +0100
+++ b/services/HeartRateService.h Fri Jun 19 15:52:06 2015 +0100
@@ -114,7 +114,7 @@
* @param[in] params
* Information about the characterisitc being updated.
*/
- virtual void onDataWritten(const GattWriteCallbackParams *params) {
+ virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) {
if (params->charHandle == controlPoint.getValueAttribute().getHandle()) {
/* Do something here if the new value is 1; else you can override this method by
* extending this class.
@@ -125,23 +125,16 @@
}
}
-private:
+protected:
void setupService(void) {
- static bool serviceAdded = false; /* We should only ever need to add the heart rate service once. */
- if (serviceAdded) {
- return;
- }
-
GattCharacteristic *charTable[] = {&hrmRate, &hrmLocation, &controlPoint};
GattService hrmService(GattService::UUID_HEART_RATE_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
ble.addService(hrmService);
- serviceAdded = true;
-
ble.onDataWritten(this, &HeartRateService::onDataWritten);
}
-private:
+protected:
/* Private internal representation for the bytes used to work with the vaulue of the heart-rate characteristic. */
struct HeartRateValueBytes {
static const unsigned MAX_VALUE_BYTES = 3; /* FLAGS + up to two bytes for heart-rate */
@@ -181,13 +174,13 @@
return 1 + ((valueBytes[FLAGS_BYTE_INDEX] & VALUE_FORMAT_FLAG) ? sizeof(uint16_t) : sizeof(uint8_t));
}
-private:
+ private:
/* First byte = 8-bit values, no extra info, Second byte = uint8_t HRM value */
/* See --> https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml */
uint8_t valueBytes[MAX_VALUE_BYTES];
};
-private:
+protected:
BLEDevice &ble;
HeartRateValueBytes valueBytes;
