Improve readability with getHandle inline
Fork of BLE_API by
Diff: services/HeartRateService.h
- Revision:
- 244:0e9201b67e2f
- Parent:
- 236:aac647674384
- Child:
- 245:98f930d14515
--- a/services/HeartRateService.h Tue Dec 09 07:41:43 2014 +0000 +++ b/services/HeartRateService.h Tue Dec 09 08:18:11 2014 +0000 @@ -19,19 +19,18 @@ #include "BLEDevice.h" -/** +/** * @class HeartRateService -* @breif BLE Service for HeartRate. This BLE Service contains the location of the sensor, the heartrate in beats per minute. <br> +* @brief BLE Service for HeartRate. This BLE Service contains the location of the sensor, the heartrate in beats per minute. <br> * Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.heart_rate.xml <br> * HRM Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml <br> -* Location: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.body_sensor_location.xml +* Location: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.body_sensor_location.xml */ class HeartRateService { public: - /** * @enum SensorLocation - * @breif Location of HeartRate sensor on body. + * @brief Location of HeartRate sensor on body. */ enum { LOCATION_OTHER = 0, /*!< Other Location */ @@ -45,7 +44,7 @@ public: /** - * @breif Constructor with 8bit HRM Counter value. + * @brief Constructor with 8bit HRM Counter value. * * @param[ref] _ble * Reference to the underlying BLEDevice. @@ -68,7 +67,7 @@ } /** - * @breif Constructor with a 16-bit HRM Counter value. + * @brief Constructor with a 16-bit HRM Counter value. * * @param[in] _ble * Reference to the underlying BLEDevice. @@ -91,10 +90,10 @@ } /** - * @breif Set a new 8-bit value for heart rate. + * @brief Set a new 8-bit value for heart rate. * * @param[in] hrmCounter - * HeartRate in bpm. + * HeartRate in bpm. */ void updateHeartRate(uint8_t hrmCounter) { valueBytes.updateHeartRate(hrmCounter); @@ -105,7 +104,7 @@ * Set a new 16-bit value for heart rate. * * @param[in] hrmCounter - * HeartRate in bpm. + * HeartRate in bpm. */ void updateHeartRate(uint16_t hrmCounter) { valueBytes.updateHeartRate(hrmCounter); @@ -115,7 +114,7 @@ /** * This callback allows the HeartRateService to receive updates to the * controlPoint Characteristic. - * + * */ virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) { if (params->charHandle == controlPoint.getValueAttribute().getHandle()) { @@ -162,17 +161,17 @@ } void updateHeartRate(uint8_t hrmCounter) { - valueBytes[FLAGS_BYTE_INDEX] &= ~VALUE_FORMAT_FLAG; + valueBytes[FLAGS_BYTE_INDEX] &= ~VALUE_FORMAT_FLAG; valueBytes[FLAGS_BYTE_INDEX + 1] = hrmCounter; } void updateHeartRate(uint16_t hrmCounter) { - valueBytes[FLAGS_BYTE_INDEX] |= VALUE_FORMAT_FLAG; + valueBytes[FLAGS_BYTE_INDEX] |= VALUE_FORMAT_FLAG; valueBytes[FLAGS_BYTE_INDEX + 1] = (uint8_t)(hrmCounter & 0xFF); valueBytes[FLAGS_BYTE_INDEX + 2] = (uint8_t)(hrmCounter >> 8); } - uint8_t *getPointer(void) { + uint8_t *getPointer(void) { return valueBytes; } @@ -180,11 +179,11 @@ return valueBytes; } - unsigned getNumValueBytes(void) const { + unsigned getNumValueBytes(void) const { 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]; @@ -199,4 +198,4 @@ GattCharacteristic controlPoint; }; -#endif /* #ifndef __BLE_HEART_RATE_SERVICE_H__*/ +#endif /* #ifndef __BLE_HEART_RATE_SERVICE_H__*/ \ No newline at end of file