Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

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