adaptation for book and plug demo
Fork of BLE_API by
Embed:
(wiki syntax)
Show/hide line numbers
Gap.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef __GAP_H__ 00018 #define __GAP_H__ 00019 00020 #include "ble/BLEProtocol.h" 00021 #include "GapAdvertisingData.h" 00022 #include "GapAdvertisingParams.h" 00023 #include "GapScanningParams.h" 00024 #include "GapEvents.h" 00025 #include "CallChainOfFunctionPointersWithContext.h" 00026 #include "FunctionPointerWithContext.h" 00027 #include "deprecate.h" 00028 00029 /* Forward declarations for classes that will only be used for pointers or references in the following. */ 00030 class GapAdvertisingParams; 00031 class GapScanningParams; 00032 class GapAdvertisingData; 00033 00034 class Gap { 00035 /* 00036 * DEPRECATION ALERT: all of the APIs in this `public` block are deprecated. 00037 * They have been relocated to the class BLEProtocol. 00038 */ 00039 public: 00040 /** 00041 * Address-type for BLEProtocol addresses. 00042 * 00043 * @deprecated Use BLEProtocol::AddressType_t instead. 00044 */ 00045 typedef BLEProtocol::AddressType_t AddressType_t; 00046 00047 /** 00048 * Address-type for BLEProtocol addresses. 00049 * 00050 * @deprecated Use BLEProtocol::AddressType_t instead. 00051 */ 00052 typedef BLEProtocol::AddressType_t addr_type_t; 00053 00054 /** 00055 * Address-type for BLEProtocol addresses. 00056 * 00057 * @deprecated Use BLEProtocol::AddressType_t instead. The following 00058 * constants have been left in their deprecated state to 00059 * transparenly support existing applications which may have 00060 * used Gap::ADDR_TYPE_*. 00061 */ 00062 enum DeprecatedAddressType_t { 00063 ADDR_TYPE_PUBLIC = BLEProtocol::AddressType::PUBLIC, 00064 ADDR_TYPE_RANDOM_STATIC = BLEProtocol::AddressType::RANDOM_STATIC, 00065 ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE, 00066 ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE 00067 }; 00068 00069 /** 00070 * Length (in octets) of the BLE MAC address. 00071 */ 00072 static const unsigned ADDR_LEN = BLEProtocol::ADDR_LEN; 00073 /** 00074 * 48-bit address, LSB format. 00075 * 00076 * @deprecated Use BLEProtocol::AddressBytes_t instead. 00077 */ 00078 typedef BLEProtocol::AddressBytes_t Address_t; 00079 /** 00080 * 48-bit address, LSB format. 00081 * 00082 * @deprecated Use BLEProtocol::AddressBytes_t instead. 00083 */ 00084 typedef BLEProtocol::AddressBytes_t address_t; 00085 00086 public: 00087 /** 00088 * Enumeration for timeout sources. 00089 */ 00090 enum TimeoutSource_t { 00091 TIMEOUT_SRC_ADVERTISING = 0x00, /**< Advertising timeout. */ 00092 TIMEOUT_SRC_SECURITY_REQUEST = 0x01, /**< Security request timeout. */ 00093 TIMEOUT_SRC_SCAN = 0x02, /**< Scanning timeout. */ 00094 TIMEOUT_SRC_CONN = 0x03, /**< Connection timeout. */ 00095 }; 00096 00097 /** 00098 * Enumeration for disconnection reasons. The values for these reasons are 00099 * derived from Nordic's implementation, but the reasons are meant to be 00100 * independent of the transport. If you are returned a reason that is not 00101 * covered by this enumeration, please refer to the underlying 00102 * transport library. 00103 */ 00104 enum DisconnectionReason_t { 00105 CONNECTION_TIMEOUT = 0x08, 00106 REMOTE_USER_TERMINATED_CONNECTION = 0x13, 00107 REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14, /**< Remote device terminated connection due to low resources.*/ 00108 REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15, /**< Remote device terminated connection due to power off. */ 00109 LOCAL_HOST_TERMINATED_CONNECTION = 0x16, 00110 CONN_INTERVAL_UNACCEPTABLE = 0x3B, 00111 }; 00112 00113 /** 00114 * Enumeration for whitelist advertising policy filter modes. The possible 00115 * filter modes were obtained from the Bluetooth Core Specification 00116 * 4.2 (Vol. 6), Part B, Section 4.3.2. 00117 * 00118 * @experimental 00119 */ 00120 enum AdvertisingPolicyMode_t { 00121 ADV_POLICY_IGNORE_WHITELIST = 0, 00122 ADV_POLICY_FILTER_SCAN_REQS = 1, 00123 ADV_POLICY_FILTER_CONN_REQS = 2, 00124 ADV_POLICY_FILTER_ALL_REQS = 3, 00125 }; 00126 00127 /** 00128 * Enumeration for whitelist scanning policy filter modes. The possible 00129 * filter modes were obtained from the Bluetooth Core Specification 00130 * 4.2 (Vol. 6), Part B, Section 4.3.3. 00131 * 00132 * @experimental 00133 */ 00134 enum ScanningPolicyMode_t { 00135 SCAN_POLICY_IGNORE_WHITELIST = 0, 00136 SCAN_POLICY_FILTER_ALL_ADV = 1, 00137 }; 00138 00139 /** 00140 * Enumeration for the whitelist initiator policy fiter modes. The possible 00141 * filter modes were obtained from the Bluetooth Core Specification 00142 * 4.2 (vol. 6), Part B, Section 4.4.4. 00143 * 00144 * @experimental 00145 */ 00146 enum InitiatorPolicyMode_t { 00147 INIT_POLICY_IGNORE_WHITELIST = 0, 00148 INIT_POLICY_FILTER_ALL_ADV = 1, 00149 }; 00150 00151 /** 00152 * Representation of a Bluetooth Low Enery Whitelist containing addresses. 00153 * 00154 * @experimental 00155 */ 00156 struct Whitelist_t { 00157 BLEProtocol::Address_t *addresses; /**< List of BLE addresses in the whitelist. */ 00158 uint8_t size; /**< Total number of BLE addresses in this whitelist */ 00159 uint8_t capacity; /**< Maximum number of BLE addresses that can be added to this whitelist. */ 00160 }; 00161 00162 00163 /** 00164 * Describes the current state of the device (more than one bit can be set). 00165 */ 00166 struct GapState_t { 00167 unsigned advertising : 1; /**< Peripheral is currently advertising. */ 00168 unsigned connected : 1; /**< Peripheral is connected to a central. */ 00169 }; 00170 00171 /** 00172 * Type for connection handle. 00173 */ 00174 typedef uint16_t Handle_t; 00175 00176 /** 00177 * Structure containing GAP connection parameters. When in peripheral role 00178 * the connection parameters are suggestions. The choice of the connection 00179 * parameters is eventually up to the central. 00180 */ 00181 typedef struct { 00182 uint16_t minConnectionInterval; /**< Minimum Connection Interval in 1.25 ms units, see BLE_GAP_CP_LIMITS.*/ 00183 uint16_t maxConnectionInterval; /**< Maximum Connection Interval in 1.25 ms units, see BLE_GAP_CP_LIMITS.*/ 00184 uint16_t slaveLatency; /**< Slave Latency in number of connection events, see BLE_GAP_CP_LIMITS.*/ 00185 uint16_t connectionSupervisionTimeout; /**< Connection Supervision Timeout in 10 ms units, see BLE_GAP_CP_LIMITS.*/ 00186 } ConnectionParams_t; 00187 00188 /** 00189 * Enumeration for the possible GAP roles of a BLE device. 00190 */ 00191 enum Role_t { 00192 PERIPHERAL = 0x1, /**< Peripheral Role. */ 00193 CENTRAL = 0x2, /**< Central Role. */ 00194 }; 00195 00196 /** 00197 * Structure containing data and metadata of a scanned advertising packet. 00198 */ 00199 struct AdvertisementCallbackParams_t { 00200 BLEProtocol::AddressBytes_t peerAddr; /**< The peer's BLE address. */ 00201 int8_t rssi; /**< The advertisement packet RSSI value. */ 00202 bool isScanResponse; /**< Whether this packet is the response to a scan request. */ 00203 GapAdvertisingParams::AdvertisingType_t type; /**< The type of advertisement. */ 00204 uint8_t advertisingDataLen; /**< Length of the advertisement data. */ 00205 const uint8_t *advertisingData; /**< Pointer to the advertisement packet's data. */ 00206 }; 00207 00208 /** 00209 * Type for the handlers of advertisement callback events. Refer to 00210 * Gap::startScan(). 00211 */ 00212 typedef FunctionPointerWithContext<const AdvertisementCallbackParams_t *> AdvertisementReportCallback_t; 00213 00214 /** 00215 * Encapsulates the parameters of a connection. This information is passed 00216 * to the registered handler of connection events. Refer to Gap::onConnection(). 00217 */ 00218 struct ConnectionCallbackParams_t { 00219 Handle_t handle; /**< The ID for this connection */ 00220 Role_t role; /**< This device's role in the connection */ 00221 BLEProtocol::AddressType_t peerAddrType; /**< The peer's BLE address type */ 00222 BLEProtocol::AddressBytes_t peerAddr; /**< The peer's BLE address */ 00223 BLEProtocol::AddressType_t ownAddrType; /**< This device's BLE address type */ 00224 BLEProtocol::AddressBytes_t ownAddr; /**< This devices's BLE address */ 00225 const ConnectionParams_t *connectionParams; /**< The currently configured connection parameters */ 00226 00227 /** 00228 * Constructor for ConnectionCallbackParams_t. 00229 * 00230 * @param[in] handleIn 00231 * Value for ConnectionCallbackParams_t::handle 00232 * @param[in] roleIn 00233 * Value for ConnectionCallbackParams_t::role 00234 * @param[in] peerAddrTypeIn 00235 * Value for ConnectionCallbackParams_t::peerAddrType 00236 * @param[in] peerAddrIn 00237 * Value for ConnectionCallbackParams_t::peerAddr 00238 * @param[in] ownAddrTypeIn 00239 * Value for ConnectionCallbackParams_t::ownAddrType 00240 * @param[in] ownAddrIn 00241 * Value for ConnectionCallbackParams_t::ownAddr 00242 * @param[in] connectionParamsIn 00243 * Value for ConnectionCallbackParams_t::connectionParams 00244 */ 00245 ConnectionCallbackParams_t(Handle_t handleIn, 00246 Role_t roleIn, 00247 BLEProtocol::AddressType_t peerAddrTypeIn, 00248 const uint8_t *peerAddrIn, 00249 BLEProtocol::AddressType_t ownAddrTypeIn, 00250 const uint8_t *ownAddrIn, 00251 const ConnectionParams_t *connectionParamsIn) : 00252 handle(handleIn), 00253 role(roleIn), 00254 peerAddrType(peerAddrTypeIn), 00255 peerAddr(), 00256 ownAddrType(ownAddrTypeIn), 00257 ownAddr(), 00258 connectionParams(connectionParamsIn) { 00259 memcpy(peerAddr, peerAddrIn, ADDR_LEN); 00260 memcpy(ownAddr, ownAddrIn, ADDR_LEN); 00261 } 00262 }; 00263 00264 /** 00265 * Structure that encapsulates information about a disconnection event. 00266 * Refer to Gap::onDisconnection(). 00267 */ 00268 struct DisconnectionCallbackParams_t { 00269 Handle_t handle; /**< The ID of the connection that caused the disconnection event */ 00270 DisconnectionReason_t reason; /**< The reason of the disconnection event */ 00271 00272 /** 00273 * Constructor for DisconnectionCallbackParams_t. 00274 * 00275 * @param[in] handleIn 00276 * Value for DisconnectionCallbackParams_t::handle. 00277 * @param[in] reasonIn 00278 * Value for DisconnectionCallbackParams_t::reason. 00279 */ 00280 DisconnectionCallbackParams_t(Handle_t handleIn, 00281 DisconnectionReason_t reasonIn) : 00282 handle(handleIn), 00283 reason(reasonIn) 00284 {} 00285 }; 00286 00287 static const uint16_t UNIT_1_25_MS = 1250; /**< Number of microseconds in 1.25 milliseconds. */ 00288 /** 00289 * Helper function to convert from units of milliseconds to GAP duration 00290 * units. 00291 * 00292 * @param[in] durationInMillis 00293 * The duration in milliseconds. 00294 * 00295 * @return The duration in GAP duration units. 00296 */ 00297 static uint16_t MSEC_TO_GAP_DURATION_UNITS(uint32_t durationInMillis) { 00298 return (durationInMillis * 1000) / UNIT_1_25_MS; 00299 } 00300 00301 /** 00302 * Type for the registered callbacks added to the timeout event callchain. 00303 * Refer to Gap::onTimeout(). 00304 */ 00305 typedef FunctionPointerWithContext<TimeoutSource_t> TimeoutEventCallback_t; 00306 /** 00307 * Type for the timeout event callchain. Refer to Gap::onTimeout(). 00308 */ 00309 typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t> TimeoutEventCallbackChain_t; 00310 00311 /** 00312 * Type for the registered callbacks added to the connection event 00313 * callchain. Refer to Gap::onConnection(). 00314 */ 00315 typedef FunctionPointerWithContext<const ConnectionCallbackParams_t *> ConnectionEventCallback_t; 00316 /** 00317 * Type for the connection event callchain. Refer to Gap::onConnection(). 00318 */ 00319 typedef CallChainOfFunctionPointersWithContext<const ConnectionCallbackParams_t *> ConnectionEventCallbackChain_t; 00320 00321 /** 00322 * Type for the registered callbacks added to the disconnection event 00323 * callchain. Refer to Gap::onDisconnetion(). 00324 */ 00325 typedef FunctionPointerWithContext<const DisconnectionCallbackParams_t*> DisconnectionEventCallback_t; 00326 /** 00327 * Type for the disconnection event callchain. Refer to Gap::onDisconnection(). 00328 */ 00329 typedef CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t*> DisconnectionEventCallbackChain_t; 00330 00331 /** 00332 * Type for the handlers of radio notification callback events. Refer to 00333 * Gap::onRadioNotification(). 00334 */ 00335 typedef FunctionPointerWithContext<bool> RadioNotificationEventCallback_t; 00336 00337 /** 00338 * Type for the handlers of shutdown callback events. Refer to 00339 * Gap::onShutdown(). 00340 */ 00341 typedef FunctionPointerWithContext<const Gap *> GapShutdownCallback_t; 00342 /** 00343 * Type for the shutdown event callchain. Refer to Gap::onShutdown(). 00344 */ 00345 typedef CallChainOfFunctionPointersWithContext<const Gap *> GapShutdownCallbackChain_t; 00346 00347 /* 00348 * The following functions are meant to be overridden in the platform-specific sub-class. 00349 */ 00350 public: 00351 /** 00352 * Set the BTLE MAC address and type. Please note that the address format is 00353 * least significant byte first (LSB). Please refer to BLEProtocol::AddressBytes_t. 00354 * 00355 * @param[in] type 00356 * The type of the BLE address to set. 00357 * @param[in] address 00358 * The BLE address to set. 00359 * 00360 * @return BLE_ERROR_NONE on success. 00361 */ 00362 virtual ble_error_t setAddress(BLEProtocol::AddressType_t type, const BLEProtocol::AddressBytes_t address) { 00363 /* avoid compiler warnings about unused variables */ 00364 (void)type; 00365 (void)address; 00366 00367 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00368 } 00369 00370 /** 00371 * Fetch the BTLE MAC address and type. 00372 * 00373 * @param[out] typeP 00374 * The current BLE address type. 00375 * @param[out] address 00376 * The current BLE address. 00377 * 00378 * @return BLE_ERROR_NONE on success. 00379 */ 00380 virtual ble_error_t getAddress(BLEProtocol::AddressType_t *typeP, BLEProtocol::AddressBytes_t address) { 00381 /* Avoid compiler warnings about unused variables. */ 00382 (void)typeP; 00383 (void)address; 00384 00385 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00386 } 00387 00388 /** 00389 * Get the minimum advertising interval in milliseconds for connectable 00390 * undirected and connectable directed event types supported by the 00391 * underlying BLE stack. 00392 * 00393 * @return Minimum Advertising interval in milliseconds for connectable 00394 * undirected and connectable directed event types. 00395 */ 00396 virtual uint16_t getMinAdvertisingInterval(void) const { 00397 return 0; /* Requesting action from porter(s): override this API if this capability is supported. */ 00398 } 00399 00400 /** 00401 * Get the minimum advertising interval in milliseconds for scannable 00402 * undirected and non-connectable undirected even types supported by the 00403 * underlying BLE stack. 00404 * 00405 * @return Minimum Advertising interval in milliseconds for scannable 00406 * undirected and non-connectable undirected event types. 00407 */ 00408 virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const { 00409 return 0; /* Requesting action from porter(s): override this API if this capability is supported. */ 00410 } 00411 00412 /** 00413 * Get the maximum advertising interval in milliseconds for all event types 00414 * supported by the underlying BLE stack. 00415 * 00416 * @return Maximum Advertising interval in milliseconds. 00417 */ 00418 virtual uint16_t getMaxAdvertisingInterval(void) const { 00419 return 0xFFFF; /* Requesting action from porter(s): override this API if this capability is supported. */ 00420 } 00421 00422 /** 00423 * Stop advertising. The current advertising parameters remain in effect. 00424 * 00425 * @retval BLE_ERROR_NONE if successfully stopped advertising procedure. 00426 */ 00427 virtual ble_error_t stopAdvertising(void) { 00428 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00429 } 00430 00431 /** 00432 * Stop scanning. The current scanning parameters remain in effect. 00433 * 00434 * @retval BLE_ERROR_NONE if successfully stopped scanning procedure. 00435 */ 00436 virtual ble_error_t stopScan() { 00437 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00438 } 00439 00440 /** 00441 * Create a connection (GAP Link Establishment). 00442 * 00443 * @param[in] peerAddr 00444 * 48-bit address, LSB format. 00445 * @param[in] peerAddrType 00446 * Address type of the peer. 00447 * @param[in] connectionParams 00448 * Connection parameters. 00449 * @param[in] scanParams 00450 * Paramters to be used while scanning for the peer. 00451 * 00452 * @return BLE_ERROR_NONE if connection establishment procedure is started 00453 * successfully. The connectionCallChain (if set) will be invoked upon 00454 * a connection event. 00455 */ 00456 virtual ble_error_t connect(const BLEProtocol::AddressBytes_t peerAddr, 00457 BLEProtocol::AddressType_t peerAddrType, 00458 const ConnectionParams_t *connectionParams, 00459 const GapScanningParams *scanParams) { 00460 /* Avoid compiler warnings about unused variables. */ 00461 (void)peerAddr; 00462 (void)peerAddrType; 00463 (void)connectionParams; 00464 (void)scanParams; 00465 00466 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00467 } 00468 00469 /** 00470 * Create a connection (GAP Link Establishment). 00471 * 00472 * @deprecated This funtion overloads Gap::connect(const BLEProtocol::Address_t peerAddr, 00473 * BLEProtocol::AddressType_t peerAddrType, 00474 * const ConnectionParams_t *connectionParams, 00475 * const GapScanningParams *scanParams) 00476 * to maintain backward compatibility for change from Gap::AddressType_t to 00477 * BLEProtocol::AddressType_t. 00478 */ 00479 ble_error_t connect(const BLEProtocol::AddressBytes_t peerAddr, 00480 DeprecatedAddressType_t peerAddrType, 00481 const ConnectionParams_t *connectionParams, 00482 const GapScanningParams *scanParams) 00483 __deprecated_message("Gap::DeprecatedAddressType_t is deprecated, use BLEProtocol::AddressType_t instead") { 00484 return connect(peerAddr, (BLEProtocol::AddressType_t) peerAddrType, connectionParams, scanParams); 00485 } 00486 00487 /** 00488 * This call initiates the disconnection procedure, and its completion will 00489 * be communicated to the application with an invocation of the 00490 * disconnectionCallback. 00491 * 00492 * @param[in] reason 00493 * The reason for disconnection; to be sent back to the peer. 00494 * @param[in] connectionHandle 00495 * The handle of the connection to disconnect from. 00496 * 00497 * @return BLE_ERROR_NONE if disconnection was successful. 00498 */ 00499 virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason) { 00500 /* avoid compiler warnings about unused variables */ 00501 (void)connectionHandle; 00502 (void)reason; 00503 00504 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00505 } 00506 00507 /** 00508 * This call initiates the disconnection procedure, and its completion will 00509 * be communicated to the application with an invocation of the 00510 * disconnectionCallback. 00511 * 00512 * @param[in] reason 00513 * The reason for disconnection; to be sent back to the peer. 00514 * 00515 * @return BLE_ERROR_NONE if disconnection was successful. 00516 * 00517 * @deprecated This version of disconnect() doesn't take a connection handle. It 00518 * works reliably only for stacks that are limited to a single 00519 * connection. Use instead Gap::disconnect(Handle_t connectionHandle, 00520 * DisconnectionReason_t reason) instead. 00521 */ 00522 virtual ble_error_t disconnect(DisconnectionReason_t reason) { 00523 /* Avoid compiler warnings about unused variables. */ 00524 (void)reason; 00525 00526 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00527 } 00528 00529 /** 00530 * Get the GAP peripheral preferred connection parameters. These are the 00531 * defaults that the peripheral would like to have in a connection. The 00532 * choice of the connection parameters is eventually up to the central. 00533 * 00534 * @param[out] params 00535 * The structure where the parameters will be stored. Memory 00536 * for this is owned by the caller. 00537 * 00538 * @return BLE_ERROR_NONE if the parameters were successfully filled into 00539 * the given structure pointed to by params. 00540 */ 00541 virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params) { 00542 /* Avoid compiler warnings about unused variables. */ 00543 (void)params; 00544 00545 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00546 } 00547 00548 /** 00549 * Set the GAP peripheral preferred connection parameters. These are the 00550 * defaults that the peripheral would like to have in a connection. The 00551 * choice of the connection parameters is eventually up to the central. 00552 * 00553 * @param[in] params 00554 * The structure containing the desired parameters. 00555 * 00556 * @return BLE_ERROR_NONE if the preferred connection params were set 00557 * correctly. 00558 */ 00559 virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params) { 00560 /* Avoid compiler warnings about unused variables. */ 00561 (void)params; 00562 00563 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00564 } 00565 00566 /** 00567 * Update connection parameters. In the central role this will initiate a 00568 * Link Layer connection parameter update procedure. In the peripheral role, 00569 * this will send the corresponding L2CAP request and wait for the central 00570 * to perform the procedure. 00571 * 00572 * @param[in] handle 00573 * Connection Handle. 00574 * @param[in] params 00575 * Pointer to desired connection parameters. If NULL is provided on a peripheral role, 00576 * the parameters in the PPCP characteristic of the GAP service will be used instead. 00577 * 00578 * @return BLE_ERROR_NONE if the connection parameters were updated correctly. 00579 */ 00580 virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) { 00581 /* avoid compiler warnings about unused variables */ 00582 (void)handle; 00583 (void)params; 00584 00585 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00586 } 00587 00588 /** 00589 * Set the device name characteristic in the GAP service. 00590 * 00591 * @param[in] deviceName 00592 * The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string. 00593 * 00594 * @return BLE_ERROR_NONE if the device name was set correctly. 00595 */ 00596 virtual ble_error_t setDeviceName(const uint8_t *deviceName) { 00597 /* Avoid compiler warnings about unused variables. */ 00598 (void)deviceName; 00599 00600 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00601 } 00602 00603 /** 00604 * Get the value of the device name characteristic in the GAP service. 00605 * 00606 * @param[out] deviceName 00607 * Pointer to an empty buffer where the UTF-8 *non NULL- 00608 * terminated* string will be placed. Set this 00609 * value to NULL in order to obtain the deviceName-length 00610 * from the 'length' parameter. 00611 * 00612 * @param[in,out] lengthP 00613 * (on input) Length of the buffer pointed to by deviceName; 00614 * (on output) the complete device name length (without the 00615 * null terminator). 00616 * 00617 * @return BLE_ERROR_NONE if the device name was fetched correctly from the 00618 * underlying BLE stack. 00619 * 00620 * @note If the device name is longer than the size of the supplied buffer, 00621 * length will return the complete device name length, and not the 00622 * number of bytes actually returned in deviceName. The application may 00623 * use this information to retry with a suitable buffer size. 00624 */ 00625 virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) { 00626 /* avoid compiler warnings about unused variables */ 00627 (void)deviceName; 00628 (void)lengthP; 00629 00630 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00631 } 00632 00633 /** 00634 * Set the appearance characteristic in the GAP service. 00635 * 00636 * @param[in] appearance 00637 * The new value for the device-appearance. 00638 * 00639 * @return BLE_ERROR_NONE if the new appearance was set correctly. 00640 */ 00641 virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) { 00642 /* Avoid compiler warnings about unused variables. */ 00643 (void)appearance; 00644 00645 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00646 } 00647 00648 /** 00649 * Get the appearance characteristic in the GAP service. 00650 * 00651 * @param[out] appearance 00652 * The current device-appearance value. 00653 * 00654 * @return BLE_ERROR_NONE if the device-appearance was fetched correctly 00655 * from the underlying BLE stack. 00656 */ 00657 virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) { 00658 /* Avoid compiler warnings about unused variables. */ 00659 (void)appearanceP; 00660 00661 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00662 } 00663 00664 /** 00665 * Set the radio's transmit power. 00666 * 00667 * @param[in] txPower 00668 * Radio's transmit power in dBm. 00669 * 00670 * @return BLE_ERROR_NONE if the new radio's transmit power was set 00671 * correctly. 00672 */ 00673 virtual ble_error_t setTxPower(int8_t txPower) { 00674 /* Avoid compiler warnings about unused variables. */ 00675 (void)txPower; 00676 00677 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00678 } 00679 00680 /** 00681 * Query the underlying stack for permitted arguments for setTxPower(). 00682 * 00683 * @param[out] valueArrayPP 00684 * Out parameter to receive the immutable array of Tx values. 00685 * @param[out] countP 00686 * Out parameter to receive the array's size. 00687 */ 00688 virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) { 00689 /* Avoid compiler warnings about unused variables. */ 00690 (void)valueArrayPP; 00691 (void)countP; 00692 00693 *countP = 0; /* Requesting action from porter(s): override this API if this capability is supported. */ 00694 } 00695 00696 /** 00697 * Get the maximum size of the whitelist. 00698 * 00699 * @return Maximum size of the whitelist. 00700 * 00701 * @note If using mbed OS the size of the whitelist can be configured by 00702 * setting the YOTTA_CFG_WHITELIST_MAX_SIZE macro in your yotta 00703 * config file. 00704 * 00705 * @experimental 00706 */ 00707 virtual uint8_t getMaxWhitelistSize(void) const 00708 { 00709 return 0; 00710 } 00711 00712 /** 00713 * Get the internal whitelist to be used by the Link Layer when scanning, 00714 * advertising or initiating a connection depending on the filter policies. 00715 * 00716 * @param[in,out] whitelist 00717 * (on input) whitelist.capacity contains the maximum number 00718 * of addresses to be returned. 00719 * (on output) The populated whitelist with copies of the 00720 * addresses in the implementation's whitelist. 00721 * 00722 * @return BLE_ERROR_NONE if the implementation's whitelist was successfully 00723 * copied into the supplied reference. 00724 * 00725 * @experimental 00726 */ 00727 virtual ble_error_t getWhitelist(Whitelist_t &whitelist) const 00728 { 00729 (void) whitelist; 00730 return BLE_ERROR_NOT_IMPLEMENTED; 00731 } 00732 00733 /** 00734 * Set the internal whitelist to be used by the Link Layer when scanning, 00735 * advertising or initiating a connection depending on the filter policies. 00736 * 00737 * @param[in] whitelist 00738 * A reference to a whitelist containing the addresses to 00739 * be added to the internal whitelist. 00740 * 00741 * @return BLE_ERROR_NONE if the implementation's whitelist was successfully 00742 * populated with the addresses in the given whitelist. 00743 * 00744 * @note The whitelist must not contain addresses of type @ref 00745 * BLEProtocol::AddressType_t::RANDOM_PRIVATE_NON_RESOLVABLE, this 00746 * this will result in a @ref BLE_ERROR_INVALID_PARAM since the 00747 * remote peer might change its private address at any time and it 00748 * is not possible to resolve it. 00749 * @note If the input whitelist is larger than @ref getMaxWhitelistSize() 00750 * the @ref BLE_ERROR_PARAM_OUT_OF_RANGE is returned. 00751 * 00752 * @experimental 00753 */ 00754 virtual ble_error_t setWhitelist(const Whitelist_t &whitelist) 00755 { 00756 (void) whitelist; 00757 return BLE_ERROR_NOT_IMPLEMENTED; 00758 } 00759 00760 /** 00761 * Set the advertising policy filter mode to be used in the next call 00762 * to startAdvertising(). 00763 * 00764 * @param[in] mode 00765 * The new advertising policy filter mode. 00766 * 00767 * @return BLE_ERROR_NONE if the specified policy filter mode was set 00768 * successfully. 00769 * 00770 * @experimental 00771 */ 00772 virtual ble_error_t setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode) 00773 { 00774 (void) mode; 00775 return BLE_ERROR_NOT_IMPLEMENTED; 00776 } 00777 00778 /** 00779 * Set the scan policy filter mode to be used in the next call 00780 * to startScan(). 00781 * 00782 * @param[in] mode 00783 * The new scan policy filter mode. 00784 * 00785 * @return BLE_ERROR_NONE if the specified policy filter mode was set 00786 * successfully. 00787 * 00788 * @experimental 00789 */ 00790 virtual ble_error_t setScanningPolicyMode(ScanningPolicyMode_t mode) 00791 { 00792 (void) mode; 00793 return BLE_ERROR_NOT_IMPLEMENTED; 00794 } 00795 00796 /** 00797 * Set the initiator policy filter mode to be used. 00798 * 00799 * @param[in] mode 00800 * The new initiator policy filter mode. 00801 * 00802 * @return BLE_ERROR_NONE if the specified policy filter mode was set 00803 * successfully. 00804 * 00805 * @experimental 00806 */ 00807 virtual ble_error_t setInitiatorPolicyMode(InitiatorPolicyMode_t mode) 00808 { 00809 (void) mode; 00810 return BLE_ERROR_NOT_IMPLEMENTED; 00811 } 00812 00813 /** 00814 * Get the advertising policy filter mode that will be used in the next 00815 * call to startAdvertising(). 00816 * 00817 * @return The set advertising policy filter mode. 00818 * 00819 * @experimental 00820 */ 00821 virtual AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const 00822 { 00823 return ADV_POLICY_IGNORE_WHITELIST; 00824 } 00825 00826 /** 00827 * Get the scan policy filter mode that will be used in the next 00828 * call to startScan(). 00829 * 00830 * @return The set scan policy filter mode. 00831 * 00832 * @experimental 00833 */ 00834 virtual ScanningPolicyMode_t getScanningPolicyMode(void) const 00835 { 00836 return SCAN_POLICY_IGNORE_WHITELIST; 00837 } 00838 00839 /** 00840 * Get the initiator policy filter mode that will be used. 00841 * 00842 * @return The set scan policy filter mode. 00843 * 00844 * @experimental 00845 */ 00846 virtual InitiatorPolicyMode_t getInitiatorPolicyMode(void) const 00847 { 00848 return INIT_POLICY_IGNORE_WHITELIST; 00849 } 00850 00851 protected: 00852 /* Override the following in the underlying adaptation layer to provide the functionality of scanning. */ 00853 00854 /** 00855 * Start scanning procedure in the underlying BLE stack. 00856 * 00857 * @param[in] scanningParams 00858 * The GAP scanning parameters. 00859 * 00860 * @return BLE_ERROR_NONE if the scan procedure started successfully. 00861 */ 00862 virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams) { 00863 (void)scanningParams; 00864 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 00865 } 00866 00867 /* 00868 * APIs with non-virtual implementations. 00869 */ 00870 public: 00871 /** 00872 * Get the current GAP state of the device using a bitmask that 00873 * describes whether the device is advertising or connected. 00874 * 00875 * @return The current GAP state of the device. 00876 */ 00877 GapState_t getState(void) const { 00878 return state; 00879 } 00880 00881 /** 00882 * Set the GAP advertising mode to use for this device. 00883 * 00884 * @param[in] advType 00885 * The new type of the advertising packets. 00886 */ 00887 void setAdvertisingType(GapAdvertisingParams::AdvertisingType_t advType) { 00888 _advParams.setAdvertisingType(advType); 00889 } 00890 00891 /** 00892 * Set the advertising interval. 00893 * 00894 * @param[in] interval 00895 * Advertising interval in units of milliseconds. Advertising 00896 * is disabled if interval is 0. If interval is smaller than 00897 * the minimum supported value, then the minimum supported 00898 * value is used instead. This minimum value can be discovered 00899 * using getMinAdvertisingInterval(). 00900 * 00901 * This field must be set to 0 if connectionMode is equal 00902 * to ADV_CONNECTABLE_DIRECTED. 00903 * 00904 * @note Decreasing this value will allow central devices to detect a 00905 * peripheral faster, at the expense of more power being used by the radio 00906 * due to the higher data transmit rate. 00907 * 00908 * @note [WARNING] This API previously used 0.625ms as the unit for its 00909 * @p interval argument. That required an explicit conversion from 00910 * milliseconds using Gap::MSEC_TO_GAP_DURATION_UNITS(). This conversion is 00911 * no longer required as the new units are milliseconds. Any application 00912 * code depending on the old semantics needs to be updated accordingly. 00913 */ 00914 void setAdvertisingInterval(uint16_t interval) { 00915 if (interval == 0) { 00916 stopAdvertising(); 00917 } else if (interval < getMinAdvertisingInterval()) { 00918 interval = getMinAdvertisingInterval(); 00919 } 00920 _advParams.setInterval(interval); 00921 } 00922 00923 /** 00924 * Set the advertising timeout. The length of time to advertise for before 00925 * a timeout event is generated. 00926 * 00927 * @param[in] timeout 00928 * Advertising timeout (in seconds) between 0x1 and 0x3FFF (1 00929 * and 16383). Use 0 to disable the advertising timeout. 00930 */ 00931 void setAdvertisingTimeout(uint16_t timeout) { 00932 _advParams.setTimeout(timeout); 00933 } 00934 00935 /** 00936 * Start advertising. 00937 * 00938 * @return BLE_ERROR_NONE if the device started advertising successfully. 00939 */ 00940 ble_error_t startAdvertising(void) { 00941 ble_error_t rc; 00942 if ((rc = startAdvertising(_advParams)) == BLE_ERROR_NONE) { 00943 state.advertising = 1; 00944 } 00945 return rc; 00946 } 00947 00948 /** 00949 * Reset any advertising payload prepared from prior calls to 00950 * accumulateAdvertisingPayload(). This automatically propagates the re- 00951 * initialized advertising payload to the underlying stack. 00952 */ 00953 void clearAdvertisingPayload(void) { 00954 _advPayload.clear(); 00955 setAdvertisingData(_advPayload, _scanResponse); 00956 } 00957 00958 /** 00959 * Accumulate an AD structure in the advertising payload. Please note that 00960 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used 00961 * as an additional 31 bytes if the advertising payload is too 00962 * small. 00963 * 00964 * @param[in] flags 00965 * The flags to be added. Please refer to 00966 * GapAdvertisingData::Flags for valid flags. Multiple 00967 * flags may be specified in combination. 00968 * 00969 * @return BLE_ERROR_NONE if the data was successfully added to the 00970 * advertising payload. 00971 */ 00972 ble_error_t accumulateAdvertisingPayload(uint8_t flags) { 00973 GapAdvertisingData advPayloadCopy = _advPayload; 00974 ble_error_t rc; 00975 if ((rc = advPayloadCopy.addFlags(flags)) != BLE_ERROR_NONE) { 00976 return rc; 00977 } 00978 00979 rc = setAdvertisingData(advPayloadCopy, _scanResponse); 00980 if (rc == BLE_ERROR_NONE) { 00981 _advPayload = advPayloadCopy; 00982 } 00983 00984 return rc; 00985 } 00986 00987 /** 00988 * Accumulate an AD structure in the advertising payload. Please note that 00989 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used 00990 * as an additional 31 bytes if the advertising payload is too 00991 * small. 00992 * 00993 * @param[in] app 00994 * The appearance of the peripheral. 00995 * 00996 * @return BLE_ERROR_NONE if the data was successfully added to the 00997 * advertising payload. 00998 */ 00999 ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app) { 01000 GapAdvertisingData advPayloadCopy = _advPayload; 01001 ble_error_t rc; 01002 if ((rc = advPayloadCopy.addAppearance(app)) != BLE_ERROR_NONE) { 01003 return rc; 01004 } 01005 01006 rc = setAdvertisingData(advPayloadCopy, _scanResponse); 01007 if (rc == BLE_ERROR_NONE) { 01008 _advPayload = advPayloadCopy; 01009 } 01010 01011 return rc; 01012 } 01013 01014 /** 01015 * Accumulate an AD structure in the advertising payload. Please note that 01016 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used 01017 * as an additional 31 bytes if the advertising payload is too 01018 * small. 01019 * 01020 * @param[in] power 01021 * The max transmit power to be used by the controller (in dBm). 01022 * 01023 * @return BLE_ERROR_NONE if the data was successfully added to the 01024 * advertising payload. 01025 */ 01026 ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power) { 01027 GapAdvertisingData advPayloadCopy = _advPayload; 01028 ble_error_t rc; 01029 if ((rc = advPayloadCopy.addTxPower(power)) != BLE_ERROR_NONE) { 01030 return rc; 01031 } 01032 01033 rc = setAdvertisingData(advPayloadCopy, _scanResponse); 01034 if (rc == BLE_ERROR_NONE) { 01035 _advPayload = advPayloadCopy; 01036 } 01037 01038 return rc; 01039 } 01040 01041 /** 01042 * Accumulate a variable length byte-stream as an AD structure in the 01043 * advertising payload. Please note that the payload is limited to 31 bytes. 01044 * The SCAN_RESPONSE message may be used as an additional 31 bytes if the 01045 * advertising payload is too small. 01046 * 01047 * @param[in] type 01048 * The type describing the variable length data. 01049 * @param[in] data 01050 * Data bytes. 01051 * @param[in] len 01052 * Length of data. 01053 * 01054 * @return BLE_ERROR_NONE if the advertisement payload was updated based on 01055 * matching AD type; otherwise, an appropriate error. 01056 * 01057 * @note When the specified AD type is INCOMPLETE_LIST_16BIT_SERVICE_IDS, 01058 * COMPLETE_LIST_16BIT_SERVICE_IDS, INCOMPLETE_LIST_32BIT_SERVICE_IDS, 01059 * COMPLETE_LIST_32BIT_SERVICE_IDS, INCOMPLETE_LIST_128BIT_SERVICE_IDS, 01060 * COMPLETE_LIST_128BIT_SERVICE_IDS or LIST_128BIT_SOLICITATION_IDS the 01061 * supplied value is appended to the values previously added to the 01062 * payload. 01063 */ 01064 ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { 01065 GapAdvertisingData advPayloadCopy = _advPayload; 01066 ble_error_t rc; 01067 if ((rc = advPayloadCopy.addData(type, data, len)) != BLE_ERROR_NONE) { 01068 return rc; 01069 } 01070 01071 rc = setAdvertisingData(advPayloadCopy, _scanResponse); 01072 if (rc == BLE_ERROR_NONE) { 01073 _advPayload = advPayloadCopy; 01074 } 01075 01076 return rc; 01077 } 01078 01079 /** 01080 * Update a particular ADV field in the advertising payload (based on 01081 * matching type). 01082 * 01083 * @param[in] type 01084 * The ADV type field describing the variable length data. 01085 * @param[in] data 01086 * Data bytes. 01087 * @param[in] len 01088 * Length of data. 01089 * 01090 * @note If advertisements are enabled, then the update will take effect immediately. 01091 * 01092 * @return BLE_ERROR_NONE if the advertisement payload was updated based on 01093 * matching AD type; otherwise, an appropriate error. 01094 */ 01095 ble_error_t updateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { 01096 GapAdvertisingData advPayloadCopy = _advPayload; 01097 ble_error_t rc; 01098 if ((rc = advPayloadCopy.updateData(type, data, len)) != BLE_ERROR_NONE) { 01099 return rc; 01100 } 01101 01102 rc = setAdvertisingData(advPayloadCopy, _scanResponse); 01103 if (rc == BLE_ERROR_NONE) { 01104 _advPayload = advPayloadCopy; 01105 } 01106 01107 return rc; 01108 } 01109 01110 /** 01111 * Set up a particular, user-constructed advertisement payload for the 01112 * underlying stack. It would be uncommon for this API to be used directly; 01113 * there are other APIs to build an advertisement payload (refer to 01114 * Gap::accumulateAdvertisingPayload()). 01115 * 01116 * @param[in] payload 01117 * A reference to a user constructed advertisement 01118 * payload. 01119 * 01120 * @return BLE_ERROR_NONE if the advertisement payload was successfully 01121 * set. 01122 */ 01123 ble_error_t setAdvertisingPayload(const GapAdvertisingData &payload) { 01124 ble_error_t rc = setAdvertisingData(payload, _scanResponse); 01125 if (rc == BLE_ERROR_NONE) { 01126 _advPayload = payload; 01127 } 01128 01129 return rc; 01130 } 01131 01132 /** 01133 * Get a reference to the advertising payload. 01134 * 01135 * @return Read back advertising data. 01136 * 01137 * @note Useful for storing and restoring payload. 01138 */ 01139 const GapAdvertisingData &getAdvertisingPayload(void) const { 01140 return _advPayload; 01141 } 01142 01143 /** 01144 * Accumulate a variable length byte-stream as an AD structure in the 01145 * scanResponse payload. 01146 * 01147 * @param[in] type 01148 * The type describing the variable length data. 01149 * @param[in] data 01150 * Data bytes. 01151 * @param[in] len 01152 * Length of data. 01153 * 01154 * @return BLE_ERROR_NONE if the data was successfully added to the scan 01155 * response payload. 01156 */ 01157 ble_error_t accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { 01158 GapAdvertisingData scanResponseCopy = _scanResponse; 01159 ble_error_t rc; 01160 if ((rc = scanResponseCopy.addData(type, data, len)) != BLE_ERROR_NONE) { 01161 return rc; 01162 } 01163 01164 rc = setAdvertisingData(_advPayload, scanResponseCopy); 01165 if (rc == BLE_ERROR_NONE) { 01166 _scanResponse = scanResponseCopy; 01167 } 01168 01169 return rc; 01170 } 01171 01172 /** 01173 * Reset any scan response prepared from prior calls to 01174 * Gap::accumulateScanResponse(). 01175 * 01176 * @note This should be followed by a call to Gap::setAdvertisingPayload() or 01177 * Gap::startAdvertising() before the update takes effect. 01178 */ 01179 void clearScanResponse(void) { 01180 _scanResponse.clear(); 01181 setAdvertisingData(_advPayload, _scanResponse); 01182 } 01183 01184 /** 01185 * Set up parameters for GAP scanning (observer mode). 01186 * 01187 * @param[in] interval 01188 * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. 01189 * @param[in] window 01190 * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. 01191 * @param[in] timeout 01192 * Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables the timeout. 01193 * @param[in] activeScanning 01194 * Set to True if active-scanning is required. This is used to fetch the 01195 * scan response from a peer if possible. 01196 * 01197 * @return BLE_ERROR_NONE if the scan parameters were correctly set. 01198 * 01199 * @note The scanning window divided by the interval determines the duty cycle for 01200 * scanning. For example, if the interval is 100ms and the window is 10ms, 01201 * then the controller will scan for 10 percent of the time. It is possible 01202 * to have the interval and window set to the same value. In this case, 01203 * scanning is continuous, with a change of scanning frequency once every 01204 * interval. 01205 * 01206 * @note Once the scanning parameters have been configured, scanning can be 01207 * enabled by using startScan(). 01208 * 01209 * @note The scan interval and window are recommendations to the BLE stack. 01210 */ 01211 ble_error_t setScanParams(uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX, 01212 uint16_t window = GapScanningParams::SCAN_WINDOW_MAX, 01213 uint16_t timeout = 0, 01214 bool activeScanning = false) { 01215 ble_error_t rc; 01216 if (((rc = _scanningParams.setInterval(interval)) == BLE_ERROR_NONE) && 01217 ((rc = _scanningParams.setWindow(window)) == BLE_ERROR_NONE) && 01218 ((rc = _scanningParams.setTimeout(timeout)) == BLE_ERROR_NONE)) { 01219 _scanningParams.setActiveScanning(activeScanning); 01220 return BLE_ERROR_NONE; 01221 } 01222 01223 return rc; 01224 } 01225 01226 /** 01227 * Set up the scanInterval parameter for GAP scanning (observer mode). 01228 * 01229 * @param[in] interval 01230 * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. 01231 * 01232 * @return BLE_ERROR_NONE if the scan interval was correctly set. 01233 * 01234 * @note The scanning window divided by the interval determines the duty cycle for 01235 * scanning. For example, if the interval is 100ms and the window is 10ms, 01236 * then the controller will scan for 10 percent of the time. It is possible 01237 * to have the interval and window set to the same value. In this case, 01238 * scanning is continuous, with a change of scanning frequency once every 01239 * interval. 01240 * 01241 * @note Once the scanning parameters have been configured, scanning can be 01242 * enabled by using startScan(). 01243 */ 01244 ble_error_t setScanInterval(uint16_t interval) { 01245 return _scanningParams.setInterval(interval); 01246 } 01247 01248 /** 01249 * Set up the scanWindow parameter for GAP scanning (observer mode). 01250 * 01251 * @param[in] window 01252 * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. 01253 * 01254 * @return BLE_ERROR_NONE if the scan window was correctly set. 01255 * 01256 * @note The scanning window divided by the interval determines the duty cycle for 01257 * scanning. For example, if the interval is 100ms and the window is 10ms, 01258 * then the controller will scan for 10 percent of the time. It is possible 01259 * to have the interval and window set to the same value. In this case, 01260 * scanning is continuous, with a change of scanning frequency once every 01261 * interval. 01262 * 01263 * @note Once the scanning parameters have been configured, scanning can be 01264 * enabled by using startScan(). 01265 * 01266 * @note If scanning is already active, the updated value of scanWindow will be 01267 * propagated to the underlying BLE stack. 01268 */ 01269 ble_error_t setScanWindow(uint16_t window) { 01270 ble_error_t rc; 01271 if ((rc = _scanningParams.setWindow(window)) != BLE_ERROR_NONE) { 01272 return rc; 01273 } 01274 01275 /* If scanning is already active, propagate the new setting to the stack. */ 01276 if (scanningActive) { 01277 return startRadioScan(_scanningParams); 01278 } 01279 01280 return BLE_ERROR_NONE; 01281 } 01282 01283 /** 01284 * Set up parameters for GAP scanning (observer mode). 01285 * 01286 * @param[in] timeout 01287 * Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables the timeout. 01288 * 01289 * @return BLE_ERROR_NONE if the scan timeout was correctly set. 01290 * 01291 * @note Once the scanning parameters have been configured, scanning can be 01292 * enabled by using startScan(). 01293 * 01294 * @note If scanning is already active, the updated value of scanTimeout will be 01295 * propagated to the underlying BLE stack. 01296 */ 01297 ble_error_t setScanTimeout(uint16_t timeout) { 01298 ble_error_t rc; 01299 if ((rc = _scanningParams.setTimeout(timeout)) != BLE_ERROR_NONE) { 01300 return rc; 01301 } 01302 01303 /* If scanning is already active, propagate the new settings to the stack. */ 01304 if (scanningActive) { 01305 return startRadioScan(_scanningParams); 01306 } 01307 01308 return BLE_ERROR_NONE; 01309 } 01310 01311 /** 01312 * Modify the active scanning parameter for GAP scanning (observer mode). 01313 * This is used to fetch the scan response from a peer if possible. 01314 * 01315 * @param[in] activeScanning 01316 * Set to True if active-scanning is required. 01317 * 01318 * @return BLE_ERROR_NONE if active scanning was successfully set. 01319 * 01320 * @note Once the scanning parameters have been configured, scanning can be 01321 * enabled by using startScan(). 01322 * 01323 * @note If scanning is already in progress, then active-scanning will be enabled 01324 * for the underlying BLE stack. 01325 */ 01326 ble_error_t setActiveScanning(bool activeScanning) { 01327 _scanningParams.setActiveScanning(activeScanning); 01328 01329 /* If scanning is already active, propagate the new settings to the stack. */ 01330 if (scanningActive) { 01331 return startRadioScan(_scanningParams); 01332 } 01333 01334 return BLE_ERROR_NONE; 01335 } 01336 01337 /** 01338 * Start scanning (Observer Procedure) based on the parameters currently in 01339 * effect. 01340 * 01341 * @param[in] callback 01342 * The application-specific callback to be invoked upon 01343 * receiving every advertisement report. This can be passed in 01344 * as NULL, in which case scanning may not be enabled at all. 01345 * 01346 * @return BLE_ERROR_NONE if the device successfully started the scan 01347 * procedure. 01348 */ 01349 ble_error_t startScan(void (*callback)(const AdvertisementCallbackParams_t *params)) { 01350 ble_error_t err = BLE_ERROR_NONE; 01351 if (callback) { 01352 if ((err = startRadioScan(_scanningParams)) == BLE_ERROR_NONE) { 01353 scanningActive = true; 01354 onAdvertisementReport.attach(callback); 01355 } 01356 } 01357 01358 return err; 01359 } 01360 01361 /** 01362 * Same as Gap::startScan(), but allows the possibility to add an object 01363 * reference and member function as handler for advertisement event 01364 * callbacks. 01365 * 01366 * @param[in] object 01367 * Pointer to the object of a class defining the member callback 01368 * function (@p callbackMember). 01369 * @param[in] callbackMember 01370 * The member callback (within the context of an object) to be 01371 * invoked. 01372 * 01373 * @return BLE_ERROR_NONE if the device successfully started the scan 01374 * procedure. 01375 */ 01376 template<typename T> 01377 ble_error_t startScan(T *object, void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)) { 01378 ble_error_t err = BLE_ERROR_NONE; 01379 if (object && callbackMember) { 01380 if ((err = startRadioScan(_scanningParams)) == BLE_ERROR_NONE) { 01381 scanningActive = true; 01382 onAdvertisementReport.attach(object, callbackMember); 01383 } 01384 } 01385 01386 return err; 01387 } 01388 01389 /** 01390 * Initialize radio-notification events to be generated from the stack. 01391 * This API doesn't need to be called directly. 01392 * 01393 * Radio Notification is a feature that enables ACTIVE and INACTIVE 01394 * (nACTIVE) signals from the stack that notify the application when the 01395 * radio is in use. 01396 * 01397 * The ACTIVE signal is sent before the radio event starts. The nACTIVE 01398 * signal is sent at the end of the radio event. These signals can be used 01399 * by the application programmer to synchronize application logic with radio 01400 * activity. For example, the ACTIVE signal can be used to shut off external 01401 * devices, to manage peak current drawn during periods when the radio is on, 01402 * or to trigger sensor data collection for transmission in the Radio Event. 01403 * 01404 * @return BLE_ERROR_NONE on successful initialization, otherwise an error code. 01405 */ 01406 virtual ble_error_t initRadioNotification(void) { 01407 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ 01408 } 01409 01410 private: 01411 /** 01412 * Functionality that is BLE stack-dependent and must be implemented by the 01413 * ported. This is a helper function to set the advertising data in the 01414 * BLE stack. 01415 * 01416 * @param[in] advData 01417 * The new advertising data. 01418 * @param[in] scanResponse 01419 * The new scan response data. 01420 * 01421 * @return BLE_ERROR_NONE if the advertising data was set successfully. 01422 */ 01423 virtual ble_error_t setAdvertisingData(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse) = 0; 01424 01425 /** 01426 * Functionality that is BLE stack-dependent and must be implemented by the 01427 * ported. This is a helper function to start the advertising procedure in 01428 * the underlying BLE stack. 01429 * 01430 * @param[in] 01431 * The advertising parameters. 01432 * 01433 * @return BLE_ERROR_NONE if the advertising procedure was successfully 01434 * started. 01435 */ 01436 virtual ble_error_t startAdvertising(const GapAdvertisingParams &) = 0; 01437 01438 public: 01439 /** 01440 * Accessor to read back currently active advertising parameters. 01441 * 01442 * @return A reference to the current advertising parameters. 01443 */ 01444 GapAdvertisingParams &getAdvertisingParams(void) { 01445 return _advParams; 01446 } 01447 01448 /** 01449 * A const alternative to Gap::getAdvertisingParams(). 01450 * 01451 * @return A const reference to the current advertising parameters. 01452 */ 01453 const GapAdvertisingParams &getAdvertisingParams(void) const { 01454 return _advParams; 01455 } 01456 01457 /** 01458 * Set up a particular, user-constructed set of advertisement parameters for 01459 * the underlying stack. It would be uncommon for this API to be used 01460 * directly; there are other APIs to tweak advertisement parameters 01461 * individually. 01462 * 01463 * @param[in] newParams 01464 * The new advertising parameters. 01465 */ 01466 void setAdvertisingParams(const GapAdvertisingParams &newParams) { 01467 _advParams = newParams; 01468 } 01469 01470 /* Event callback handlers. */ 01471 public: 01472 /** 01473 * Set up a callback for timeout events. Refer to TimeoutSource_t for 01474 * possible event types. 01475 * 01476 * @param[in] callback 01477 * Event handler being registered. 01478 * 01479 * @note It is possible to unregister callbacks using onTimeout().detach(callback). 01480 */ 01481 void onTimeout(TimeoutEventCallback_t callback) { 01482 timeoutCallbackChain.add(callback); 01483 } 01484 01485 /** 01486 * @brief Provide access to the callchain of timeout event callbacks. 01487 * 01488 * @note It is possible to register callbacks using onTimeout().add(callback). 01489 * 01490 * @note It is possible to unregister callbacks using onTimeout().detach(callback). 01491 * 01492 * @return A reference to the timeout event callbacks chain. 01493 */ 01494 TimeoutEventCallbackChain_t& onTimeout() { 01495 return timeoutCallbackChain; 01496 } 01497 01498 /** 01499 * Append to a chain of callbacks to be invoked upon GAP connection. 01500 * 01501 * @param[in] callback 01502 * Event handler being registered. 01503 * 01504 * @note It is possible to unregister callbacks using onConnection().detach(callback) 01505 */ 01506 void onConnection(ConnectionEventCallback_t callback) { 01507 connectionCallChain.add(callback); 01508 } 01509 01510 /** 01511 * Same as Gap::onConnection(), but allows the possibility to add an object 01512 * reference and member function as handler for connection event 01513 * callbacks. 01514 * 01515 * @param[in] tptr 01516 * Pointer to the object of a class defining the member callback 01517 * function (@p mptr). 01518 * @param[in] mptr 01519 * The member callback (within the context of an object) to be 01520 * invoked. 01521 */ 01522 template<typename T> 01523 void onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t*)) { 01524 connectionCallChain.add(tptr, mptr); 01525 } 01526 01527 /** 01528 * @brief Provide access to the callchain of connection event callbacks. 01529 * 01530 * @return A reference to the connection event callbacks chain. 01531 * 01532 * @note It is possible to register callbacks using onConnection().add(callback). 01533 * 01534 * @note It is possible to unregister callbacks using onConnection().detach(callback). 01535 */ 01536 ConnectionEventCallbackChain_t& onConnection() { 01537 return connectionCallChain; 01538 } 01539 01540 /** 01541 * Append to a chain of callbacks to be invoked upon GAP disconnection. 01542 * 01543 * @param[in] callback 01544 Event handler being registered. 01545 * 01546 * @note It is possible to unregister callbacks using onDisconnection().detach(callback). 01547 */ 01548 void onDisconnection(DisconnectionEventCallback_t callback) { 01549 disconnectionCallChain.add(callback); 01550 } 01551 01552 /** 01553 * Same as Gap::onDisconnection(), but allows the possibility to add an object 01554 * reference and member function as handler for disconnection event 01555 * callbacks. 01556 * 01557 * @param[in] tptr 01558 * Pointer to the object of a class defining the member callback 01559 * function (@p mptr). 01560 * @param[in] mptr 01561 * The member callback (within the context of an object) to be 01562 * invoked. 01563 */ 01564 template<typename T> 01565 void onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t*)) { 01566 disconnectionCallChain.add(tptr, mptr); 01567 } 01568 01569 /** 01570 * @brief Provide access to the callchain of disconnection event callbacks. 01571 * 01572 * @return A reference to the disconnection event callback chain. 01573 * 01574 * @note It is possible to register callbacks using onDisconnection().add(callback). 01575 * 01576 * @note It is possible to unregister callbacks using onDisconnection().detach(callback). 01577 */ 01578 DisconnectionEventCallbackChain_t& onDisconnection() { 01579 return disconnectionCallChain; 01580 } 01581 01582 /** 01583 * Set the application callback for radio-notification events. 01584 * 01585 * Radio Notification is a feature that enables ACTIVE and INACTIVE 01586 * (nACTIVE) signals from the stack that notify the application when the 01587 * radio is in use. 01588 * 01589 * The ACTIVE signal is sent before the radio event starts. The nACTIVE 01590 * signal is sent at the end of the radio event. These signals can be used 01591 * by the application programmer to synchronize application logic with radio 01592 * activity. For example, the ACTIVE signal can be used to shut off external 01593 * devices, to manage peak current drawn during periods when the radio is on, 01594 * or to trigger sensor data collection for transmission in the Radio Event. 01595 * 01596 * @param[in] callback 01597 * The application handler to be invoked in response to a radio 01598 * ACTIVE/INACTIVE event. 01599 */ 01600 void onRadioNotification(void (*callback)(bool param)) { 01601 radioNotificationCallback.attach(callback); 01602 } 01603 01604 /** 01605 * Same as Gap::onRadioNotification(), but allows the posibility to 01606 * register an object reference and member function as handler for radio 01607 * notification events. 01608 * 01609 * @param[in] tptr 01610 * Pointer to the object of a class defining the member callback 01611 * function (@p mptr). 01612 * @param[in] mptr 01613 * The member callback (within the context of an object) to be 01614 * invoked in response to a radio ACTIVE/INACTIVE event. 01615 */ 01616 template <typename T> 01617 void onRadioNotification(T *tptr, void (T::*mptr)(bool)) { 01618 radioNotificationCallback.attach(tptr, mptr); 01619 } 01620 01621 /** 01622 * Setup a callback to be invoked to notify the user application that the 01623 * Gap instance is about to shutdown (possibly as a result of a call 01624 * to BLE::shutdown()). 01625 * 01626 * @param[in] callback 01627 * The handler that is being registered to be notified of 01628 * shutdown events. 01629 * 01630 * @note It is possible to chain together multiple onShutdown callbacks 01631 * (potentially from different modules of an application) to be notified 01632 * before the Gap instance is shutdown. 01633 * 01634 * @note It is also possible to set up a callback into a member function of 01635 * some object. 01636 * 01637 * @note It is possible to unregister a callback using onShutdown().detach(callback) 01638 */ 01639 void onShutdown(const GapShutdownCallback_t& callback) { 01640 shutdownCallChain.add(callback); 01641 } 01642 01643 /** 01644 * Same as Gap::onShutdown(), but allows the posibility to 01645 * register an object reference and member function as handler for shutdown 01646 * events. 01647 * 01648 * @param[in] objPtr 01649 * Pointer to the object of a class defining the member callback 01650 * function (@p memberPtr). 01651 * @param[in] memberPtr 01652 * The member callback (within the context of an object) to be 01653 * invoked in response to a shutdown event. 01654 */ 01655 template <typename T> 01656 void onShutdown(T *objPtr, void (T::*memberPtr)(const Gap *)) { 01657 shutdownCallChain.add(objPtr, memberPtr); 01658 } 01659 01660 /** 01661 * @brief Provide access to the callchain of shutdown event callbacks. 01662 * 01663 * @return A reference to the shutdown event callback chain. 01664 * 01665 * @note It is possible to register callbacks using onShutdown().add(callback). 01666 * 01667 * @note It is possible to unregister callbacks using onShutdown().detach(callback). 01668 */ 01669 GapShutdownCallbackChain_t& onShutdown() { 01670 return shutdownCallChain; 01671 } 01672 01673 public: 01674 /** 01675 * Notify all registered onShutdown callbacks that the Gap instance is 01676 * about to be shutdown and clear all Gap state of the 01677 * associated object. 01678 * 01679 * This function is meant to be overridden in the platform-specific 01680 * sub-class. Nevertheless, the sub-class is only expected to reset its 01681 * state and not the data held in Gap members. This shall be achieved by a 01682 * call to Gap::reset() from the sub-class' reset() implementation. 01683 * 01684 * @return BLE_ERROR_NONE on success. 01685 * 01686 * @note Currently a call to reset() does not reset the advertising and 01687 * scan parameters to default values. 01688 */ 01689 virtual ble_error_t reset(void) { 01690 /* Notify that the instance is about to shutdown */ 01691 shutdownCallChain.call(this); 01692 shutdownCallChain.clear(); 01693 01694 /* Clear Gap state */ 01695 state.advertising = 0; 01696 state.connected = 0; 01697 connectionCount = 0; 01698 01699 /* Clear scanning state */ 01700 scanningActive = false; 01701 01702 /* Clear advertising and scanning data */ 01703 _advPayload.clear(); 01704 _scanResponse.clear(); 01705 01706 /* Clear callbacks */ 01707 timeoutCallbackChain.clear(); 01708 connectionCallChain.clear(); 01709 disconnectionCallChain.clear(); 01710 radioNotificationCallback = NULL; 01711 onAdvertisementReport = NULL; 01712 01713 return BLE_ERROR_NONE; 01714 } 01715 01716 protected: 01717 /** 01718 * Construct a Gap instance. 01719 */ 01720 Gap() : 01721 _advParams(), 01722 _advPayload(), 01723 _scanningParams(), 01724 _scanResponse(), 01725 connectionCount(0), 01726 state(), 01727 scanningActive(false), 01728 timeoutCallbackChain(), 01729 radioNotificationCallback(), 01730 onAdvertisementReport(), 01731 connectionCallChain(), 01732 disconnectionCallChain() { 01733 _advPayload.clear(); 01734 _scanResponse.clear(); 01735 } 01736 01737 /* Entry points for the underlying stack to report events back to the user. */ 01738 public: 01739 /** 01740 * Helper function that notifies all registered handlers of an occurrence 01741 * of a connection event. This function is meant to be called from the 01742 * BLE stack specific implementation when a connection event occurs. 01743 * 01744 * @param[in] handle 01745 * The ID of the connection that generated the event. 01746 * @param[in] role 01747 * The role of this BLE device in the connection. 01748 * @param[in] peerAddrType 01749 * The peer's BLE address type. 01750 * @param[in] peerAddr 01751 * The peer's BLE address. 01752 * @param[in] ownAddrType 01753 * This device's BLE address type. 01754 * @param[in] ownAddr 01755 * This device's BLE address. 01756 * @param[in] connectionParams 01757 * The parameters configured for this connection. 01758 */ 01759 void processConnectionEvent(Handle_t handle, 01760 Role_t role, 01761 BLEProtocol::AddressType_t peerAddrType, 01762 const BLEProtocol::AddressBytes_t peerAddr, 01763 BLEProtocol::AddressType_t ownAddrType, 01764 const BLEProtocol::AddressBytes_t ownAddr, 01765 const ConnectionParams_t *connectionParams) { 01766 /* Update Gap state */ 01767 state.advertising = 0; 01768 state.connected = 1; 01769 ++connectionCount; 01770 01771 ConnectionCallbackParams_t callbackParams(handle, role, peerAddrType, peerAddr, ownAddrType, ownAddr, connectionParams); 01772 connectionCallChain.call(&callbackParams); 01773 } 01774 01775 /** 01776 * Helper function that notifies all registered handlers of an occurrence 01777 * of a disconnection event. This function is meant to be called from the 01778 * BLE stack specific implementation when a disconnection event occurs. 01779 * 01780 * @param[in] handle 01781 * The ID of the connection that generated the event. 01782 * @param[in] reason 01783 * The reason for disconnection. 01784 */ 01785 void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason) { 01786 /* Update Gap state */ 01787 --connectionCount; 01788 if (!connectionCount) { 01789 state.connected = 0; 01790 } 01791 01792 DisconnectionCallbackParams_t callbackParams(handle, reason); 01793 disconnectionCallChain.call(&callbackParams); 01794 } 01795 01796 /** 01797 * Helper function that notifies the registered handler of a scanned 01798 * advertisement packet. This function is meant to be called from the 01799 * BLE stack specific implementation when a such event occurs. 01800 * 01801 * @param[in] peerAddr 01802 * The peer's BLE address. 01803 * @param[in] rssi 01804 * The advertisement packet RSSI value. 01805 * @param[in] isScanReponse 01806 * Whether this packet is the response to a scan request. 01807 * @param[in] type 01808 * The type of advertisement. 01809 * @param[in] advertisingDataLen 01810 * Length of the advertisement data. 01811 * @param[in] advertisingData 01812 * Pointer to the advertisement packet's data. 01813 */ 01814 void processAdvertisementReport(const BLEProtocol::AddressBytes_t peerAddr, 01815 int8_t rssi, 01816 bool isScanResponse, 01817 GapAdvertisingParams::AdvertisingType_t type, 01818 uint8_t advertisingDataLen, 01819 const uint8_t *advertisingData) { 01820 AdvertisementCallbackParams_t params; 01821 memcpy(params.peerAddr, peerAddr, ADDR_LEN); 01822 params.rssi = rssi; 01823 params.isScanResponse = isScanResponse; 01824 params.type = type; 01825 params.advertisingDataLen = advertisingDataLen; 01826 params.advertisingData = advertisingData; 01827 onAdvertisementReport.call(¶ms); 01828 } 01829 01830 /** 01831 * Helper function that notifies all registered handlers of an occurrence 01832 * of a timeout event. This function is meant to be called from the 01833 * BLE stack specific implementation when a timeout event occurs. 01834 * 01835 * @param[in] source 01836 * The source of the timout event. 01837 */ 01838 void processTimeoutEvent(TimeoutSource_t source) { 01839 if (source == TIMEOUT_SRC_ADVERTISING) { 01840 /* Update gap state if the source is an advertising timeout */ 01841 state.advertising = 0; 01842 } 01843 if (timeoutCallbackChain) { 01844 timeoutCallbackChain(source); 01845 } 01846 } 01847 01848 protected: 01849 /** 01850 * Currently set advertising parameters. 01851 */ 01852 GapAdvertisingParams _advParams; 01853 /** 01854 * Currently set advertising data. 01855 */ 01856 GapAdvertisingData _advPayload; 01857 /** 01858 * Currently set scanning parameters. 01859 */ 01860 GapScanningParams _scanningParams; 01861 /** 01862 * Currently set scan response data. 01863 */ 01864 GapAdvertisingData _scanResponse; 01865 01866 /** 01867 * Total number of open connections. 01868 */ 01869 uint8_t connectionCount; 01870 /** 01871 * The current GAP state. 01872 */ 01873 GapState_t state; 01874 /** 01875 * Whether active scanning is set. This is used to fetch the scan response 01876 * from a peer if possible. 01877 */ 01878 bool scanningActive; 01879 01880 protected: 01881 /** 01882 * Callchain containing all registered callback handlers for timeout 01883 * events. 01884 */ 01885 TimeoutEventCallbackChain_t timeoutCallbackChain; 01886 /** 01887 * The registered callback handler for radio notification events. 01888 */ 01889 RadioNotificationEventCallback_t radioNotificationCallback; 01890 /** 01891 * The registered callback handler for scanned advertisement packet 01892 * notifications. 01893 */ 01894 AdvertisementReportCallback_t onAdvertisementReport; 01895 /** 01896 * Callchain containing all registered callback handlers for connection 01897 * events. 01898 */ 01899 ConnectionEventCallbackChain_t connectionCallChain; 01900 /** 01901 * Callchain containing all registered callback handlers for disconnection 01902 * events. 01903 */ 01904 DisconnectionEventCallbackChain_t disconnectionCallChain; 01905 01906 private: 01907 /** 01908 * Callchain containing all registered callback handlers for shutdown 01909 * events. 01910 */ 01911 GapShutdownCallbackChain_t shutdownCallChain; 01912 01913 private: 01914 /* Disallow copy and assignment. */ 01915 Gap(const Gap &); 01916 Gap& operator=(const Gap &); 01917 }; 01918 01919 #endif // ifndef __GAP_H__
Generated on Wed Jul 13 2022 09:31:10 by 1.7.2