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