Bike service
Fork of BLE_API by
ble/DiscoveredCharacteristic.h@1156:e28c7aac64ab, 2016-04-06 (annotated)
- Committer:
- vcoubard
- Date:
- Wed Apr 06 19:14:34 2016 +0100
- Revision:
- 1156:e28c7aac64ab
- Parent:
- 1155:702de9e6b049
- Child:
- 1157:e1ea38b576c6
Synchronized with git rev e20c8c58
Author: Vincent Coubard
Merge pull request #163 from ARMmbed/develop
merge version 2.5.0 into master
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 1132:692ddf04fc42 | 1 | /* mbed Microcontroller Library |
vcoubard | 1132:692ddf04fc42 | 2 | * Copyright (c) 2006-2013 ARM Limited |
vcoubard | 1132:692ddf04fc42 | 3 | * |
vcoubard | 1132:692ddf04fc42 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
vcoubard | 1132:692ddf04fc42 | 5 | * you may not use this file except in compliance with the License. |
vcoubard | 1132:692ddf04fc42 | 6 | * You may obtain a copy of the License at |
vcoubard | 1132:692ddf04fc42 | 7 | * |
vcoubard | 1132:692ddf04fc42 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
vcoubard | 1132:692ddf04fc42 | 9 | * |
vcoubard | 1132:692ddf04fc42 | 10 | * Unless required by applicable law or agreed to in writing, software |
vcoubard | 1132:692ddf04fc42 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
vcoubard | 1132:692ddf04fc42 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
vcoubard | 1132:692ddf04fc42 | 13 | * See the License for the specific language governing permissions and |
vcoubard | 1132:692ddf04fc42 | 14 | * limitations under the License. |
vcoubard | 1132:692ddf04fc42 | 15 | */ |
vcoubard | 1132:692ddf04fc42 | 16 | |
vcoubard | 1132:692ddf04fc42 | 17 | #ifndef __DISCOVERED_CHARACTERISTIC_H__ |
vcoubard | 1132:692ddf04fc42 | 18 | #define __DISCOVERED_CHARACTERISTIC_H__ |
vcoubard | 1132:692ddf04fc42 | 19 | |
vcoubard | 1132:692ddf04fc42 | 20 | #include "UUID.h" |
vcoubard | 1132:692ddf04fc42 | 21 | #include "Gap.h" |
vcoubard | 1132:692ddf04fc42 | 22 | #include "GattAttribute.h" |
vcoubard | 1132:692ddf04fc42 | 23 | #include "GattClient.h" |
vcoubard | 1136:22aada733dbd | 24 | #include "CharacteristicDescriptorDiscovery.h" |
vcoubard | 1136:22aada733dbd | 25 | #include "ble/DiscoveredCharacteristicDescriptor.h" |
vcoubard | 1132:692ddf04fc42 | 26 | |
vcoubard | 1132:692ddf04fc42 | 27 | /** |
vcoubard | 1136:22aada733dbd | 28 | * @brief Representation of a characteristic discovered during a GattClient |
vcoubard | 1136:22aada733dbd | 29 | * discovery procedure (see GattClient::launchServiceDiscovery ). |
vcoubard | 1136:22aada733dbd | 30 | * |
vcoubard | 1156:e28c7aac64ab | 31 | * @detail Provide detailed informations about a discovered characteristic like: |
vcoubard | 1136:22aada733dbd | 32 | * - Its UUID (see #getUUID). |
vcoubard | 1136:22aada733dbd | 33 | * - The most important handles of the characteristic definition |
vcoubard | 1136:22aada733dbd | 34 | * (see #getDeclHandle, #getValueHandle, #getLastHandle ) |
vcoubard | 1136:22aada733dbd | 35 | * - Its properties (see #getProperties). |
vcoubard | 1136:22aada733dbd | 36 | * This class also provide functions to operate on the characteristic: |
vcoubard | 1136:22aada733dbd | 37 | * - Read the characteristic value (see #read) |
vcoubard | 1136:22aada733dbd | 38 | * - Writing a characteristic value (see #write or #writeWoResponse) |
vcoubard | 1136:22aada733dbd | 39 | * - Discover descriptors inside the characteristic definition. These descriptors |
vcoubard | 1136:22aada733dbd | 40 | * extends the characteristic. More information about descriptor usage is |
vcoubard | 1136:22aada733dbd | 41 | * available in DiscoveredCharacteristicDescriptor class. |
vcoubard | 1132:692ddf04fc42 | 42 | */ |
vcoubard | 1132:692ddf04fc42 | 43 | class DiscoveredCharacteristic { |
vcoubard | 1132:692ddf04fc42 | 44 | public: |
vcoubard | 1132:692ddf04fc42 | 45 | struct Properties_t { |
vcoubard | 1132:692ddf04fc42 | 46 | uint8_t _broadcast :1; /**< Broadcasting the value permitted. */ |
vcoubard | 1132:692ddf04fc42 | 47 | uint8_t _read :1; /**< Reading the value permitted. */ |
vcoubard | 1132:692ddf04fc42 | 48 | uint8_t _writeWoResp :1; /**< Writing the value with Write Command permitted. */ |
vcoubard | 1132:692ddf04fc42 | 49 | uint8_t _write :1; /**< Writing the value with Write Request permitted. */ |
vcoubard | 1136:22aada733dbd | 50 | uint8_t _notify :1; /**< Notifications of the value permitted. */ |
vcoubard | 1132:692ddf04fc42 | 51 | uint8_t _indicate :1; /**< Indications of the value permitted. */ |
vcoubard | 1132:692ddf04fc42 | 52 | uint8_t _authSignedWrite :1; /**< Writing the value with Signed Write Command permitted. */ |
vcoubard | 1132:692ddf04fc42 | 53 | |
vcoubard | 1132:692ddf04fc42 | 54 | public: |
vcoubard | 1156:e28c7aac64ab | 55 | bool broadcast(void) const {return _broadcast; } |
vcoubard | 1156:e28c7aac64ab | 56 | bool read(void) const {return _read; } |
vcoubard | 1156:e28c7aac64ab | 57 | bool writeWoResp(void) const {return _writeWoResp; } |
vcoubard | 1156:e28c7aac64ab | 58 | bool write(void) const {return _write; } |
vcoubard | 1156:e28c7aac64ab | 59 | bool notify(void) const {return _notify; } |
vcoubard | 1156:e28c7aac64ab | 60 | bool indicate(void) const {return _indicate; } |
vcoubard | 1156:e28c7aac64ab | 61 | bool authSignedWrite(void) const {return _authSignedWrite;} |
vcoubard | 1132:692ddf04fc42 | 62 | |
vcoubard | 1136:22aada733dbd | 63 | /** |
vcoubard | 1136:22aada733dbd | 64 | * @brief "Equal to" operator for DiscoveredCharacteristic::Properties_t |
vcoubard | 1136:22aada733dbd | 65 | * |
vcoubard | 1156:e28c7aac64ab | 66 | * @param lhs[in] The left hand side of the equality expression |
vcoubard | 1156:e28c7aac64ab | 67 | * @param rhs[in] The right hand side of the equality expression |
vcoubard | 1136:22aada733dbd | 68 | * |
vcoubard | 1136:22aada733dbd | 69 | * @return true if operands are equals, false otherwise. |
vcoubard | 1136:22aada733dbd | 70 | */ |
vcoubard | 1136:22aada733dbd | 71 | friend bool operator==(Properties_t lhs, Properties_t rhs) { |
vcoubard | 1136:22aada733dbd | 72 | return lhs._broadcast == rhs._broadcast && |
vcoubard | 1136:22aada733dbd | 73 | lhs._read == rhs._read && |
vcoubard | 1136:22aada733dbd | 74 | lhs._writeWoResp == rhs._writeWoResp && |
vcoubard | 1136:22aada733dbd | 75 | lhs._write == rhs._write && |
vcoubard | 1136:22aada733dbd | 76 | lhs._notify == rhs._notify && |
vcoubard | 1136:22aada733dbd | 77 | lhs._indicate == rhs._indicate && |
vcoubard | 1136:22aada733dbd | 78 | lhs._authSignedWrite == rhs._authSignedWrite; |
vcoubard | 1136:22aada733dbd | 79 | } |
vcoubard | 1136:22aada733dbd | 80 | |
vcoubard | 1136:22aada733dbd | 81 | /** |
vcoubard | 1136:22aada733dbd | 82 | * @brief "Not equal to" operator for DiscoveredCharacteristic::Properties_t |
vcoubard | 1136:22aada733dbd | 83 | * |
vcoubard | 1136:22aada733dbd | 84 | * @param lhs The right hand side of the expression |
vcoubard | 1136:22aada733dbd | 85 | * @param rhs The left hand side of the expression |
vcoubard | 1136:22aada733dbd | 86 | * |
vcoubard | 1136:22aada733dbd | 87 | * @return true if operands are not equals, false otherwise. |
vcoubard | 1136:22aada733dbd | 88 | */ |
vcoubard | 1136:22aada733dbd | 89 | friend bool operator!=(Properties_t lhs, Properties_t rhs) { |
vcoubard | 1136:22aada733dbd | 90 | return !(lhs == rhs); |
vcoubard | 1136:22aada733dbd | 91 | } |
vcoubard | 1136:22aada733dbd | 92 | |
vcoubard | 1132:692ddf04fc42 | 93 | private: |
vcoubard | 1132:692ddf04fc42 | 94 | operator uint8_t() const; /* Disallow implicit conversion into an integer. */ |
vcoubard | 1132:692ddf04fc42 | 95 | operator unsigned() const; /* Disallow implicit conversion into an integer. */ |
vcoubard | 1132:692ddf04fc42 | 96 | }; |
vcoubard | 1132:692ddf04fc42 | 97 | |
vcoubard | 1132:692ddf04fc42 | 98 | /** |
vcoubard | 1132:692ddf04fc42 | 99 | * Initiate (or continue) a read for the value attribute, optionally at a |
vcoubard | 1132:692ddf04fc42 | 100 | * given offset. If the characteristic or descriptor to be read is longer |
vcoubard | 1132:692ddf04fc42 | 101 | * than ATT_MTU - 1, this function must be called multiple times with |
vcoubard | 1132:692ddf04fc42 | 102 | * appropriate offset to read the complete value. |
vcoubard | 1132:692ddf04fc42 | 103 | * |
vcoubard | 1156:e28c7aac64ab | 104 | * @param offset[in] The position - in the characteristic value bytes stream - where |
vcoubard | 1156:e28c7aac64ab | 105 | * the read operation begin. |
vcoubard | 1136:22aada733dbd | 106 | * |
vcoubard | 1132:692ddf04fc42 | 107 | * @return BLE_ERROR_NONE if a read has been initiated, or |
vcoubard | 1132:692ddf04fc42 | 108 | * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or |
vcoubard | 1132:692ddf04fc42 | 109 | * BLE_STACK_BUSY if some client procedure is already in progress, or |
vcoubard | 1132:692ddf04fc42 | 110 | * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties. |
vcoubard | 1132:692ddf04fc42 | 111 | */ |
vcoubard | 1132:692ddf04fc42 | 112 | ble_error_t read(uint16_t offset = 0) const; |
vcoubard | 1132:692ddf04fc42 | 113 | |
vcoubard | 1136:22aada733dbd | 114 | /** |
vcoubard | 1136:22aada733dbd | 115 | * @brief Same as #read(uint16_t) const but allow the user to register a callback |
vcoubard | 1136:22aada733dbd | 116 | * which will be fired once the read is done. |
vcoubard | 1136:22aada733dbd | 117 | * |
vcoubard | 1156:e28c7aac64ab | 118 | * @param offset[in] The position - in the characteristic value bytes stream - where |
vcoubard | 1156:e28c7aac64ab | 119 | * the read operation begin. |
vcoubard | 1156:e28c7aac64ab | 120 | * @param onRead[in] Continuation of the read operation |
vcoubard | 1136:22aada733dbd | 121 | */ |
vcoubard | 1132:692ddf04fc42 | 122 | ble_error_t read(uint16_t offset, const GattClient::ReadCallback_t& onRead) const; |
vcoubard | 1132:692ddf04fc42 | 123 | |
vcoubard | 1132:692ddf04fc42 | 124 | /** |
vcoubard | 1132:692ddf04fc42 | 125 | * Perform a write without response procedure. |
vcoubard | 1132:692ddf04fc42 | 126 | * |
vcoubard | 1136:22aada733dbd | 127 | * @param[in] length |
vcoubard | 1132:692ddf04fc42 | 128 | * The amount of data being written. |
vcoubard | 1136:22aada733dbd | 129 | * @param[in] value |
vcoubard | 1132:692ddf04fc42 | 130 | * The bytes being written. |
vcoubard | 1132:692ddf04fc42 | 131 | * |
vcoubard | 1132:692ddf04fc42 | 132 | * @note It is important to note that a write without response will generate |
vcoubard | 1132:692ddf04fc42 | 133 | * an onDataSent() callback when the packet has been transmitted. There |
vcoubard | 1132:692ddf04fc42 | 134 | * will be a BLE-stack specific limit to the number of pending |
vcoubard | 1132:692ddf04fc42 | 135 | * writeWoResponse operations; the user may want to use the onDataSent() |
vcoubard | 1132:692ddf04fc42 | 136 | * callback for flow-control. |
vcoubard | 1132:692ddf04fc42 | 137 | * |
vcoubard | 1132:692ddf04fc42 | 138 | * @retval BLE_ERROR_NONE Successfully started the Write procedure, or |
vcoubard | 1132:692ddf04fc42 | 139 | * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or |
vcoubard | 1132:692ddf04fc42 | 140 | * BLE_STACK_BUSY if some client procedure is already in progress, or |
vcoubard | 1132:692ddf04fc42 | 141 | * BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or |
vcoubard | 1132:692ddf04fc42 | 142 | * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties. |
vcoubard | 1132:692ddf04fc42 | 143 | */ |
vcoubard | 1132:692ddf04fc42 | 144 | ble_error_t writeWoResponse(uint16_t length, const uint8_t *value) const; |
vcoubard | 1132:692ddf04fc42 | 145 | |
vcoubard | 1132:692ddf04fc42 | 146 | /** |
vcoubard | 1132:692ddf04fc42 | 147 | * Initiate a GATT Characteristic Descriptor Discovery procedure for descriptors within this characteristic. |
vcoubard | 1132:692ddf04fc42 | 148 | * |
vcoubard | 1136:22aada733dbd | 149 | * @param[in] onDescriptorDiscovered This callback will be called every time a descriptor is discovered |
vcoubard | 1136:22aada733dbd | 150 | * @param[in] onTermination This callback will be called when the discovery process is over. |
vcoubard | 1132:692ddf04fc42 | 151 | * |
vcoubard | 1136:22aada733dbd | 152 | * @return BLE_ERROR_NONE if descriptor discovery is launched successfully; else an appropriate error. |
vcoubard | 1132:692ddf04fc42 | 153 | */ |
vcoubard | 1136:22aada733dbd | 154 | ble_error_t discoverDescriptors(const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& onDescriptorDiscovered, |
vcoubard | 1136:22aada733dbd | 155 | const CharacteristicDescriptorDiscovery::TerminationCallback_t& onTermination) const; |
vcoubard | 1132:692ddf04fc42 | 156 | |
vcoubard | 1132:692ddf04fc42 | 157 | /** |
vcoubard | 1132:692ddf04fc42 | 158 | * Perform a write procedure. |
vcoubard | 1132:692ddf04fc42 | 159 | * |
vcoubard | 1136:22aada733dbd | 160 | * @param[in] length |
vcoubard | 1132:692ddf04fc42 | 161 | * The amount of data being written. |
vcoubard | 1136:22aada733dbd | 162 | * @param[in] value |
vcoubard | 1132:692ddf04fc42 | 163 | * The bytes being written. |
vcoubard | 1132:692ddf04fc42 | 164 | * |
vcoubard | 1132:692ddf04fc42 | 165 | * @note It is important to note that a write will generate |
vcoubard | 1132:692ddf04fc42 | 166 | * an onDataWritten() callback when the peer acknowledges the request. |
vcoubard | 1132:692ddf04fc42 | 167 | * |
vcoubard | 1132:692ddf04fc42 | 168 | * @retval BLE_ERROR_NONE Successfully started the Write procedure, or |
vcoubard | 1132:692ddf04fc42 | 169 | * BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or |
vcoubard | 1132:692ddf04fc42 | 170 | * BLE_STACK_BUSY if some client procedure is already in progress, or |
vcoubard | 1132:692ddf04fc42 | 171 | * BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or |
vcoubard | 1132:692ddf04fc42 | 172 | * BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties. |
vcoubard | 1132:692ddf04fc42 | 173 | */ |
vcoubard | 1132:692ddf04fc42 | 174 | ble_error_t write(uint16_t length, const uint8_t *value) const; |
vcoubard | 1132:692ddf04fc42 | 175 | |
vcoubard | 1135:d540a48f650d | 176 | /** |
vcoubard | 1156:e28c7aac64ab | 177 | * Same as #write(uint16_t, const uint8_t *) const but register a callback |
vcoubard | 1136:22aada733dbd | 178 | * which will be called once the data has been written. |
vcoubard | 1136:22aada733dbd | 179 | * |
vcoubard | 1156:e28c7aac64ab | 180 | * @param[in] length The amount of bytes to write. |
vcoubard | 1156:e28c7aac64ab | 181 | * @param[in] value The bytes to write. |
vcoubard | 1156:e28c7aac64ab | 182 | * @param[in] onRead Continuation callback for the write operation |
vcoubard | 1132:692ddf04fc42 | 183 | */ |
vcoubard | 1136:22aada733dbd | 184 | ble_error_t write(uint16_t length, const uint8_t *value, const GattClient::WriteCallback_t& onWrite) const; |
vcoubard | 1132:692ddf04fc42 | 185 | |
vcoubard | 1135:d540a48f650d | 186 | void setupLongUUID(UUID::LongUUIDBytes_t longUUID, UUID::ByteOrder_t order = UUID::MSB) { |
vcoubard | 1135:d540a48f650d | 187 | uuid.setupLong(longUUID, order); |
vcoubard | 1132:692ddf04fc42 | 188 | } |
vcoubard | 1132:692ddf04fc42 | 189 | |
vcoubard | 1132:692ddf04fc42 | 190 | public: |
vcoubard | 1136:22aada733dbd | 191 | /** |
vcoubard | 1136:22aada733dbd | 192 | * @brief Get the UUID of the discovered characteristic |
vcoubard | 1136:22aada733dbd | 193 | * @return the UUID of this characteristic |
vcoubard | 1136:22aada733dbd | 194 | */ |
vcoubard | 1132:692ddf04fc42 | 195 | const UUID& getUUID(void) const { |
vcoubard | 1132:692ddf04fc42 | 196 | return uuid; |
vcoubard | 1132:692ddf04fc42 | 197 | } |
vcoubard | 1132:692ddf04fc42 | 198 | |
vcoubard | 1136:22aada733dbd | 199 | /** |
vcoubard | 1136:22aada733dbd | 200 | * @brief Get the properties of this characteristic |
vcoubard | 1136:22aada733dbd | 201 | * @return the set of properties of this characteristic |
vcoubard | 1136:22aada733dbd | 202 | */ |
vcoubard | 1132:692ddf04fc42 | 203 | const Properties_t& getProperties(void) const { |
vcoubard | 1132:692ddf04fc42 | 204 | return props; |
vcoubard | 1132:692ddf04fc42 | 205 | } |
vcoubard | 1132:692ddf04fc42 | 206 | |
vcoubard | 1136:22aada733dbd | 207 | /** |
vcoubard | 1136:22aada733dbd | 208 | * @brief Get the declaration handle of this characteristic. |
vcoubard | 1156:e28c7aac64ab | 209 | * @detail The declaration handle is the first handle of a characteristic |
vcoubard | 1136:22aada733dbd | 210 | * definition. The value accessible at this handle contains the following |
vcoubard | 1136:22aada733dbd | 211 | * informations: |
vcoubard | 1136:22aada733dbd | 212 | * - The characteristics properties (see Properties_t). This value can |
vcoubard | 1136:22aada733dbd | 213 | * be accessed by using #getProperties . |
vcoubard | 1136:22aada733dbd | 214 | * - The characteristic value attribute handle. This field can be accessed |
vcoubard | 1136:22aada733dbd | 215 | * by using #getValueHandle . |
vcoubard | 1136:22aada733dbd | 216 | * - The characteristic UUID, this value can be accessed by using the |
vcoubard | 1136:22aada733dbd | 217 | * function #getUUID . |
vcoubard | 1136:22aada733dbd | 218 | * @return the declaration handle of this characteristic. |
vcoubard | 1136:22aada733dbd | 219 | */ |
vcoubard | 1136:22aada733dbd | 220 | GattAttribute::Handle_t getDeclHandle(void) const { |
vcoubard | 1132:692ddf04fc42 | 221 | return declHandle; |
vcoubard | 1132:692ddf04fc42 | 222 | } |
vcoubard | 1136:22aada733dbd | 223 | |
vcoubard | 1136:22aada733dbd | 224 | /** |
vcoubard | 1136:22aada733dbd | 225 | * @brief Return the handle used to access the value of this characteristic. |
vcoubard | 1136:22aada733dbd | 226 | * @details This handle is the one provided in the characteristic declaration |
vcoubard | 1136:22aada733dbd | 227 | * value. Usually, it is equal to #getDeclHandle() + 1. But it is not always |
vcoubard | 1136:22aada733dbd | 228 | * the case. Anyway, users are allowed to use #getDeclHandle() + 1 to access |
vcoubard | 1136:22aada733dbd | 229 | * the value of a characteristic. |
vcoubard | 1136:22aada733dbd | 230 | * @return The handle to access the value of this characteristic. |
vcoubard | 1136:22aada733dbd | 231 | */ |
vcoubard | 1136:22aada733dbd | 232 | GattAttribute::Handle_t getValueHandle(void) const { |
vcoubard | 1132:692ddf04fc42 | 233 | return valueHandle; |
vcoubard | 1132:692ddf04fc42 | 234 | } |
vcoubard | 1132:692ddf04fc42 | 235 | |
vcoubard | 1136:22aada733dbd | 236 | /** |
vcoubard | 1136:22aada733dbd | 237 | * @brief Return the last handle of the characteristic definition. |
vcoubard | 1136:22aada733dbd | 238 | * @details A Characteristic definition can contain a lot of handles: |
vcoubard | 1136:22aada733dbd | 239 | * - one for the declaration (see #getDeclHandle) |
vcoubard | 1136:22aada733dbd | 240 | * - one for the value (see #getValueHandle) |
vcoubard | 1136:22aada733dbd | 241 | * - zero of more for the characteristic descriptors. |
vcoubard | 1136:22aada733dbd | 242 | * This handle is the last handle of the characteristic definition. |
vcoubard | 1136:22aada733dbd | 243 | * @return The last handle of this characteristic definition. |
vcoubard | 1136:22aada733dbd | 244 | */ |
vcoubard | 1136:22aada733dbd | 245 | GattAttribute::Handle_t getLastHandle(void) const { |
vcoubard | 1136:22aada733dbd | 246 | return lastHandle; |
vcoubard | 1136:22aada733dbd | 247 | } |
vcoubard | 1136:22aada733dbd | 248 | |
vcoubard | 1136:22aada733dbd | 249 | /** |
vcoubard | 1136:22aada733dbd | 250 | * @brief Return the GattClient which can operate on this characteristic. |
vcoubard | 1136:22aada733dbd | 251 | * @return The GattClient which can operate on this characteristic. |
vcoubard | 1136:22aada733dbd | 252 | */ |
vcoubard | 1136:22aada733dbd | 253 | GattClient* getGattClient() { |
vcoubard | 1136:22aada733dbd | 254 | return gattc; |
vcoubard | 1136:22aada733dbd | 255 | } |
vcoubard | 1136:22aada733dbd | 256 | |
vcoubard | 1136:22aada733dbd | 257 | /** |
vcoubard | 1136:22aada733dbd | 258 | * @brief Return the GattClient which can operate on this characteristic. |
vcoubard | 1136:22aada733dbd | 259 | * @return The GattClient which can operate on this characteristic. |
vcoubard | 1136:22aada733dbd | 260 | */ |
vcoubard | 1136:22aada733dbd | 261 | const GattClient* getGattClient() const { |
vcoubard | 1136:22aada733dbd | 262 | return gattc; |
vcoubard | 1136:22aada733dbd | 263 | } |
vcoubard | 1136:22aada733dbd | 264 | |
vcoubard | 1136:22aada733dbd | 265 | /** |
vcoubard | 1136:22aada733dbd | 266 | * @brief Return the connection handle to the GattServer which contain |
vcoubard | 1136:22aada733dbd | 267 | * this characteristic. |
vcoubard | 1136:22aada733dbd | 268 | * @return the connection handle to the GattServer which contain |
vcoubard | 1136:22aada733dbd | 269 | * this characteristic. |
vcoubard | 1136:22aada733dbd | 270 | */ |
vcoubard | 1136:22aada733dbd | 271 | Gap::Handle_t getConnectionHandle() const { |
vcoubard | 1136:22aada733dbd | 272 | return connHandle; |
vcoubard | 1136:22aada733dbd | 273 | } |
vcoubard | 1136:22aada733dbd | 274 | |
vcoubard | 1136:22aada733dbd | 275 | /** |
vcoubard | 1136:22aada733dbd | 276 | * @brief "Equal to" operator for DiscoveredCharacteristic |
vcoubard | 1136:22aada733dbd | 277 | * |
vcoubard | 1156:e28c7aac64ab | 278 | * @param lhs[in] The left hand side of the equality expression |
vcoubard | 1156:e28c7aac64ab | 279 | * @param rhs[in] The right hand side of the equality expression |
vcoubard | 1136:22aada733dbd | 280 | * |
vcoubard | 1136:22aada733dbd | 281 | * @return true if operands are equals, false otherwise. |
vcoubard | 1136:22aada733dbd | 282 | */ |
vcoubard | 1136:22aada733dbd | 283 | friend bool operator==(const DiscoveredCharacteristic& lhs, const DiscoveredCharacteristic& rhs) { |
vcoubard | 1136:22aada733dbd | 284 | return lhs.gattc == rhs.gattc && |
vcoubard | 1136:22aada733dbd | 285 | lhs.uuid == rhs.uuid && |
vcoubard | 1136:22aada733dbd | 286 | lhs.props == rhs.props && |
vcoubard | 1136:22aada733dbd | 287 | lhs.declHandle == rhs.declHandle && |
vcoubard | 1136:22aada733dbd | 288 | lhs.valueHandle == rhs.valueHandle && |
vcoubard | 1136:22aada733dbd | 289 | lhs.lastHandle == rhs.lastHandle && |
vcoubard | 1136:22aada733dbd | 290 | lhs.connHandle == rhs.connHandle; |
vcoubard | 1136:22aada733dbd | 291 | } |
vcoubard | 1136:22aada733dbd | 292 | |
vcoubard | 1136:22aada733dbd | 293 | /** |
vcoubard | 1136:22aada733dbd | 294 | * @brief "Not equal to" operator for DiscoveredCharacteristic |
vcoubard | 1136:22aada733dbd | 295 | * |
vcoubard | 1156:e28c7aac64ab | 296 | * @param lhs[in] The right hand side of the expression |
vcoubard | 1156:e28c7aac64ab | 297 | * @param rhs[in] The left hand side of the expression |
vcoubard | 1136:22aada733dbd | 298 | * |
vcoubard | 1156:e28c7aac64ab | 299 | * @return true if operands are not equals, false otherwise. |
vcoubard | 1136:22aada733dbd | 300 | */ |
vcoubard | 1136:22aada733dbd | 301 | friend bool operator !=(const DiscoveredCharacteristic& lhs, const DiscoveredCharacteristic& rhs) { |
vcoubard | 1136:22aada733dbd | 302 | return !(lhs == rhs); |
vcoubard | 1136:22aada733dbd | 303 | } |
vcoubard | 1136:22aada733dbd | 304 | |
vcoubard | 1132:692ddf04fc42 | 305 | public: |
vcoubard | 1132:692ddf04fc42 | 306 | DiscoveredCharacteristic() : gattc(NULL), |
vcoubard | 1132:692ddf04fc42 | 307 | uuid(UUID::ShortUUIDBytes_t(0)), |
vcoubard | 1132:692ddf04fc42 | 308 | props(), |
vcoubard | 1132:692ddf04fc42 | 309 | declHandle(GattAttribute::INVALID_HANDLE), |
vcoubard | 1136:22aada733dbd | 310 | valueHandle(GattAttribute::INVALID_HANDLE), |
vcoubard | 1136:22aada733dbd | 311 | lastHandle(GattAttribute::INVALID_HANDLE), |
vcoubard | 1136:22aada733dbd | 312 | connHandle() { |
vcoubard | 1132:692ddf04fc42 | 313 | /* empty */ |
vcoubard | 1132:692ddf04fc42 | 314 | } |
vcoubard | 1132:692ddf04fc42 | 315 | |
vcoubard | 1132:692ddf04fc42 | 316 | protected: |
vcoubard | 1132:692ddf04fc42 | 317 | GattClient *gattc; |
vcoubard | 1132:692ddf04fc42 | 318 | |
vcoubard | 1132:692ddf04fc42 | 319 | protected: |
vcoubard | 1132:692ddf04fc42 | 320 | UUID uuid; |
vcoubard | 1132:692ddf04fc42 | 321 | Properties_t props; |
vcoubard | 1132:692ddf04fc42 | 322 | GattAttribute::Handle_t declHandle; |
vcoubard | 1132:692ddf04fc42 | 323 | GattAttribute::Handle_t valueHandle; |
vcoubard | 1136:22aada733dbd | 324 | GattAttribute::Handle_t lastHandle; |
vcoubard | 1132:692ddf04fc42 | 325 | |
vcoubard | 1132:692ddf04fc42 | 326 | Gap::Handle_t connHandle; |
vcoubard | 1132:692ddf04fc42 | 327 | }; |
vcoubard | 1132:692ddf04fc42 | 328 | |
rgrover1 | 716:11b41f651697 | 329 | #endif /*__DISCOVERED_CHARACTERISTIC_H__*/ |