fka mod
Fork of BLE_API by
ble/GattClient.h@1164:7e84487d45fc, 2016-04-06 (annotated)
- Committer:
- vcoubard
- Date:
- Wed Apr 06 19:14:53 2016 +0100
- Revision:
- 1164:7e84487d45fc
- Parent:
- 1156:e1ea38b576c6
- Child:
- 1179:4ab722f8dca0
Synchronized with git rev b6607902
Author: Andres Amaya Garcia
Add missing docs and fix doxy warnings in GattClient.h
Who changed what in which revision?
User | Revision | Line number | New 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 __GATT_CLIENT_H__ |
vcoubard | 1131:692ddf04fc42 | 18 | #define __GATT_CLIENT_H__ |
vcoubard | 1131:692ddf04fc42 | 19 | |
vcoubard | 1131:692ddf04fc42 | 20 | #include "Gap.h" |
vcoubard | 1131:692ddf04fc42 | 21 | #include "GattAttribute.h" |
vcoubard | 1131:692ddf04fc42 | 22 | #include "ServiceDiscovery.h" |
vcoubard | 1135:22aada733dbd | 23 | #include "CharacteristicDescriptorDiscovery.h" |
vcoubard | 1131:692ddf04fc42 | 24 | |
vcoubard | 1131:692ddf04fc42 | 25 | #include "GattCallbackParamTypes.h" |
vcoubard | 1131:692ddf04fc42 | 26 | |
vcoubard | 1131:692ddf04fc42 | 27 | #include "CallChainOfFunctionPointersWithContext.h" |
vcoubard | 1131:692ddf04fc42 | 28 | |
vcoubard | 1131:692ddf04fc42 | 29 | class GattClient { |
vcoubard | 1131:692ddf04fc42 | 30 | public: |
vcoubard | 1164:7e84487d45fc | 31 | /** |
vcoubard | 1164:7e84487d45fc | 32 | * Type for the registered callbacks added to the data read callchain. |
vcoubard | 1164:7e84487d45fc | 33 | * Refer to GattClient::onDataRead(). |
vcoubard | 1164:7e84487d45fc | 34 | */ |
vcoubard | 1131:692ddf04fc42 | 35 | typedef FunctionPointerWithContext<const GattReadCallbackParams*> ReadCallback_t; |
vcoubard | 1164:7e84487d45fc | 36 | /** |
vcoubard | 1164:7e84487d45fc | 37 | * Type for the data read event callchain. Refer to GattClient::onDataRead(). |
vcoubard | 1164:7e84487d45fc | 38 | */ |
vcoubard | 1131:692ddf04fc42 | 39 | typedef CallChainOfFunctionPointersWithContext<const GattReadCallbackParams*> ReadCallbackChain_t; |
vcoubard | 1131:692ddf04fc42 | 40 | |
vcoubard | 1164:7e84487d45fc | 41 | /** |
vcoubard | 1164:7e84487d45fc | 42 | * Enumerator for write operations. |
vcoubard | 1164:7e84487d45fc | 43 | */ |
vcoubard | 1131:692ddf04fc42 | 44 | enum WriteOp_t { |
vcoubard | 1131:692ddf04fc42 | 45 | GATT_OP_WRITE_REQ = 0x01, /**< Write request. */ |
vcoubard | 1131:692ddf04fc42 | 46 | GATT_OP_WRITE_CMD = 0x02, /**< Write command. */ |
vcoubard | 1131:692ddf04fc42 | 47 | }; |
vcoubard | 1131:692ddf04fc42 | 48 | |
vcoubard | 1164:7e84487d45fc | 49 | /** |
vcoubard | 1164:7e84487d45fc | 50 | * Type for the registered callbacks added to the data write callchain. |
vcoubard | 1164:7e84487d45fc | 51 | * Refer to GattClient::onDataWrite(). |
vcoubard | 1164:7e84487d45fc | 52 | */ |
vcoubard | 1131:692ddf04fc42 | 53 | typedef FunctionPointerWithContext<const GattWriteCallbackParams*> WriteCallback_t; |
vcoubard | 1164:7e84487d45fc | 54 | /** |
vcoubard | 1164:7e84487d45fc | 55 | * Type for the data write event callchain. Refer to GattClient::onDataWrite(). |
vcoubard | 1164:7e84487d45fc | 56 | */ |
vcoubard | 1131:692ddf04fc42 | 57 | typedef CallChainOfFunctionPointersWithContext<const GattWriteCallbackParams*> WriteCallbackChain_t; |
vcoubard | 1131:692ddf04fc42 | 58 | |
vcoubard | 1164:7e84487d45fc | 59 | /** |
vcoubard | 1164:7e84487d45fc | 60 | * Type for the registered callbacks added to the update event callchain. |
vcoubard | 1164:7e84487d45fc | 61 | * Refer to GattClient::onHVX(). |
vcoubard | 1164:7e84487d45fc | 62 | */ |
vcoubard | 1131:692ddf04fc42 | 63 | typedef FunctionPointerWithContext<const GattHVXCallbackParams*> HVXCallback_t; |
vcoubard | 1164:7e84487d45fc | 64 | /** |
vcoubard | 1164:7e84487d45fc | 65 | * Type for the update event callchain. Refer to GattClient::onHVX(). |
vcoubard | 1164:7e84487d45fc | 66 | */ |
vcoubard | 1131:692ddf04fc42 | 67 | typedef CallChainOfFunctionPointersWithContext<const GattHVXCallbackParams*> HVXCallbackChain_t; |
vcoubard | 1131:692ddf04fc42 | 68 | |
vcoubard | 1164:7e84487d45fc | 69 | /** |
vcoubard | 1164:7e84487d45fc | 70 | * Type for the registered callbacks added to the shutdown callchain. |
vcoubard | 1164:7e84487d45fc | 71 | * Refer to GattClient::onShutdown(). |
vcoubard | 1164:7e84487d45fc | 72 | */ |
vcoubard | 1135:22aada733dbd | 73 | typedef FunctionPointerWithContext<const GattClient *> GattClientShutdownCallback_t; |
vcoubard | 1164:7e84487d45fc | 74 | /** |
vcoubard | 1164:7e84487d45fc | 75 | * Type for the shutdown event callchain. Refer to GattClient::onShutown(). |
vcoubard | 1164:7e84487d45fc | 76 | */ |
vcoubard | 1135:22aada733dbd | 77 | typedef CallChainOfFunctionPointersWithContext<const GattClient *> GattClientShutdownCallbackChain_t; |
vcoubard | 1135:22aada733dbd | 78 | |
vcoubard | 1131:692ddf04fc42 | 79 | /* |
vcoubard | 1131:692ddf04fc42 | 80 | * The following functions are meant to be overridden in the platform-specific sub-class. |
vcoubard | 1131:692ddf04fc42 | 81 | */ |
vcoubard | 1131:692ddf04fc42 | 82 | public: |
vcoubard | 1131:692ddf04fc42 | 83 | /** |
vcoubard | 1131:692ddf04fc42 | 84 | * Launch service discovery. Once launched, application callbacks will be |
vcoubard | 1131:692ddf04fc42 | 85 | * invoked for matching services or characteristics. isServiceDiscoveryActive() |
vcoubard | 1131:692ddf04fc42 | 86 | * can be used to determine status, and a termination callback (if one was set up) |
vcoubard | 1131:692ddf04fc42 | 87 | * will be invoked at the end. Service discovery can be terminated prematurely, |
vcoubard | 1131:692ddf04fc42 | 88 | * if needed, using terminateServiceDiscovery(). |
vcoubard | 1131:692ddf04fc42 | 89 | * |
vcoubard | 1164:7e84487d45fc | 90 | * @param[in] connectionHandle |
vcoubard | 1164:7e84487d45fc | 91 | * Handle for the connection with the peer. |
vcoubard | 1164:7e84487d45fc | 92 | * @param[in] sc |
vcoubard | 1164:7e84487d45fc | 93 | * This is the application callback for a matching service. Taken as |
vcoubard | 1164:7e84487d45fc | 94 | * NULL by default. Note: service discovery may still be active |
vcoubard | 1164:7e84487d45fc | 95 | * when this callback is issued; calling asynchronous BLE-stack |
vcoubard | 1164:7e84487d45fc | 96 | * APIs from within this application callback might cause the |
vcoubard | 1164:7e84487d45fc | 97 | * stack to abort service discovery. If this becomes an issue, it |
vcoubard | 1164:7e84487d45fc | 98 | * may be better to make a local copy of the discoveredService and |
vcoubard | 1164:7e84487d45fc | 99 | * wait for service discovery to terminate before operating on the |
vcoubard | 1164:7e84487d45fc | 100 | * service. |
vcoubard | 1164:7e84487d45fc | 101 | * @param[in] cc |
vcoubard | 1164:7e84487d45fc | 102 | * This is the application callback for a matching characteristic. |
vcoubard | 1164:7e84487d45fc | 103 | * Taken as NULL by default. Note: service discovery may still be |
vcoubard | 1164:7e84487d45fc | 104 | * active when this callback is issued; calling asynchronous |
vcoubard | 1164:7e84487d45fc | 105 | * BLE-stack APIs from within this application callback might cause |
vcoubard | 1164:7e84487d45fc | 106 | * the stack to abort service discovery. If this becomes an issue, |
vcoubard | 1164:7e84487d45fc | 107 | * it may be better to make a local copy of the discoveredCharacteristic |
vcoubard | 1164:7e84487d45fc | 108 | * and wait for service discovery to terminate before operating on the |
vcoubard | 1164:7e84487d45fc | 109 | * characteristic. |
vcoubard | 1164:7e84487d45fc | 110 | * @param[in] matchingServiceUUID |
vcoubard | 1164:7e84487d45fc | 111 | * UUID-based filter for specifying a service in which the application is |
vcoubard | 1164:7e84487d45fc | 112 | * interested. By default it is set as the wildcard UUID_UNKNOWN, |
vcoubard | 1164:7e84487d45fc | 113 | * in which case it matches all services. If characteristic-UUID |
vcoubard | 1164:7e84487d45fc | 114 | * filter (below) is set to the wildcard value, then a service |
vcoubard | 1164:7e84487d45fc | 115 | * callback will be invoked for the matching service (or for every |
vcoubard | 1164:7e84487d45fc | 116 | * service if the service filter is a wildcard). |
vcoubard | 1164:7e84487d45fc | 117 | * @param[in] matchingCharacteristicUUIDIn |
vcoubard | 1164:7e84487d45fc | 118 | * UUID-based filter for specifying characteristic in which the application |
vcoubard | 1164:7e84487d45fc | 119 | * is interested. By default it is set as the wildcard UUID_UKNOWN |
vcoubard | 1164:7e84487d45fc | 120 | * to match against any characteristic. If both service-UUID |
vcoubard | 1164:7e84487d45fc | 121 | * filter and characteristic-UUID filter are used with non-wildcard |
vcoubard | 1164:7e84487d45fc | 122 | * values, then only a single characteristic callback is |
vcoubard | 1164:7e84487d45fc | 123 | * invoked for the matching characteristic. |
vcoubard | 1131:692ddf04fc42 | 124 | * |
vcoubard | 1131:692ddf04fc42 | 125 | * @note Using wildcard values for both service-UUID and characteristic- |
vcoubard | 1131:692ddf04fc42 | 126 | * UUID will result in complete service discovery: callbacks being |
vcoubard | 1131:692ddf04fc42 | 127 | * called for every service and characteristic. |
vcoubard | 1131:692ddf04fc42 | 128 | * |
vcoubard | 1131:692ddf04fc42 | 129 | * @note Providing NULL for the characteristic callback will result in |
vcoubard | 1131:692ddf04fc42 | 130 | * characteristic discovery being skipped for each matching |
vcoubard | 1131:692ddf04fc42 | 131 | * service. This allows for an inexpensive method to discover only |
vcoubard | 1131:692ddf04fc42 | 132 | * services. |
vcoubard | 1131:692ddf04fc42 | 133 | * |
vcoubard | 1131:692ddf04fc42 | 134 | * @return |
vcoubard | 1131:692ddf04fc42 | 135 | * BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error. |
vcoubard | 1131:692ddf04fc42 | 136 | */ |
vcoubard | 1131:692ddf04fc42 | 137 | virtual ble_error_t launchServiceDiscovery(Gap::Handle_t connectionHandle, |
vcoubard | 1131:692ddf04fc42 | 138 | ServiceDiscovery::ServiceCallback_t sc = NULL, |
vcoubard | 1131:692ddf04fc42 | 139 | ServiceDiscovery::CharacteristicCallback_t cc = NULL, |
vcoubard | 1131:692ddf04fc42 | 140 | const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN), |
vcoubard | 1131:692ddf04fc42 | 141 | const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) { |
vcoubard | 1131:692ddf04fc42 | 142 | /* Avoid compiler warnings about unused variables. */ |
vcoubard | 1131:692ddf04fc42 | 143 | (void)connectionHandle; |
vcoubard | 1131:692ddf04fc42 | 144 | (void)sc; |
vcoubard | 1131:692ddf04fc42 | 145 | (void)cc; |
vcoubard | 1131:692ddf04fc42 | 146 | (void)matchingServiceUUID; |
vcoubard | 1131:692ddf04fc42 | 147 | (void)matchingCharacteristicUUIDIn; |
vcoubard | 1131:692ddf04fc42 | 148 | |
vcoubard | 1131:692ddf04fc42 | 149 | return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if this capability is supported. */ |
vcoubard | 1131:692ddf04fc42 | 150 | } |
vcoubard | 1131:692ddf04fc42 | 151 | |
vcoubard | 1131:692ddf04fc42 | 152 | /** |
vcoubard | 1131:692ddf04fc42 | 153 | * Launch service discovery for services. Once launched, service discovery will remain |
vcoubard | 1131:692ddf04fc42 | 154 | * active with service-callbacks being issued back into the application for matching |
vcoubard | 1131:692ddf04fc42 | 155 | * services. isServiceDiscoveryActive() can be used to |
vcoubard | 1131:692ddf04fc42 | 156 | * determine status, and a termination callback (if set up) will be invoked |
vcoubard | 1131:692ddf04fc42 | 157 | * at the end. Service discovery can be terminated prematurely, if needed, |
vcoubard | 1131:692ddf04fc42 | 158 | * using terminateServiceDiscovery(). |
vcoubard | 1131:692ddf04fc42 | 159 | * |
vcoubard | 1164:7e84487d45fc | 160 | * @param[in] connectionHandle |
vcoubard | 1164:7e84487d45fc | 161 | * Handle for the connection with the peer. |
vcoubard | 1164:7e84487d45fc | 162 | * @param[in] callback |
vcoubard | 1164:7e84487d45fc | 163 | * This is the application callback for a matching service. |
vcoubard | 1164:7e84487d45fc | 164 | * Note: service discovery may still be active |
vcoubard | 1164:7e84487d45fc | 165 | * when this callback is issued; calling asynchronous BLE-stack |
vcoubard | 1164:7e84487d45fc | 166 | * APIs from within this application callback might cause the |
vcoubard | 1164:7e84487d45fc | 167 | * stack to abort service discovery. If this becomes an issue, it |
vcoubard | 1164:7e84487d45fc | 168 | * may be better to make a local copy of the discoveredService and |
vcoubard | 1164:7e84487d45fc | 169 | * wait for service discovery to terminate before operating on the |
vcoubard | 1164:7e84487d45fc | 170 | * service. |
vcoubard | 1164:7e84487d45fc | 171 | * @param[in] matchingServiceUUID |
vcoubard | 1164:7e84487d45fc | 172 | * UUID-based filter for specifying a service in which the application is |
vcoubard | 1164:7e84487d45fc | 173 | * interested. By default it is set as the wildcard UUID_UNKNOWN, |
vcoubard | 1164:7e84487d45fc | 174 | * in which case it matches all services. |
vcoubard | 1131:692ddf04fc42 | 175 | * |
vcoubard | 1131:692ddf04fc42 | 176 | * @return |
vcoubard | 1131:692ddf04fc42 | 177 | * BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error. |
vcoubard | 1131:692ddf04fc42 | 178 | */ |
vcoubard | 1131:692ddf04fc42 | 179 | virtual ble_error_t discoverServices(Gap::Handle_t connectionHandle, |
vcoubard | 1131:692ddf04fc42 | 180 | ServiceDiscovery::ServiceCallback_t callback, |
vcoubard | 1131:692ddf04fc42 | 181 | const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) { |
vcoubard | 1131:692ddf04fc42 | 182 | return launchServiceDiscovery(connectionHandle, callback, NULL, matchingServiceUUID); /* We take advantage of the property |
vcoubard | 1131:692ddf04fc42 | 183 | * that providing NULL for the characteristic callback will result in |
vcoubard | 1131:692ddf04fc42 | 184 | * characteristic discovery being skipped for each matching |
vcoubard | 1131:692ddf04fc42 | 185 | * service. This allows for an inexpensive method to discover only |
vcoubard | 1131:692ddf04fc42 | 186 | * services. Porters are free to override this. */ |
vcoubard | 1131:692ddf04fc42 | 187 | } |
vcoubard | 1131:692ddf04fc42 | 188 | |
vcoubard | 1131:692ddf04fc42 | 189 | /** |
vcoubard | 1131:692ddf04fc42 | 190 | * Launch service discovery for services. Once launched, service discovery will remain |
vcoubard | 1131:692ddf04fc42 | 191 | * active with service-callbacks being issued back into the application for matching |
vcoubard | 1131:692ddf04fc42 | 192 | * services. isServiceDiscoveryActive() can be used to |
vcoubard | 1131:692ddf04fc42 | 193 | * determine status, and a termination callback (if set up) will be invoked |
vcoubard | 1131:692ddf04fc42 | 194 | * at the end. Service discovery can be terminated prematurely, if needed, |
vcoubard | 1131:692ddf04fc42 | 195 | * using terminateServiceDiscovery(). |
vcoubard | 1131:692ddf04fc42 | 196 | * |
vcoubard | 1164:7e84487d45fc | 197 | * @param[in] connectionHandle |
vcoubard | 1164:7e84487d45fc | 198 | * Handle for the connection with the peer. |
vcoubard | 1164:7e84487d45fc | 199 | * @param[in] callback |
vcoubard | 1164:7e84487d45fc | 200 | * This is the application callback for a matching service. |
vcoubard | 1164:7e84487d45fc | 201 | * Note: service discovery may still be active |
vcoubard | 1164:7e84487d45fc | 202 | * when this callback is issued; calling asynchronous BLE-stack |
vcoubard | 1164:7e84487d45fc | 203 | * APIs from within this application callback might cause the |
vcoubard | 1164:7e84487d45fc | 204 | * stack to abort service discovery. If this becomes an issue, it |
vcoubard | 1164:7e84487d45fc | 205 | * may be better to make a local copy of the discoveredService and |
vcoubard | 1164:7e84487d45fc | 206 | * wait for service discovery to terminate before operating on the |
vcoubard | 1164:7e84487d45fc | 207 | * service. |
vcoubard | 1164:7e84487d45fc | 208 | * @param[in] startHandle, endHandle |
vcoubard | 1164:7e84487d45fc | 209 | * Handle range within which to limit the search. |
vcoubard | 1131:692ddf04fc42 | 210 | * |
vcoubard | 1131:692ddf04fc42 | 211 | * @return |
vcoubard | 1131:692ddf04fc42 | 212 | * BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error. |
vcoubard | 1131:692ddf04fc42 | 213 | */ |
vcoubard | 1131:692ddf04fc42 | 214 | virtual ble_error_t discoverServices(Gap::Handle_t connectionHandle, |
vcoubard | 1131:692ddf04fc42 | 215 | ServiceDiscovery::ServiceCallback_t callback, |
vcoubard | 1131:692ddf04fc42 | 216 | GattAttribute::Handle_t startHandle, |
vcoubard | 1131:692ddf04fc42 | 217 | GattAttribute::Handle_t endHandle) { |
vcoubard | 1131:692ddf04fc42 | 218 | /* Avoid compiler warnings about unused variables. */ |
vcoubard | 1131:692ddf04fc42 | 219 | (void)connectionHandle; |
vcoubard | 1131:692ddf04fc42 | 220 | (void)callback; |
vcoubard | 1131:692ddf04fc42 | 221 | (void)startHandle; |
vcoubard | 1131:692ddf04fc42 | 222 | (void)endHandle; |
vcoubard | 1131:692ddf04fc42 | 223 | |
vcoubard | 1131:692ddf04fc42 | 224 | return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if this capability is supported. */ |
vcoubard | 1131:692ddf04fc42 | 225 | } |
vcoubard | 1131:692ddf04fc42 | 226 | |
vcoubard | 1131:692ddf04fc42 | 227 | /** |
vcoubard | 1164:7e84487d45fc | 228 | * Check if service-discovery is currently active. |
vcoubard | 1164:7e84487d45fc | 229 | * |
vcoubard | 1164:7e84487d45fc | 230 | * @return true if service-discovery is active, false otherwise. |
vcoubard | 1131:692ddf04fc42 | 231 | */ |
vcoubard | 1131:692ddf04fc42 | 232 | virtual bool isServiceDiscoveryActive(void) const { |
vcoubard | 1131:692ddf04fc42 | 233 | return false; /* Requesting action from porters: override this API if this capability is supported. */ |
vcoubard | 1131:692ddf04fc42 | 234 | } |
vcoubard | 1131:692ddf04fc42 | 235 | |
vcoubard | 1131:692ddf04fc42 | 236 | /** |
vcoubard | 1131:692ddf04fc42 | 237 | * Terminate an ongoing service discovery. This should result in an |
vcoubard | 1131:692ddf04fc42 | 238 | * invocation of TerminationCallback if service-discovery is active. |
vcoubard | 1131:692ddf04fc42 | 239 | */ |
vcoubard | 1131:692ddf04fc42 | 240 | virtual void terminateServiceDiscovery(void) { |
vcoubard | 1131:692ddf04fc42 | 241 | /* Requesting action from porters: override this API if this capability is supported. */ |
vcoubard | 1131:692ddf04fc42 | 242 | } |
vcoubard | 1131:692ddf04fc42 | 243 | |
vcoubard | 1164:7e84487d45fc | 244 | /** |
vcoubard | 1164:7e84487d45fc | 245 | * Initiate a GATT Client read procedure by attribute-handle. |
vcoubard | 1164:7e84487d45fc | 246 | * |
vcoubard | 1164:7e84487d45fc | 247 | * @param[in] connHandle |
vcoubard | 1164:7e84487d45fc | 248 | * Handle for the connection with the peer. |
vcoubard | 1164:7e84487d45fc | 249 | * @param[in] attributeHandle |
vcoubard | 1164:7e84487d45fc | 250 | * Handle of the attribute to read data from. |
vcoubard | 1164:7e84487d45fc | 251 | * @param[in] offset |
vcoubard | 1164:7e84487d45fc | 252 | * The offset from the start of the attribute value to be read. |
vcoubard | 1164:7e84487d45fc | 253 | * |
vcoubard | 1164:7e84487d45fc | 254 | * @return |
vcoubard | 1164:7e84487d45fc | 255 | * BLE_ERROR_NONE if read procedure was successfully started. |
vcoubard | 1164:7e84487d45fc | 256 | */ |
vcoubard | 1131:692ddf04fc42 | 257 | virtual ble_error_t read(Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, uint16_t offset) const { |
vcoubard | 1131:692ddf04fc42 | 258 | /* Avoid compiler warnings about unused variables. */ |
vcoubard | 1131:692ddf04fc42 | 259 | (void)connHandle; |
vcoubard | 1131:692ddf04fc42 | 260 | (void)attributeHandle; |
vcoubard | 1131:692ddf04fc42 | 261 | (void)offset; |
vcoubard | 1131:692ddf04fc42 | 262 | |
vcoubard | 1131:692ddf04fc42 | 263 | return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if this capability is supported. */ |
vcoubard | 1131:692ddf04fc42 | 264 | } |
vcoubard | 1131:692ddf04fc42 | 265 | |
vcoubard | 1131:692ddf04fc42 | 266 | /** |
vcoubard | 1131:692ddf04fc42 | 267 | * Initiate a GATT Client write procedure. |
vcoubard | 1131:692ddf04fc42 | 268 | * |
vcoubard | 1131:692ddf04fc42 | 269 | * @param[in] cmd |
vcoubard | 1135:22aada733dbd | 270 | * Command can be either a write-request (which generates a |
vcoubard | 1135:22aada733dbd | 271 | * matching response from the peripheral), or a write-command |
vcoubard | 1131:692ddf04fc42 | 272 | * (which doesn't require the connected peer to respond). |
vcoubard | 1131:692ddf04fc42 | 273 | * @param[in] connHandle |
vcoubard | 1131:692ddf04fc42 | 274 | * Connection handle. |
vcoubard | 1131:692ddf04fc42 | 275 | * @param[in] attributeHandle |
vcoubard | 1131:692ddf04fc42 | 276 | * Handle for the target attribtue on the remote GATT server. |
vcoubard | 1131:692ddf04fc42 | 277 | * @param[in] length |
vcoubard | 1131:692ddf04fc42 | 278 | * Length of the new value. |
vcoubard | 1131:692ddf04fc42 | 279 | * @param[in] value |
vcoubard | 1131:692ddf04fc42 | 280 | * New value being written. |
vcoubard | 1164:7e84487d45fc | 281 | * |
vcoubard | 1164:7e84487d45fc | 282 | * @return |
vcoubard | 1164:7e84487d45fc | 283 | * BLE_ERROR_NONE if write procedure was successfully started. |
vcoubard | 1131:692ddf04fc42 | 284 | */ |
vcoubard | 1131:692ddf04fc42 | 285 | virtual ble_error_t write(GattClient::WriteOp_t cmd, |
vcoubard | 1131:692ddf04fc42 | 286 | Gap::Handle_t connHandle, |
vcoubard | 1131:692ddf04fc42 | 287 | GattAttribute::Handle_t attributeHandle, |
vcoubard | 1131:692ddf04fc42 | 288 | size_t length, |
vcoubard | 1131:692ddf04fc42 | 289 | const uint8_t *value) const { |
vcoubard | 1131:692ddf04fc42 | 290 | /* Avoid compiler warnings about unused variables. */ |
vcoubard | 1131:692ddf04fc42 | 291 | (void)cmd; |
vcoubard | 1131:692ddf04fc42 | 292 | (void)connHandle; |
vcoubard | 1131:692ddf04fc42 | 293 | (void)attributeHandle; |
vcoubard | 1131:692ddf04fc42 | 294 | (void)length; |
vcoubard | 1131:692ddf04fc42 | 295 | (void)value; |
vcoubard | 1131:692ddf04fc42 | 296 | |
vcoubard | 1131:692ddf04fc42 | 297 | return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if this capability is supported. */ |
vcoubard | 1131:692ddf04fc42 | 298 | } |
vcoubard | 1131:692ddf04fc42 | 299 | |
vcoubard | 1131:692ddf04fc42 | 300 | /* Event callback handlers. */ |
vcoubard | 1131:692ddf04fc42 | 301 | public: |
vcoubard | 1131:692ddf04fc42 | 302 | /** |
vcoubard | 1135:22aada733dbd | 303 | * Set up a callback for read response events. |
vcoubard | 1164:7e84487d45fc | 304 | * |
vcoubard | 1164:7e84487d45fc | 305 | * @param[in] callback |
vcoubard | 1164:7e84487d45fc | 306 | * Event handler being registered. |
vcoubard | 1164:7e84487d45fc | 307 | * |
vcoubard | 1164:7e84487d45fc | 308 | * @note It is possible to chain together multiple onDataRead callbacks |
vcoubard | 1164:7e84487d45fc | 309 | * (potentially from different modules of an application). |
vcoubard | 1164:7e84487d45fc | 310 | * |
vcoubard | 1164:7e84487d45fc | 311 | * @note It is possible to unregister a callback using |
vcoubard | 1164:7e84487d45fc | 312 | * onDataRead().detach(callbackToRemove). |
vcoubard | 1131:692ddf04fc42 | 313 | */ |
vcoubard | 1131:692ddf04fc42 | 314 | void onDataRead(ReadCallback_t callback) { |
vcoubard | 1131:692ddf04fc42 | 315 | onDataReadCallbackChain.add(callback); |
vcoubard | 1131:692ddf04fc42 | 316 | } |
vcoubard | 1131:692ddf04fc42 | 317 | |
vcoubard | 1131:692ddf04fc42 | 318 | /** |
vcoubard | 1164:7e84487d45fc | 319 | * @brief Provide access to the callchain of read event callbacks. |
vcoubard | 1164:7e84487d45fc | 320 | * |
vcoubard | 1164:7e84487d45fc | 321 | * @return A reference to the read event callback chain. |
vcoubard | 1164:7e84487d45fc | 322 | * |
vcoubard | 1164:7e84487d45fc | 323 | * @note It is possible to register callbacks using onDataRead().add(callback). |
vcoubard | 1164:7e84487d45fc | 324 | * |
vcoubard | 1164:7e84487d45fc | 325 | * @note It is possible to unregister callbacks using onDataRead().detach(callback). |
vcoubard | 1131:692ddf04fc42 | 326 | */ |
vcoubard | 1131:692ddf04fc42 | 327 | ReadCallbackChain_t& onDataRead() { |
vcoubard | 1131:692ddf04fc42 | 328 | return onDataReadCallbackChain; |
vcoubard | 1131:692ddf04fc42 | 329 | } |
vcoubard | 1131:692ddf04fc42 | 330 | |
vcoubard | 1131:692ddf04fc42 | 331 | /** |
vcoubard | 1131:692ddf04fc42 | 332 | * Set up a callback for write response events. |
vcoubard | 1164:7e84487d45fc | 333 | * |
vcoubard | 1164:7e84487d45fc | 334 | * @param[in] callback |
vcoubard | 1164:7e84487d45fc | 335 | * Event handler being registered. |
vcoubard | 1164:7e84487d45fc | 336 | * |
vcoubard | 1164:7e84487d45fc | 337 | * @note It is possible to remove registered callbacks using |
vcoubard | 1131:692ddf04fc42 | 338 | * onDataWritten().detach(callbackToRemove). |
vcoubard | 1164:7e84487d45fc | 339 | * |
vcoubard | 1164:7e84487d45fc | 340 | * @note Write commands (issued using writeWoResponse) don't generate a response. |
vcoubard | 1131:692ddf04fc42 | 341 | */ |
vcoubard | 1131:692ddf04fc42 | 342 | void onDataWritten(WriteCallback_t callback) { |
vcoubard | 1131:692ddf04fc42 | 343 | onDataWriteCallbackChain.add(callback); |
vcoubard | 1131:692ddf04fc42 | 344 | } |
vcoubard | 1131:692ddf04fc42 | 345 | |
vcoubard | 1131:692ddf04fc42 | 346 | /** |
vcoubard | 1164:7e84487d45fc | 347 | * @brief Provide access to the callchain of data written callbacks. |
vcoubard | 1164:7e84487d45fc | 348 | * |
vcoubard | 1164:7e84487d45fc | 349 | * @return A reference to the data written callbacks chain. |
vcoubard | 1164:7e84487d45fc | 350 | * |
vcoubard | 1164:7e84487d45fc | 351 | * @note It is possible to register callbacks using onDataWritten().add(callback). |
vcoubard | 1164:7e84487d45fc | 352 | * |
vcoubard | 1164:7e84487d45fc | 353 | * @note It is possible to unregister callbacks using onDataWritten().detach(callback). |
vcoubard | 1131:692ddf04fc42 | 354 | */ |
vcoubard | 1135:22aada733dbd | 355 | WriteCallbackChain_t& onDataWritten() { |
vcoubard | 1131:692ddf04fc42 | 356 | return onDataWriteCallbackChain; |
vcoubard | 1131:692ddf04fc42 | 357 | } |
vcoubard | 1131:692ddf04fc42 | 358 | |
vcoubard | 1131:692ddf04fc42 | 359 | /** |
vcoubard | 1131:692ddf04fc42 | 360 | * Set up a callback for write response events. |
vcoubard | 1164:7e84487d45fc | 361 | * |
vcoubard | 1164:7e84487d45fc | 362 | * @param[in] callback |
vcoubard | 1164:7e84487d45fc | 363 | * Event handler being registered. |
vcoubard | 1131:692ddf04fc42 | 364 | * |
vcoubard | 1164:7e84487d45fc | 365 | * @note Write commands (issued using writeWoResponse) don't generate a response. |
vcoubard | 1164:7e84487d45fc | 366 | * |
vcoubard | 1164:7e84487d45fc | 367 | * @deprecated Please use GattServer::onDataWritten() instead. |
vcoubard | 1131:692ddf04fc42 | 368 | */ |
vcoubard | 1131:692ddf04fc42 | 369 | void onDataWrite(WriteCallback_t callback) { |
vcoubard | 1131:692ddf04fc42 | 370 | onDataWritten(callback); |
vcoubard | 1131:692ddf04fc42 | 371 | } |
vcoubard | 1131:692ddf04fc42 | 372 | |
vcoubard | 1131:692ddf04fc42 | 373 | /** |
vcoubard | 1131:692ddf04fc42 | 374 | * Set up a callback for when serviceDiscovery terminates. |
vcoubard | 1164:7e84487d45fc | 375 | * |
vcoubard | 1164:7e84487d45fc | 376 | * @param[in] callback |
vcoubard | 1164:7e84487d45fc | 377 | * Event handler being registered. |
vcoubard | 1131:692ddf04fc42 | 378 | */ |
vcoubard | 1131:692ddf04fc42 | 379 | virtual void onServiceDiscoveryTermination(ServiceDiscovery::TerminationCallback_t callback) { |
vcoubard | 1131:692ddf04fc42 | 380 | (void)callback; /* Avoid compiler warnings about ununsed variables. */ |
vcoubard | 1131:692ddf04fc42 | 381 | |
vcoubard | 1131:692ddf04fc42 | 382 | /* Requesting action from porters: override this API if this capability is supported. */ |
vcoubard | 1131:692ddf04fc42 | 383 | } |
vcoubard | 1131:692ddf04fc42 | 384 | |
vcoubard | 1131:692ddf04fc42 | 385 | /** |
vcoubard | 1164:7e84487d45fc | 386 | * @brief Launch discovery of descriptors for a given characteristic. |
vcoubard | 1164:7e84487d45fc | 387 | * |
vcoubard | 1135:22aada733dbd | 388 | * @details This function will discover all descriptors available for a |
vcoubard | 1164:7e84487d45fc | 389 | * specific characteristic. |
vcoubard | 1135:22aada733dbd | 390 | * |
vcoubard | 1164:7e84487d45fc | 391 | * @param[in] characteristic |
vcoubard | 1164:7e84487d45fc | 392 | * The characteristic targeted by this discovery procedure. |
vcoubard | 1164:7e84487d45fc | 393 | * @param[in] discoveryCallback |
vcoubard | 1164:7e84487d45fc | 394 | * User function called each time a descriptor is found during |
vcoubard | 1164:7e84487d45fc | 395 | * the procedure. |
vcoubard | 1164:7e84487d45fc | 396 | * @param[in] terminationCallback |
vcoubard | 1164:7e84487d45fc | 397 | * User provided function which will be called once the |
vcoubard | 1164:7e84487d45fc | 398 | * discovery procedure is terminating. This will get called |
vcoubard | 1164:7e84487d45fc | 399 | * when all the descriptors have been discovered or if an |
vcoubard | 1164:7e84487d45fc | 400 | * error occur during the discovery procedure. |
vcoubard | 1135:22aada733dbd | 401 | * |
vcoubard | 1135:22aada733dbd | 402 | * @return |
vcoubard | 1135:22aada733dbd | 403 | * BLE_ERROR_NONE if characteristic descriptor discovery is launched |
vcoubard | 1135:22aada733dbd | 404 | * successfully; else an appropriate error. |
vcoubard | 1135:22aada733dbd | 405 | */ |
vcoubard | 1135:22aada733dbd | 406 | virtual ble_error_t discoverCharacteristicDescriptors( |
vcoubard | 1135:22aada733dbd | 407 | const DiscoveredCharacteristic& characteristic, |
vcoubard | 1135:22aada733dbd | 408 | const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback, |
vcoubard | 1135:22aada733dbd | 409 | const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback) { |
vcoubard | 1135:22aada733dbd | 410 | (void) characteristic; |
vcoubard | 1135:22aada733dbd | 411 | (void) discoveryCallback; |
vcoubard | 1135:22aada733dbd | 412 | (void) terminationCallback; |
vcoubard | 1135:22aada733dbd | 413 | /* Requesting action from porter(s): override this API if this capability is supported. */ |
vcoubard | 1135:22aada733dbd | 414 | return BLE_ERROR_NOT_IMPLEMENTED; |
vcoubard | 1135:22aada733dbd | 415 | } |
vcoubard | 1135:22aada733dbd | 416 | |
vcoubard | 1135:22aada733dbd | 417 | /** |
vcoubard | 1164:7e84487d45fc | 418 | * @brief Indicate if the discovery of characteristic descriptors is active |
vcoubard | 1164:7e84487d45fc | 419 | * for a given characteristic or not. |
vcoubard | 1164:7e84487d45fc | 420 | * |
vcoubard | 1164:7e84487d45fc | 421 | * @param[in] characteristic |
vcoubard | 1164:7e84487d45fc | 422 | * The characteristic concerned by the descriptors discovery. |
vcoubard | 1164:7e84487d45fc | 423 | * |
vcoubard | 1164:7e84487d45fc | 424 | * @return true if a descriptors discovery is active for the characteristic |
vcoubard | 1164:7e84487d45fc | 425 | * in input; otherwise false. |
vcoubard | 1135:22aada733dbd | 426 | */ |
vcoubard | 1135:22aada733dbd | 427 | virtual bool isCharacteristicDescriptorDiscoveryActive(const DiscoveredCharacteristic& characteristic) const |
vcoubard | 1135:22aada733dbd | 428 | { |
vcoubard | 1135:22aada733dbd | 429 | (void) characteristic; |
vcoubard | 1135:22aada733dbd | 430 | return false; /* Requesting action from porter(s): override this API if this capability is supported. */ |
vcoubard | 1135:22aada733dbd | 431 | } |
vcoubard | 1135:22aada733dbd | 432 | |
vcoubard | 1135:22aada733dbd | 433 | /** |
vcoubard | 1135:22aada733dbd | 434 | * @brief Terminate an ongoing characteristic descriptor discovery. |
vcoubard | 1164:7e84487d45fc | 435 | * |
vcoubard | 1156:e1ea38b576c6 | 436 | * @details This should result in an invocation of the TerminationCallback if |
vcoubard | 1164:7e84487d45fc | 437 | * the characteristic descriptor discovery is active. |
vcoubard | 1164:7e84487d45fc | 438 | * |
vcoubard | 1164:7e84487d45fc | 439 | * @param[in] characteristic |
vcoubard | 1164:7e84487d45fc | 440 | * The characteristic on which the running descriptors |
vcoubard | 1164:7e84487d45fc | 441 | * discovery should be stopped. |
vcoubard | 1135:22aada733dbd | 442 | */ |
vcoubard | 1135:22aada733dbd | 443 | virtual void terminateCharacteristicDescriptorDiscovery(const DiscoveredCharacteristic& characteristic) { |
vcoubard | 1135:22aada733dbd | 444 | /* Requesting action from porter(s): override this API if this capability is supported. */ |
vcoubard | 1135:22aada733dbd | 445 | (void) characteristic; |
vcoubard | 1135:22aada733dbd | 446 | } |
vcoubard | 1135:22aada733dbd | 447 | |
vcoubard | 1135:22aada733dbd | 448 | /** |
vcoubard | 1164:7e84487d45fc | 449 | * Set up a callback for when the GATT Client receives an update event |
vcoubard | 1131:692ddf04fc42 | 450 | * corresponding to a change in the value of a characteristic on the remote |
vcoubard | 1164:7e84487d45fc | 451 | * GATT Server. |
vcoubard | 1164:7e84487d45fc | 452 | * |
vcoubard | 1164:7e84487d45fc | 453 | * @note It is possible to unregister callbacks using |
vcoubard | 1164:7e84487d45fc | 454 | * onHVX().detach(callbackToRemove). |
vcoubard | 1131:692ddf04fc42 | 455 | */ |
vcoubard | 1131:692ddf04fc42 | 456 | void onHVX(HVXCallback_t callback) { |
vcoubard | 1131:692ddf04fc42 | 457 | onHVXCallbackChain.add(callback); |
vcoubard | 1131:692ddf04fc42 | 458 | } |
vcoubard | 1131:692ddf04fc42 | 459 | |
vcoubard | 1135:22aada733dbd | 460 | /** |
vcoubard | 1135:22aada733dbd | 461 | * Setup a callback to be invoked to notify the user application that the |
vcoubard | 1135:22aada733dbd | 462 | * GattClient instance is about to shutdown (possibly as a result of a call |
vcoubard | 1135:22aada733dbd | 463 | * to BLE::shutdown()). |
vcoubard | 1135:22aada733dbd | 464 | * |
vcoubard | 1164:7e84487d45fc | 465 | * @param[in] callback |
vcoubard | 1164:7e84487d45fc | 466 | * Event handler being registered. |
vcoubard | 1135:22aada733dbd | 467 | * |
vcoubard | 1164:7e84487d45fc | 468 | * @note It is possible to chain together multiple onShutdown callbacks |
vcoubard | 1164:7e84487d45fc | 469 | * (potentially from different modules of an application) to be notified |
vcoubard | 1164:7e84487d45fc | 470 | * before the GattClient is shutdown. |
vcoubard | 1135:22aada733dbd | 471 | * |
vcoubard | 1164:7e84487d45fc | 472 | * @note It is also possible to set up a callback into a member function of |
vcoubard | 1164:7e84487d45fc | 473 | * some object. |
vcoubard | 1164:7e84487d45fc | 474 | * |
vcoubard | 1164:7e84487d45fc | 475 | * @note It is possible to unregister a callback using onShutdown().detach(callback). |
vcoubard | 1135:22aada733dbd | 476 | */ |
vcoubard | 1135:22aada733dbd | 477 | void onShutdown(const GattClientShutdownCallback_t& callback) { |
vcoubard | 1135:22aada733dbd | 478 | shutdownCallChain.add(callback); |
vcoubard | 1135:22aada733dbd | 479 | } |
vcoubard | 1164:7e84487d45fc | 480 | |
vcoubard | 1164:7e84487d45fc | 481 | /** |
vcoubard | 1164:7e84487d45fc | 482 | * Same as GattClient::onShutdown(), but allows the possibility to add an object |
vcoubard | 1164:7e84487d45fc | 483 | * reference and member function as handler for shutdown event |
vcoubard | 1164:7e84487d45fc | 484 | * callbacks. |
vcoubard | 1164:7e84487d45fc | 485 | * |
vcoubard | 1164:7e84487d45fc | 486 | * @param[in] objPtr |
vcoubard | 1164:7e84487d45fc | 487 | * Pointer to the object of a class defining the member callback |
vcoubard | 1164:7e84487d45fc | 488 | * function (@p memberPtr). |
vcoubard | 1164:7e84487d45fc | 489 | * @param[in] memberPtr |
vcoubard | 1164:7e84487d45fc | 490 | * The member callback (within the context of an object) to be |
vcoubard | 1164:7e84487d45fc | 491 | * invoked. |
vcoubard | 1164:7e84487d45fc | 492 | */ |
vcoubard | 1135:22aada733dbd | 493 | template <typename T> |
vcoubard | 1135:22aada733dbd | 494 | void onShutdown(T *objPtr, void (T::*memberPtr)(void)) { |
vcoubard | 1135:22aada733dbd | 495 | shutdownCallChain.add(objPtr, memberPtr); |
vcoubard | 1135:22aada733dbd | 496 | } |
vcoubard | 1135:22aada733dbd | 497 | |
vcoubard | 1135:22aada733dbd | 498 | /** |
vcoubard | 1164:7e84487d45fc | 499 | * @brief Provide access to the callchain of shutdown event callbacks. |
vcoubard | 1164:7e84487d45fc | 500 | * |
vcoubard | 1164:7e84487d45fc | 501 | * @return A reference to the shutdown event callbacks chain. |
vcoubard | 1164:7e84487d45fc | 502 | * |
vcoubard | 1164:7e84487d45fc | 503 | * @note It is possible to register callbacks using onShutdown().add(callback). |
vcoubard | 1164:7e84487d45fc | 504 | * |
vcoubard | 1164:7e84487d45fc | 505 | * @note It is possible to unregister callbacks using onShutdown().detach(callback). |
vcoubard | 1135:22aada733dbd | 506 | */ |
vcoubard | 1135:22aada733dbd | 507 | GattClientShutdownCallbackChain_t& onShutdown() { |
vcoubard | 1135:22aada733dbd | 508 | return shutdownCallChain; |
vcoubard | 1135:22aada733dbd | 509 | } |
vcoubard | 1131:692ddf04fc42 | 510 | |
vcoubard | 1131:692ddf04fc42 | 511 | /** |
vcoubard | 1164:7e84487d45fc | 512 | * @brief provide access to the callchain of HVX callbacks. |
vcoubard | 1164:7e84487d45fc | 513 | * |
vcoubard | 1164:7e84487d45fc | 514 | * @return A reference to the HVX callbacks chain. |
vcoubard | 1164:7e84487d45fc | 515 | * |
vcoubard | 1164:7e84487d45fc | 516 | * @note It is possible to register callbacks using onHVX().add(callback). |
vcoubard | 1164:7e84487d45fc | 517 | * |
vcoubard | 1164:7e84487d45fc | 518 | * @note It is possible to unregister callbacks using onHVX().detach(callback). |
vcoubard | 1131:692ddf04fc42 | 519 | */ |
vcoubard | 1135:22aada733dbd | 520 | HVXCallbackChain_t& onHVX() { |
vcoubard | 1131:692ddf04fc42 | 521 | return onHVXCallbackChain; |
vcoubard | 1131:692ddf04fc42 | 522 | } |
vcoubard | 1131:692ddf04fc42 | 523 | |
vcoubard | 1135:22aada733dbd | 524 | public: |
vcoubard | 1135:22aada733dbd | 525 | /** |
vcoubard | 1135:22aada733dbd | 526 | * Notify all registered onShutdown callbacks that the GattClient is |
vcoubard | 1135:22aada733dbd | 527 | * about to be shutdown and clear all GattClient state of the |
vcoubard | 1135:22aada733dbd | 528 | * associated object. |
vcoubard | 1135:22aada733dbd | 529 | * |
vcoubard | 1135:22aada733dbd | 530 | * This function is meant to be overridden in the platform-specific |
vcoubard | 1135:22aada733dbd | 531 | * sub-class. Nevertheless, the sub-class is only expected to reset its |
vcoubard | 1135:22aada733dbd | 532 | * state and not the data held in GattClient members. This shall be achieved |
vcoubard | 1135:22aada733dbd | 533 | * by a call to GattClient::reset() from the sub-class' reset() |
vcoubard | 1135:22aada733dbd | 534 | * implementation. |
vcoubard | 1135:22aada733dbd | 535 | * |
vcoubard | 1135:22aada733dbd | 536 | * @return BLE_ERROR_NONE on success. |
vcoubard | 1135:22aada733dbd | 537 | */ |
vcoubard | 1135:22aada733dbd | 538 | virtual ble_error_t reset(void) { |
vcoubard | 1135:22aada733dbd | 539 | /* Notify that the instance is about to shutdown */ |
vcoubard | 1135:22aada733dbd | 540 | shutdownCallChain.call(this); |
vcoubard | 1135:22aada733dbd | 541 | shutdownCallChain.clear(); |
vcoubard | 1135:22aada733dbd | 542 | |
vcoubard | 1135:22aada733dbd | 543 | onDataReadCallbackChain.clear(); |
vcoubard | 1135:22aada733dbd | 544 | onDataWriteCallbackChain.clear(); |
vcoubard | 1135:22aada733dbd | 545 | onHVXCallbackChain.clear(); |
vcoubard | 1135:22aada733dbd | 546 | |
vcoubard | 1135:22aada733dbd | 547 | return BLE_ERROR_NONE; |
vcoubard | 1135:22aada733dbd | 548 | } |
vcoubard | 1135:22aada733dbd | 549 | |
vcoubard | 1131:692ddf04fc42 | 550 | protected: |
vcoubard | 1131:692ddf04fc42 | 551 | GattClient() { |
vcoubard | 1131:692ddf04fc42 | 552 | /* Empty */ |
vcoubard | 1131:692ddf04fc42 | 553 | } |
vcoubard | 1131:692ddf04fc42 | 554 | |
vcoubard | 1131:692ddf04fc42 | 555 | /* Entry points for the underlying stack to report events back to the user. */ |
vcoubard | 1131:692ddf04fc42 | 556 | public: |
vcoubard | 1164:7e84487d45fc | 557 | /** |
vcoubard | 1164:7e84487d45fc | 558 | * Helper function that notifies all registered handlers of an occurrence |
vcoubard | 1164:7e84487d45fc | 559 | * of a data read event. This function is meant to be called from the |
vcoubard | 1164:7e84487d45fc | 560 | * BLE stack specific implementation when a data read event occurs. |
vcoubard | 1164:7e84487d45fc | 561 | * |
vcoubard | 1164:7e84487d45fc | 562 | * @param[in] params |
vcoubard | 1164:7e84487d45fc | 563 | * The data read parameters passed to the registered |
vcoubard | 1164:7e84487d45fc | 564 | * handlers. |
vcoubard | 1164:7e84487d45fc | 565 | */ |
vcoubard | 1131:692ddf04fc42 | 566 | void processReadResponse(const GattReadCallbackParams *params) { |
vcoubard | 1131:692ddf04fc42 | 567 | onDataReadCallbackChain(params); |
vcoubard | 1131:692ddf04fc42 | 568 | } |
vcoubard | 1131:692ddf04fc42 | 569 | |
vcoubard | 1164:7e84487d45fc | 570 | /** |
vcoubard | 1164:7e84487d45fc | 571 | * Helper function that notifies all registered handlers of an occurrence |
vcoubard | 1164:7e84487d45fc | 572 | * of a data written event. This function is meant to be called from the |
vcoubard | 1164:7e84487d45fc | 573 | * BLE stack specific implementation when a data written event occurs. |
vcoubard | 1164:7e84487d45fc | 574 | * |
vcoubard | 1164:7e84487d45fc | 575 | * @param[in] params |
vcoubard | 1164:7e84487d45fc | 576 | * The data written parameters passed to the registered |
vcoubard | 1164:7e84487d45fc | 577 | * handlers. |
vcoubard | 1164:7e84487d45fc | 578 | */ |
vcoubard | 1131:692ddf04fc42 | 579 | void processWriteResponse(const GattWriteCallbackParams *params) { |
vcoubard | 1131:692ddf04fc42 | 580 | onDataWriteCallbackChain(params); |
vcoubard | 1131:692ddf04fc42 | 581 | } |
vcoubard | 1131:692ddf04fc42 | 582 | |
vcoubard | 1164:7e84487d45fc | 583 | /** |
vcoubard | 1164:7e84487d45fc | 584 | * Helper function that notifies all registered handlers of an occurrence |
vcoubard | 1164:7e84487d45fc | 585 | * of an update event. This function is meant to be called from the |
vcoubard | 1164:7e84487d45fc | 586 | * BLE stack specific implementation when an update event occurs. |
vcoubard | 1164:7e84487d45fc | 587 | * |
vcoubard | 1164:7e84487d45fc | 588 | * @param[in] params |
vcoubard | 1164:7e84487d45fc | 589 | * The update event parameters passed to the registered |
vcoubard | 1164:7e84487d45fc | 590 | * handlers. |
vcoubard | 1164:7e84487d45fc | 591 | */ |
vcoubard | 1131:692ddf04fc42 | 592 | void processHVXEvent(const GattHVXCallbackParams *params) { |
vcoubard | 1131:692ddf04fc42 | 593 | if (onHVXCallbackChain) { |
vcoubard | 1131:692ddf04fc42 | 594 | onHVXCallbackChain(params); |
vcoubard | 1131:692ddf04fc42 | 595 | } |
vcoubard | 1131:692ddf04fc42 | 596 | } |
vcoubard | 1131:692ddf04fc42 | 597 | |
vcoubard | 1131:692ddf04fc42 | 598 | protected: |
vcoubard | 1164:7e84487d45fc | 599 | /** |
vcoubard | 1164:7e84487d45fc | 600 | * Callchain containing all registered callback handlers for data read |
vcoubard | 1164:7e84487d45fc | 601 | * events. |
vcoubard | 1164:7e84487d45fc | 602 | */ |
vcoubard | 1135:22aada733dbd | 603 | ReadCallbackChain_t onDataReadCallbackChain; |
vcoubard | 1164:7e84487d45fc | 604 | /** |
vcoubard | 1164:7e84487d45fc | 605 | * Callchain containing all registered callback handlers for data write |
vcoubard | 1164:7e84487d45fc | 606 | * events. |
vcoubard | 1164:7e84487d45fc | 607 | */ |
vcoubard | 1135:22aada733dbd | 608 | WriteCallbackChain_t onDataWriteCallbackChain; |
vcoubard | 1164:7e84487d45fc | 609 | /** |
vcoubard | 1164:7e84487d45fc | 610 | * Callchain containing all registered callback handlers for update |
vcoubard | 1164:7e84487d45fc | 611 | * events. |
vcoubard | 1164:7e84487d45fc | 612 | */ |
vcoubard | 1135:22aada733dbd | 613 | HVXCallbackChain_t onHVXCallbackChain; |
vcoubard | 1164:7e84487d45fc | 614 | /** |
vcoubard | 1164:7e84487d45fc | 615 | * Callchain containing all registered callback handlers for shutdown |
vcoubard | 1164:7e84487d45fc | 616 | * events. |
vcoubard | 1164:7e84487d45fc | 617 | */ |
vcoubard | 1135:22aada733dbd | 618 | GattClientShutdownCallbackChain_t shutdownCallChain; |
vcoubard | 1131:692ddf04fc42 | 619 | |
vcoubard | 1131:692ddf04fc42 | 620 | private: |
vcoubard | 1131:692ddf04fc42 | 621 | /* Disallow copy and assignment. */ |
vcoubard | 1131:692ddf04fc42 | 622 | GattClient(const GattClient &); |
vcoubard | 1131:692ddf04fc42 | 623 | GattClient& operator=(const GattClient &); |
vcoubard | 1131:692ddf04fc42 | 624 | }; |
vcoubard | 1131:692ddf04fc42 | 625 | |
vcoubard | 1164:7e84487d45fc | 626 | #endif /* ifndef __GATT_CLIENT_H__ */ |