fka mod
Fork of BLE_API by
ble/DiscoveredCharacteristic.h@1183:1589830dbdb7, 2016-04-06 (annotated)
- Committer:
- vcoubard
- Date:
- Wed Apr 06 19:15:36 2016 +0100
- Revision:
- 1183:1589830dbdb7
- Parent:
- 1179:4ab722f8dca0
Synchronized with git rev 44cc6871
Author: Andres Amaya Garcia
Merge branch 'develop' into fix-doxy-warnings
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 __DISCOVERED_CHARACTERISTIC_H__ |
vcoubard | 1131:692ddf04fc42 | 18 | #define __DISCOVERED_CHARACTERISTIC_H__ |
vcoubard | 1131:692ddf04fc42 | 19 | |
vcoubard | 1131:692ddf04fc42 | 20 | #include "UUID.h" |
vcoubard | 1131:692ddf04fc42 | 21 | #include "Gap.h" |
vcoubard | 1131:692ddf04fc42 | 22 | #include "GattAttribute.h" |
vcoubard | 1131:692ddf04fc42 | 23 | #include "GattClient.h" |
vcoubard | 1135:22aada733dbd | 24 | #include "CharacteristicDescriptorDiscovery.h" |
vcoubard | 1135:22aada733dbd | 25 | #include "ble/DiscoveredCharacteristicDescriptor.h" |
vcoubard | 1131:692ddf04fc42 | 26 | |
vcoubard | 1131:692ddf04fc42 | 27 | /** |
vcoubard | 1135:22aada733dbd | 28 | * @brief Representation of a characteristic discovered during a GattClient |
vcoubard | 1135:22aada733dbd | 29 | * discovery procedure (see GattClient::launchServiceDiscovery ). |
vcoubard | 1135:22aada733dbd | 30 | * |
vcoubard | 1183:1589830dbdb7 | 31 | * @details Provide detailed informations about a discovered characteristic like: |
vcoubard | 1183:1589830dbdb7 | 32 | * - Its UUID (see getUUID()). |
vcoubard | 1135:22aada733dbd | 33 | * - The most important handles of the characteristic definition |
vcoubard | 1183:1589830dbdb7 | 34 | * (see getDeclHandle(), getValueHandle(), getLastHandle()) |
vcoubard | 1183:1589830dbdb7 | 35 | * - Its properties (see getProperties()). |
vcoubard | 1135:22aada733dbd | 36 | * This class also provide functions to operate on the characteristic: |
vcoubard | 1183:1589830dbdb7 | 37 | * - Read the characteristic value (see read()) |
vcoubard | 1183:1589830dbdb7 | 38 | * - Writing a characteristic value (see write() or writeWoResponse()) |
vcoubard | 1135:22aada733dbd | 39 | * - Discover descriptors inside the characteristic definition. These descriptors |
vcoubard | 1135:22aada733dbd | 40 | * extends the characteristic. More information about descriptor usage is |
vcoubard | 1135:22aada733dbd | 41 | * available in DiscoveredCharacteristicDescriptor class. |
vcoubard | 1131:692ddf04fc42 | 42 | */ |
vcoubard | 1131:692ddf04fc42 | 43 | class DiscoveredCharacteristic { |
vcoubard | 1131:692ddf04fc42 | 44 | public: |
vcoubard | 1183:1589830dbdb7 | 45 | /** |
vcoubard | 1183:1589830dbdb7 | 46 | * Structure that encapsulates the properties of a discovered |
vcoubard | 1183:1589830dbdb7 | 47 | * characteristic. |
vcoubard | 1183:1589830dbdb7 | 48 | */ |
vcoubard | 1131:692ddf04fc42 | 49 | struct Properties_t { |
vcoubard | 1131:692ddf04fc42 | 50 | uint8_t _broadcast :1; /**< Broadcasting the value permitted. */ |
vcoubard | 1131:692ddf04fc42 | 51 | uint8_t _read :1; /**< Reading the value permitted. */ |
vcoubard | 1131:692ddf04fc42 | 52 | uint8_t _writeWoResp :1; /**< Writing the value with Write Command permitted. */ |
vcoubard | 1131:692ddf04fc42 | 53 | uint8_t _write :1; /**< Writing the value with Write Request permitted. */ |
vcoubard | 1135:22aada733dbd | 54 | uint8_t _notify :1; /**< Notifications of the value permitted. */ |
vcoubard | 1131:692ddf04fc42 | 55 | uint8_t _indicate :1; /**< Indications of the value permitted. */ |
vcoubard | 1131:692ddf04fc42 | 56 | uint8_t _authSignedWrite :1; /**< Writing the value with Signed Write Command permitted. */ |
vcoubard | 1131:692ddf04fc42 | 57 | |
vcoubard | 1131:692ddf04fc42 | 58 | public: |
vcoubard | 1183:1589830dbdb7 | 59 | /** |
vcoubard | 1183:1589830dbdb7 | 60 | * @brief Check if broadcasting is permitted. |
vcoubard | 1183:1589830dbdb7 | 61 | * |
vcoubard | 1183:1589830dbdb7 | 62 | * @return true if broadcasting the value is permitted, and false |
vcoubard | 1183:1589830dbdb7 | 63 | * otherwise. |
vcoubard | 1183:1589830dbdb7 | 64 | */ |
vcoubard | 1183:1589830dbdb7 | 65 | bool broadcast(void) const { |
vcoubard | 1183:1589830dbdb7 | 66 | return _broadcast; |
vcoubard | 1183:1589830dbdb7 | 67 | } |
vcoubard | 1183:1589830dbdb7 | 68 | |
vcoubard | 1183:1589830dbdb7 | 69 | /** |
vcoubard | 1183:1589830dbdb7 | 70 | * @brief Check reading is permitted. |
vcoubard | 1183:1589830dbdb7 | 71 | * |
vcoubard | 1183:1589830dbdb7 | 72 | * @return true if reading the value is permitted, and false |
vcoubard | 1183:1589830dbdb7 | 73 | * otherwise. |
vcoubard | 1183:1589830dbdb7 | 74 | */ |
vcoubard | 1183:1589830dbdb7 | 75 | bool read(void) const { |
vcoubard | 1183:1589830dbdb7 | 76 | return _read; |
vcoubard | 1183:1589830dbdb7 | 77 | } |
vcoubard | 1183:1589830dbdb7 | 78 | |
vcoubard | 1183:1589830dbdb7 | 79 | /** |
vcoubard | 1183:1589830dbdb7 | 80 | * @brief Check if writing with Write Command is permitted. |
vcoubard | 1183:1589830dbdb7 | 81 | * |
vcoubard | 1183:1589830dbdb7 | 82 | * @return true if writing the value with Write Command is permitted, |
vcoubard | 1183:1589830dbdb7 | 83 | * false otherwise. |
vcoubard | 1183:1589830dbdb7 | 84 | */ |
vcoubard | 1183:1589830dbdb7 | 85 | bool writeWoResp(void) const { |
vcoubard | 1183:1589830dbdb7 | 86 | return _writeWoResp; |
vcoubard | 1183:1589830dbdb7 | 87 | } |
vcoubard | 1183:1589830dbdb7 | 88 | |
vcoubard | 1183:1589830dbdb7 | 89 | /** |
vcoubard | 1183:1589830dbdb7 | 90 | * @brief Check if writing with Write Request is permitted. |
vcoubard | 1183:1589830dbdb7 | 91 | * |
vcoubard | 1183:1589830dbdb7 | 92 | * @return true if writing the value with Write Request is permitted, |
vcoubard | 1183:1589830dbdb7 | 93 | * false otherwise. |
vcoubard | 1183:1589830dbdb7 | 94 | */ |
vcoubard | 1183:1589830dbdb7 | 95 | bool write(void) const { |
vcoubard | 1183:1589830dbdb7 | 96 | return _write; |
vcoubard | 1183:1589830dbdb7 | 97 | } |
vcoubard | 1183:1589830dbdb7 | 98 | |
vcoubard | 1183:1589830dbdb7 | 99 | /** |
vcoubard | 1183:1589830dbdb7 | 100 | * @brief Check notifications are permitted. |
vcoubard | 1183:1589830dbdb7 | 101 | * |
vcoubard | 1183:1589830dbdb7 | 102 | * @return true if notifications of the value are permitted, false |
vcoubard | 1183:1589830dbdb7 | 103 | * otherwise. |
vcoubard | 1183:1589830dbdb7 | 104 | */ |
vcoubard | 1183:1589830dbdb7 | 105 | bool notify(void) const { |
vcoubard | 1183:1589830dbdb7 | 106 | return _notify; |
vcoubard | 1183:1589830dbdb7 | 107 | } |
vcoubard | 1183:1589830dbdb7 | 108 | |
vcoubard | 1183:1589830dbdb7 | 109 | /** |
vcoubard | 1183:1589830dbdb7 | 110 | * @brief Check if indications are permitted. |
vcoubard | 1183:1589830dbdb7 | 111 | * |
vcoubard | 1183:1589830dbdb7 | 112 | * @return true if indications of the value are permitted, false |
vcoubard | 1183:1589830dbdb7 | 113 | * otherwise. |
vcoubard | 1183:1589830dbdb7 | 114 | */ |
vcoubard | 1183:1589830dbdb7 | 115 | bool indicate(void) const { |
vcoubard | 1183:1589830dbdb7 | 116 | return _indicate; |
vcoubard | 1183:1589830dbdb7 | 117 | } |
vcoubard | 1183:1589830dbdb7 | 118 | |
vcoubard | 1183:1589830dbdb7 | 119 | /** |
vcoubard | 1183:1589830dbdb7 | 120 | * @brief Check if writing with Signed Write Command is permitted. |
vcoubard | 1183:1589830dbdb7 | 121 | * |
vcoubard | 1183:1589830dbdb7 | 122 | * @return true if writing the value with Signed Write Command is |
vcoubard | 1183:1589830dbdb7 | 123 | * permitted, false otherwise. |
vcoubard | 1183:1589830dbdb7 | 124 | */ |
vcoubard | 1183:1589830dbdb7 | 125 | bool authSignedWrite(void) const { |
vcoubard | 1183:1589830dbdb7 | 126 | return _authSignedWrite; |
vcoubard | 1183:1589830dbdb7 | 127 | } |
vcoubard | 1131:692ddf04fc42 | 128 | |
vcoubard | 1135:22aada733dbd | 129 | /** |
vcoubard | 1135:22aada733dbd | 130 | * @brief "Equal to" operator for DiscoveredCharacteristic::Properties_t |
vcoubard | 1135:22aada733dbd | 131 | * |
vcoubard | 1183:1589830dbdb7 | 132 | * @param[in] lhs The left hand side of the equality expression |
vcoubard | 1183:1589830dbdb7 | 133 | * @param[in] rhs The right hand side of the equality expression |
vcoubard | 1135:22aada733dbd | 134 | * |
vcoubard | 1135:22aada733dbd | 135 | * @return true if operands are equals, false otherwise. |
vcoubard | 1135:22aada733dbd | 136 | */ |
vcoubard | 1135:22aada733dbd | 137 | friend bool operator==(Properties_t lhs, Properties_t rhs) { |
vcoubard | 1135:22aada733dbd | 138 | return lhs._broadcast == rhs._broadcast && |
vcoubard | 1135:22aada733dbd | 139 | lhs._read == rhs._read && |
vcoubard | 1135:22aada733dbd | 140 | lhs._writeWoResp == rhs._writeWoResp && |
vcoubard | 1135:22aada733dbd | 141 | lhs._write == rhs._write && |
vcoubard | 1135:22aada733dbd | 142 | lhs._notify == rhs._notify && |
vcoubard | 1135:22aada733dbd | 143 | lhs._indicate == rhs._indicate && |
vcoubard | 1135:22aada733dbd | 144 | lhs._authSignedWrite == rhs._authSignedWrite; |
vcoubard | 1135:22aada733dbd | 145 | } |
vcoubard | 1135:22aada733dbd | 146 | |
vcoubard | 1135:22aada733dbd | 147 | /** |
vcoubard | 1135:22aada733dbd | 148 | * @brief "Not equal to" operator for DiscoveredCharacteristic::Properties_t |
vcoubard | 1135:22aada733dbd | 149 | * |
vcoubard | 1135:22aada733dbd | 150 | * @param lhs The right hand side of the expression |
vcoubard | 1135:22aada733dbd | 151 | * @param rhs The left hand side of the expression |
vcoubard | 1135:22aada733dbd | 152 | * |
vcoubard | 1135:22aada733dbd | 153 | * @return true if operands are not equals, false otherwise. |
vcoubard | 1135:22aada733dbd | 154 | */ |
vcoubard | 1135:22aada733dbd | 155 | friend bool operator!=(Properties_t lhs, Properties_t rhs) { |
vcoubard | 1135:22aada733dbd | 156 | return !(lhs == rhs); |
vcoubard | 1135:22aada733dbd | 157 | } |
vcoubard | 1135:22aada733dbd | 158 | |
vcoubard | 1131:692ddf04fc42 | 159 | private: |
vcoubard | 1131:692ddf04fc42 | 160 | operator uint8_t() const; /* Disallow implicit conversion into an integer. */ |
vcoubard | 1131:692ddf04fc42 | 161 | operator unsigned() const; /* Disallow implicit conversion into an integer. */ |
vcoubard | 1131:692ddf04fc42 | 162 | }; |
vcoubard | 1131:692ddf04fc42 | 163 | |
vcoubard | 1131:692ddf04fc42 | 164 | /** |
vcoubard | 1131:692ddf04fc42 | 165 | * Initiate (or continue) a read for the value attribute, optionally at a |
vcoubard | 1131:692ddf04fc42 | 166 | * given offset. If the characteristic or descriptor to be read is longer |
vcoubard | 1131:692ddf04fc42 | 167 | * than ATT_MTU - 1, this function must be called multiple times with |
vcoubard | 1131:692ddf04fc42 | 168 | * appropriate offset to read the complete value. |
vcoubard | 1131:692ddf04fc42 | 169 | * |
vcoubard | 1183:1589830dbdb7 | 170 | * @param[in] offset |
vcoubard | 1183:1589830dbdb7 | 171 | * The position - in the characteristic value bytes stream - where |
vcoubard | 1183:1589830dbdb7 | 172 | * the read operation begin. |
vcoubard | 1135:22aada733dbd | 173 | * |
vcoubard | 1131:692ddf04fc42 | 174 | * @return BLE_ERROR_NONE if a read has been initiated, or |
vcoubard | 1131:692ddf04fc42 | 175 | * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or |
vcoubard | 1131:692ddf04fc42 | 176 | * BLE_STACK_BUSY if some client procedure is already in progress, or |
vcoubard | 1131:692ddf04fc42 | 177 | * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties. |
vcoubard | 1131:692ddf04fc42 | 178 | */ |
vcoubard | 1131:692ddf04fc42 | 179 | ble_error_t read(uint16_t offset = 0) const; |
vcoubard | 1131:692ddf04fc42 | 180 | |
vcoubard | 1135:22aada733dbd | 181 | /** |
vcoubard | 1135:22aada733dbd | 182 | * @brief Same as #read(uint16_t) const but allow the user to register a callback |
vcoubard | 1135:22aada733dbd | 183 | * which will be fired once the read is done. |
vcoubard | 1135:22aada733dbd | 184 | * |
vcoubard | 1183:1589830dbdb7 | 185 | * @param[in] offset |
vcoubard | 1183:1589830dbdb7 | 186 | * The position - in the characteristic value bytes stream - where |
vcoubard | 1183:1589830dbdb7 | 187 | * the read operation begin. |
vcoubard | 1183:1589830dbdb7 | 188 | * @param[in] onRead |
vcoubard | 1183:1589830dbdb7 | 189 | * Continuation of the read operation |
vcoubard | 1135:22aada733dbd | 190 | */ |
vcoubard | 1131:692ddf04fc42 | 191 | ble_error_t read(uint16_t offset, const GattClient::ReadCallback_t& onRead) const; |
vcoubard | 1131:692ddf04fc42 | 192 | |
vcoubard | 1131:692ddf04fc42 | 193 | /** |
vcoubard | 1131:692ddf04fc42 | 194 | * Perform a write without response procedure. |
vcoubard | 1131:692ddf04fc42 | 195 | * |
vcoubard | 1135:22aada733dbd | 196 | * @param[in] length |
vcoubard | 1131:692ddf04fc42 | 197 | * The amount of data being written. |
vcoubard | 1135:22aada733dbd | 198 | * @param[in] value |
vcoubard | 1131:692ddf04fc42 | 199 | * The bytes being written. |
vcoubard | 1131:692ddf04fc42 | 200 | * |
vcoubard | 1131:692ddf04fc42 | 201 | * @note It is important to note that a write without response will generate |
vcoubard | 1131:692ddf04fc42 | 202 | * an onDataSent() callback when the packet has been transmitted. There |
vcoubard | 1131:692ddf04fc42 | 203 | * will be a BLE-stack specific limit to the number of pending |
vcoubard | 1131:692ddf04fc42 | 204 | * writeWoResponse operations; the user may want to use the onDataSent() |
vcoubard | 1131:692ddf04fc42 | 205 | * callback for flow-control. |
vcoubard | 1131:692ddf04fc42 | 206 | * |
vcoubard | 1131:692ddf04fc42 | 207 | * @retval BLE_ERROR_NONE Successfully started the Write procedure, or |
vcoubard | 1131:692ddf04fc42 | 208 | * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or |
vcoubard | 1131:692ddf04fc42 | 209 | * BLE_STACK_BUSY if some client procedure is already in progress, or |
vcoubard | 1131:692ddf04fc42 | 210 | * BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or |
vcoubard | 1131:692ddf04fc42 | 211 | * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties. |
vcoubard | 1131:692ddf04fc42 | 212 | */ |
vcoubard | 1131:692ddf04fc42 | 213 | ble_error_t writeWoResponse(uint16_t length, const uint8_t *value) const; |
vcoubard | 1131:692ddf04fc42 | 214 | |
vcoubard | 1131:692ddf04fc42 | 215 | /** |
vcoubard | 1131:692ddf04fc42 | 216 | * Initiate a GATT Characteristic Descriptor Discovery procedure for descriptors within this characteristic. |
vcoubard | 1131:692ddf04fc42 | 217 | * |
vcoubard | 1135:22aada733dbd | 218 | * @param[in] onDescriptorDiscovered This callback will be called every time a descriptor is discovered |
vcoubard | 1135:22aada733dbd | 219 | * @param[in] onTermination This callback will be called when the discovery process is over. |
vcoubard | 1131:692ddf04fc42 | 220 | * |
vcoubard | 1135:22aada733dbd | 221 | * @return BLE_ERROR_NONE if descriptor discovery is launched successfully; else an appropriate error. |
vcoubard | 1131:692ddf04fc42 | 222 | */ |
vcoubard | 1135:22aada733dbd | 223 | ble_error_t discoverDescriptors(const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& onDescriptorDiscovered, |
vcoubard | 1135:22aada733dbd | 224 | const CharacteristicDescriptorDiscovery::TerminationCallback_t& onTermination) const; |
vcoubard | 1131:692ddf04fc42 | 225 | |
vcoubard | 1131:692ddf04fc42 | 226 | /** |
vcoubard | 1131:692ddf04fc42 | 227 | * Perform a write procedure. |
vcoubard | 1131:692ddf04fc42 | 228 | * |
vcoubard | 1135:22aada733dbd | 229 | * @param[in] length |
vcoubard | 1131:692ddf04fc42 | 230 | * The amount of data being written. |
vcoubard | 1135:22aada733dbd | 231 | * @param[in] value |
vcoubard | 1131:692ddf04fc42 | 232 | * The bytes being written. |
vcoubard | 1131:692ddf04fc42 | 233 | * |
vcoubard | 1131:692ddf04fc42 | 234 | * @note It is important to note that a write will generate |
vcoubard | 1131:692ddf04fc42 | 235 | * an onDataWritten() callback when the peer acknowledges the request. |
vcoubard | 1131:692ddf04fc42 | 236 | * |
vcoubard | 1131:692ddf04fc42 | 237 | * @retval BLE_ERROR_NONE Successfully started the Write procedure, or |
vcoubard | 1131:692ddf04fc42 | 238 | * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or |
vcoubard | 1131:692ddf04fc42 | 239 | * BLE_STACK_BUSY if some client procedure is already in progress, or |
vcoubard | 1131:692ddf04fc42 | 240 | * BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or |
vcoubard | 1131:692ddf04fc42 | 241 | * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties. |
vcoubard | 1131:692ddf04fc42 | 242 | */ |
vcoubard | 1131:692ddf04fc42 | 243 | ble_error_t write(uint16_t length, const uint8_t *value) const; |
vcoubard | 1131:692ddf04fc42 | 244 | |
vcoubard | 1134:d540a48f650d | 245 | /** |
vcoubard | 1183:1589830dbdb7 | 246 | * Same as write(uint16_t, const uint8_t *) const but register a callback |
vcoubard | 1135:22aada733dbd | 247 | * which will be called once the data has been written. |
vcoubard | 1135:22aada733dbd | 248 | * |
vcoubard | 1183:1589830dbdb7 | 249 | * @param[in] length |
vcoubard | 1183:1589830dbdb7 | 250 | * The amount of bytes to write. |
vcoubard | 1183:1589830dbdb7 | 251 | * @param[in] value |
vcoubard | 1183:1589830dbdb7 | 252 | * The bytes to write. |
vcoubard | 1183:1589830dbdb7 | 253 | * @param[in] onWrite |
vcoubard | 1183:1589830dbdb7 | 254 | * Continuation callback for the write operation |
vcoubard | 1183:1589830dbdb7 | 255 | * |
vcoubard | 1183:1589830dbdb7 | 256 | * @retval BLE_ERROR_NONE Successfully started the Write procedure, or |
vcoubard | 1183:1589830dbdb7 | 257 | * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or |
vcoubard | 1183:1589830dbdb7 | 258 | * BLE_STACK_BUSY if some client procedure is already in progress, or |
vcoubard | 1183:1589830dbdb7 | 259 | * BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or |
vcoubard | 1183:1589830dbdb7 | 260 | * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties. |
vcoubard | 1131:692ddf04fc42 | 261 | */ |
vcoubard | 1135:22aada733dbd | 262 | ble_error_t write(uint16_t length, const uint8_t *value, const GattClient::WriteCallback_t& onWrite) const; |
vcoubard | 1131:692ddf04fc42 | 263 | |
vcoubard | 1134:d540a48f650d | 264 | void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) { |
vcoubard | 1134:d540a48f650d | 265 | uuid.setupLong(longUUID, order); |
vcoubard | 1131:692ddf04fc42 | 266 | } |
vcoubard | 1131:692ddf04fc42 | 267 | |
vcoubard | 1131:692ddf04fc42 | 268 | public: |
vcoubard | 1135:22aada733dbd | 269 | /** |
vcoubard | 1135:22aada733dbd | 270 | * @brief Get the UUID of the discovered characteristic |
vcoubard | 1135:22aada733dbd | 271 | * @return the UUID of this characteristic |
vcoubard | 1135:22aada733dbd | 272 | */ |
vcoubard | 1131:692ddf04fc42 | 273 | const UUID& getUUID(void) const { |
vcoubard | 1131:692ddf04fc42 | 274 | return uuid; |
vcoubard | 1131:692ddf04fc42 | 275 | } |
vcoubard | 1131:692ddf04fc42 | 276 | |
vcoubard | 1135:22aada733dbd | 277 | /** |
vcoubard | 1135:22aada733dbd | 278 | * @brief Get the properties of this characteristic |
vcoubard | 1135:22aada733dbd | 279 | * @return the set of properties of this characteristic |
vcoubard | 1135:22aada733dbd | 280 | */ |
vcoubard | 1131:692ddf04fc42 | 281 | const Properties_t& getProperties(void) const { |
vcoubard | 1131:692ddf04fc42 | 282 | return props; |
vcoubard | 1131:692ddf04fc42 | 283 | } |
vcoubard | 1131:692ddf04fc42 | 284 | |
vcoubard | 1135:22aada733dbd | 285 | /** |
vcoubard | 1135:22aada733dbd | 286 | * @brief Get the declaration handle of this characteristic. |
vcoubard | 1183:1589830dbdb7 | 287 | * @details The declaration handle is the first handle of a characteristic |
vcoubard | 1135:22aada733dbd | 288 | * definition. The value accessible at this handle contains the following |
vcoubard | 1135:22aada733dbd | 289 | * informations: |
vcoubard | 1135:22aada733dbd | 290 | * - The characteristics properties (see Properties_t). This value can |
vcoubard | 1135:22aada733dbd | 291 | * be accessed by using #getProperties . |
vcoubard | 1135:22aada733dbd | 292 | * - The characteristic value attribute handle. This field can be accessed |
vcoubard | 1135:22aada733dbd | 293 | * by using #getValueHandle . |
vcoubard | 1135:22aada733dbd | 294 | * - The characteristic UUID, this value can be accessed by using the |
vcoubard | 1135:22aada733dbd | 295 | * function #getUUID . |
vcoubard | 1135:22aada733dbd | 296 | * @return the declaration handle of this characteristic. |
vcoubard | 1135:22aada733dbd | 297 | */ |
vcoubard | 1135:22aada733dbd | 298 | GattAttribute::Handle_t getDeclHandle(void) const { |
vcoubard | 1131:692ddf04fc42 | 299 | return declHandle; |
vcoubard | 1131:692ddf04fc42 | 300 | } |
vcoubard | 1135:22aada733dbd | 301 | |
vcoubard | 1135:22aada733dbd | 302 | /** |
vcoubard | 1135:22aada733dbd | 303 | * @brief Return the handle used to access the value of this characteristic. |
vcoubard | 1135:22aada733dbd | 304 | * @details This handle is the one provided in the characteristic declaration |
vcoubard | 1135:22aada733dbd | 305 | * value. Usually, it is equal to #getDeclHandle() + 1. But it is not always |
vcoubard | 1135:22aada733dbd | 306 | * the case. Anyway, users are allowed to use #getDeclHandle() + 1 to access |
vcoubard | 1135:22aada733dbd | 307 | * the value of a characteristic. |
vcoubard | 1135:22aada733dbd | 308 | * @return The handle to access the value of this characteristic. |
vcoubard | 1135:22aada733dbd | 309 | */ |
vcoubard | 1135:22aada733dbd | 310 | GattAttribute::Handle_t getValueHandle(void) const { |
vcoubard | 1131:692ddf04fc42 | 311 | return valueHandle; |
vcoubard | 1131:692ddf04fc42 | 312 | } |
vcoubard | 1131:692ddf04fc42 | 313 | |
vcoubard | 1135:22aada733dbd | 314 | /** |
vcoubard | 1135:22aada733dbd | 315 | * @brief Return the last handle of the characteristic definition. |
vcoubard | 1135:22aada733dbd | 316 | * @details A Characteristic definition can contain a lot of handles: |
vcoubard | 1135:22aada733dbd | 317 | * - one for the declaration (see #getDeclHandle) |
vcoubard | 1135:22aada733dbd | 318 | * - one for the value (see #getValueHandle) |
vcoubard | 1135:22aada733dbd | 319 | * - zero of more for the characteristic descriptors. |
vcoubard | 1135:22aada733dbd | 320 | * This handle is the last handle of the characteristic definition. |
vcoubard | 1135:22aada733dbd | 321 | * @return The last handle of this characteristic definition. |
vcoubard | 1135:22aada733dbd | 322 | */ |
vcoubard | 1135:22aada733dbd | 323 | GattAttribute::Handle_t getLastHandle(void) const { |
vcoubard | 1135:22aada733dbd | 324 | return lastHandle; |
vcoubard | 1135:22aada733dbd | 325 | } |
vcoubard | 1135:22aada733dbd | 326 | |
vcoubard | 1135:22aada733dbd | 327 | /** |
vcoubard | 1135:22aada733dbd | 328 | * @brief Return the GattClient which can operate on this characteristic. |
vcoubard | 1135:22aada733dbd | 329 | * @return The GattClient which can operate on this characteristic. |
vcoubard | 1135:22aada733dbd | 330 | */ |
vcoubard | 1135:22aada733dbd | 331 | GattClient* getGattClient() { |
vcoubard | 1135:22aada733dbd | 332 | return gattc; |
vcoubard | 1135:22aada733dbd | 333 | } |
vcoubard | 1135:22aada733dbd | 334 | |
vcoubard | 1135:22aada733dbd | 335 | /** |
vcoubard | 1135:22aada733dbd | 336 | * @brief Return the GattClient which can operate on this characteristic. |
vcoubard | 1135:22aada733dbd | 337 | * @return The GattClient which can operate on this characteristic. |
vcoubard | 1135:22aada733dbd | 338 | */ |
vcoubard | 1135:22aada733dbd | 339 | const GattClient* getGattClient() const { |
vcoubard | 1135:22aada733dbd | 340 | return gattc; |
vcoubard | 1135:22aada733dbd | 341 | } |
vcoubard | 1135:22aada733dbd | 342 | |
vcoubard | 1135:22aada733dbd | 343 | /** |
vcoubard | 1135:22aada733dbd | 344 | * @brief Return the connection handle to the GattServer which contain |
vcoubard | 1135:22aada733dbd | 345 | * this characteristic. |
vcoubard | 1135:22aada733dbd | 346 | * @return the connection handle to the GattServer which contain |
vcoubard | 1135:22aada733dbd | 347 | * this characteristic. |
vcoubard | 1135:22aada733dbd | 348 | */ |
vcoubard | 1135:22aada733dbd | 349 | Gap::Handle_t getConnectionHandle() const { |
vcoubard | 1135:22aada733dbd | 350 | return connHandle; |
vcoubard | 1135:22aada733dbd | 351 | } |
vcoubard | 1135:22aada733dbd | 352 | |
vcoubard | 1135:22aada733dbd | 353 | /** |
vcoubard | 1135:22aada733dbd | 354 | * @brief "Equal to" operator for DiscoveredCharacteristic |
vcoubard | 1135:22aada733dbd | 355 | * |
vcoubard | 1183:1589830dbdb7 | 356 | * @param[in] lhs |
vcoubard | 1183:1589830dbdb7 | 357 | * The left hand side of the equality expression |
vcoubard | 1183:1589830dbdb7 | 358 | * @param[in] rhs |
vcoubard | 1183:1589830dbdb7 | 359 | * The right hand side of the equality expression |
vcoubard | 1135:22aada733dbd | 360 | * |
vcoubard | 1135:22aada733dbd | 361 | * @return true if operands are equals, false otherwise. |
vcoubard | 1135:22aada733dbd | 362 | */ |
vcoubard | 1135:22aada733dbd | 363 | friend bool operator==(const DiscoveredCharacteristic& lhs, const DiscoveredCharacteristic& rhs) { |
vcoubard | 1135:22aada733dbd | 364 | return lhs.gattc == rhs.gattc && |
vcoubard | 1135:22aada733dbd | 365 | lhs.uuid == rhs.uuid && |
vcoubard | 1135:22aada733dbd | 366 | lhs.props == rhs.props && |
vcoubard | 1135:22aada733dbd | 367 | lhs.declHandle == rhs.declHandle && |
vcoubard | 1135:22aada733dbd | 368 | lhs.valueHandle == rhs.valueHandle && |
vcoubard | 1135:22aada733dbd | 369 | lhs.lastHandle == rhs.lastHandle && |
vcoubard | 1135:22aada733dbd | 370 | lhs.connHandle == rhs.connHandle; |
vcoubard | 1135:22aada733dbd | 371 | } |
vcoubard | 1135:22aada733dbd | 372 | |
vcoubard | 1135:22aada733dbd | 373 | /** |
vcoubard | 1135:22aada733dbd | 374 | * @brief "Not equal to" operator for DiscoveredCharacteristic |
vcoubard | 1135:22aada733dbd | 375 | * |
vcoubard | 1183:1589830dbdb7 | 376 | * @param[in] lhs |
vcoubard | 1183:1589830dbdb7 | 377 | * The right hand side of the expression |
vcoubard | 1183:1589830dbdb7 | 378 | * @param[in] rhs |
vcoubard | 1183:1589830dbdb7 | 379 | * The left hand side of the expression |
vcoubard | 1135:22aada733dbd | 380 | * |
vcoubard | 1183:1589830dbdb7 | 381 | * @return true if operands are not equal, false otherwise. |
vcoubard | 1135:22aada733dbd | 382 | */ |
vcoubard | 1135:22aada733dbd | 383 | friend bool operator !=(const DiscoveredCharacteristic& lhs, const DiscoveredCharacteristic& rhs) { |
vcoubard | 1135:22aada733dbd | 384 | return !(lhs == rhs); |
vcoubard | 1135:22aada733dbd | 385 | } |
vcoubard | 1135:22aada733dbd | 386 | |
vcoubard | 1131:692ddf04fc42 | 387 | public: |
vcoubard | 1131:692ddf04fc42 | 388 | DiscoveredCharacteristic() : gattc(NULL), |
vcoubard | 1131:692ddf04fc42 | 389 | uuid(UUID::ShortUUIDBytes_t(0)), |
vcoubard | 1131:692ddf04fc42 | 390 | props(), |
vcoubard | 1131:692ddf04fc42 | 391 | declHandle(GattAttribute::INVALID_HANDLE), |
vcoubard | 1135:22aada733dbd | 392 | valueHandle(GattAttribute::INVALID_HANDLE), |
vcoubard | 1135:22aada733dbd | 393 | lastHandle(GattAttribute::INVALID_HANDLE), |
vcoubard | 1135:22aada733dbd | 394 | connHandle() { |
vcoubard | 1131:692ddf04fc42 | 395 | /* empty */ |
vcoubard | 1131:692ddf04fc42 | 396 | } |
vcoubard | 1131:692ddf04fc42 | 397 | |
vcoubard | 1131:692ddf04fc42 | 398 | protected: |
vcoubard | 1183:1589830dbdb7 | 399 | /** |
vcoubard | 1183:1589830dbdb7 | 400 | * Pointer to the underlying GattClient for this DiscoveredCharacteristic object. |
vcoubard | 1183:1589830dbdb7 | 401 | */ |
vcoubard | 1131:692ddf04fc42 | 402 | GattClient *gattc; |
vcoubard | 1131:692ddf04fc42 | 403 | |
vcoubard | 1131:692ddf04fc42 | 404 | protected: |
vcoubard | 1183:1589830dbdb7 | 405 | /** |
vcoubard | 1183:1589830dbdb7 | 406 | * Discovered characteristic's UUID. |
vcoubard | 1183:1589830dbdb7 | 407 | */ |
vcoubard | 1131:692ddf04fc42 | 408 | UUID uuid; |
vcoubard | 1183:1589830dbdb7 | 409 | /** |
vcoubard | 1183:1589830dbdb7 | 410 | * Hold the configured properties of the discovered characteristic. |
vcoubard | 1183:1589830dbdb7 | 411 | * For more information refer to Properties_t. |
vcoubard | 1183:1589830dbdb7 | 412 | */ |
vcoubard | 1131:692ddf04fc42 | 413 | Properties_t props; |
vcoubard | 1183:1589830dbdb7 | 414 | /** |
vcoubard | 1183:1589830dbdb7 | 415 | * Value handle of the discovered characteristic's declaration attribute. |
vcoubard | 1183:1589830dbdb7 | 416 | */ |
vcoubard | 1131:692ddf04fc42 | 417 | GattAttribute::Handle_t declHandle; |
vcoubard | 1183:1589830dbdb7 | 418 | /** |
vcoubard | 1183:1589830dbdb7 | 419 | * Value handle of the discovered characteristic's value attribute. |
vcoubard | 1183:1589830dbdb7 | 420 | */ |
vcoubard | 1131:692ddf04fc42 | 421 | GattAttribute::Handle_t valueHandle; |
vcoubard | 1183:1589830dbdb7 | 422 | /** |
vcoubard | 1183:1589830dbdb7 | 423 | * Value handle of the discovered characteristic's last attribute. |
vcoubard | 1183:1589830dbdb7 | 424 | */ |
vcoubard | 1135:22aada733dbd | 425 | GattAttribute::Handle_t lastHandle; |
vcoubard | 1131:692ddf04fc42 | 426 | |
vcoubard | 1183:1589830dbdb7 | 427 | /** |
vcoubard | 1183:1589830dbdb7 | 428 | * Handle for the connection where the characteristic was discovered. |
vcoubard | 1183:1589830dbdb7 | 429 | */ |
vcoubard | 1131:692ddf04fc42 | 430 | Gap::Handle_t connHandle; |
vcoubard | 1131:692ddf04fc42 | 431 | }; |
vcoubard | 1131:692ddf04fc42 | 432 | |
rgrover1 | 716:11b41f651697 | 433 | #endif /*__DISCOVERED_CHARACTERISTIC_H__*/ |