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.
Dependents: BLE_PowerBank_HeyFaradey
Fork of BLE_API by
public/GattAttribute.h@491:ed557c8084fd, 2015-06-19 (annotated)
- Committer:
- rgrover1
- Date:
- Fri Jun 19 15:52:02 2015 +0100
- Revision:
- 491:ed557c8084fd
- Parent:
- 437:9d5f32258762
- Child:
- 514:1fa338281798
Synchronized with git rev bab5a281
Author: Rohit Grover
add missing include for UUID.h
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rgrover1 | 260:ea7f9f14cc15 | 1 | /* mbed Microcontroller Library |
| rgrover1 | 260:ea7f9f14cc15 | 2 | * Copyright (c) 2006-2013 ARM Limited |
| rgrover1 | 260:ea7f9f14cc15 | 3 | * |
| rgrover1 | 260:ea7f9f14cc15 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| rgrover1 | 260:ea7f9f14cc15 | 5 | * you may not use this file except in compliance with the License. |
| rgrover1 | 260:ea7f9f14cc15 | 6 | * You may obtain a copy of the License at |
| rgrover1 | 260:ea7f9f14cc15 | 7 | * |
| rgrover1 | 260:ea7f9f14cc15 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| rgrover1 | 260:ea7f9f14cc15 | 9 | * |
| rgrover1 | 260:ea7f9f14cc15 | 10 | * Unless required by applicable law or agreed to in writing, software |
| rgrover1 | 260:ea7f9f14cc15 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| rgrover1 | 260:ea7f9f14cc15 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| rgrover1 | 260:ea7f9f14cc15 | 13 | * See the License for the specific language governing permissions and |
| rgrover1 | 260:ea7f9f14cc15 | 14 | * limitations under the License. |
| rgrover1 | 260:ea7f9f14cc15 | 15 | */ |
| rgrover1 | 260:ea7f9f14cc15 | 16 | |
| rgrover1 | 260:ea7f9f14cc15 | 17 | #ifndef __GATT_ATTRIBUTE_H__ |
| rgrover1 | 260:ea7f9f14cc15 | 18 | #define __GATT_ATTRIBUTE_H__ |
| rgrover1 | 260:ea7f9f14cc15 | 19 | |
| rgrover1 | 491:ed557c8084fd | 20 | #include "UUID.h" |
| rgrover1 | 491:ed557c8084fd | 21 | |
| rgrover1 | 260:ea7f9f14cc15 | 22 | class GattAttribute { |
| rgrover1 | 260:ea7f9f14cc15 | 23 | public: |
| rgrover1 | 260:ea7f9f14cc15 | 24 | typedef uint16_t Handle_t; |
| rgrover1 | 437:9d5f32258762 | 25 | static const Handle_t INVALID_HANDLE = 0x0000; |
| rgrover1 | 260:ea7f9f14cc15 | 26 | |
| rgrover1 | 260:ea7f9f14cc15 | 27 | public: |
| rgrover1 | 260:ea7f9f14cc15 | 28 | /** |
| rgrover1 | 260:ea7f9f14cc15 | 29 | * @brief Creates a new GattAttribute using the specified |
| rgrover1 | 260:ea7f9f14cc15 | 30 | * UUID, value length, and inital value |
| rgrover1 | 260:ea7f9f14cc15 | 31 | * |
| rgrover1 | 260:ea7f9f14cc15 | 32 | * @param[in] uuid |
| rgrover1 | 260:ea7f9f14cc15 | 33 | * The UUID to use for this attribute |
| rgrover1 | 260:ea7f9f14cc15 | 34 | * @param[in] valuePtr |
| rgrover1 | 260:ea7f9f14cc15 | 35 | * The memory holding the initial value. |
| rgrover1 | 260:ea7f9f14cc15 | 36 | * @param[in] initialLen |
| rgrover1 | 344:241987ac6b8b | 37 | * The min length in bytes of this attribute's value |
| rgrover1 | 260:ea7f9f14cc15 | 38 | * @param[in] maxLen |
| rgrover1 | 344:241987ac6b8b | 39 | * The max length in bytes of this attribute's value |
| rgrover1 | 260:ea7f9f14cc15 | 40 | * |
| rgrover1 | 260:ea7f9f14cc15 | 41 | * @section EXAMPLE |
| rgrover1 | 260:ea7f9f14cc15 | 42 | * |
| rgrover1 | 260:ea7f9f14cc15 | 43 | * @code |
| rgrover1 | 260:ea7f9f14cc15 | 44 | * |
| rgrover1 | 344:241987ac6b8b | 45 | * // UUID = 0x2A19, Min length 2, Max len = 2 |
| rgrover1 | 344:241987ac6b8b | 46 | * GattAttribute attr = GattAttribute(0x2A19, &someValue, 2, 2); |
| rgrover1 | 260:ea7f9f14cc15 | 47 | * |
| rgrover1 | 260:ea7f9f14cc15 | 48 | * @endcode |
| rgrover1 | 260:ea7f9f14cc15 | 49 | */ |
| rgrover1 | 260:ea7f9f14cc15 | 50 | GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0) : |
| rgrover1 | 304:30618b2c9808 | 51 | _uuid(uuid), _valuePtr(valuePtr), _initialLen(initialLen), _lenMax(maxLen), _len(initialLen), _handle() { |
| rgrover1 | 260:ea7f9f14cc15 | 52 | /* empty */ |
| rgrover1 | 260:ea7f9f14cc15 | 53 | } |
| rgrover1 | 260:ea7f9f14cc15 | 54 | |
| rgrover1 | 260:ea7f9f14cc15 | 55 | public: |
| rgrover1 | 260:ea7f9f14cc15 | 56 | Handle_t getHandle(void) const {return _handle; } |
| rgrover1 | 260:ea7f9f14cc15 | 57 | const UUID &getUUID(void) const {return _uuid; } |
| rgrover1 | 304:30618b2c9808 | 58 | uint16_t getLength(void) const {return _len; } |
| rgrover1 | 260:ea7f9f14cc15 | 59 | uint16_t getInitialLength(void) const {return _initialLen;} |
| rgrover1 | 260:ea7f9f14cc15 | 60 | uint16_t getMaxLength(void) const {return _lenMax; } |
| rgrover1 | 304:30618b2c9808 | 61 | uint16_t *getLengthPtr(void) {return &_len; } |
| rgrover1 | 260:ea7f9f14cc15 | 62 | void setHandle(Handle_t id) {_handle = id; } |
| rgrover1 | 260:ea7f9f14cc15 | 63 | uint8_t *getValuePtr(void) {return _valuePtr; } |
| rgrover1 | 260:ea7f9f14cc15 | 64 | |
| rgrover1 | 260:ea7f9f14cc15 | 65 | private: |
| rgrover1 | 260:ea7f9f14cc15 | 66 | UUID _uuid; /* Characteristic UUID */ |
| rgrover1 | 260:ea7f9f14cc15 | 67 | uint8_t *_valuePtr; |
| rgrover1 | 260:ea7f9f14cc15 | 68 | uint16_t _initialLen; /* Initial length of the value */ |
| rgrover1 | 260:ea7f9f14cc15 | 69 | uint16_t _lenMax; /* Maximum length of the value */ |
| rgrover1 | 304:30618b2c9808 | 70 | uint16_t _len; /* Current length of the value */ |
| rgrover1 | 260:ea7f9f14cc15 | 71 | Handle_t _handle; |
| rgrover1 | 260:ea7f9f14cc15 | 72 | |
| rgrover1 | 260:ea7f9f14cc15 | 73 | private: |
| rgrover1 | 260:ea7f9f14cc15 | 74 | /* disallow copy and assignment */ |
| rgrover1 | 260:ea7f9f14cc15 | 75 | GattAttribute(const GattAttribute &); |
| rgrover1 | 260:ea7f9f14cc15 | 76 | GattAttribute& operator=(const GattAttribute &); |
| rgrover1 | 260:ea7f9f14cc15 | 77 | }; |
| rgrover1 | 260:ea7f9f14cc15 | 78 | |
| rgrover1 | 260:ea7f9f14cc15 | 79 | #endif // ifndef __GATT_ATTRIBUTE_H__ |
