just a fork

Fork of BLE_API by Bluetooth Low Energy

Committer:
marfife
Date:
Fri Jul 08 23:39:31 2016 +0000
Revision:
1201:6dd8b141406e
Parent:
1183:1589830dbdb7
init

Who changed what in which revision?

UserRevisionLine numberNew 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;
marfife 1201:6dd8b141406e 263
marfife 1201:6dd8b141406e 264 /**
marfife 1201:6dd8b141406e 265 * Request Server to send notify/inform messages for the characteristic
marfife 1201:6dd8b141406e 266 *
marfife 1201:6dd8b141406e 267 * @param type
marfife 1201:6dd8b141406e 268 * BLE_HVX_NOTIFICATION or BLE_HVX_INDICATION.
marfife 1201:6dd8b141406e 269 *
marfife 1201:6dd8b141406e 270 * @retval BLE_ERROR_NONE Successfully requested notification/informa messages
marfife 1201:6dd8b141406e 271 * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or
marfife 1201:6dd8b141406e 272 * BLE_STACK_BUSY if some client procedure already in progress, or
marfife 1201:6dd8b141406e 273 * BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or
marfife 1201:6dd8b141406e 274 * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties.
marfife 1201:6dd8b141406e 275 */
marfife 1201:6dd8b141406e 276 ble_error_t requestHVX(HVXType_t type) const;
vcoubard 1131:692ddf04fc42 277
vcoubard 1134:d540a48f650d 278 void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) {
vcoubard 1134:d540a48f650d 279 uuid.setupLong(longUUID, order);
vcoubard 1131:692ddf04fc42 280 }
vcoubard 1131:692ddf04fc42 281
vcoubard 1131:692ddf04fc42 282 public:
vcoubard 1135:22aada733dbd 283 /**
vcoubard 1135:22aada733dbd 284 * @brief Get the UUID of the discovered characteristic
vcoubard 1135:22aada733dbd 285 * @return the UUID of this characteristic
vcoubard 1135:22aada733dbd 286 */
vcoubard 1131:692ddf04fc42 287 const UUID& getUUID(void) const {
vcoubard 1131:692ddf04fc42 288 return uuid;
vcoubard 1131:692ddf04fc42 289 }
vcoubard 1131:692ddf04fc42 290
vcoubard 1135:22aada733dbd 291 /**
vcoubard 1135:22aada733dbd 292 * @brief Get the properties of this characteristic
vcoubard 1135:22aada733dbd 293 * @return the set of properties of this characteristic
vcoubard 1135:22aada733dbd 294 */
vcoubard 1131:692ddf04fc42 295 const Properties_t& getProperties(void) const {
vcoubard 1131:692ddf04fc42 296 return props;
vcoubard 1131:692ddf04fc42 297 }
vcoubard 1131:692ddf04fc42 298
vcoubard 1135:22aada733dbd 299 /**
vcoubard 1135:22aada733dbd 300 * @brief Get the declaration handle of this characteristic.
vcoubard 1183:1589830dbdb7 301 * @details The declaration handle is the first handle of a characteristic
vcoubard 1135:22aada733dbd 302 * definition. The value accessible at this handle contains the following
vcoubard 1135:22aada733dbd 303 * informations:
vcoubard 1135:22aada733dbd 304 * - The characteristics properties (see Properties_t). This value can
vcoubard 1135:22aada733dbd 305 * be accessed by using #getProperties .
vcoubard 1135:22aada733dbd 306 * - The characteristic value attribute handle. This field can be accessed
vcoubard 1135:22aada733dbd 307 * by using #getValueHandle .
vcoubard 1135:22aada733dbd 308 * - The characteristic UUID, this value can be accessed by using the
vcoubard 1135:22aada733dbd 309 * function #getUUID .
vcoubard 1135:22aada733dbd 310 * @return the declaration handle of this characteristic.
vcoubard 1135:22aada733dbd 311 */
vcoubard 1135:22aada733dbd 312 GattAttribute::Handle_t getDeclHandle(void) const {
vcoubard 1131:692ddf04fc42 313 return declHandle;
vcoubard 1131:692ddf04fc42 314 }
vcoubard 1135:22aada733dbd 315
vcoubard 1135:22aada733dbd 316 /**
vcoubard 1135:22aada733dbd 317 * @brief Return the handle used to access the value of this characteristic.
vcoubard 1135:22aada733dbd 318 * @details This handle is the one provided in the characteristic declaration
vcoubard 1135:22aada733dbd 319 * value. Usually, it is equal to #getDeclHandle() + 1. But it is not always
vcoubard 1135:22aada733dbd 320 * the case. Anyway, users are allowed to use #getDeclHandle() + 1 to access
vcoubard 1135:22aada733dbd 321 * the value of a characteristic.
vcoubard 1135:22aada733dbd 322 * @return The handle to access the value of this characteristic.
vcoubard 1135:22aada733dbd 323 */
vcoubard 1135:22aada733dbd 324 GattAttribute::Handle_t getValueHandle(void) const {
vcoubard 1131:692ddf04fc42 325 return valueHandle;
vcoubard 1131:692ddf04fc42 326 }
vcoubard 1131:692ddf04fc42 327
vcoubard 1135:22aada733dbd 328 /**
vcoubard 1135:22aada733dbd 329 * @brief Return the last handle of the characteristic definition.
vcoubard 1135:22aada733dbd 330 * @details A Characteristic definition can contain a lot of handles:
vcoubard 1135:22aada733dbd 331 * - one for the declaration (see #getDeclHandle)
vcoubard 1135:22aada733dbd 332 * - one for the value (see #getValueHandle)
vcoubard 1135:22aada733dbd 333 * - zero of more for the characteristic descriptors.
vcoubard 1135:22aada733dbd 334 * This handle is the last handle of the characteristic definition.
vcoubard 1135:22aada733dbd 335 * @return The last handle of this characteristic definition.
vcoubard 1135:22aada733dbd 336 */
vcoubard 1135:22aada733dbd 337 GattAttribute::Handle_t getLastHandle(void) const {
vcoubard 1135:22aada733dbd 338 return lastHandle;
vcoubard 1135:22aada733dbd 339 }
vcoubard 1135:22aada733dbd 340
vcoubard 1135:22aada733dbd 341 /**
vcoubard 1135:22aada733dbd 342 * @brief Return the GattClient which can operate on this characteristic.
vcoubard 1135:22aada733dbd 343 * @return The GattClient which can operate on this characteristic.
vcoubard 1135:22aada733dbd 344 */
vcoubard 1135:22aada733dbd 345 GattClient* getGattClient() {
vcoubard 1135:22aada733dbd 346 return gattc;
vcoubard 1135:22aada733dbd 347 }
vcoubard 1135:22aada733dbd 348
vcoubard 1135:22aada733dbd 349 /**
vcoubard 1135:22aada733dbd 350 * @brief Return the GattClient which can operate on this characteristic.
vcoubard 1135:22aada733dbd 351 * @return The GattClient which can operate on this characteristic.
vcoubard 1135:22aada733dbd 352 */
vcoubard 1135:22aada733dbd 353 const GattClient* getGattClient() const {
vcoubard 1135:22aada733dbd 354 return gattc;
vcoubard 1135:22aada733dbd 355 }
vcoubard 1135:22aada733dbd 356
vcoubard 1135:22aada733dbd 357 /**
vcoubard 1135:22aada733dbd 358 * @brief Return the connection handle to the GattServer which contain
vcoubard 1135:22aada733dbd 359 * this characteristic.
vcoubard 1135:22aada733dbd 360 * @return the connection handle to the GattServer which contain
vcoubard 1135:22aada733dbd 361 * this characteristic.
vcoubard 1135:22aada733dbd 362 */
vcoubard 1135:22aada733dbd 363 Gap::Handle_t getConnectionHandle() const {
vcoubard 1135:22aada733dbd 364 return connHandle;
vcoubard 1135:22aada733dbd 365 }
vcoubard 1135:22aada733dbd 366
vcoubard 1135:22aada733dbd 367 /**
vcoubard 1135:22aada733dbd 368 * @brief "Equal to" operator for DiscoveredCharacteristic
vcoubard 1135:22aada733dbd 369 *
vcoubard 1183:1589830dbdb7 370 * @param[in] lhs
vcoubard 1183:1589830dbdb7 371 * The left hand side of the equality expression
vcoubard 1183:1589830dbdb7 372 * @param[in] rhs
vcoubard 1183:1589830dbdb7 373 * The right hand side of the equality expression
vcoubard 1135:22aada733dbd 374 *
vcoubard 1135:22aada733dbd 375 * @return true if operands are equals, false otherwise.
vcoubard 1135:22aada733dbd 376 */
vcoubard 1135:22aada733dbd 377 friend bool operator==(const DiscoveredCharacteristic& lhs, const DiscoveredCharacteristic& rhs) {
vcoubard 1135:22aada733dbd 378 return lhs.gattc == rhs.gattc &&
vcoubard 1135:22aada733dbd 379 lhs.uuid == rhs.uuid &&
vcoubard 1135:22aada733dbd 380 lhs.props == rhs.props &&
vcoubard 1135:22aada733dbd 381 lhs.declHandle == rhs.declHandle &&
vcoubard 1135:22aada733dbd 382 lhs.valueHandle == rhs.valueHandle &&
vcoubard 1135:22aada733dbd 383 lhs.lastHandle == rhs.lastHandle &&
vcoubard 1135:22aada733dbd 384 lhs.connHandle == rhs.connHandle;
vcoubard 1135:22aada733dbd 385 }
vcoubard 1135:22aada733dbd 386
vcoubard 1135:22aada733dbd 387 /**
vcoubard 1135:22aada733dbd 388 * @brief "Not equal to" operator for DiscoveredCharacteristic
vcoubard 1135:22aada733dbd 389 *
vcoubard 1183:1589830dbdb7 390 * @param[in] lhs
vcoubard 1183:1589830dbdb7 391 * The right hand side of the expression
vcoubard 1183:1589830dbdb7 392 * @param[in] rhs
vcoubard 1183:1589830dbdb7 393 * The left hand side of the expression
vcoubard 1135:22aada733dbd 394 *
vcoubard 1183:1589830dbdb7 395 * @return true if operands are not equal, false otherwise.
vcoubard 1135:22aada733dbd 396 */
vcoubard 1135:22aada733dbd 397 friend bool operator !=(const DiscoveredCharacteristic& lhs, const DiscoveredCharacteristic& rhs) {
vcoubard 1135:22aada733dbd 398 return !(lhs == rhs);
vcoubard 1135:22aada733dbd 399 }
vcoubard 1135:22aada733dbd 400
vcoubard 1131:692ddf04fc42 401 public:
vcoubard 1131:692ddf04fc42 402 DiscoveredCharacteristic() : gattc(NULL),
vcoubard 1131:692ddf04fc42 403 uuid(UUID::ShortUUIDBytes_t(0)),
vcoubard 1131:692ddf04fc42 404 props(),
vcoubard 1131:692ddf04fc42 405 declHandle(GattAttribute::INVALID_HANDLE),
vcoubard 1135:22aada733dbd 406 valueHandle(GattAttribute::INVALID_HANDLE),
vcoubard 1135:22aada733dbd 407 lastHandle(GattAttribute::INVALID_HANDLE),
vcoubard 1135:22aada733dbd 408 connHandle() {
vcoubard 1131:692ddf04fc42 409 /* empty */
vcoubard 1131:692ddf04fc42 410 }
vcoubard 1131:692ddf04fc42 411
vcoubard 1131:692ddf04fc42 412 protected:
vcoubard 1183:1589830dbdb7 413 /**
vcoubard 1183:1589830dbdb7 414 * Pointer to the underlying GattClient for this DiscoveredCharacteristic object.
vcoubard 1183:1589830dbdb7 415 */
vcoubard 1131:692ddf04fc42 416 GattClient *gattc;
vcoubard 1131:692ddf04fc42 417
vcoubard 1131:692ddf04fc42 418 protected:
vcoubard 1183:1589830dbdb7 419 /**
vcoubard 1183:1589830dbdb7 420 * Discovered characteristic's UUID.
vcoubard 1183:1589830dbdb7 421 */
vcoubard 1131:692ddf04fc42 422 UUID uuid;
vcoubard 1183:1589830dbdb7 423 /**
vcoubard 1183:1589830dbdb7 424 * Hold the configured properties of the discovered characteristic.
vcoubard 1183:1589830dbdb7 425 * For more information refer to Properties_t.
vcoubard 1183:1589830dbdb7 426 */
vcoubard 1131:692ddf04fc42 427 Properties_t props;
vcoubard 1183:1589830dbdb7 428 /**
vcoubard 1183:1589830dbdb7 429 * Value handle of the discovered characteristic's declaration attribute.
vcoubard 1183:1589830dbdb7 430 */
vcoubard 1131:692ddf04fc42 431 GattAttribute::Handle_t declHandle;
vcoubard 1183:1589830dbdb7 432 /**
vcoubard 1183:1589830dbdb7 433 * Value handle of the discovered characteristic's value attribute.
vcoubard 1183:1589830dbdb7 434 */
vcoubard 1131:692ddf04fc42 435 GattAttribute::Handle_t valueHandle;
vcoubard 1183:1589830dbdb7 436 /**
vcoubard 1183:1589830dbdb7 437 * Value handle of the discovered characteristic's last attribute.
vcoubard 1183:1589830dbdb7 438 */
vcoubard 1135:22aada733dbd 439 GattAttribute::Handle_t lastHandle;
vcoubard 1131:692ddf04fc42 440
vcoubard 1183:1589830dbdb7 441 /**
vcoubard 1183:1589830dbdb7 442 * Handle for the connection where the characteristic was discovered.
vcoubard 1183:1589830dbdb7 443 */
vcoubard 1131:692ddf04fc42 444 Gap::Handle_t connHandle;
vcoubard 1131:692ddf04fc42 445 };
vcoubard 1131:692ddf04fc42 446
rgrover1 716:11b41f651697 447 #endif /*__DISCOVERED_CHARACTERISTIC_H__*/