fka mod
Fork of BLE_API by
ble/GattAttribute.h@1132:6362b7c2fdff, 2016-04-06 (annotated)
- Committer:
- vcoubard
- Date:
- Wed Apr 06 19:13:49 2016 +0100
- Revision:
- 1132:6362b7c2fdff
- Parent:
- 1131:692ddf04fc42
- Child:
- 1161:515032db6feb
Synchronized with git rev 35adda98
Author: Rohit Grover
Release 2.1.6
=============
Minor update around GattCharacteristics having variable length.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 1131:692ddf04fc42 | 1 | /* mbed Microcontroller Library |
vcoubard | 1131:692ddf04fc42 | 2 | * Copyright (c) 2006-2013 ARM Limited |
vcoubard | 1131:692ddf04fc42 | 3 | * |
vcoubard | 1131:692ddf04fc42 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
vcoubard | 1131:692ddf04fc42 | 5 | * you may not use this file except in compliance with the License. |
vcoubard | 1131:692ddf04fc42 | 6 | * You may obtain a copy of the License at |
vcoubard | 1131:692ddf04fc42 | 7 | * |
vcoubard | 1131:692ddf04fc42 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
vcoubard | 1131:692ddf04fc42 | 9 | * |
vcoubard | 1131:692ddf04fc42 | 10 | * Unless required by applicable law or agreed to in writing, software |
vcoubard | 1131:692ddf04fc42 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
vcoubard | 1131:692ddf04fc42 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
vcoubard | 1131:692ddf04fc42 | 13 | * See the License for the specific language governing permissions and |
vcoubard | 1131:692ddf04fc42 | 14 | * limitations under the License. |
vcoubard | 1131:692ddf04fc42 | 15 | */ |
vcoubard | 1131:692ddf04fc42 | 16 | |
vcoubard | 1131:692ddf04fc42 | 17 | #ifndef __GATT_ATTRIBUTE_H__ |
vcoubard | 1131:692ddf04fc42 | 18 | #define __GATT_ATTRIBUTE_H__ |
vcoubard | 1131:692ddf04fc42 | 19 | |
vcoubard | 1131:692ddf04fc42 | 20 | #include "UUID.h" |
vcoubard | 1131:692ddf04fc42 | 21 | |
vcoubard | 1131:692ddf04fc42 | 22 | class GattAttribute { |
vcoubard | 1131:692ddf04fc42 | 23 | public: |
vcoubard | 1131:692ddf04fc42 | 24 | typedef uint16_t Handle_t; |
vcoubard | 1131:692ddf04fc42 | 25 | static const Handle_t INVALID_HANDLE = 0x0000; |
vcoubard | 1131:692ddf04fc42 | 26 | |
vcoubard | 1131:692ddf04fc42 | 27 | public: |
vcoubard | 1131:692ddf04fc42 | 28 | /** |
vcoubard | 1131:692ddf04fc42 | 29 | * @brief Creates a new GattAttribute using the specified |
vcoubard | 1131:692ddf04fc42 | 30 | * UUID, value length, and inital value. |
vcoubard | 1131:692ddf04fc42 | 31 | * |
vcoubard | 1131:692ddf04fc42 | 32 | * @param[in] uuid |
vcoubard | 1131:692ddf04fc42 | 33 | * The UUID to use for this attribute. |
vcoubard | 1131:692ddf04fc42 | 34 | * @param[in] valuePtr |
vcoubard | 1131:692ddf04fc42 | 35 | * The memory holding the initial value. |
vcoubard | 1131:692ddf04fc42 | 36 | * @param[in] len |
vcoubard | 1131:692ddf04fc42 | 37 | * The length in bytes of this attribute's value. |
vcoubard | 1131:692ddf04fc42 | 38 | * @param[in] maxLen |
vcoubard | 1131:692ddf04fc42 | 39 | * The max length in bytes of this attribute's value. |
vcoubard | 1132:6362b7c2fdff | 40 | * @param[in] hasVariableLen |
vcoubard | 1132:6362b7c2fdff | 41 | * Whether the attribute's value length changes overtime. |
vcoubard | 1131:692ddf04fc42 | 42 | * |
vcoubard | 1131:692ddf04fc42 | 43 | * @section EXAMPLE |
vcoubard | 1131:692ddf04fc42 | 44 | * |
vcoubard | 1131:692ddf04fc42 | 45 | * @code |
vcoubard | 1131:692ddf04fc42 | 46 | * |
vcoubard | 1131:692ddf04fc42 | 47 | * // UUID = 0x2A19, Min length 2, Max len = 2 |
vcoubard | 1131:692ddf04fc42 | 48 | * GattAttribute attr = GattAttribute(0x2A19, &someValue, 2, 2); |
vcoubard | 1131:692ddf04fc42 | 49 | * |
vcoubard | 1131:692ddf04fc42 | 50 | * @endcode |
vcoubard | 1131:692ddf04fc42 | 51 | */ |
vcoubard | 1132:6362b7c2fdff | 52 | GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t len = 0, uint16_t maxLen = 0, bool hasVariableLen = true) : |
vcoubard | 1132:6362b7c2fdff | 53 | _uuid(uuid), _valuePtr(valuePtr), _lenMax(maxLen), _len(len), _hasVariableLen(hasVariableLen), _handle() { |
vcoubard | 1131:692ddf04fc42 | 54 | /* Empty */ |
vcoubard | 1131:692ddf04fc42 | 55 | } |
vcoubard | 1131:692ddf04fc42 | 56 | |
vcoubard | 1131:692ddf04fc42 | 57 | public: |
vcoubard | 1132:6362b7c2fdff | 58 | Handle_t getHandle(void) const {return _handle; } |
vcoubard | 1132:6362b7c2fdff | 59 | const UUID &getUUID(void) const {return _uuid; } |
vcoubard | 1132:6362b7c2fdff | 60 | uint16_t getLength(void) const {return _len; } |
vcoubard | 1132:6362b7c2fdff | 61 | uint16_t getMaxLength(void) const {return _lenMax; } |
vcoubard | 1132:6362b7c2fdff | 62 | uint16_t *getLengthPtr(void) {return &_len; } |
vcoubard | 1132:6362b7c2fdff | 63 | void setHandle(Handle_t id) {_handle = id; } |
vcoubard | 1132:6362b7c2fdff | 64 | uint8_t *getValuePtr(void) {return _valuePtr; } |
vcoubard | 1132:6362b7c2fdff | 65 | bool hasVariableLength(void) const {return _hasVariableLen;} |
vcoubard | 1131:692ddf04fc42 | 66 | |
vcoubard | 1131:692ddf04fc42 | 67 | private: |
vcoubard | 1132:6362b7c2fdff | 68 | UUID _uuid; /* Characteristic UUID. */ |
vcoubard | 1131:692ddf04fc42 | 69 | uint8_t *_valuePtr; |
vcoubard | 1132:6362b7c2fdff | 70 | uint16_t _lenMax; /* Maximum length of the value. */ |
vcoubard | 1132:6362b7c2fdff | 71 | uint16_t _len; /* Current length of the value. */ |
vcoubard | 1132:6362b7c2fdff | 72 | bool _hasVariableLen; |
vcoubard | 1131:692ddf04fc42 | 73 | Handle_t _handle; |
vcoubard | 1131:692ddf04fc42 | 74 | |
vcoubard | 1131:692ddf04fc42 | 75 | private: |
vcoubard | 1131:692ddf04fc42 | 76 | /* Disallow copy and assignment. */ |
vcoubard | 1131:692ddf04fc42 | 77 | GattAttribute(const GattAttribute &); |
vcoubard | 1131:692ddf04fc42 | 78 | GattAttribute& operator=(const GattAttribute &); |
vcoubard | 1131:692ddf04fc42 | 79 | }; |
vcoubard | 1131:692ddf04fc42 | 80 | |
rgrover1 | 710:b2e1a2660ec2 | 81 | #endif // ifndef __GATT_ATTRIBUTE_H__ |