Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

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