add "LE Device Address" 0x1B to advertising data types

Fork of BLE_API by Bluetooth Low Energy

Committer:
vcoubard
Date:
Mon Jan 11 08:51:56 2016 +0000
Revision:
1104:0244fbb0324e
Parent:
1100:c3d484a482d8
Child:
1107:93b0b9304c53
Synchronized with git rev 02ca65bc
Author: Andres Amaya Garcia
Make update adv payload replace previous data

Accumulate and update advertising payload now differ in their implementations.
Accumulate updates the previous value, if it is UUID then the previously added
values are kept and the new one is simple appended. In contrast, update
replaces the previous value in all cases.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 710:b2e1a2660ec2 1 /* mbed Microcontroller Library
rgrover1 710:b2e1a2660ec2 2 * Copyright (c) 2006-2013 ARM Limited
rgrover1 710:b2e1a2660ec2 3 *
rgrover1 710:b2e1a2660ec2 4 * Licensed under the Apache License, Version 2.0 (the "License");
rgrover1 710:b2e1a2660ec2 5 * you may not use this file except in compliance with the License.
rgrover1 710:b2e1a2660ec2 6 * You may obtain a copy of the License at
rgrover1 710:b2e1a2660ec2 7 *
rgrover1 710:b2e1a2660ec2 8 * http://www.apache.org/licenses/LICENSE-2.0
rgrover1 710:b2e1a2660ec2 9 *
rgrover1 710:b2e1a2660ec2 10 * Unless required by applicable law or agreed to in writing, software
rgrover1 710:b2e1a2660ec2 11 * distributed under the License is distributed on an "AS IS" BASIS,
rgrover1 710:b2e1a2660ec2 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rgrover1 710:b2e1a2660ec2 13 * See the License for the specific language governing permissions and
rgrover1 710:b2e1a2660ec2 14 * limitations under the License.
rgrover1 710:b2e1a2660ec2 15 */
rgrover1 710:b2e1a2660ec2 16
rgrover1 710:b2e1a2660ec2 17 #ifndef __GAP_H__
rgrover1 710:b2e1a2660ec2 18 #define __GAP_H__
rgrover1 710:b2e1a2660ec2 19
vcoubard 1078:79c089630b38 20 #include "ble/BLEProtocol.h"
rgrover1 710:b2e1a2660ec2 21 #include "GapAdvertisingData.h"
rgrover1 710:b2e1a2660ec2 22 #include "GapAdvertisingParams.h"
rgrover1 710:b2e1a2660ec2 23 #include "GapScanningParams.h"
rgrover1 710:b2e1a2660ec2 24 #include "GapEvents.h"
rgrover1 829:9072de50087b 25 #include "CallChainOfFunctionPointersWithContext.h"
rgrover1 710:b2e1a2660ec2 26 #include "FunctionPointerWithContext.h"
rgrover1 710:b2e1a2660ec2 27
vcoubard 1048:efb29faf12fc 28 /* Forward declarations for classes that will only be used for pointers or references in the following. */
rgrover1 710:b2e1a2660ec2 29 class GapAdvertisingParams;
rgrover1 710:b2e1a2660ec2 30 class GapScanningParams;
rgrover1 710:b2e1a2660ec2 31 class GapAdvertisingData;
rgrover1 710:b2e1a2660ec2 32
rgrover1 710:b2e1a2660ec2 33 class Gap {
vcoubard 1078:79c089630b38 34 /*
vcoubard 1078:79c089630b38 35 * DEPRECATION ALERT: all of the APIs in this `public` block are deprecated.
vcoubard 1078:79c089630b38 36 * They have been relocated to the class BLEProtocol.
vcoubard 1078:79c089630b38 37 */
rgrover1 710:b2e1a2660ec2 38 public:
vcoubard 1078:79c089630b38 39 /**
vcoubard 1078:79c089630b38 40 * Address-type for BLEProtocol addresses.
vcoubard 1091:58b2dac13261 41 *
vcoubard 1086:75d4e8ce277d 42 * @note: deprecated. Use BLEProtocol::AddressType_t instead.
vcoubard 1078:79c089630b38 43 */
vcoubard 1086:75d4e8ce277d 44 typedef BLEProtocol::AddressType_t AddressType_t;
vcoubard 1086:75d4e8ce277d 45
vcoubard 1086:75d4e8ce277d 46 /**
vcoubard 1086:75d4e8ce277d 47 * Address-type for BLEProtocol addresses.
vcoubard 1086:75d4e8ce277d 48 * @note: deprecated. Use BLEProtocol::AddressType_t instead.
vcoubard 1087:4c6e11878033 49 */
vcoubard 1087:4c6e11878033 50 typedef BLEProtocol::AddressType_t addr_type_t;
vcoubard 1087:4c6e11878033 51
vcoubard 1091:58b2dac13261 52 /**
vcoubard 1091:58b2dac13261 53 * Address-type for BLEProtocol addresses.
vcoubard 1091:58b2dac13261 54 * @note: deprecated. Use BLEProtocol::AddressType_t instead.
vcoubard 1091:58b2dac13261 55 *
vcoubard 1091:58b2dac13261 56 * DEPRECATION ALERT: The following constants have been left in their
vcoubard 1091:58b2dac13261 57 * deprecated state to transparenly support existing applications which may
vcoubard 1091:58b2dac13261 58 * have used Gap::ADDR_TYPE_*.
vcoubard 1091:58b2dac13261 59 */
vcoubard 1091:58b2dac13261 60 enum {
vcoubard 1091:58b2dac13261 61 ADDR_TYPE_PUBLIC = BLEProtocol::AddressType::PUBLIC,
vcoubard 1091:58b2dac13261 62 ADDR_TYPE_RANDOM_STATIC = BLEProtocol::AddressType::RANDOM_STATIC,
vcoubard 1091:58b2dac13261 63 ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE,
vcoubard 1091:58b2dac13261 64 ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE
vcoubard 1091:58b2dac13261 65 };
vcoubard 1091:58b2dac13261 66
vcoubard 1078:79c089630b38 67 static const unsigned ADDR_LEN = BLEProtocol::ADDR_LEN; /**< Length (in octets) of the BLE MAC address. */
vcoubard 1078:79c089630b38 68 typedef BLEProtocol::Address_t Address_t; /**< 48-bit address, LSB format. @Note: Deprecated. Use BLEProtocol::Address_t instead. */
vcoubard 1078:79c089630b38 69 typedef BLEProtocol::Address_t address_t; /**< 48-bit address, LSB format. @Note: Deprecated. Use BLEProtocol::Address_t instead. */
vcoubard 1078:79c089630b38 70
vcoubard 1078:79c089630b38 71 public:
rgrover1 710:b2e1a2660ec2 72 enum TimeoutSource_t {
rgrover1 710:b2e1a2660ec2 73 TIMEOUT_SRC_ADVERTISING = 0x00, /**< Advertising timeout. */
rgrover1 710:b2e1a2660ec2 74 TIMEOUT_SRC_SECURITY_REQUEST = 0x01, /**< Security request timeout. */
rgrover1 710:b2e1a2660ec2 75 TIMEOUT_SRC_SCAN = 0x02, /**< Scanning timeout. */
rgrover1 710:b2e1a2660ec2 76 TIMEOUT_SRC_CONN = 0x03, /**< Connection timeout. */
rgrover1 710:b2e1a2660ec2 77 };
rgrover1 710:b2e1a2660ec2 78
rgrover1 710:b2e1a2660ec2 79 /**
rgrover1 710:b2e1a2660ec2 80 * Enumeration for disconnection reasons. The values for these reasons are
vcoubard 1048:efb29faf12fc 81 * derived from Nordic's implementation, but the reasons are meant to be
vcoubard 1048:efb29faf12fc 82 * independent of the transport. If you are returned a reason that is not
vcoubard 1048:efb29faf12fc 83 * covered by this enumeration, please refer to the underlying
rgrover1 710:b2e1a2660ec2 84 * transport library.
rgrover1 710:b2e1a2660ec2 85 */
rgrover1 710:b2e1a2660ec2 86 enum DisconnectionReason_t {
rgrover1 710:b2e1a2660ec2 87 CONNECTION_TIMEOUT = 0x08,
rgrover1 710:b2e1a2660ec2 88 REMOTE_USER_TERMINATED_CONNECTION = 0x13,
vcoubard 1048:efb29faf12fc 89 REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14, /**< Remote device terminated connection due to low resources.*/
vcoubard 1048:efb29faf12fc 90 REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15, /**< Remote device terminated connection due to power off. */
rgrover1 710:b2e1a2660ec2 91 LOCAL_HOST_TERMINATED_CONNECTION = 0x16,
rgrover1 710:b2e1a2660ec2 92 CONN_INTERVAL_UNACCEPTABLE = 0x3B,
rgrover1 710:b2e1a2660ec2 93 };
rgrover1 710:b2e1a2660ec2 94
vcoubard 1048:efb29faf12fc 95 /* Describes the current state of the device (more than one bit can be set). */
rgrover1 710:b2e1a2660ec2 96 struct GapState_t {
vcoubard 1048:efb29faf12fc 97 unsigned advertising : 1; /**< Peripheral is currently advertising. */
vcoubard 1048:efb29faf12fc 98 unsigned connected : 1; /**< Peripheral is connected to a central. */
rgrover1 710:b2e1a2660ec2 99 };
rgrover1 710:b2e1a2660ec2 100
rgrover1 710:b2e1a2660ec2 101 typedef uint16_t Handle_t; /* Type for connection handle. */
rgrover1 710:b2e1a2660ec2 102
rgrover1 710:b2e1a2660ec2 103 typedef struct {
rgrover1 710:b2e1a2660ec2 104 uint16_t minConnectionInterval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
rgrover1 710:b2e1a2660ec2 105 uint16_t maxConnectionInterval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
rgrover1 710:b2e1a2660ec2 106 uint16_t slaveLatency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
rgrover1 710:b2e1a2660ec2 107 uint16_t connectionSupervisionTimeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
rgrover1 710:b2e1a2660ec2 108 } ConnectionParams_t;
rgrover1 710:b2e1a2660ec2 109
rgrover1 710:b2e1a2660ec2 110 enum Role_t {
rgrover1 710:b2e1a2660ec2 111 PERIPHERAL = 0x1, /**< Peripheral Role. */
rgrover1 710:b2e1a2660ec2 112 CENTRAL = 0x2, /**< Central Role. */
rgrover1 710:b2e1a2660ec2 113 };
rgrover1 710:b2e1a2660ec2 114
rgrover1 710:b2e1a2660ec2 115 struct AdvertisementCallbackParams_t {
vcoubard 1079:6e2d9514f3df 116 BLEProtocol::Address_t peerAddr;
vcoubard 1079:6e2d9514f3df 117 int8_t rssi;
vcoubard 1079:6e2d9514f3df 118 bool isScanResponse;
vcoubard 1079:6e2d9514f3df 119 GapAdvertisingParams::AdvertisingType_t type;
vcoubard 1079:6e2d9514f3df 120 uint8_t advertisingDataLen;
vcoubard 1079:6e2d9514f3df 121 const uint8_t *advertisingData;
rgrover1 710:b2e1a2660ec2 122 };
rgrover1 710:b2e1a2660ec2 123 typedef FunctionPointerWithContext<const AdvertisementCallbackParams_t *> AdvertisementReportCallback_t;
rgrover1 710:b2e1a2660ec2 124
rgrover1 710:b2e1a2660ec2 125 struct ConnectionCallbackParams_t {
vcoubard 1078:79c089630b38 126 Handle_t handle;
vcoubard 1078:79c089630b38 127 Role_t role;
vcoubard 1078:79c089630b38 128 BLEProtocol::AddressType_t peerAddrType;
vcoubard 1079:6e2d9514f3df 129 BLEProtocol::Address_t peerAddr;
vcoubard 1078:79c089630b38 130 BLEProtocol::AddressType_t ownAddrType;
vcoubard 1079:6e2d9514f3df 131 BLEProtocol::Address_t ownAddr;
vcoubard 1078:79c089630b38 132 const ConnectionParams_t *connectionParams;
rgrover1 710:b2e1a2660ec2 133
vcoubard 1078:79c089630b38 134 ConnectionCallbackParams_t(Handle_t handleIn,
vcoubard 1078:79c089630b38 135 Role_t roleIn,
vcoubard 1078:79c089630b38 136 BLEProtocol::AddressType_t peerAddrTypeIn,
vcoubard 1078:79c089630b38 137 const uint8_t *peerAddrIn,
vcoubard 1078:79c089630b38 138 BLEProtocol::AddressType_t ownAddrTypeIn,
vcoubard 1078:79c089630b38 139 const uint8_t *ownAddrIn,
vcoubard 1078:79c089630b38 140 const ConnectionParams_t *connectionParamsIn) :
rgrover1 710:b2e1a2660ec2 141 handle(handleIn),
rgrover1 710:b2e1a2660ec2 142 role(roleIn),
rgrover1 710:b2e1a2660ec2 143 peerAddrType(peerAddrTypeIn),
rgrover1 710:b2e1a2660ec2 144 peerAddr(),
rgrover1 710:b2e1a2660ec2 145 ownAddrType(ownAddrTypeIn),
rgrover1 710:b2e1a2660ec2 146 ownAddr(),
rgrover1 710:b2e1a2660ec2 147 connectionParams(connectionParamsIn) {
rgrover1 710:b2e1a2660ec2 148 memcpy(peerAddr, peerAddrIn, ADDR_LEN);
rgrover1 710:b2e1a2660ec2 149 memcpy(ownAddr, ownAddrIn, ADDR_LEN);
rgrover1 710:b2e1a2660ec2 150 }
rgrover1 710:b2e1a2660ec2 151 };
rgrover1 710:b2e1a2660ec2 152
rgrover1 829:9072de50087b 153 struct DisconnectionCallbackParams_t {
rgrover1 829:9072de50087b 154 Handle_t handle;
rgrover1 829:9072de50087b 155 DisconnectionReason_t reason;
rgrover1 829:9072de50087b 156
rgrover1 829:9072de50087b 157 DisconnectionCallbackParams_t(Handle_t handleIn,
rgrover1 829:9072de50087b 158 DisconnectionReason_t reasonIn) :
rgrover1 829:9072de50087b 159 handle(handleIn),
rgrover1 829:9072de50087b 160 reason(reasonIn)
rgrover1 829:9072de50087b 161 {}
rgrover1 829:9072de50087b 162 };
rgrover1 829:9072de50087b 163
rgrover1 710:b2e1a2660ec2 164 static const uint16_t UNIT_1_25_MS = 1250; /**< Number of microseconds in 1.25 milliseconds. */
rgrover1 710:b2e1a2660ec2 165 static uint16_t MSEC_TO_GAP_DURATION_UNITS(uint32_t durationInMillis) {
rgrover1 710:b2e1a2660ec2 166 return (durationInMillis * 1000) / UNIT_1_25_MS;
rgrover1 710:b2e1a2660ec2 167 }
rgrover1 766:03f1a26f132f 168
vcoubard 1052:b55e1ad3e1b3 169 typedef FunctionPointerWithContext<TimeoutSource_t> TimeoutEventCallback_t;
vcoubard 1052:b55e1ad3e1b3 170 typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t> TimeoutEventCallbackChain_t;
rgrover1 710:b2e1a2660ec2 171
vcoubard 1052:b55e1ad3e1b3 172 typedef FunctionPointerWithContext<const ConnectionCallbackParams_t *> ConnectionEventCallback_t;
vcoubard 1052:b55e1ad3e1b3 173 typedef CallChainOfFunctionPointersWithContext<const ConnectionCallbackParams_t *> ConnectionEventCallbackChain_t;
vcoubard 1052:b55e1ad3e1b3 174
vcoubard 1052:b55e1ad3e1b3 175 typedef FunctionPointerWithContext<const DisconnectionCallbackParams_t*> DisconnectionEventCallback_t;
vcoubard 1054:f59e5d9a992a 176 typedef CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t*> DisconnectionEventCallbackChain_t;
vcoubard 1052:b55e1ad3e1b3 177
rgrover1 753:0f60274cd3ad 178 typedef FunctionPointerWithContext<bool> RadioNotificationEventCallback_t;
rgrover1 710:b2e1a2660ec2 179
vcoubard 1090:148d8b9b56a5 180 typedef FunctionPointerWithContext<const Gap *> GapShutdownCallback_t;
vcoubard 1090:148d8b9b56a5 181 typedef CallChainOfFunctionPointersWithContext<const Gap *> GapShutdownCallbackChain_t;
vcoubard 1090:148d8b9b56a5 182
rgrover1 710:b2e1a2660ec2 183 /*
rgrover1 710:b2e1a2660ec2 184 * The following functions are meant to be overridden in the platform-specific sub-class.
rgrover1 710:b2e1a2660ec2 185 */
rgrover1 710:b2e1a2660ec2 186 public:
rgrover1 710:b2e1a2660ec2 187 /**
rgrover1 710:b2e1a2660ec2 188 * Set the BTLE MAC address and type. Please note that the address format is
vcoubard 1079:6e2d9514f3df 189 * least significant byte first (LSB). Please refer to BLEProtocol::Address_t.
rgrover1 710:b2e1a2660ec2 190 *
rgrover1 710:b2e1a2660ec2 191 * @return BLE_ERROR_NONE on success.
rgrover1 710:b2e1a2660ec2 192 */
vcoubard 1079:6e2d9514f3df 193 virtual ble_error_t setAddress(BLEProtocol::AddressType_t type, const BLEProtocol::Address_t address) {
rgrover1 734:4872b70437ce 194 /* avoid compiler warnings about unused variables */
rgrover1 734:4872b70437ce 195 (void)type;
rgrover1 734:4872b70437ce 196 (void)address;
rgrover1 734:4872b70437ce 197
rgrover1 728:997ba5e7b3b6 198 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 199 }
rgrover1 710:b2e1a2660ec2 200
rgrover1 710:b2e1a2660ec2 201 /**
rgrover1 710:b2e1a2660ec2 202 * Fetch the BTLE MAC address and type.
rgrover1 710:b2e1a2660ec2 203 *
rgrover1 710:b2e1a2660ec2 204 * @return BLE_ERROR_NONE on success.
rgrover1 710:b2e1a2660ec2 205 */
vcoubard 1079:6e2d9514f3df 206 virtual ble_error_t getAddress(BLEProtocol::AddressType_t *typeP, BLEProtocol::Address_t address) {
vcoubard 1048:efb29faf12fc 207 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 208 (void)typeP;
rgrover1 734:4872b70437ce 209 (void)address;
rgrover1 734:4872b70437ce 210
rgrover1 728:997ba5e7b3b6 211 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 212 }
rgrover1 710:b2e1a2660ec2 213
rgrover1 710:b2e1a2660ec2 214 /**
vcoubard 1056:ce2fb3d09929 215 * @return Minimum Advertising interval in milliseconds for connectable
vcoubard 1056:ce2fb3d09929 216 * undirected and connectable directed event types.
rgrover1 710:b2e1a2660ec2 217 */
rgrover1 710:b2e1a2660ec2 218 virtual uint16_t getMinAdvertisingInterval(void) const {
rgrover1 742:861ed7eb186d 219 return 0; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 220 }
rgrover1 710:b2e1a2660ec2 221
rgrover1 710:b2e1a2660ec2 222 /**
vcoubard 1056:ce2fb3d09929 223 * @return Minimum Advertising interval in milliseconds for scannable
vcoubard 1056:ce2fb3d09929 224 * undirected and non-connectable undirected event types.
rgrover1 710:b2e1a2660ec2 225 */
rgrover1 710:b2e1a2660ec2 226 virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const {
rgrover1 742:861ed7eb186d 227 return 0; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 228 }
rgrover1 710:b2e1a2660ec2 229
rgrover1 710:b2e1a2660ec2 230 /**
rgrover1 710:b2e1a2660ec2 231 * @return Maximum Advertising interval in milliseconds.
rgrover1 710:b2e1a2660ec2 232 */
rgrover1 710:b2e1a2660ec2 233 virtual uint16_t getMaxAdvertisingInterval(void) const {
rgrover1 742:861ed7eb186d 234 return 0xFFFF; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 235 }
rgrover1 710:b2e1a2660ec2 236
rgrover1 710:b2e1a2660ec2 237 virtual ble_error_t stopAdvertising(void) {
rgrover1 728:997ba5e7b3b6 238 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 239 }
rgrover1 710:b2e1a2660ec2 240
rgrover1 710:b2e1a2660ec2 241 /**
rgrover1 710:b2e1a2660ec2 242 * Stop scanning. The current scanning parameters remain in effect.
rgrover1 710:b2e1a2660ec2 243 *
rgrover1 710:b2e1a2660ec2 244 * @retval BLE_ERROR_NONE if successfully stopped scanning procedure.
rgrover1 710:b2e1a2660ec2 245 */
rgrover1 710:b2e1a2660ec2 246 virtual ble_error_t stopScan() {
rgrover1 728:997ba5e7b3b6 247 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 248 }
rgrover1 710:b2e1a2660ec2 249
rgrover1 710:b2e1a2660ec2 250 /**
rgrover1 710:b2e1a2660ec2 251 * Create a connection (GAP Link Establishment).
rgrover1 710:b2e1a2660ec2 252 *
rgrover1 710:b2e1a2660ec2 253 * @param peerAddr
rgrover1 710:b2e1a2660ec2 254 * 48-bit address, LSB format.
rgrover1 710:b2e1a2660ec2 255 * @param peerAddrType
rgrover1 710:b2e1a2660ec2 256 * Address type of the peer.
rgrover1 710:b2e1a2660ec2 257 * @param connectionParams
rgrover1 710:b2e1a2660ec2 258 * Connection parameters.
rgrover1 710:b2e1a2660ec2 259 * @param scanParams
rgrover1 710:b2e1a2660ec2 260 * Paramters to be used while scanning for the peer.
rgrover1 710:b2e1a2660ec2 261 * @return BLE_ERROR_NONE if connection establishment procedure is started
rgrover1 829:9072de50087b 262 * successfully. The connectionCallChain (if set) will be invoked upon
rgrover1 710:b2e1a2660ec2 263 * a connection event.
rgrover1 710:b2e1a2660ec2 264 */
vcoubard 1079:6e2d9514f3df 265 virtual ble_error_t connect(const BLEProtocol::Address_t peerAddr,
vcoubard 1079:6e2d9514f3df 266 BLEProtocol::AddressType_t peerAddrType,
vcoubard 1079:6e2d9514f3df 267 const ConnectionParams_t *connectionParams,
vcoubard 1079:6e2d9514f3df 268 const GapScanningParams *scanParams) {
vcoubard 1048:efb29faf12fc 269 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 270 (void)peerAddr;
rgrover1 734:4872b70437ce 271 (void)peerAddrType;
rgrover1 734:4872b70437ce 272 (void)connectionParams;
rgrover1 734:4872b70437ce 273 (void)scanParams;
rgrover1 734:4872b70437ce 274
rgrover1 728:997ba5e7b3b6 275 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 276 }
rgrover1 710:b2e1a2660ec2 277
rgrover1 710:b2e1a2660ec2 278 /**
rgrover1 710:b2e1a2660ec2 279 * This call initiates the disconnection procedure, and its completion will
rgrover1 710:b2e1a2660ec2 280 * be communicated to the application with an invocation of the
rgrover1 710:b2e1a2660ec2 281 * disconnectionCallback.
rgrover1 710:b2e1a2660ec2 282 *
rgrover1 710:b2e1a2660ec2 283 * @param reason
vcoubard 1048:efb29faf12fc 284 * The reason for disconnection; to be sent back to the peer.
rgrover1 710:b2e1a2660ec2 285 */
rgrover1 710:b2e1a2660ec2 286 virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason) {
rgrover1 734:4872b70437ce 287 /* avoid compiler warnings about unused variables */
rgrover1 734:4872b70437ce 288 (void)connectionHandle;
rgrover1 734:4872b70437ce 289 (void)reason;
rgrover1 734:4872b70437ce 290
rgrover1 728:997ba5e7b3b6 291 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 292 }
rgrover1 710:b2e1a2660ec2 293
rgrover1 710:b2e1a2660ec2 294 /**
rgrover1 710:b2e1a2660ec2 295 * This call initiates the disconnection procedure, and its completion will
rgrover1 710:b2e1a2660ec2 296 * be communicated to the application with an invocation of the
rgrover1 710:b2e1a2660ec2 297 * disconnectionCallback.
rgrover1 710:b2e1a2660ec2 298 *
rgrover1 710:b2e1a2660ec2 299 * @param reason
vcoubard 1048:efb29faf12fc 300 * The reason for disconnection; to be sent back to the peer.
rgrover1 710:b2e1a2660ec2 301 *
vcoubard 1048:efb29faf12fc 302 * @note: This version of disconnect() doesn't take a connection handle. It
vcoubard 1048:efb29faf12fc 303 * works reliably only for stacks that are limited to a single
rgrover1 710:b2e1a2660ec2 304 * connection. This API should be considered *deprecated* in favour of the
vcoubard 1048:efb29faf12fc 305 * alternative, which takes a connection handle. It will be dropped in the future.
rgrover1 710:b2e1a2660ec2 306 */
rgrover1 710:b2e1a2660ec2 307 virtual ble_error_t disconnect(DisconnectionReason_t reason) {
vcoubard 1048:efb29faf12fc 308 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 309 (void)reason;
rgrover1 734:4872b70437ce 310
rgrover1 728:997ba5e7b3b6 311 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 312 }
rgrover1 710:b2e1a2660ec2 313
rgrover1 710:b2e1a2660ec2 314 /**
rgrover1 710:b2e1a2660ec2 315 * Get the GAP peripheral preferred connection parameters. These are the
rgrover1 710:b2e1a2660ec2 316 * defaults that the peripheral would like to have in a connection. The
rgrover1 710:b2e1a2660ec2 317 * choice of the connection parameters is eventually up to the central.
rgrover1 710:b2e1a2660ec2 318 *
rgrover1 710:b2e1a2660ec2 319 * @param[out] params
rgrover1 710:b2e1a2660ec2 320 * The structure where the parameters will be stored. Memory
rgrover1 710:b2e1a2660ec2 321 * for this is owned by the caller.
rgrover1 710:b2e1a2660ec2 322 *
rgrover1 710:b2e1a2660ec2 323 * @return BLE_ERROR_NONE if the parameters were successfully filled into
rgrover1 710:b2e1a2660ec2 324 * the given structure pointed to by params.
rgrover1 710:b2e1a2660ec2 325 */
rgrover1 710:b2e1a2660ec2 326 virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params) {
vcoubard 1048:efb29faf12fc 327 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 328 (void)params;
rgrover1 734:4872b70437ce 329
rgrover1 728:997ba5e7b3b6 330 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 331 }
rgrover1 710:b2e1a2660ec2 332
rgrover1 710:b2e1a2660ec2 333 /**
rgrover1 710:b2e1a2660ec2 334 * Set the GAP peripheral preferred connection parameters. These are the
rgrover1 710:b2e1a2660ec2 335 * defaults that the peripheral would like to have in a connection. The
rgrover1 710:b2e1a2660ec2 336 * choice of the connection parameters is eventually up to the central.
rgrover1 710:b2e1a2660ec2 337 *
rgrover1 710:b2e1a2660ec2 338 * @param[in] params
rgrover1 710:b2e1a2660ec2 339 * The structure containing the desired parameters.
rgrover1 710:b2e1a2660ec2 340 */
rgrover1 710:b2e1a2660ec2 341 virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params) {
vcoubard 1048:efb29faf12fc 342 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 343 (void)params;
rgrover1 734:4872b70437ce 344
rgrover1 728:997ba5e7b3b6 345 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 346 }
rgrover1 710:b2e1a2660ec2 347
rgrover1 710:b2e1a2660ec2 348 /**
rgrover1 816:2b4f0ef8c06e 349 * Update connection parameters.
vcoubard 1048:efb29faf12fc 350 * In the central role this will initiate a Link Layer connection parameter update procedure.
vcoubard 1048:efb29faf12fc 351 * In the peripheral role, this will send the corresponding L2CAP request and wait for
rgrover1 816:2b4f0ef8c06e 352 * the central to perform the procedure.
rgrover1 816:2b4f0ef8c06e 353 *
rgrover1 710:b2e1a2660ec2 354 * @param[in] handle
vcoubard 1048:efb29faf12fc 355 * Connection Handle.
rgrover1 710:b2e1a2660ec2 356 * @param[in] params
rgrover1 710:b2e1a2660ec2 357 * Pointer to desired connection parameters. If NULL is provided on a peripheral role,
rgrover1 710:b2e1a2660ec2 358 * the parameters in the PPCP characteristic of the GAP service will be used instead.
rgrover1 710:b2e1a2660ec2 359 */
rgrover1 710:b2e1a2660ec2 360 virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) {
rgrover1 734:4872b70437ce 361 /* avoid compiler warnings about unused variables */
rgrover1 734:4872b70437ce 362 (void)handle;
rgrover1 734:4872b70437ce 363 (void)params;
rgrover1 734:4872b70437ce 364
rgrover1 728:997ba5e7b3b6 365 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 366 }
rgrover1 710:b2e1a2660ec2 367
rgrover1 710:b2e1a2660ec2 368 /**
rgrover1 710:b2e1a2660ec2 369 * Set the device name characteristic in the GAP service.
rgrover1 710:b2e1a2660ec2 370 * @param[in] deviceName
rgrover1 710:b2e1a2660ec2 371 * The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string.
rgrover1 710:b2e1a2660ec2 372 */
rgrover1 710:b2e1a2660ec2 373 virtual ble_error_t setDeviceName(const uint8_t *deviceName) {
vcoubard 1048:efb29faf12fc 374 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 375 (void)deviceName;
rgrover1 734:4872b70437ce 376
rgrover1 728:997ba5e7b3b6 377 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 378 }
rgrover1 710:b2e1a2660ec2 379
rgrover1 710:b2e1a2660ec2 380 /**
rgrover1 710:b2e1a2660ec2 381 * Get the value of the device name characteristic in the GAP service.
rgrover1 710:b2e1a2660ec2 382 * @param[out] deviceName
rgrover1 710:b2e1a2660ec2 383 * Pointer to an empty buffer where the UTF-8 *non NULL-
rgrover1 710:b2e1a2660ec2 384 * terminated* string will be placed. Set this
rgrover1 710:b2e1a2660ec2 385 * value to NULL in order to obtain the deviceName-length
rgrover1 710:b2e1a2660ec2 386 * from the 'length' parameter.
rgrover1 710:b2e1a2660ec2 387 *
rgrover1 710:b2e1a2660ec2 388 * @param[in/out] lengthP
rgrover1 710:b2e1a2660ec2 389 * (on input) Length of the buffer pointed to by deviceName;
rgrover1 710:b2e1a2660ec2 390 * (on output) the complete device name length (without the
rgrover1 710:b2e1a2660ec2 391 * null terminator).
rgrover1 710:b2e1a2660ec2 392 *
rgrover1 710:b2e1a2660ec2 393 * @note If the device name is longer than the size of the supplied buffer,
rgrover1 710:b2e1a2660ec2 394 * length will return the complete device name length, and not the
rgrover1 710:b2e1a2660ec2 395 * number of bytes actually returned in deviceName. The application may
rgrover1 710:b2e1a2660ec2 396 * use this information to retry with a suitable buffer size.
rgrover1 710:b2e1a2660ec2 397 */
rgrover1 710:b2e1a2660ec2 398 virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) {
rgrover1 734:4872b70437ce 399 /* avoid compiler warnings about unused variables */
rgrover1 734:4872b70437ce 400 (void)deviceName;
rgrover1 734:4872b70437ce 401 (void)lengthP;
rgrover1 734:4872b70437ce 402
rgrover1 728:997ba5e7b3b6 403 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 404 }
rgrover1 710:b2e1a2660ec2 405
rgrover1 710:b2e1a2660ec2 406 /**
rgrover1 710:b2e1a2660ec2 407 * Set the appearance characteristic in the GAP service.
rgrover1 710:b2e1a2660ec2 408 * @param[in] appearance
rgrover1 710:b2e1a2660ec2 409 * The new value for the device-appearance.
rgrover1 710:b2e1a2660ec2 410 */
rgrover1 710:b2e1a2660ec2 411 virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) {
vcoubard 1048:efb29faf12fc 412 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 413 (void)appearance;
rgrover1 734:4872b70437ce 414
rgrover1 728:997ba5e7b3b6 415 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 416 }
rgrover1 710:b2e1a2660ec2 417
rgrover1 710:b2e1a2660ec2 418 /**
rgrover1 710:b2e1a2660ec2 419 * Get the appearance characteristic in the GAP service.
rgrover1 710:b2e1a2660ec2 420 * @param[out] appearance
rgrover1 710:b2e1a2660ec2 421 * The new value for the device-appearance.
rgrover1 710:b2e1a2660ec2 422 */
rgrover1 710:b2e1a2660ec2 423 virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) {
vcoubard 1048:efb29faf12fc 424 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 425 (void)appearanceP;
rgrover1 734:4872b70437ce 426
rgrover1 728:997ba5e7b3b6 427 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 428 }
rgrover1 710:b2e1a2660ec2 429
rgrover1 710:b2e1a2660ec2 430 /**
rgrover1 710:b2e1a2660ec2 431 * Set the radio's transmit power.
rgrover1 710:b2e1a2660ec2 432 * @param[in] txPower Radio transmit power in dBm.
rgrover1 710:b2e1a2660ec2 433 */
rgrover1 710:b2e1a2660ec2 434 virtual ble_error_t setTxPower(int8_t txPower) {
vcoubard 1048:efb29faf12fc 435 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 436 (void)txPower;
rgrover1 734:4872b70437ce 437
rgrover1 728:997ba5e7b3b6 438 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 439 }
rgrover1 710:b2e1a2660ec2 440
rgrover1 710:b2e1a2660ec2 441 /**
rgrover1 710:b2e1a2660ec2 442 * Query the underlying stack for permitted arguments for setTxPower().
rgrover1 710:b2e1a2660ec2 443 *
rgrover1 710:b2e1a2660ec2 444 * @param[out] valueArrayPP
rgrover1 710:b2e1a2660ec2 445 * Out parameter to receive the immutable array of Tx values.
rgrover1 710:b2e1a2660ec2 446 * @param[out] countP
rgrover1 710:b2e1a2660ec2 447 * Out parameter to receive the array's size.
rgrover1 710:b2e1a2660ec2 448 */
rgrover1 710:b2e1a2660ec2 449 virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) {
vcoubard 1048:efb29faf12fc 450 /* Avoid compiler warnings about unused variables. */
rgrover1 734:4872b70437ce 451 (void)valueArrayPP;
rgrover1 734:4872b70437ce 452 (void)countP;
rgrover1 734:4872b70437ce 453
rgrover1 742:861ed7eb186d 454 *countP = 0; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 455 }
rgrover1 710:b2e1a2660ec2 456
rgrover1 710:b2e1a2660ec2 457 protected:
rgrover1 710:b2e1a2660ec2 458 /* Override the following in the underlying adaptation layer to provide the functionality of scanning. */
rgrover1 710:b2e1a2660ec2 459 virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams) {
rgrover1 772:b6d27ab66c94 460 (void)scanningParams;
rgrover1 728:997ba5e7b3b6 461 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 710:b2e1a2660ec2 462 }
rgrover1 710:b2e1a2660ec2 463
rgrover1 710:b2e1a2660ec2 464 /*
rgrover1 710:b2e1a2660ec2 465 * APIs with non-virtual implementations.
rgrover1 710:b2e1a2660ec2 466 */
rgrover1 710:b2e1a2660ec2 467 public:
rgrover1 710:b2e1a2660ec2 468 /**
vcoubard 1048:efb29faf12fc 469 * Returns the current GAP state of the device using a bitmask that
vcoubard 1048:efb29faf12fc 470 * describes whether the device is advertising or connected.
rgrover1 710:b2e1a2660ec2 471 */
rgrover1 710:b2e1a2660ec2 472 GapState_t getState(void) const {
rgrover1 710:b2e1a2660ec2 473 return state;
rgrover1 710:b2e1a2660ec2 474 }
rgrover1 710:b2e1a2660ec2 475
rgrover1 710:b2e1a2660ec2 476 /**
rgrover1 710:b2e1a2660ec2 477 * Set the GAP advertising mode to use for this device.
rgrover1 710:b2e1a2660ec2 478 */
rgrover1 710:b2e1a2660ec2 479 void setAdvertisingType(GapAdvertisingParams::AdvertisingType_t advType) {
rgrover1 710:b2e1a2660ec2 480 _advParams.setAdvertisingType(advType);
rgrover1 710:b2e1a2660ec2 481 }
rgrover1 710:b2e1a2660ec2 482
rgrover1 710:b2e1a2660ec2 483 /**
rgrover1 710:b2e1a2660ec2 484 * @param[in] interval
rgrover1 710:b2e1a2660ec2 485 * Advertising interval in units of milliseconds. Advertising
rgrover1 710:b2e1a2660ec2 486 * is disabled if interval is 0. If interval is smaller than
rgrover1 710:b2e1a2660ec2 487 * the minimum supported value, then the minimum supported
rgrover1 710:b2e1a2660ec2 488 * value is used instead. This minimum value can be discovered
rgrover1 710:b2e1a2660ec2 489 * using getMinAdvertisingInterval().
rgrover1 710:b2e1a2660ec2 490 *
rgrover1 710:b2e1a2660ec2 491 * This field must be set to 0 if connectionMode is equal
rgrover1 710:b2e1a2660ec2 492 * to ADV_CONNECTABLE_DIRECTED.
rgrover1 710:b2e1a2660ec2 493 *
rgrover1 710:b2e1a2660ec2 494 * @note: Decreasing this value will allow central devices to detect a
vcoubard 1048:efb29faf12fc 495 * peripheral faster, at the expense of more power being used by the radio
rgrover1 710:b2e1a2660ec2 496 * due to the higher data transmit rate.
rgrover1 710:b2e1a2660ec2 497 *
rgrover1 710:b2e1a2660ec2 498 * @Note: [WARNING] This API previously used 0.625ms as the unit for its
rgrover1 710:b2e1a2660ec2 499 * 'interval' argument. That required an explicit conversion from
rgrover1 710:b2e1a2660ec2 500 * milliseconds using Gap::MSEC_TO_GAP_DURATION_UNITS(). This conversion is
rgrover1 710:b2e1a2660ec2 501 * no longer required as the new units are milliseconds. Any application
vcoubard 1048:efb29faf12fc 502 * code depending on the old semantics needs to be updated accordingly.
rgrover1 710:b2e1a2660ec2 503 */
rgrover1 710:b2e1a2660ec2 504 void setAdvertisingInterval(uint16_t interval) {
rgrover1 710:b2e1a2660ec2 505 if (interval == 0) {
rgrover1 710:b2e1a2660ec2 506 stopAdvertising();
rgrover1 710:b2e1a2660ec2 507 } else if (interval < getMinAdvertisingInterval()) {
rgrover1 710:b2e1a2660ec2 508 interval = getMinAdvertisingInterval();
rgrover1 710:b2e1a2660ec2 509 }
rgrover1 786:d6d7087d8377 510 _advParams.setInterval(interval);
rgrover1 710:b2e1a2660ec2 511 }
rgrover1 710:b2e1a2660ec2 512
rgrover1 710:b2e1a2660ec2 513 /**
rgrover1 710:b2e1a2660ec2 514 * @param[in] timeout
rgrover1 710:b2e1a2660ec2 515 * Advertising timeout (in seconds) between 0x1 and 0x3FFF (1
rgrover1 710:b2e1a2660ec2 516 * and 16383). Use 0 to disable the advertising timeout.
rgrover1 710:b2e1a2660ec2 517 */
rgrover1 710:b2e1a2660ec2 518 void setAdvertisingTimeout(uint16_t timeout) {
rgrover1 710:b2e1a2660ec2 519 _advParams.setTimeout(timeout);
rgrover1 710:b2e1a2660ec2 520 }
rgrover1 710:b2e1a2660ec2 521
rgrover1 710:b2e1a2660ec2 522 /**
rgrover1 710:b2e1a2660ec2 523 * Start advertising.
rgrover1 710:b2e1a2660ec2 524 */
rgrover1 710:b2e1a2660ec2 525 ble_error_t startAdvertising(void) {
vcoubard 1048:efb29faf12fc 526 setAdvertisingData(); /* Update the underlying stack. */
rgrover1 710:b2e1a2660ec2 527 return startAdvertising(_advParams);
rgrover1 710:b2e1a2660ec2 528 }
rgrover1 710:b2e1a2660ec2 529
rgrover1 710:b2e1a2660ec2 530 /**
rgrover1 710:b2e1a2660ec2 531 * Reset any advertising payload prepared from prior calls to
rgrover1 710:b2e1a2660ec2 532 * accumulateAdvertisingPayload(). This automatically propagates the re-
vcoubard 1048:efb29faf12fc 533 * initialized advertising payload to the underlying stack.
rgrover1 710:b2e1a2660ec2 534 */
rgrover1 710:b2e1a2660ec2 535 void clearAdvertisingPayload(void) {
rgrover1 710:b2e1a2660ec2 536 _advPayload.clear();
rgrover1 710:b2e1a2660ec2 537 setAdvertisingData();
rgrover1 710:b2e1a2660ec2 538 }
rgrover1 710:b2e1a2660ec2 539
rgrover1 710:b2e1a2660ec2 540 /**
rgrover1 710:b2e1a2660ec2 541 * Accumulate an AD structure in the advertising payload. Please note that
rgrover1 710:b2e1a2660ec2 542 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
vcoubard 1048:efb29faf12fc 543 * as an additional 31 bytes if the advertising payload is too
rgrover1 710:b2e1a2660ec2 544 * small.
rgrover1 710:b2e1a2660ec2 545 *
rgrover1 710:b2e1a2660ec2 546 * @param[in] flags
rgrover1 710:b2e1a2660ec2 547 * The flags to be added. Please refer to
rgrover1 710:b2e1a2660ec2 548 * GapAdvertisingData::Flags for valid flags. Multiple
rgrover1 710:b2e1a2660ec2 549 * flags may be specified in combination.
rgrover1 710:b2e1a2660ec2 550 */
rgrover1 710:b2e1a2660ec2 551 ble_error_t accumulateAdvertisingPayload(uint8_t flags) {
rgrover1 710:b2e1a2660ec2 552 ble_error_t rc;
rgrover1 710:b2e1a2660ec2 553 if ((rc = _advPayload.addFlags(flags)) != BLE_ERROR_NONE) {
rgrover1 710:b2e1a2660ec2 554 return rc;
rgrover1 710:b2e1a2660ec2 555 }
rgrover1 710:b2e1a2660ec2 556
rgrover1 710:b2e1a2660ec2 557 return setAdvertisingData();
rgrover1 710:b2e1a2660ec2 558 }
rgrover1 710:b2e1a2660ec2 559
rgrover1 710:b2e1a2660ec2 560 /**
rgrover1 710:b2e1a2660ec2 561 * Accumulate an AD structure in the advertising payload. Please note that
rgrover1 710:b2e1a2660ec2 562 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
vcoubard 1048:efb29faf12fc 563 * as an additional 31 bytes if the advertising payload is too
rgrover1 710:b2e1a2660ec2 564 * small.
rgrover1 710:b2e1a2660ec2 565 *
rgrover1 710:b2e1a2660ec2 566 * @param app
rgrover1 710:b2e1a2660ec2 567 * The appearance of the peripheral.
rgrover1 710:b2e1a2660ec2 568 */
rgrover1 710:b2e1a2660ec2 569 ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app) {
rgrover1 710:b2e1a2660ec2 570 setAppearance(app);
rgrover1 710:b2e1a2660ec2 571
rgrover1 710:b2e1a2660ec2 572 ble_error_t rc;
rgrover1 710:b2e1a2660ec2 573 if ((rc = _advPayload.addAppearance(app)) != BLE_ERROR_NONE) {
rgrover1 710:b2e1a2660ec2 574 return rc;
rgrover1 710:b2e1a2660ec2 575 }
rgrover1 710:b2e1a2660ec2 576
rgrover1 710:b2e1a2660ec2 577 return setAdvertisingData();
rgrover1 710:b2e1a2660ec2 578 }
rgrover1 710:b2e1a2660ec2 579
rgrover1 710:b2e1a2660ec2 580 /**
rgrover1 710:b2e1a2660ec2 581 * Accumulate an AD structure in the advertising payload. Please note that
rgrover1 710:b2e1a2660ec2 582 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
vcoubard 1048:efb29faf12fc 583 * as an additional 31 bytes if the advertising payload is too
rgrover1 710:b2e1a2660ec2 584 * small.
rgrover1 710:b2e1a2660ec2 585 *
vcoubard 1048:efb29faf12fc 586 * @param power
rgrover1 764:1e560f0d45e1 587 * The max transmit power to be used by the controller (in dBm).
rgrover1 710:b2e1a2660ec2 588 */
rgrover1 710:b2e1a2660ec2 589 ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power) {
rgrover1 710:b2e1a2660ec2 590 ble_error_t rc;
rgrover1 710:b2e1a2660ec2 591 if ((rc = _advPayload.addTxPower(power)) != BLE_ERROR_NONE) {
rgrover1 710:b2e1a2660ec2 592 return rc;
rgrover1 710:b2e1a2660ec2 593 }
rgrover1 710:b2e1a2660ec2 594
rgrover1 710:b2e1a2660ec2 595 return setAdvertisingData();
rgrover1 710:b2e1a2660ec2 596 }
rgrover1 710:b2e1a2660ec2 597
rgrover1 710:b2e1a2660ec2 598 /**
rgrover1 710:b2e1a2660ec2 599 * Accumulate a variable length byte-stream as an AD structure in the
rgrover1 710:b2e1a2660ec2 600 * advertising payload. Please note that the payload is limited to 31 bytes.
rgrover1 710:b2e1a2660ec2 601 * The SCAN_RESPONSE message may be used as an additional 31 bytes if the
vcoubard 1048:efb29faf12fc 602 * advertising payload is too small.
rgrover1 710:b2e1a2660ec2 603 *
vcoubard 1048:efb29faf12fc 604 * @param type The type describing the variable length data.
vcoubard 1048:efb29faf12fc 605 * @param data Data bytes.
vcoubard 1048:efb29faf12fc 606 * @param len Length of data.
vcoubard 1104:0244fbb0324e 607 *
vcoubard 1104:0244fbb0324e 608 * @return BLE_ERROR_NONE if the advertisement payload was updated based on
vcoubard 1104:0244fbb0324e 609 * matching AD type; otherwise, an appropriate error.
vcoubard 1104:0244fbb0324e 610 *
vcoubard 1104:0244fbb0324e 611 * @note When the specified AD type is INCOMPLETE_LIST_16BIT_SERVICE_IDS,
vcoubard 1104:0244fbb0324e 612 * COMPLETE_LIST_16BIT_SERVICE_IDS, INCOMPLETE_LIST_32BIT_SERVICE_IDS,
vcoubard 1104:0244fbb0324e 613 * COMPLETE_LIST_32BIT_SERVICE_IDS, INCOMPLETE_LIST_128BIT_SERVICE_IDS,
vcoubard 1104:0244fbb0324e 614 * COMPLETE_LIST_128BIT_SERVICE_IDS or LIST_128BIT_SOLICITATION_IDS the
vcoubard 1104:0244fbb0324e 615 * supplied value is appended to the values previously added to the
vcoubard 1104:0244fbb0324e 616 * payload.
rgrover1 710:b2e1a2660ec2 617 */
rgrover1 710:b2e1a2660ec2 618 ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) {
rgrover1 710:b2e1a2660ec2 619 if (type == GapAdvertisingData::COMPLETE_LOCAL_NAME) {
rgrover1 710:b2e1a2660ec2 620 setDeviceName(data);
rgrover1 710:b2e1a2660ec2 621 }
rgrover1 710:b2e1a2660ec2 622
rgrover1 710:b2e1a2660ec2 623 ble_error_t rc;
rgrover1 710:b2e1a2660ec2 624 if ((rc = _advPayload.addData(type, data, len)) != BLE_ERROR_NONE) {
rgrover1 710:b2e1a2660ec2 625 return rc;
rgrover1 710:b2e1a2660ec2 626 }
rgrover1 710:b2e1a2660ec2 627
rgrover1 710:b2e1a2660ec2 628 return setAdvertisingData();
rgrover1 710:b2e1a2660ec2 629 }
rgrover1 710:b2e1a2660ec2 630
rgrover1 710:b2e1a2660ec2 631 /**
rgrover1 765:4cd91998cd48 632 * Update a particular ADV field in the advertising payload (based on
vcoubard 1104:0244fbb0324e 633 * matching type).
rgrover1 763:36c3e2b1f1ae 634 *
vcoubard 1048:efb29faf12fc 635 * @param[in] type The ADV type field describing the variable length data.
vcoubard 1048:efb29faf12fc 636 * @param[in] data Data bytes.
vcoubard 1048:efb29faf12fc 637 * @param[in] len Length of data.
rgrover1 765:4cd91998cd48 638 *
rgrover1 765:4cd91998cd48 639 * @note: If advertisements are enabled, then the update will take effect immediately.
rgrover1 765:4cd91998cd48 640 *
rgrover1 765:4cd91998cd48 641 * @return BLE_ERROR_NONE if the advertisement payload was updated based on
vcoubard 1104:0244fbb0324e 642 * matching AD type; otherwise, an appropriate error.
rgrover1 763:36c3e2b1f1ae 643 */
rgrover1 763:36c3e2b1f1ae 644 ble_error_t updateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) {
rgrover1 763:36c3e2b1f1ae 645 if (type == GapAdvertisingData::COMPLETE_LOCAL_NAME) {
rgrover1 763:36c3e2b1f1ae 646 setDeviceName(data);
rgrover1 763:36c3e2b1f1ae 647 }
rgrover1 763:36c3e2b1f1ae 648
rgrover1 763:36c3e2b1f1ae 649 ble_error_t rc;
rgrover1 763:36c3e2b1f1ae 650 if ((rc = _advPayload.updateData(type, data, len)) != BLE_ERROR_NONE) {
rgrover1 763:36c3e2b1f1ae 651 return rc;
rgrover1 763:36c3e2b1f1ae 652 }
rgrover1 763:36c3e2b1f1ae 653
rgrover1 763:36c3e2b1f1ae 654 return setAdvertisingData();
rgrover1 763:36c3e2b1f1ae 655 }
rgrover1 763:36c3e2b1f1ae 656
rgrover1 763:36c3e2b1f1ae 657 /**
vcoubard 1048:efb29faf12fc 658 * Set up a particular, user-constructed advertisement payload for the
rgrover1 710:b2e1a2660ec2 659 * underlying stack. It would be uncommon for this API to be used directly;
rgrover1 710:b2e1a2660ec2 660 * there are other APIs to build an advertisement payload (see above).
rgrover1 710:b2e1a2660ec2 661 */
rgrover1 710:b2e1a2660ec2 662 ble_error_t setAdvertisingPayload(const GapAdvertisingData &payload) {
rgrover1 710:b2e1a2660ec2 663 _advPayload = payload;
rgrover1 710:b2e1a2660ec2 664 return setAdvertisingData();
rgrover1 710:b2e1a2660ec2 665 }
rgrover1 710:b2e1a2660ec2 666
rgrover1 710:b2e1a2660ec2 667 /**
rgrover1 710:b2e1a2660ec2 668 * @return Read back advertising data. Useful for storing and
rgrover1 710:b2e1a2660ec2 669 * restoring payload.
rgrover1 710:b2e1a2660ec2 670 */
rgrover1 710:b2e1a2660ec2 671 const GapAdvertisingData &getAdvertisingPayload(void) const {
rgrover1 710:b2e1a2660ec2 672 return _advPayload;
rgrover1 710:b2e1a2660ec2 673 }
rgrover1 710:b2e1a2660ec2 674
rgrover1 710:b2e1a2660ec2 675 /**
rgrover1 710:b2e1a2660ec2 676 * Accumulate a variable length byte-stream as an AD structure in the
rgrover1 710:b2e1a2660ec2 677 * scanResponse payload.
rgrover1 710:b2e1a2660ec2 678 *
vcoubard 1048:efb29faf12fc 679 * @param[in] type The type describing the variable length data.
vcoubard 1048:efb29faf12fc 680 * @param[in] data Data bytes.
vcoubard 1048:efb29faf12fc 681 * @param[in] len Length of data.
rgrover1 710:b2e1a2660ec2 682 */
rgrover1 710:b2e1a2660ec2 683 ble_error_t accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) {
rgrover1 710:b2e1a2660ec2 684 ble_error_t rc;
rgrover1 710:b2e1a2660ec2 685 if ((rc = _scanResponse.addData(type, data, len)) != BLE_ERROR_NONE) {
rgrover1 710:b2e1a2660ec2 686 return rc;
rgrover1 710:b2e1a2660ec2 687 }
rgrover1 710:b2e1a2660ec2 688
rgrover1 710:b2e1a2660ec2 689 return setAdvertisingData();
rgrover1 710:b2e1a2660ec2 690 }
rgrover1 710:b2e1a2660ec2 691
rgrover1 710:b2e1a2660ec2 692 /**
rgrover1 710:b2e1a2660ec2 693 * Reset any scan response prepared from prior calls to
rgrover1 710:b2e1a2660ec2 694 * accumulateScanResponse().
rgrover1 710:b2e1a2660ec2 695 *
rgrover1 710:b2e1a2660ec2 696 * Note: This should be followed by a call to setAdvertisingPayload() or
rgrover1 710:b2e1a2660ec2 697 * startAdvertising() before the update takes effect.
rgrover1 710:b2e1a2660ec2 698 */
rgrover1 710:b2e1a2660ec2 699 void clearScanResponse(void) {
rgrover1 710:b2e1a2660ec2 700 _scanResponse.clear();
rgrover1 710:b2e1a2660ec2 701 setAdvertisingData();
rgrover1 710:b2e1a2660ec2 702 }
rgrover1 710:b2e1a2660ec2 703
rgrover1 710:b2e1a2660ec2 704 /**
vcoubard 1048:efb29faf12fc 705 * Set up parameters for GAP scanning (observer mode).
rgrover1 710:b2e1a2660ec2 706 * @param[in] interval
rgrover1 710:b2e1a2660ec2 707 * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s].
rgrover1 710:b2e1a2660ec2 708 * @param[in] window
rgrover1 710:b2e1a2660ec2 709 * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s].
rgrover1 710:b2e1a2660ec2 710 * @param[in] timeout
vcoubard 1048:efb29faf12fc 711 * Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables the timeout.
rgrover1 710:b2e1a2660ec2 712 * @param[in] activeScanning
rgrover1 710:b2e1a2660ec2 713 * Set to True if active-scanning is required. This is used to fetch the
rgrover1 710:b2e1a2660ec2 714 * scan response from a peer if possible.
rgrover1 710:b2e1a2660ec2 715 *
rgrover1 710:b2e1a2660ec2 716 * The scanning window divided by the interval determines the duty cycle for
rgrover1 710:b2e1a2660ec2 717 * scanning. For example, if the interval is 100ms and the window is 10ms,
rgrover1 710:b2e1a2660ec2 718 * then the controller will scan for 10 percent of the time. It is possible
rgrover1 710:b2e1a2660ec2 719 * to have the interval and window set to the same value. In this case,
rgrover1 710:b2e1a2660ec2 720 * scanning is continuous, with a change of scanning frequency once every
rgrover1 710:b2e1a2660ec2 721 * interval.
rgrover1 710:b2e1a2660ec2 722 *
rgrover1 710:b2e1a2660ec2 723 * Once the scanning parameters have been configured, scanning can be
rgrover1 710:b2e1a2660ec2 724 * enabled by using startScan().
rgrover1 710:b2e1a2660ec2 725 *
rgrover1 710:b2e1a2660ec2 726 * @Note: The scan interval and window are recommendations to the BLE stack.
rgrover1 710:b2e1a2660ec2 727 */
rgrover1 710:b2e1a2660ec2 728 ble_error_t setScanParams(uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX,
rgrover1 710:b2e1a2660ec2 729 uint16_t window = GapScanningParams::SCAN_WINDOW_MAX,
rgrover1 710:b2e1a2660ec2 730 uint16_t timeout = 0,
rgrover1 710:b2e1a2660ec2 731 bool activeScanning = false) {
rgrover1 710:b2e1a2660ec2 732 ble_error_t rc;
rgrover1 710:b2e1a2660ec2 733 if (((rc = _scanningParams.setInterval(interval)) == BLE_ERROR_NONE) &&
rgrover1 710:b2e1a2660ec2 734 ((rc = _scanningParams.setWindow(window)) == BLE_ERROR_NONE) &&
rgrover1 710:b2e1a2660ec2 735 ((rc = _scanningParams.setTimeout(timeout)) == BLE_ERROR_NONE)) {
rgrover1 710:b2e1a2660ec2 736 _scanningParams.setActiveScanning(activeScanning);
rgrover1 710:b2e1a2660ec2 737 return BLE_ERROR_NONE;
rgrover1 710:b2e1a2660ec2 738 }
rgrover1 710:b2e1a2660ec2 739
rgrover1 710:b2e1a2660ec2 740 return rc;
rgrover1 710:b2e1a2660ec2 741 }
rgrover1 710:b2e1a2660ec2 742
rgrover1 710:b2e1a2660ec2 743 /**
vcoubard 1048:efb29faf12fc 744 * Set up the scanInterval parameter for GAP scanning (observer mode).
rgrover1 710:b2e1a2660ec2 745 * @param[in] interval
rgrover1 710:b2e1a2660ec2 746 * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s].
rgrover1 710:b2e1a2660ec2 747 *
rgrover1 710:b2e1a2660ec2 748 * The scanning window divided by the interval determines the duty cycle for
rgrover1 710:b2e1a2660ec2 749 * scanning. For example, if the interval is 100ms and the window is 10ms,
rgrover1 710:b2e1a2660ec2 750 * then the controller will scan for 10 percent of the time. It is possible
rgrover1 710:b2e1a2660ec2 751 * to have the interval and window set to the same value. In this case,
rgrover1 710:b2e1a2660ec2 752 * scanning is continuous, with a change of scanning frequency once every
rgrover1 710:b2e1a2660ec2 753 * interval.
rgrover1 710:b2e1a2660ec2 754 *
rgrover1 710:b2e1a2660ec2 755 * Once the scanning parameters have been configured, scanning can be
rgrover1 710:b2e1a2660ec2 756 * enabled by using startScan().
rgrover1 710:b2e1a2660ec2 757 */
rgrover1 710:b2e1a2660ec2 758 ble_error_t setScanInterval(uint16_t interval) {
rgrover1 710:b2e1a2660ec2 759 return _scanningParams.setInterval(interval);
rgrover1 710:b2e1a2660ec2 760 }
rgrover1 710:b2e1a2660ec2 761
rgrover1 710:b2e1a2660ec2 762 /**
vcoubard 1048:efb29faf12fc 763 * Set up the scanWindow parameter for GAP scanning (observer mode).
rgrover1 710:b2e1a2660ec2 764 * @param[in] window
rgrover1 710:b2e1a2660ec2 765 * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s].
rgrover1 710:b2e1a2660ec2 766 *
rgrover1 710:b2e1a2660ec2 767 * The scanning window divided by the interval determines the duty cycle for
rgrover1 710:b2e1a2660ec2 768 * scanning. For example, if the interval is 100ms and the window is 10ms,
rgrover1 710:b2e1a2660ec2 769 * then the controller will scan for 10 percent of the time. It is possible
rgrover1 710:b2e1a2660ec2 770 * to have the interval and window set to the same value. In this case,
rgrover1 710:b2e1a2660ec2 771 * scanning is continuous, with a change of scanning frequency once every
rgrover1 710:b2e1a2660ec2 772 * interval.
rgrover1 710:b2e1a2660ec2 773 *
rgrover1 710:b2e1a2660ec2 774 * Once the scanning parameters have been configured, scanning can be
rgrover1 710:b2e1a2660ec2 775 * enabled by using startScan().
rgrover1 770:079b714e9c1a 776 *
rgrover1 770:079b714e9c1a 777 * If scanning is already active, the updated value of scanWindow will be
rgrover1 770:079b714e9c1a 778 * propagated to the underlying BLE stack.
rgrover1 710:b2e1a2660ec2 779 */
rgrover1 710:b2e1a2660ec2 780 ble_error_t setScanWindow(uint16_t window) {
rgrover1 770:079b714e9c1a 781 ble_error_t rc;
rgrover1 770:079b714e9c1a 782 if ((rc = _scanningParams.setWindow(window)) != BLE_ERROR_NONE) {
rgrover1 770:079b714e9c1a 783 return rc;
rgrover1 770:079b714e9c1a 784 }
rgrover1 770:079b714e9c1a 785
rgrover1 770:079b714e9c1a 786 /* If scanning is already active, propagate the new setting to the stack. */
rgrover1 770:079b714e9c1a 787 if (scanningActive) {
rgrover1 770:079b714e9c1a 788 return startRadioScan(_scanningParams);
rgrover1 770:079b714e9c1a 789 }
rgrover1 770:079b714e9c1a 790
rgrover1 770:079b714e9c1a 791 return BLE_ERROR_NONE;
rgrover1 710:b2e1a2660ec2 792 }
rgrover1 710:b2e1a2660ec2 793
rgrover1 710:b2e1a2660ec2 794 /**
vcoubard 1048:efb29faf12fc 795 * Set up parameters for GAP scanning (observer mode).
rgrover1 710:b2e1a2660ec2 796 * @param[in] timeout
vcoubard 1048:efb29faf12fc 797 * Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables the timeout.
rgrover1 710:b2e1a2660ec2 798 *
rgrover1 710:b2e1a2660ec2 799 * Once the scanning parameters have been configured, scanning can be
rgrover1 710:b2e1a2660ec2 800 * enabled by using startScan().
rgrover1 770:079b714e9c1a 801 *
rgrover1 770:079b714e9c1a 802 * If scanning is already active, the updated value of scanTimeout will be
rgrover1 770:079b714e9c1a 803 * propagated to the underlying BLE stack.
rgrover1 710:b2e1a2660ec2 804 */
rgrover1 710:b2e1a2660ec2 805 ble_error_t setScanTimeout(uint16_t timeout) {
rgrover1 770:079b714e9c1a 806 ble_error_t rc;
rgrover1 770:079b714e9c1a 807 if ((rc = _scanningParams.setTimeout(timeout)) != BLE_ERROR_NONE) {
rgrover1 770:079b714e9c1a 808 return rc;
rgrover1 770:079b714e9c1a 809 }
rgrover1 770:079b714e9c1a 810
rgrover1 770:079b714e9c1a 811 /* If scanning is already active, propagate the new settings to the stack. */
rgrover1 770:079b714e9c1a 812 if (scanningActive) {
rgrover1 770:079b714e9c1a 813 return startRadioScan(_scanningParams);
rgrover1 770:079b714e9c1a 814 }
rgrover1 770:079b714e9c1a 815
rgrover1 770:079b714e9c1a 816 return BLE_ERROR_NONE;
rgrover1 710:b2e1a2660ec2 817 }
rgrover1 710:b2e1a2660ec2 818
rgrover1 710:b2e1a2660ec2 819 /**
vcoubard 1048:efb29faf12fc 820 * Set up parameters for GAP scanning (observer mode).
rgrover1 710:b2e1a2660ec2 821 * @param[in] activeScanning
rgrover1 710:b2e1a2660ec2 822 * Set to True if active-scanning is required. This is used to fetch the
rgrover1 710:b2e1a2660ec2 823 * scan response from a peer if possible.
rgrover1 710:b2e1a2660ec2 824 *
rgrover1 710:b2e1a2660ec2 825 * Once the scanning parameters have been configured, scanning can be
rgrover1 710:b2e1a2660ec2 826 * enabled by using startScan().
rgrover1 770:079b714e9c1a 827 *
rgrover1 770:079b714e9c1a 828 * If scanning is already in progress, then active-scanning will be enabled
rgrover1 770:079b714e9c1a 829 * for the underlying BLE stack.
rgrover1 710:b2e1a2660ec2 830 */
rgrover1 770:079b714e9c1a 831 ble_error_t setActiveScanning(bool activeScanning) {
rgrover1 710:b2e1a2660ec2 832 _scanningParams.setActiveScanning(activeScanning);
rgrover1 770:079b714e9c1a 833
rgrover1 770:079b714e9c1a 834 /* If scanning is already active, propagate the new settings to the stack. */
rgrover1 770:079b714e9c1a 835 if (scanningActive) {
rgrover1 770:079b714e9c1a 836 return startRadioScan(_scanningParams);
rgrover1 770:079b714e9c1a 837 }
rgrover1 770:079b714e9c1a 838
rgrover1 770:079b714e9c1a 839 return BLE_ERROR_NONE;
rgrover1 710:b2e1a2660ec2 840 }
rgrover1 710:b2e1a2660ec2 841
rgrover1 710:b2e1a2660ec2 842 /**
rgrover1 710:b2e1a2660ec2 843 * Start scanning (Observer Procedure) based on the parameters currently in
rgrover1 710:b2e1a2660ec2 844 * effect.
rgrover1 710:b2e1a2660ec2 845 *
rgrover1 710:b2e1a2660ec2 846 * @param[in] callback
vcoubard 1048:efb29faf12fc 847 * The application-specific callback to be invoked upon
rgrover1 710:b2e1a2660ec2 848 * receiving every advertisement report. This can be passed in
rgrover1 710:b2e1a2660ec2 849 * as NULL, in which case scanning may not be enabled at all.
rgrover1 710:b2e1a2660ec2 850 */
rgrover1 710:b2e1a2660ec2 851 ble_error_t startScan(void (*callback)(const AdvertisementCallbackParams_t *params)) {
rgrover1 710:b2e1a2660ec2 852 ble_error_t err = BLE_ERROR_NONE;
rgrover1 710:b2e1a2660ec2 853 if (callback) {
rgrover1 710:b2e1a2660ec2 854 if ((err = startRadioScan(_scanningParams)) == BLE_ERROR_NONE) {
rgrover1 770:079b714e9c1a 855 scanningActive = true;
rgrover1 710:b2e1a2660ec2 856 onAdvertisementReport.attach(callback);
rgrover1 710:b2e1a2660ec2 857 }
rgrover1 710:b2e1a2660ec2 858 }
rgrover1 710:b2e1a2660ec2 859
rgrover1 710:b2e1a2660ec2 860 return err;
rgrover1 710:b2e1a2660ec2 861 }
rgrover1 710:b2e1a2660ec2 862
rgrover1 710:b2e1a2660ec2 863 /**
rgrover1 710:b2e1a2660ec2 864 * Same as above, but this takes an (object, method) pair for a callback.
rgrover1 710:b2e1a2660ec2 865 */
rgrover1 710:b2e1a2660ec2 866 template<typename T>
rgrover1 710:b2e1a2660ec2 867 ble_error_t startScan(T *object, void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)) {
rgrover1 710:b2e1a2660ec2 868 ble_error_t err = BLE_ERROR_NONE;
rgrover1 710:b2e1a2660ec2 869 if (object && callbackMember) {
rgrover1 710:b2e1a2660ec2 870 if ((err = startRadioScan(_scanningParams)) == BLE_ERROR_NONE) {
rgrover1 770:079b714e9c1a 871 scanningActive = true;
rgrover1 710:b2e1a2660ec2 872 onAdvertisementReport.attach(object, callbackMember);
rgrover1 710:b2e1a2660ec2 873 }
rgrover1 710:b2e1a2660ec2 874 }
rgrover1 710:b2e1a2660ec2 875
rgrover1 710:b2e1a2660ec2 876 return err;
rgrover1 710:b2e1a2660ec2 877 }
rgrover1 710:b2e1a2660ec2 878
rgrover1 753:0f60274cd3ad 879 /**
rgrover1 753:0f60274cd3ad 880 * Initialize radio-notification events to be generated from the stack.
vcoubard 1048:efb29faf12fc 881 * This API doesn't need to be called directly.
rgrover1 753:0f60274cd3ad 882 *
rgrover1 753:0f60274cd3ad 883 * Radio Notification is a feature that enables ACTIVE and INACTIVE
rgrover1 753:0f60274cd3ad 884 * (nACTIVE) signals from the stack that notify the application when the
rgrover1 753:0f60274cd3ad 885 * radio is in use.
rgrover1 753:0f60274cd3ad 886 *
vcoubard 1048:efb29faf12fc 887 * The ACTIVE signal is sent before the radio event starts. The nACTIVE
vcoubard 1048:efb29faf12fc 888 * signal is sent at the end of the radio event. These signals can be used
rgrover1 753:0f60274cd3ad 889 * by the application programmer to synchronize application logic with radio
rgrover1 753:0f60274cd3ad 890 * activity. For example, the ACTIVE signal can be used to shut off external
vcoubard 1048:efb29faf12fc 891 * devices, to manage peak current drawn during periods when the radio is on,
rgrover1 753:0f60274cd3ad 892 * or to trigger sensor data collection for transmission in the Radio Event.
rgrover1 753:0f60274cd3ad 893 *
rgrover1 753:0f60274cd3ad 894 * @return BLE_ERROR_NONE on successful initialization, otherwise an error code.
rgrover1 753:0f60274cd3ad 895 */
rgrover1 753:0f60274cd3ad 896 virtual ble_error_t initRadioNotification(void) {
rgrover1 753:0f60274cd3ad 897 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
rgrover1 753:0f60274cd3ad 898 }
rgrover1 753:0f60274cd3ad 899
rgrover1 710:b2e1a2660ec2 900 private:
rgrover1 710:b2e1a2660ec2 901 ble_error_t setAdvertisingData(void) {
rgrover1 710:b2e1a2660ec2 902 return setAdvertisingData(_advPayload, _scanResponse);
rgrover1 710:b2e1a2660ec2 903 }
rgrover1 710:b2e1a2660ec2 904
rgrover1 710:b2e1a2660ec2 905 private:
rgrover1 896:791741895cd8 906 virtual ble_error_t setAdvertisingData(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse) = 0;
rgrover1 896:791741895cd8 907 virtual ble_error_t startAdvertising(const GapAdvertisingParams &) = 0;
rgrover1 710:b2e1a2660ec2 908
rgrover1 710:b2e1a2660ec2 909 public:
rgrover1 710:b2e1a2660ec2 910 /**
rgrover1 710:b2e1a2660ec2 911 * Accessors to read back currently active advertising params.
rgrover1 710:b2e1a2660ec2 912 */
rgrover1 710:b2e1a2660ec2 913 GapAdvertisingParams &getAdvertisingParams(void) {
rgrover1 710:b2e1a2660ec2 914 return _advParams;
rgrover1 710:b2e1a2660ec2 915 }
rgrover1 710:b2e1a2660ec2 916 const GapAdvertisingParams &getAdvertisingParams(void) const {
rgrover1 710:b2e1a2660ec2 917 return _advParams;
rgrover1 710:b2e1a2660ec2 918 }
rgrover1 710:b2e1a2660ec2 919
rgrover1 710:b2e1a2660ec2 920 /**
vcoubard 1048:efb29faf12fc 921 * Set up a particular, user-constructed set of advertisement parameters for
rgrover1 710:b2e1a2660ec2 922 * the underlying stack. It would be uncommon for this API to be used
rgrover1 710:b2e1a2660ec2 923 * directly; there are other APIs to tweak advertisement parameters
rgrover1 710:b2e1a2660ec2 924 * individually.
rgrover1 710:b2e1a2660ec2 925 */
rgrover1 710:b2e1a2660ec2 926 void setAdvertisingParams(const GapAdvertisingParams &newParams) {
rgrover1 710:b2e1a2660ec2 927 _advParams = newParams;
rgrover1 710:b2e1a2660ec2 928 }
rgrover1 710:b2e1a2660ec2 929
rgrover1 710:b2e1a2660ec2 930 /* Event callback handlers. */
rgrover1 710:b2e1a2660ec2 931 public:
rgrover1 710:b2e1a2660ec2 932 /**
vcoubard 1048:efb29faf12fc 933 * Set up a callback for timeout events. Refer to TimeoutSource_t for
rgrover1 710:b2e1a2660ec2 934 * possible event types.
vcoubard 1052:b55e1ad3e1b3 935 * @note It is possible to unregister callbacks using onTimeout().detach(callback)
rgrover1 710:b2e1a2660ec2 936 */
vcoubard 1052:b55e1ad3e1b3 937 void onTimeout(TimeoutEventCallback_t callback) {
vcoubard 1052:b55e1ad3e1b3 938 timeoutCallbackChain.add(callback);
vcoubard 1052:b55e1ad3e1b3 939 }
vcoubard 1052:b55e1ad3e1b3 940
vcoubard 1052:b55e1ad3e1b3 941 /**
vcoubard 1052:b55e1ad3e1b3 942 * @brief provide access to the callchain of timeout event callbacks
vcoubard 1052:b55e1ad3e1b3 943 * It is possible to register callbacks using onTimeout().add(callback);
vcoubard 1054:f59e5d9a992a 944 * It is possible to unregister callbacks using onTimeout().detach(callback)
vcoubard 1052:b55e1ad3e1b3 945 * @return The timeout event callbacks chain
vcoubard 1052:b55e1ad3e1b3 946 */
vcoubard 1052:b55e1ad3e1b3 947 TimeoutEventCallbackChain_t& onTimeout() {
vcoubard 1052:b55e1ad3e1b3 948 return timeoutCallbackChain;
vcoubard 1052:b55e1ad3e1b3 949 }
rgrover1 710:b2e1a2660ec2 950
rgrover1 710:b2e1a2660ec2 951 /**
rgrover1 829:9072de50087b 952 * Append to a chain of callbacks to be invoked upon GAP connection.
vcoubard 1052:b55e1ad3e1b3 953 * @note It is possible to unregister callbacks using onConnection().detach(callback)
rgrover1 710:b2e1a2660ec2 954 */
rgrover1 829:9072de50087b 955 void onConnection(ConnectionEventCallback_t callback) {connectionCallChain.add(callback);}
rgrover1 710:b2e1a2660ec2 956
rgrover1 829:9072de50087b 957 template<typename T>
rgrover1 829:9072de50087b 958 void onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t*)) {connectionCallChain.add(tptr, mptr);}
rgrover1 710:b2e1a2660ec2 959
rgrover1 710:b2e1a2660ec2 960 /**
vcoubard 1052:b55e1ad3e1b3 961 * @brief provide access to the callchain of connection event callbacks
vcoubard 1052:b55e1ad3e1b3 962 * It is possible to register callbacks using onConnection().add(callback);
vcoubard 1054:f59e5d9a992a 963 * It is possible to unregister callbacks using onConnection().detach(callback)
vcoubard 1052:b55e1ad3e1b3 964 * @return The connection event callbacks chain
vcoubard 1052:b55e1ad3e1b3 965 */
vcoubard 1054:f59e5d9a992a 966 ConnectionEventCallbackChain_t& onConnection() {
vcoubard 1052:b55e1ad3e1b3 967 return connectionCallChain;
vcoubard 1052:b55e1ad3e1b3 968 }
vcoubard 1052:b55e1ad3e1b3 969
vcoubard 1052:b55e1ad3e1b3 970 /**
rgrover1 829:9072de50087b 971 * Append to a chain of callbacks to be invoked upon GAP disconnection.
vcoubard 1052:b55e1ad3e1b3 972 * @note It is possible to unregister callbacks using onDisconnection().detach(callback)
rgrover1 816:2b4f0ef8c06e 973 */
rgrover1 829:9072de50087b 974 void onDisconnection(DisconnectionEventCallback_t callback) {disconnectionCallChain.add(callback);}
rgrover1 816:2b4f0ef8c06e 975
rgrover1 710:b2e1a2660ec2 976 template<typename T>
rgrover1 829:9072de50087b 977 void onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t*)) {disconnectionCallChain.add(tptr, mptr);}
rgrover1 710:b2e1a2660ec2 978
rgrover1 710:b2e1a2660ec2 979 /**
vcoubard 1052:b55e1ad3e1b3 980 * @brief provide access to the callchain of disconnection event callbacks
vcoubard 1052:b55e1ad3e1b3 981 * It is possible to register callbacks using onDisconnection().add(callback);
vcoubard 1054:f59e5d9a992a 982 * It is possible to unregister callbacks using onDisconnection().detach(callback)
vcoubard 1052:b55e1ad3e1b3 983 * @return The disconnection event callbacks chain
vcoubard 1052:b55e1ad3e1b3 984 */
vcoubard 1052:b55e1ad3e1b3 985 DisconnectionEventCallbackChain_t& onDisconnection() {
vcoubard 1052:b55e1ad3e1b3 986 return disconnectionCallChain;
vcoubard 1052:b55e1ad3e1b3 987 }
vcoubard 1052:b55e1ad3e1b3 988
vcoubard 1052:b55e1ad3e1b3 989 /**
rgrover1 710:b2e1a2660ec2 990 * Set the application callback for radio-notification events.
rgrover1 710:b2e1a2660ec2 991 *
rgrover1 710:b2e1a2660ec2 992 * Radio Notification is a feature that enables ACTIVE and INACTIVE
rgrover1 710:b2e1a2660ec2 993 * (nACTIVE) signals from the stack that notify the application when the
rgrover1 753:0f60274cd3ad 994 * radio is in use.
rgrover1 710:b2e1a2660ec2 995 *
vcoubard 1048:efb29faf12fc 996 * The ACTIVE signal is sent before the radio event starts. The nACTIVE
vcoubard 1048:efb29faf12fc 997 * signal is sent at the end of the radio event. These signals can be used
rgrover1 710:b2e1a2660ec2 998 * by the application programmer to synchronize application logic with radio
rgrover1 710:b2e1a2660ec2 999 * activity. For example, the ACTIVE signal can be used to shut off external
vcoubard 1048:efb29faf12fc 1000 * devices, to manage peak current drawn during periods when the radio is on,
rgrover1 710:b2e1a2660ec2 1001 * or to trigger sensor data collection for transmission in the Radio Event.
rgrover1 710:b2e1a2660ec2 1002 *
rgrover1 710:b2e1a2660ec2 1003 * @param callback
rgrover1 710:b2e1a2660ec2 1004 * The application handler to be invoked in response to a radio
rgrover1 710:b2e1a2660ec2 1005 * ACTIVE/INACTIVE event.
rgrover1 754:9b391fb5c5d7 1006 *
vcoubard 1048:efb29faf12fc 1007 * Or in the other version:
rgrover1 754:9b391fb5c5d7 1008 *
rgrover1 754:9b391fb5c5d7 1009 * @param tptr
rgrover1 754:9b391fb5c5d7 1010 * Pointer to the object of a class defining the member callback
rgrover1 754:9b391fb5c5d7 1011 * function (mptr).
rgrover1 754:9b391fb5c5d7 1012 * @param mptr
rgrover1 754:9b391fb5c5d7 1013 * The member callback (within the context of an object) to be
rgrover1 754:9b391fb5c5d7 1014 * invoked in response to a radio ACTIVE/INACTIVE event.
rgrover1 710:b2e1a2660ec2 1015 */
rgrover1 753:0f60274cd3ad 1016 void onRadioNotification(void (*callback)(bool param)) {
rgrover1 753:0f60274cd3ad 1017 radioNotificationCallback.attach(callback);
rgrover1 753:0f60274cd3ad 1018 }
rgrover1 753:0f60274cd3ad 1019 template <typename T>
rgrover1 753:0f60274cd3ad 1020 void onRadioNotification(T *tptr, void (T::*mptr)(bool)) {
rgrover1 753:0f60274cd3ad 1021 radioNotificationCallback.attach(tptr, mptr);
rgrover1 753:0f60274cd3ad 1022 }
rgrover1 710:b2e1a2660ec2 1023
vcoubard 1090:148d8b9b56a5 1024 /**
vcoubard 1090:148d8b9b56a5 1025 * Setup a callback to be invoked to notify the user application that the
vcoubard 1090:148d8b9b56a5 1026 * Gap instance is about to shutdown (possibly as a result of a call
vcoubard 1090:148d8b9b56a5 1027 * to BLE::shutdown()).
vcoubard 1090:148d8b9b56a5 1028 *
vcoubard 1090:148d8b9b56a5 1029 * @Note: It is possible to chain together multiple onShutdown callbacks
vcoubard 1090:148d8b9b56a5 1030 * (potentially from different modules of an application) to be notified
vcoubard 1090:148d8b9b56a5 1031 * before the Gap instance is shutdown.
vcoubard 1090:148d8b9b56a5 1032 *
vcoubard 1090:148d8b9b56a5 1033 * @Note: It is also possible to set up a callback into a member function of
vcoubard 1090:148d8b9b56a5 1034 * some object.
vcoubard 1090:148d8b9b56a5 1035 *
vcoubard 1090:148d8b9b56a5 1036 * @Note It is possible to unregister a callback using onShutdown().detach(callback)
vcoubard 1090:148d8b9b56a5 1037 */
vcoubard 1090:148d8b9b56a5 1038 void onShutdown(const GapShutdownCallback_t& callback) {
vcoubard 1090:148d8b9b56a5 1039 shutdownCallChain.add(callback);
vcoubard 1090:148d8b9b56a5 1040 }
vcoubard 1090:148d8b9b56a5 1041 template <typename T>
vcoubard 1090:148d8b9b56a5 1042 void onShutdown(T *objPtr, void (T::*memberPtr)(void)) {
vcoubard 1090:148d8b9b56a5 1043 shutdownCallChain.add(objPtr, memberPtr);
vcoubard 1090:148d8b9b56a5 1044 }
vcoubard 1090:148d8b9b56a5 1045
vcoubard 1090:148d8b9b56a5 1046 /**
vcoubard 1090:148d8b9b56a5 1047 * @brief provide access to the callchain of shutdown event callbacks
vcoubard 1090:148d8b9b56a5 1048 * It is possible to register callbacks using onShutdown().add(callback);
vcoubard 1090:148d8b9b56a5 1049 * It is possible to unregister callbacks using onShutdown().detach(callback)
vcoubard 1090:148d8b9b56a5 1050 * @return The shutdown event callbacks chain
vcoubard 1090:148d8b9b56a5 1051 */
vcoubard 1090:148d8b9b56a5 1052 GapShutdownCallbackChain_t& onShutdown() {
vcoubard 1090:148d8b9b56a5 1053 return shutdownCallChain;
vcoubard 1090:148d8b9b56a5 1054 }
vcoubard 1090:148d8b9b56a5 1055
vcoubard 1082:127667021827 1056 public:
vcoubard 1082:127667021827 1057 /**
vcoubard 1090:148d8b9b56a5 1058 * Notify all registered onShutdown callbacks that the Gap instance is
vcoubard 1090:148d8b9b56a5 1059 * about to be shutdown and clear all Gap state of the
vcoubard 1090:148d8b9b56a5 1060 * associated object.
vcoubard 1082:127667021827 1061 *
vcoubard 1082:127667021827 1062 * This function is meant to be overridden in the platform-specific
vcoubard 1082:127667021827 1063 * sub-class. Nevertheless, the sub-class is only expected to reset its
vcoubard 1082:127667021827 1064 * state and not the data held in Gap members. This shall be achieved by a
vcoubard 1082:127667021827 1065 * call to Gap::reset() from the sub-class' reset() implementation.
vcoubard 1082:127667021827 1066 *
vcoubard 1082:127667021827 1067 * @return BLE_ERROR_NONE on success.
vcoubard 1082:127667021827 1068 *
vcoubard 1082:127667021827 1069 * @note: Currently a call to reset() does not reset the advertising and
vcoubard 1082:127667021827 1070 * scan parameters to default values.
vcoubard 1082:127667021827 1071 */
vcoubard 1082:127667021827 1072 virtual ble_error_t reset(void) {
vcoubard 1090:148d8b9b56a5 1073 /* Notify that the instance is about to shutdown */
vcoubard 1090:148d8b9b56a5 1074 shutdownCallChain.call(this);
vcoubard 1090:148d8b9b56a5 1075 shutdownCallChain.clear();
vcoubard 1090:148d8b9b56a5 1076
vcoubard 1082:127667021827 1077 /* Clear Gap state */
vcoubard 1082:127667021827 1078 state.advertising = 0;
vcoubard 1084:40c1e518d6de 1079 state.connected = 0;
vcoubard 1082:127667021827 1080
vcoubard 1082:127667021827 1081 /* Clear scanning state */
vcoubard 1082:127667021827 1082 scanningActive = false;
vcoubard 1082:127667021827 1083
vcoubard 1082:127667021827 1084 /* Clear advertising and scanning data */
vcoubard 1082:127667021827 1085 _advPayload.clear();
vcoubard 1082:127667021827 1086 _scanResponse.clear();
vcoubard 1082:127667021827 1087
vcoubard 1082:127667021827 1088 /* Clear callbacks */
vcoubard 1082:127667021827 1089 timeoutCallbackChain.clear();
vcoubard 1082:127667021827 1090 connectionCallChain.clear();
vcoubard 1082:127667021827 1091 disconnectionCallChain.clear();
vcoubard 1082:127667021827 1092 radioNotificationCallback = NULL;
vcoubard 1084:40c1e518d6de 1093 onAdvertisementReport = NULL;
vcoubard 1082:127667021827 1094
vcoubard 1082:127667021827 1095 return BLE_ERROR_NONE;
vcoubard 1082:127667021827 1096 }
vcoubard 1082:127667021827 1097
rgrover1 710:b2e1a2660ec2 1098 protected:
rgrover1 710:b2e1a2660ec2 1099 Gap() :
rgrover1 710:b2e1a2660ec2 1100 _advParams(),
rgrover1 710:b2e1a2660ec2 1101 _advPayload(),
rgrover1 710:b2e1a2660ec2 1102 _scanningParams(),
rgrover1 710:b2e1a2660ec2 1103 _scanResponse(),
rgrover1 710:b2e1a2660ec2 1104 state(),
rgrover1 770:079b714e9c1a 1105 scanningActive(false),
vcoubard 1052:b55e1ad3e1b3 1106 timeoutCallbackChain(),
rgrover1 710:b2e1a2660ec2 1107 radioNotificationCallback(),
rgrover1 710:b2e1a2660ec2 1108 onAdvertisementReport(),
rgrover1 816:2b4f0ef8c06e 1109 connectionCallChain(),
rgrover1 710:b2e1a2660ec2 1110 disconnectionCallChain() {
rgrover1 710:b2e1a2660ec2 1111 _advPayload.clear();
rgrover1 710:b2e1a2660ec2 1112 _scanResponse.clear();
rgrover1 710:b2e1a2660ec2 1113 }
rgrover1 710:b2e1a2660ec2 1114
rgrover1 710:b2e1a2660ec2 1115 /* Entry points for the underlying stack to report events back to the user. */
rgrover1 710:b2e1a2660ec2 1116 public:
vcoubard 1079:6e2d9514f3df 1117 void processConnectionEvent(Handle_t handle,
vcoubard 1079:6e2d9514f3df 1118 Role_t role,
vcoubard 1079:6e2d9514f3df 1119 BLEProtocol::AddressType_t peerAddrType,
vcoubard 1079:6e2d9514f3df 1120 const BLEProtocol::Address_t peerAddr,
vcoubard 1079:6e2d9514f3df 1121 BLEProtocol::AddressType_t ownAddrType,
vcoubard 1079:6e2d9514f3df 1122 const BLEProtocol::Address_t ownAddr,
vcoubard 1079:6e2d9514f3df 1123 const ConnectionParams_t *connectionParams) {
rgrover1 710:b2e1a2660ec2 1124 state.connected = 1;
rgrover1 829:9072de50087b 1125 ConnectionCallbackParams_t callbackParams(handle, role, peerAddrType, peerAddr, ownAddrType, ownAddr, connectionParams);
rgrover1 829:9072de50087b 1126 connectionCallChain.call(&callbackParams);
rgrover1 710:b2e1a2660ec2 1127 }
rgrover1 710:b2e1a2660ec2 1128
rgrover1 710:b2e1a2660ec2 1129 void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason) {
rgrover1 710:b2e1a2660ec2 1130 state.connected = 0;
rgrover1 829:9072de50087b 1131 DisconnectionCallbackParams_t callbackParams(handle, reason);
rgrover1 829:9072de50087b 1132 disconnectionCallChain.call(&callbackParams);
rgrover1 710:b2e1a2660ec2 1133 }
rgrover1 710:b2e1a2660ec2 1134
vcoubard 1079:6e2d9514f3df 1135 void processAdvertisementReport(const BLEProtocol::Address_t peerAddr,
vcoubard 1079:6e2d9514f3df 1136 int8_t rssi,
vcoubard 1079:6e2d9514f3df 1137 bool isScanResponse,
rgrover1 710:b2e1a2660ec2 1138 GapAdvertisingParams::AdvertisingType_t type,
vcoubard 1079:6e2d9514f3df 1139 uint8_t advertisingDataLen,
vcoubard 1079:6e2d9514f3df 1140 const uint8_t *advertisingData) {
rgrover1 710:b2e1a2660ec2 1141 AdvertisementCallbackParams_t params;
rgrover1 710:b2e1a2660ec2 1142 memcpy(params.peerAddr, peerAddr, ADDR_LEN);
rgrover1 710:b2e1a2660ec2 1143 params.rssi = rssi;
rgrover1 710:b2e1a2660ec2 1144 params.isScanResponse = isScanResponse;
rgrover1 710:b2e1a2660ec2 1145 params.type = type;
rgrover1 710:b2e1a2660ec2 1146 params.advertisingDataLen = advertisingDataLen;
rgrover1 710:b2e1a2660ec2 1147 params.advertisingData = advertisingData;
rgrover1 710:b2e1a2660ec2 1148 onAdvertisementReport.call(&params);
rgrover1 710:b2e1a2660ec2 1149 }
rgrover1 710:b2e1a2660ec2 1150
rgrover1 710:b2e1a2660ec2 1151 void processTimeoutEvent(TimeoutSource_t source) {
vcoubard 1052:b55e1ad3e1b3 1152 if (timeoutCallbackChain) {
vcoubard 1052:b55e1ad3e1b3 1153 timeoutCallbackChain(source);
rgrover1 710:b2e1a2660ec2 1154 }
rgrover1 710:b2e1a2660ec2 1155 }
rgrover1 710:b2e1a2660ec2 1156
rgrover1 710:b2e1a2660ec2 1157 protected:
rgrover1 710:b2e1a2660ec2 1158 GapAdvertisingParams _advParams;
rgrover1 710:b2e1a2660ec2 1159 GapAdvertisingData _advPayload;
rgrover1 710:b2e1a2660ec2 1160 GapScanningParams _scanningParams;
rgrover1 710:b2e1a2660ec2 1161 GapAdvertisingData _scanResponse;
rgrover1 710:b2e1a2660ec2 1162
rgrover1 710:b2e1a2660ec2 1163 GapState_t state;
rgrover1 770:079b714e9c1a 1164 bool scanningActive;
rgrover1 710:b2e1a2660ec2 1165
rgrover1 710:b2e1a2660ec2 1166 protected:
vcoubard 1052:b55e1ad3e1b3 1167 TimeoutEventCallbackChain_t timeoutCallbackChain;
vcoubard 1052:b55e1ad3e1b3 1168 RadioNotificationEventCallback_t radioNotificationCallback;
vcoubard 1052:b55e1ad3e1b3 1169 AdvertisementReportCallback_t onAdvertisementReport;
vcoubard 1052:b55e1ad3e1b3 1170 ConnectionEventCallbackChain_t connectionCallChain;
vcoubard 1052:b55e1ad3e1b3 1171 DisconnectionEventCallbackChain_t disconnectionCallChain;
rgrover1 710:b2e1a2660ec2 1172
rgrover1 710:b2e1a2660ec2 1173 private:
vcoubard 1090:148d8b9b56a5 1174 GapShutdownCallbackChain_t shutdownCallChain;
vcoubard 1090:148d8b9b56a5 1175
vcoubard 1090:148d8b9b56a5 1176 private:
vcoubard 1048:efb29faf12fc 1177 /* Disallow copy and assignment. */
rgrover1 710:b2e1a2660ec2 1178 Gap(const Gap &);
rgrover1 710:b2e1a2660ec2 1179 Gap& operator=(const Gap &);
rgrover1 710:b2e1a2660ec2 1180 };
rgrover1 710:b2e1a2660ec2 1181
rgrover1 710:b2e1a2660ec2 1182 #endif // ifndef __GAP_H__