just a fork

Fork of BLE_API by Bluetooth Low Energy

Committer:
vcoubard
Date:
Wed Apr 06 19:14:43 2016 +0100
Revision:
1158:fc9f3dbbb34e
Parent:
1156:e1ea38b576c6
Child:
1177:f9060dc8c5ab
Synchronized with git rev ed7b5d10
Author: Andres Amaya Garcia
Fix doxygen warnings in DiscoveredCharacteristic.h

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