Improve readability with getHandle inline
Fork of BLE_API by
Diff: services/HeartRateService.h
- Revision:
- 257:6be2b4b0cd71
- Parent:
- 245:98f930d14515
--- a/services/HeartRateService.h Tue Dec 02 02:51:52 2014 +0000 +++ b/services/HeartRateService.h Mon Jan 12 14:49:53 2015 -0800 @@ -19,31 +19,38 @@ #include "BLEDevice.h" -/* Heart Rate Service */ -/* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.heart_rate.xml */ -/* HRM Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.heart_rate_measurement.xml */ -/* Location: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.body_sensor_location.xml */ +/** +* @class HeartRateService +* @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 +*/ class HeartRateService { public: + /** + * @enum SensorLocation + * @brief Location of HeartRate sensor on body. + */ enum { - LOCATION_OTHER = 0, - LOCATION_CHEST, - LOCATION_WRIST, - LOCATION_FINGER, - LOCATION_HAND, - LOCATION_EAR_LOBE, - LOCATION_FOOT, + LOCATION_OTHER = 0, /*!< Other Location */ + LOCATION_CHEST, /*!< Chest */ + LOCATION_WRIST, /*!< Wrist */ + LOCATION_FINGER, /*!< Finger */ + LOCATION_HAND, /*!< Hand */ + LOCATION_EAR_LOBE, /*!< Earlobe */ + LOCATION_FOOT, /*!< Foot */ }; public: /** - * Constructor. + * @brief Constructor with 8bit HRM Counter value. * - * param[in] _ble + * @param[ref] _ble * Reference to the underlying BLEDevice. - * param[in] hrmCounter (8-bit) + * @param[in] hrmCounter (8-bit) * initial value for the hrm counter. - * param[in] location + * @param[in] location * Sensor's location. */ HeartRateService(BLEDevice &_ble, uint8_t hrmCounter, uint8_t location) : @@ -60,7 +67,14 @@ } /** - * Same constructor as above, but with a 16-bit HRM Counter value. + * @brief Constructor with a 16-bit HRM Counter value. + * + * @param[in] _ble + * Reference to the underlying BLEDevice. + * @param[in] hrmCounter (8-bit) + * initial value for the hrm counter. + * @param[in] location + * Sensor's location. */ HeartRateService(BLEDevice &_ble, uint16_t hrmCounter, uint8_t location) : ble(_ble), @@ -76,7 +90,10 @@ } /** - * 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. */ void updateHeartRate(uint8_t hrmCounter) { valueBytes.updateHeartRate(hrmCounter); @@ -85,6 +102,9 @@ /** * Set a new 16-bit value for heart rate. + * + * @param[in] hrmCounter + * HeartRate in bpm. */ void updateHeartRate(uint16_t hrmCounter) { valueBytes.updateHeartRate(hrmCounter); @@ -94,6 +114,9 @@ /** * This callback allows the HeartRateService to receive updates to the * controlPoint Characteristic. + * + * @param[in] params + * Information about the characterisitc being updated. */ virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) { if (params->charHandle == controlPoint.getValueAttribute().getHandle()) { @@ -140,17 +163,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; } @@ -158,11 +181,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]; @@ -177,4 +200,4 @@ GattCharacteristic controlPoint; }; -#endif /* #ifndef __BLE_HEART_RATE_SERVICE_H__*/ +#endif /* #ifndef __BLE_HEART_RATE_SERVICE_H__*/ \ No newline at end of file