Improve readability with getHandle inline
Fork of BLE_API by
public/GattAttribute.h@137:4b648181ea6b, 2014-11-21 (annotated)
- Committer:
- rgrover1
- Date:
- Fri Nov 21 09:23:23 2014 +0000
- Revision:
- 137:4b648181ea6b
- Parent:
- 118:620d28e7a1ba
- Child:
- 139:baaf1c5f0db2
Synchronized with git rev ae371eaf
Author: Rohit Grover
add a missing header include.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
carlescufi | 112:64c88ad45610 | 1 | /* mbed Microcontroller Library |
carlescufi | 112:64c88ad45610 | 2 | * Copyright (c) 2006-2013 ARM Limited |
carlescufi | 112:64c88ad45610 | 3 | * |
carlescufi | 112:64c88ad45610 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
carlescufi | 112:64c88ad45610 | 5 | * you may not use this file except in compliance with the License. |
carlescufi | 112:64c88ad45610 | 6 | * You may obtain a copy of the License at |
carlescufi | 112:64c88ad45610 | 7 | * |
carlescufi | 112:64c88ad45610 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
carlescufi | 112:64c88ad45610 | 9 | * |
carlescufi | 112:64c88ad45610 | 10 | * Unless required by applicable law or agreed to in writing, software |
carlescufi | 112:64c88ad45610 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
carlescufi | 112:64c88ad45610 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
carlescufi | 112:64c88ad45610 | 13 | * See the License for the specific language governing permissions and |
carlescufi | 112:64c88ad45610 | 14 | * limitations under the License. |
carlescufi | 112:64c88ad45610 | 15 | */ |
carlescufi | 112:64c88ad45610 | 16 | |
carlescufi | 112:64c88ad45610 | 17 | |
carlescufi | 112:64c88ad45610 | 18 | #ifndef __GATT_ATTRIBUTE_H__ |
carlescufi | 112:64c88ad45610 | 19 | #define __GATT_ATTRIBUTE_H__ |
carlescufi | 112:64c88ad45610 | 20 | |
rgrover1 | 137:4b648181ea6b | 21 | #include <stddef.h> |
rgrover1 | 137:4b648181ea6b | 22 | |
carlescufi | 112:64c88ad45610 | 23 | #include "blecommon.h" |
carlescufi | 112:64c88ad45610 | 24 | #include "UUID.h" |
carlescufi | 112:64c88ad45610 | 25 | |
carlescufi | 112:64c88ad45610 | 26 | /**************************************************************************/ |
carlescufi | 112:64c88ad45610 | 27 | /*! |
carlescufi | 112:64c88ad45610 | 28 | \brief GATT attribute |
carlescufi | 112:64c88ad45610 | 29 | */ |
carlescufi | 112:64c88ad45610 | 30 | /**************************************************************************/ |
carlescufi | 112:64c88ad45610 | 31 | class GattAttribute |
carlescufi | 112:64c88ad45610 | 32 | { |
carlescufi | 112:64c88ad45610 | 33 | public: |
Rohit Grover |
118:620d28e7a1ba | 34 | typedef uint16_t Handle_t; |
carlescufi | 112:64c88ad45610 | 35 | |
Rohit Grover |
118:620d28e7a1ba | 36 | public: |
carlescufi | 112:64c88ad45610 | 37 | /** |
carlescufi | 112:64c88ad45610 | 38 | * @brief Creates a new GattAttribute using the specified |
carlescufi | 112:64c88ad45610 | 39 | * UUID, value length, and inital value |
carlescufi | 112:64c88ad45610 | 40 | * |
carlescufi | 112:64c88ad45610 | 41 | * @param[in] uuid |
carlescufi | 112:64c88ad45610 | 42 | * The UUID to use for this attribute |
carlescufi | 112:64c88ad45610 | 43 | * @param[in] valuePtr |
carlescufi | 112:64c88ad45610 | 44 | * The memory holding the initial value. |
carlescufi | 112:64c88ad45610 | 45 | * @param[in] initialLen |
carlescufi | 112:64c88ad45610 | 46 | * The min length in bytes of this characteristic's value |
carlescufi | 112:64c88ad45610 | 47 | * @param[in] maxLen |
carlescufi | 112:64c88ad45610 | 48 | * The max length in bytes of this characteristic's value |
carlescufi | 112:64c88ad45610 | 49 | * |
carlescufi | 112:64c88ad45610 | 50 | * @section EXAMPLE |
carlescufi | 112:64c88ad45610 | 51 | * |
carlescufi | 112:64c88ad45610 | 52 | * @code |
carlescufi | 112:64c88ad45610 | 53 | * |
carlescufi | 112:64c88ad45610 | 54 | * // UUID = 0x2A19, Min length 2, Max len = 2, Properties = write |
carlescufi | 112:64c88ad45610 | 55 | * GattCharacteristic c = GattCharacteristic( 0x2A19, 2, 2, BLE_GATT_CHAR_PROPERTIES_WRITE ); |
carlescufi | 112:64c88ad45610 | 56 | * |
carlescufi | 112:64c88ad45610 | 57 | * @endcode |
carlescufi | 112:64c88ad45610 | 58 | */ |
carlescufi | 112:64c88ad45610 | 59 | /**************************************************************************/ |
carlescufi | 112:64c88ad45610 | 60 | GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0) : |
carlescufi | 112:64c88ad45610 | 61 | _uuid(uuid), _valuePtr(valuePtr), _initialLen(initialLen), _lenMax(maxLen), _handle(){ |
carlescufi | 112:64c88ad45610 | 62 | /* empty */ |
carlescufi | 112:64c88ad45610 | 63 | } |
carlescufi | 112:64c88ad45610 | 64 | |
carlescufi | 112:64c88ad45610 | 65 | public: |
Rohit Grover |
118:620d28e7a1ba | 66 | Handle_t getHandle(void) const { |
carlescufi | 112:64c88ad45610 | 67 | return _handle; |
carlescufi | 112:64c88ad45610 | 68 | } |
Rohit Grover |
118:620d28e7a1ba | 69 | |
Rohit Grover |
118:620d28e7a1ba | 70 | void setHandle(Handle_t id) { |
carlescufi | 112:64c88ad45610 | 71 | _handle = id; |
carlescufi | 112:64c88ad45610 | 72 | } |
Rohit Grover |
118:620d28e7a1ba | 73 | |
carlescufi | 112:64c88ad45610 | 74 | const UUID &getUUID(void) const { |
carlescufi | 112:64c88ad45610 | 75 | return _uuid; |
carlescufi | 112:64c88ad45610 | 76 | } |
Rohit Grover |
118:620d28e7a1ba | 77 | |
carlescufi | 112:64c88ad45610 | 78 | uint16_t getInitialLength(void) const { |
carlescufi | 112:64c88ad45610 | 79 | return _initialLen; |
carlescufi | 112:64c88ad45610 | 80 | } |
Rohit Grover |
118:620d28e7a1ba | 81 | |
carlescufi | 112:64c88ad45610 | 82 | uint16_t getMaxLength(void) const { |
carlescufi | 112:64c88ad45610 | 83 | return _lenMax; |
carlescufi | 112:64c88ad45610 | 84 | } |
Rohit Grover |
118:620d28e7a1ba | 85 | |
carlescufi | 112:64c88ad45610 | 86 | uint8_t *getValuePtr(void) { |
carlescufi | 112:64c88ad45610 | 87 | return _valuePtr; |
carlescufi | 112:64c88ad45610 | 88 | } |
carlescufi | 112:64c88ad45610 | 89 | |
carlescufi | 112:64c88ad45610 | 90 | protected: |
carlescufi | 112:64c88ad45610 | 91 | UUID _uuid; /* Characteristic UUID */ |
carlescufi | 112:64c88ad45610 | 92 | uint8_t *_valuePtr; |
carlescufi | 112:64c88ad45610 | 93 | uint16_t _initialLen; /* Initial length of the value */ |
carlescufi | 112:64c88ad45610 | 94 | uint16_t _lenMax; /* Maximum length of the value */ |
Rohit Grover |
118:620d28e7a1ba | 95 | Handle_t _handle; |
carlescufi | 112:64c88ad45610 | 96 | }; |
carlescufi | 112:64c88ad45610 | 97 | |
rgrover1 | 137:4b648181ea6b | 98 | #endif // ifndef __GATT_ATTRIBUTE_H__ |