just a fork
Fork of BLE_API by
Diff: ble/GattAttribute.h
- Revision:
- 1161:515032db6feb
- Parent:
- 1132:6362b7c2fdff
- Child:
- 1179:4ab722f8dca0
--- a/ble/GattAttribute.h Wed Apr 06 19:14:47 2016 +0100 +++ b/ble/GattAttribute.h Wed Apr 06 19:14:49 2016 +0100 @@ -19,9 +19,20 @@ #include "UUID.h" +/** + * Instances of this class encapsulate the data that belongs to a Bluetooth Low + * Energy attribute. + */ class GattAttribute { public: + /** + * Type for the handle or ID of the attribute in the ATT table. These are + * unique and are usually generated by the underlying BLE stack. + */ typedef uint16_t Handle_t; + /** + * Define the value of an invalid attribute handle. + */ static const Handle_t INVALID_HANDLE = 0x0000; public: @@ -55,21 +66,103 @@ } public: - Handle_t getHandle(void) const {return _handle; } - const UUID &getUUID(void) const {return _uuid; } - uint16_t getLength(void) const {return _len; } - uint16_t getMaxLength(void) const {return _lenMax; } - uint16_t *getLengthPtr(void) {return &_len; } - void setHandle(Handle_t id) {_handle = id; } - uint8_t *getValuePtr(void) {return _valuePtr; } - bool hasVariableLength(void) const {return _hasVariableLen;} + /** + * Get the attribute's handle in the ATT table. + * + * @return The attribute's handle. + */ + Handle_t getHandle(void) const { + return _handle; + } + + /** + * The UUID of the characteristic that this attribute belongs to. + * + * @return The characteristic's UUID. + */ + const UUID &getUUID(void) const { + return _uuid; + } + + /** + * Get the current length of the attribute value. + * + * @return The current length of the attribute value. + */ + uint16_t getLength(void) const { + return _len; + } + + /** + * Get the maximum length of the attribute value. + * + * The maximum length of the attribute value. + */ + uint16_t getMaxLength(void) const { + return _lenMax; + } + + /** + * Get a pointer to the current length of the attribute value. + * + * @return A pointer to the current length of the attribute value. + */ + uint16_t *getLengthPtr(void) { + return &_len; + } + + /** + * Set the attribute handle. + * + * @param[in] id + * The new attribute handle. + */ + void setHandle(Handle_t id) { + _handle = id; + } + + /** + * Get a pointer to the attribute value. + * + * @return A pointer to the attribute value. + */ + uint8_t *getValuePtr(void) { + return _valuePtr; + } + + /** + * Check whether the length of the attribute's value can change over time. + * + * @return true if the attribute has variable length, false otherwise. + */ + bool hasVariableLength(void) const { + return _hasVariableLen; + } private: - UUID _uuid; /* Characteristic UUID. */ + /** + * Characteristic's UUID. + */ + UUID _uuid; + /** + * Pointer to the attribute's value. + */ uint8_t *_valuePtr; - uint16_t _lenMax; /* Maximum length of the value. */ - uint16_t _len; /* Current length of the value. */ + /** + * Maximum length of the value pointed to by GattAttribute::_valuePtr. + */ + uint16_t _lenMax; + /** + * Current length of the value pointed to by GattAttribute::_valuePtr. + */ + uint16_t _len; + /** + * Whether the length of the value can change over time. + */ bool _hasVariableLen; + /** + * The attribute's handle in the ATT table. + */ Handle_t _handle; private: @@ -78,4 +171,4 @@ GattAttribute& operator=(const GattAttribute &); }; -#endif // ifndef __GATT_ATTRIBUTE_H__ \ No newline at end of file +#endif /* ifndef __GATT_ATTRIBUTE_H__ */ \ No newline at end of file