Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Gap.h Source File

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 MBED_BLE_GAP_H__
00018 #define MBED_BLE_GAP_H__
00019 
00020 #include "BLERoles.h"
00021 #include "ble/common/StaticInterface.h"
00022 #include "BLETypes.h"
00023 #include "BLEProtocol.h"
00024 #include "ble/GapAdvertisingData.h"
00025 #include "ble/GapAdvertisingParams.h"
00026 #include "ble/GapScanningParams.h"
00027 #include "ble/GapEvents.h"
00028 
00029 #include "CallChainOfFunctionPointersWithContext.h"
00030 #include "FunctionPointerWithContext.h "
00031 #include "platform/mbed_toolchain.h"
00032 
00033 #include "ble/gap/Gap.h"
00034 #include "BleImplementationForward.h"
00035 
00036 /**
00037  * @addtogroup ble
00038  * @{
00039  * @addtogroup gap
00040  * @{
00041  */
00042 
00043 #if !defined(DOXYGEN_ONLY)
00044 namespace ble {
00045 namespace interface {
00046 #endif
00047 
00048 /**
00049  * @copydoc ble::Gap
00050  */
00051 #if defined(DOXYGEN_ONLY)
00052 class Gap : public ble::Gap {
00053 #else
00054 template<class Impl>
00055 class LegacyGap :
00056     public ble::StaticInterface<Impl, LegacyGap>,
00057     public ble::interface::Gap<Impl>
00058 {
00059 #endif
00060     using ble::StaticInterface<Impl, ::ble::interface::LegacyGap>::impl;
00061 
00062 public:
00063 #if BLE_ROLE_BROADCASTER
00064     using ble::interface::Gap<Impl>::setAdvertisingParameters;
00065     using ble::interface::Gap<Impl>::setAdvertisingPayload;
00066     using ble::interface::Gap<Impl>::setAdvertisingScanResponse;
00067     using ble::interface::Gap<Impl>::startAdvertising;
00068     using ble::interface::Gap<Impl>::stopAdvertising;
00069 #endif // BLE_ROLE_BROADCASTER
00070 #if BLE_ROLE_CENTRAL
00071     using ble::interface::Gap<Impl>::connect;
00072 #endif
00073 #if BLE_FEATURE_CONNECTABLE
00074     using ble::interface::Gap<Impl>::disconnect;
00075 #endif
00076 #if BLE_ROLE_OBSERVER
00077     using ble::interface::Gap<Impl>::startScan;
00078 #endif
00079 
00080     /**
00081      * Address-type for BLEProtocol addresses.
00082      *
00083      * @deprecated Use BLEProtocol::AddressType_t instead.
00084      */
00085     typedef BLEProtocol::AddressType_t AddressType_t;
00086 
00087     /**
00088      * Address-type for BLEProtocol addresses.
00089      *
00090      * @deprecated Use BLEProtocol::AddressType_t instead.
00091      */
00092     typedef BLEProtocol::AddressType_t addr_type_t;
00093 
00094     /**
00095      * Address-type for BLEProtocol addresses.
00096      *
00097      * @deprecated Use BLEProtocol::AddressType_t instead. The following
00098      * constants have been left in their deprecated state to transparently
00099      * support existing applications that may have used Gap::ADDR_TYPE_*.
00100      */
00101     enum DeprecatedAddressType_t {
00102         ADDR_TYPE_PUBLIC = BLEProtocol::AddressType::PUBLIC,
00103         ADDR_TYPE_RANDOM_STATIC = BLEProtocol::AddressType::RANDOM_STATIC,
00104         ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE,
00105         ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE
00106     };
00107 
00108     /**
00109      * Length (in octets) of the BLE MAC address.
00110      */
00111     static const unsigned ADDR_LEN = BLEProtocol::ADDR_LEN;
00112 
00113     /**
00114      * 48-bit address, LSB format.
00115      *
00116      * @deprecated Use BLEProtocol::AddressBytes_t instead.
00117      */
00118     typedef BLEProtocol::AddressBytes_t Address_t;
00119 
00120     /**
00121      * 48-bit address, LSB format.
00122      *
00123      * @deprecated Use BLEProtocol::AddressBytes_t instead.
00124      */
00125     typedef BLEProtocol::AddressBytes_t address_t;
00126 
00127 public:
00128     /**
00129      * Enumeration of possible timeout sources.
00130      */
00131     enum TimeoutSource_t {
00132         /**
00133          * Advertising timeout.
00134          */
00135         TIMEOUT_SRC_ADVERTISING = 0x00,
00136 
00137         /**
00138          * Security request timeout.
00139          */
00140         TIMEOUT_SRC_SECURITY_REQUEST = 0x01,
00141 
00142         /**
00143          * Scanning timeout.
00144          */
00145         TIMEOUT_SRC_SCAN = 0x02,
00146 
00147         /**
00148          * Connection timeout.
00149          */
00150         TIMEOUT_SRC_CONN = 0x03,
00151     };
00152 
00153     /**
00154      * Enumeration of disconnection reasons.
00155      *
00156      * @attention There might be a mismatch between the disconnection reason
00157      * passed to disconnect() and the disconnection event generated locally
00158      * because the disconnection reason passed to disconnect() is the
00159      * disconnection reason to be transmitted to the peer.
00160      */
00161     enum DisconnectionReason_t {
00162 
00163         /**
00164          * GAP or GATT failed to authenticate the peer.
00165          */
00166         AUTHENTICATION_FAILURE = 0x05,
00167 
00168         /**
00169          * The connection timed out.
00170          *
00171          * @attention shall not be used as a reason in disconnect().
00172          */
00173         CONNECTION_TIMEOUT = 0x08,
00174 
00175         /**
00176          * Connection terminated by the user.
00177          */
00178         REMOTE_USER_TERMINATED_CONNECTION = 0x13,
00179 
00180         /**
00181          * Remote device terminated connection due to low resources.
00182          */
00183         REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14,
00184 
00185         /**
00186          * Remote device terminated connection due to power off.
00187          */
00188         REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15,
00189 
00190         /**
00191          * Indicate that the local user or the internal
00192          * Bluetooth subsystem terminated the connection.
00193          *
00194          * @attention shall not be used as a reason in disconnect().
00195          */
00196         LOCAL_HOST_TERMINATED_CONNECTION = 0x16,
00197 
00198         /**
00199          * Connection parameters were unacceptable.
00200          */
00201         CONN_INTERVAL_UNACCEPTABLE = 0x3B,
00202     };
00203 
00204     /**
00205      * Advertising policy filter modes.
00206      *
00207      * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.2.
00208      */
00209     enum AdvertisingPolicyMode_t {
00210         /**
00211          * The whitelist is not used to filter peer request during advertising.
00212          */
00213         ADV_POLICY_IGNORE_WHITELIST = 0,
00214 
00215         /**
00216          * The whitelist is used to filter peer scan requests.
00217          */
00218         ADV_POLICY_FILTER_SCAN_REQS = 1,
00219 
00220         /**
00221          * The whitelist is used to filter peer connection requests.
00222          */
00223         ADV_POLICY_FILTER_CONN_REQS = 2,
00224 
00225         /**
00226          * The whitelist is used to filter peer scan and connection requests.
00227          */
00228         ADV_POLICY_FILTER_ALL_REQS  = 3,
00229     };
00230 
00231     /**
00232      * Scanning policy filter mode.
00233      *
00234      * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3.
00235      */
00236     enum ScanningPolicyMode_t {
00237         /**
00238          * The whitelist is not used for scanning operations.
00239          */
00240         SCAN_POLICY_IGNORE_WHITELIST = 0,
00241 
00242         /**
00243         * The whitelist is used to filter incoming advertising.
00244         */
00245         SCAN_POLICY_FILTER_ALL_ADV = 1,
00246     };
00247 
00248     /**
00249      * Connection initiation policy filter mode.
00250      *
00251      * @see Bluetooth Core Specification 4.2 (vol. 6), Part B, Section 4.4.4.
00252      */
00253     enum InitiatorPolicyMode_t {
00254         /**
00255          * Connection can be initiated to any device.
00256          */
00257         INIT_POLICY_IGNORE_WHITELIST = 0,
00258 
00259         /**
00260          * Connection initiation is restricted to the devices present in the
00261          * whitelist.
00262          */
00263         INIT_POLICY_FILTER_ALL_ADV = 1,
00264     };
00265 
00266     /**
00267      * Representation of a whitelist of addresses.
00268      */
00269     struct Whitelist_t {
00270         /**
00271          * Pointer to the array of the addresses composing the whitelist.
00272          */
00273         BLEProtocol::Address_t *addresses;
00274 
00275         /**
00276          * Number addresses in this whitelist.
00277          */
00278         uint8_t size;
00279 
00280         /**
00281          * Capacity of the array holding the addresses.
00282          */
00283         uint8_t capacity;
00284     };
00285 
00286     /**
00287      * Description of the states of the device.
00288      */
00289     struct GapState_t {
00290         /**
00291          * If set, the device is currently advertising.
00292          */
00293         unsigned advertising : 1;
00294 
00295         /**
00296          * If set, the device is connected to at least one other peer.
00297          */
00298         unsigned connected : 1;
00299     };
00300 
00301     /**
00302      * Opaque value type representing a connection handle.
00303      *
00304      * It is used to identify to refer to a specific connection across Gap,
00305      * GattClient and GattEvent API.
00306      *
00307      * @note instances are generated by in the connection callback.
00308      */
00309     typedef ble::connection_handle_t Handle_t;
00310 
00311     /**
00312      * Enumeration of random address types.
00313      */
00314     typedef ble::random_address_type_t RandomAddressType_t;
00315 
00316     /**
00317      * Enumeration of peer address types
00318      */
00319     typedef ble::peer_address_type_t PeerAddressType_t;
00320 
00321     /**
00322      * Enumeration of BLE PHY
00323      */
00324     typedef ble::phy_t Phy_t;
00325 
00326     /**
00327      * Set of BLE PHYs
00328      */
00329     typedef ble::phy_set_t PhySet_t;
00330 
00331     /**
00332      * Enumeration of type of symbols that can be used with LE coded PHY.
00333      */
00334     typedef ble::coded_symbol_per_bit_t CodedSymbolPerBit_t;
00335 
00336     /**
00337      * Parameters of a BLE connection.
00338      */
00339     typedef struct {
00340         /**
00341          * Minimum interval between two connection events allowed for a
00342          * connection.
00343          *
00344          * It shall be less than or equal to maxConnectionInterval. This value,
00345          * in units of 1.25ms, is included in the range [0x0006 : 0x0C80].
00346          */
00347         uint16_t minConnectionInterval;
00348 
00349         /**
00350          * Maximum interval between two connection events allowed for a
00351          * connection.
00352          *
00353          * It shall be greater than or equal to minConnectionInterval. This
00354          * value is in unit of 1.25ms and is in the range [0x0006 : 0x0C80].
00355          */
00356         uint16_t maxConnectionInterval;
00357 
00358         /**
00359          * Number of connection events the slave can drop if it has nothing to
00360          * communicate to the master.
00361          *
00362          * This value shall be in the range [0x0000 : 0x01F3].
00363          */
00364         uint16_t slaveLatency;
00365 
00366         /**
00367          * Link supervision timeout for the connection.
00368          *
00369          * Time after which the connection is considered lost if the device
00370          * didn't receive a packet from its peer.
00371          *
00372          * It is larger than:
00373          *        (1 + slaveLatency) * maxConnectionInterval * 2
00374          *
00375          * This value is in the range [0x000A : 0x0C80] and is in unit of
00376          * 10 ms.
00377          *
00378          * @note maxConnectionInterval is in ms in the formulae above.
00379          */
00380         uint16_t connectionSupervisionTimeout;
00381     } ConnectionParams_t;
00382 
00383     /**
00384      * Enumeration of GAP roles.
00385      *
00386      * @note The BLE API does not express the broadcaster and scanner roles.
00387      *
00388      * @attention A device can fulfill different roles concurrently.
00389      */
00390     enum Role_t {
00391         /**
00392          * Peripheral Role.
00393          *
00394          * The device can advertise and it can be connected by a central. It
00395          * acts as a slave when connected.
00396          *
00397          * @note A peripheral is a broadcaster.
00398          */
00399         PERIPHERAL = 0x1,
00400 
00401         /**
00402          * Central Role.
00403          *
00404          * The device can scan and initiate connection to peripherals. It
00405          * acts as the master when a connection is established.
00406          *
00407          * @note A central is a scanner.
00408          */
00409         CENTRAL = 0x2,
00410     };
00411 
00412     /**
00413      * Representation of a scanned advertising packet.
00414      *
00415      * Instances of this type are passed to the callback registered in
00416      * startScan().
00417      */
00418     struct AdvertisementCallbackParams_t {
00419         /**
00420          * Default constructor.
00421          */
00422         AdvertisementCallbackParams_t();
00423 
00424         /**
00425          * BLE address of the device that has advertised the packet.
00426          */
00427         BLEProtocol::AddressBytes_t peerAddr;
00428 
00429         /**
00430          * RSSI value of the packet.
00431          */
00432         int8_t rssi;
00433 
00434         /**
00435          * Flag indicating if the packet is a response to a scan request.
00436          */
00437         bool isScanResponse;
00438 
00439         /**
00440          * Type of advertisement.
00441          */
00442         GapAdvertisingParams::AdvertisingType_t type;
00443 
00444         /**
00445          * Length of the advertisement data.
00446          */
00447         uint8_t advertisingDataLen;
00448 
00449         /**
00450          * Pointer to the advertisement packet's data.
00451          */
00452         const uint8_t *advertisingData;
00453 
00454         /**
00455          * Type of the address received.
00456          *
00457          * @deprecated AddressType_t do not carry enough information to be used
00458          * when privacy is enabled. Use peerAddressType instead.
00459          *
00460          * @note This value should be used in the connect function to establish
00461          * a connection with the peer that has sent this advertisement packet.
00462          */
00463         MBED_DEPRECATED_SINCE (
00464             "mbed-os-5.9.0",
00465             "addressType won't work in connect when privacy is enabled; please"
00466             "use peerAddrType"
00467         )
00468         AddressType_t addressType;
00469 
00470         /**
00471          * Type of the address received.
00472          *
00473          * @note This value should be used in the connect function to establish
00474          * a connection with the peer that has sent this advertisement packet.
00475          */
00476         PeerAddressType_t peerAddrType;
00477     };
00478 
00479     /**
00480      * Type of the callback handling scanned advertisement packets.
00481      *
00482      * @see Gap::startScan().
00483      */
00484     typedef FunctionPointerWithContext<const AdvertisementCallbackParams_t *>
00485         AdvertisementReportCallback_t;
00486 
00487     /**
00488      * Connection events.
00489      *
00490      * It contains all the information related to a newly established connection.
00491      *
00492      * Instances of this structure are passed to handlers that
00493      * Gap::onConnection() registers when a connection is established.
00494      */
00495     struct ConnectionCallbackParams_t {
00496         /**
00497          * Connection handle.
00498          */
00499         Handle_t handle;
00500 
00501         /**
00502          * Connection Role of the local device.
00503          */
00504         Role_t role;
00505 
00506         /**
00507          * Type of the address the peer uses.
00508          *
00509          * @deprecated The type BLEProtocol::AddressType_t is not suitable when
00510          * privacy is enabled. Use peerAddressType instead.
00511          */
00512         MBED_DEPRECATED_SINCE (
00513             "mbed-os-5.9",
00514             "The type BLEProtocol::AddressType_t is not suitable when privacy is "
00515             "enabled. Use peerAddressType instead."
00516         )
00517         BLEProtocol::AddressType_t peerAddrType;
00518 
00519         /**
00520          * Address of the peer.
00521          */
00522         BLEProtocol::AddressBytes_t peerAddr;
00523 
00524         /**
00525          * Address type of the local device.
00526          */
00527         BLEProtocol::AddressType_t  ownAddrType;
00528 
00529         /**
00530          * Address of the local device.
00531          *
00532          * @deprecated The local address used for the connection may not be known,
00533          * Therefore this field is not reliable.
00534          *
00535          * @note All bytes of the address are set to 0 if not applicable
00536          */
00537         MBED_DEPRECATED_SINCE (
00538             "mbed-os-5.9",
00539             "A Bluetooth controller is not supposed to return the address it used"
00540             "to connect. With privacy enabled the controller address may be unknown"
00541             "to the host. There is no replacement for this deprecation."
00542         )
00543         BLEProtocol::AddressBytes_t ownAddr;
00544 
00545         /**
00546          * Connection parameters.
00547          */
00548         const ConnectionParams_t *connectionParams;
00549 
00550         /**
00551          * Resolvable address used by the peer.
00552          *
00553          * @note All bytes of the address are set to 0 if not applicable
00554          */
00555         BLEProtocol::AddressBytes_t peerResolvableAddr;
00556 
00557         /**
00558          * resolvable address of the local device.
00559          *
00560          * @note All bytes of the address are set to 0 if not applicable
00561          */
00562         BLEProtocol::AddressBytes_t localResolvableAddr;
00563 
00564         /**
00565          * Type of the address the peer uses.
00566          */
00567         PeerAddressType_t peerAddressType;
00568 
00569         /**
00570          * Construct an instance of ConnectionCallbackParams_t.
00571          *
00572          * @param[in] handleIn Value to assign to handle.
00573          * @param[in] roleIn Value to assign to role.
00574          * @param[in] peerAddrTypeIn Value to assign to peerAddrType.
00575          * @param[in] peerAddrIn Value to assign to peerAddr.
00576          * @param[in] ownAddrTypeIn Value to assign to ownAddrType.
00577          * @param[in] ownAddrIn Value to assign to ownAddr. This may be NULL.
00578          * @param[in] connectionParamsIn Value to assign to connectionParams.
00579          * @param[in] peerResolvableAddrIn Value to assign to peerResolvableAddr.
00580          * @param[in] localResolvableAddrIn Value to assign to localResolvableAddr.
00581          *
00582          * @note Constructor is not meant to be called by user code.
00583          * The BLE API vendor code generates ConnectionCallbackParams_t.
00584          */
00585         ConnectionCallbackParams_t(
00586             Handle_t handleIn,
00587             Role_t roleIn,
00588             PeerAddressType_t peerAddrTypeIn,
00589             const uint8_t *peerAddrIn,
00590             BLEProtocol::AddressType_t ownAddrTypeIn,
00591             const uint8_t *ownAddrIn,
00592             const ConnectionParams_t *connectionParamsIn,
00593             const uint8_t *peerResolvableAddrIn = NULL,
00594             const uint8_t *localResolvableAddrIn = NULL
00595         );
00596 
00597         /**
00598          * Construct an instance of ConnectionCallbackParams_t.
00599          *
00600          * @param[in] handleIn Value to assign to handle.
00601          * @param[in] roleIn Value to assign to role.
00602          * @param[in] peerAddrTypeIn Value to assign to peerAddrType.
00603          * @param[in] peerAddrIn Value to assign to peerAddr.
00604          * @param[in] ownAddrTypeIn Value to assign to ownAddrType.
00605          * @param[in] ownAddrIn Value to assign to ownAddr.
00606          * @param[in] connectionParamsIn Value to assign to connectionParams.
00607          * @param[in] peerResolvableAddrIn Value to assign to peerResolvableAddr.
00608          * @param[in] localResolvableAddrIn Value to assign to localResolvableAddr.
00609          *
00610          * @note Constructor is not meant to be called by user code.
00611          * The BLE API vendor code generates ConnectionCallbackParams_t.
00612          *
00613          * @deprecated The type BLEProtocol::AddressType_t is not suitable when
00614          * privacy is enabled. Use the constructor that accepts a
00615          * PeerAddressType_t instead.
00616          */
00617         MBED_DEPRECATED_SINCE (
00618             "mbed-os-5.9.0",
00619             "The type BLEProtocol::AddressType_t is not suitable when privacy is "
00620             "enabled. Use the constructor that accepts a PeerAddressType_t instead."
00621         )
00622         ConnectionCallbackParams_t(
00623             Handle_t handleIn,
00624             Role_t roleIn,
00625             BLEProtocol::AddressType_t peerAddrTypeIn,
00626             const uint8_t *peerAddrIn,
00627             BLEProtocol::AddressType_t ownAddrTypeIn,
00628             const uint8_t *ownAddrIn,
00629             const ConnectionParams_t *connectionParamsIn,
00630             const uint8_t *peerResolvableAddrIn = NULL,
00631             const uint8_t *localResolvableAddrIn = NULL
00632         );
00633 
00634     private:
00635         void constructor_helper(
00636             const uint8_t *peerAddrIn,
00637             const uint8_t *ownAddrIn,
00638             const uint8_t *peerResolvableAddrIn,
00639             const uint8_t *localResolvableAddrIn
00640         );
00641     };
00642 
00643     /**
00644      * Disconnection event.
00645      *
00646      * Instances of this event are passed to callbacks registered with
00647      * Gap::onDisconnection() when a connection ends.
00648      *
00649      * @note Constructor is not meant to be called by user code.
00650      * The BLE API vendor code generates ConnectionCallbackParams_t.
00651      */
00652     struct DisconnectionCallbackParams_t {
00653         /**
00654          * ID of the connection that has ended.
00655          */
00656         Handle_t handle;
00657 
00658         /**
00659          * Reason of the disconnection.
00660          */
00661         DisconnectionReason_t reason;
00662 
00663         /**
00664          * Construct a DisconnectionCallbackParams_t.
00665          *
00666          * @param[in] handleIn Value assigned to handle.
00667          * @param[in] reasonIn Value assigned to reason.
00668          */
00669         DisconnectionCallbackParams_t(
00670             Handle_t handleIn,
00671             DisconnectionReason_t reasonIn
00672         ) : handle(handleIn),
00673             reason(reasonIn)
00674         {
00675         }
00676     };
00677 
00678     /**
00679      * @copydoc ble::peripheral_privacy_configuration_t
00680      */
00681     typedef ble::peripheral_privacy_configuration_t PeripheralPrivacyConfiguration_t;
00682 
00683     /**
00684      * @copydoc ble::central_privay_configuration_t
00685      */
00686     typedef ble::central_privay_configuration_t CentralPrivacyConfiguration_t;
00687 
00688     /**
00689      * Number of microseconds in 1.25 milliseconds.
00690      */
00691     static const uint16_t UNIT_1_25_MS = 1250;
00692 
00693     /**
00694      * Convert milliseconds into 1.25ms units.
00695      *
00696      * This function may be used to convert ms time of connection intervals into
00697      * the format expected for connection parameters.
00698      *
00699      * @param[in] durationInMillis The duration in milliseconds.
00700      *
00701      * @return The duration in unit of 1.25ms.
00702      */
00703     static uint16_t MSEC_TO_GAP_DURATION_UNITS(uint32_t durationInMillis)
00704     {
00705         return (durationInMillis * 1000) / UNIT_1_25_MS;
00706     }
00707 
00708     /**
00709      * Timeout event handler.
00710      *
00711      * @see Gap::onTimeout().
00712      */
00713     typedef FunctionPointerWithContext<TimeoutSource_t> TimeoutEventCallback_t;
00714 
00715     /**
00716      * Callchain of timeout event handlers.
00717      *
00718      * @see Gap::onTimeout().
00719      */
00720     typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t>
00721         TimeoutEventCallbackChain_t;
00722 
00723     /**
00724      * Connection event handler.
00725      *
00726      * @see Gap::onConnection().
00727      */
00728     typedef FunctionPointerWithContext<const ConnectionCallbackParams_t *>
00729         ConnectionEventCallback_t;
00730 
00731     /**
00732      * Callchain of connection event handlers.
00733      *
00734      * @see Gap::onConnection().
00735      */
00736     typedef CallChainOfFunctionPointersWithContext<const ConnectionCallbackParams_t *>
00737         ConnectionEventCallbackChain_t;
00738 
00739     /**
00740      * Disconnection event handler.
00741      *
00742      * @see Gap::onDisconnection().
00743      */
00744     typedef FunctionPointerWithContext<const DisconnectionCallbackParams_t *>
00745         DisconnectionEventCallback_t;
00746 
00747     /**
00748      * Callchain of disconnection event handlers.
00749      *
00750      * @see Gap::onDisconnection().
00751      */
00752     typedef CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t *>
00753         DisconnectionEventCallbackChain_t;
00754 
00755     /**
00756      * Radio notification event handler.
00757      *
00758      * @see Gap::onRadioNotification().
00759      */
00760     typedef FunctionPointerWithContext<bool> RadioNotificationEventCallback_t;
00761 
00762     /**
00763      * Gap shutdown event handler.
00764      *
00765      * @see Gap::onShutdown().
00766      */
00767     typedef FunctionPointerWithContext<const LegacyGap *> GapShutdownCallback_t;
00768 
00769     /**
00770      * Callchain of gap shutdown event handler.
00771      *
00772      * @see Gap::onShutdown().
00773      */
00774     typedef CallChainOfFunctionPointersWithContext<const LegacyGap *>
00775         GapShutdownCallbackChain_t;
00776 
00777     /*
00778      * The following functions are meant to be overridden in the platform-specific subclass.
00779      */
00780 public:
00781     /**
00782      * Set the device MAC address and type.
00783      *
00784      * The address set is used in subsequent GAP operations: scanning,
00785      * advertising and connection initiation.
00786      *
00787      * @param[in] type Type of the address to set.
00788      * @param[in] address Value of the address to set. It is ordered in
00789      * little endian. This parameter is not considered if the address type
00790      * is RANDOM_PRIVATE_RESOLVABLE or RANDOM_PRIVATE_NON_RESOLVABLE. For those
00791      * types of address, the BLE API itself generates the address.
00792      *
00793      * @note Some implementation may refuse to set a new PUBLIC address.
00794      * @note Random static address set does not change.
00795      *
00796      * @deprecated Starting with mbed-os-5.9.0 this function is deprecated and
00797      * address management is delegated to implementation. Implementations may or
00798      * may not continue to support this function. Compliance with the Bluetooth
00799      * specification and unification of behaviour between implementations are
00800      * the key reasons behind this change:
00801      *   - Many implementations do not allow changing of the public address.
00802      *   Therefore programs relying on this function are not portable across BLE
00803      *   implementations.
00804      *   - The Bluetooth specification forbid replacement of the random static
00805      *   address; this address can be set once and only once: at startup.
00806      *   Depending on the underlying implementation the random address may or
00807      *   may not have been set automatically at startup; therefore update of the
00808      *   Random Static address after ble initialisation may be a fault. As a
00809      *   result calls to this function were not portable.
00810      *   Furthermore replacement of the random static address silently
00811      *   invalidates the bond stored in the secure database.
00812 
00813      * @return BLE_ERROR_NONE on success.
00814      */
00815     MBED_DEPRECATED_SINCE (
00816         "mbed-os-5.9.0",
00817         "Non portable API, use enablePrivacy to enable use of private addresses"
00818     )
00819     ble_error_t setAddress(
00820         BLEProtocol::AddressType_t type,
00821         const BLEProtocol::AddressBytes_t address
00822     );
00823 
00824     /**
00825      * Fetch the current address and its type.
00826      *
00827      * @param[out] typeP Type of the current address set.
00828      * @param[out] address Value of the current address.
00829      *
00830      * @note If privacy is enabled the device address may be unavailable to
00831      * application code.
00832      *
00833      * @return BLE_ERROR_NONE on success.
00834      */
00835     ble_error_t getAddress(
00836         BLEProtocol::AddressType_t *typeP,
00837         BLEProtocol::AddressBytes_t address
00838     );
00839 
00840     /**
00841      * Return the type of a random address.
00842      *
00843      * @param[in] address The random address to retrieve the type from. The
00844      * address must be ordered in little endian.
00845      *
00846      * @param[out] addressType Type of the address to fill.
00847      *
00848      * @return BLE_ERROR_NONE in case of success or BLE_ERROR_INVALID_PARAM if
00849      * the address in input was not identifiable as a random address.
00850      */
00851     static ble_error_t getRandomAddressType(
00852         const BLEProtocol::AddressBytes_t address,
00853         RandomAddressType_t *addressType
00854     );
00855 
00856 #if BLE_ROLE_BROADCASTER
00857     /**
00858      * Get the minimum advertising interval in milliseconds, which can be used
00859      * for connectable advertising types.
00860      *
00861      * @return Minimum Advertising interval in milliseconds for connectable
00862      * undirected and connectable directed advertising types.
00863      */
00864     uint16_t getMinAdvertisingInterval(void) const;
00865 
00866     /**
00867      * Get the minimum advertising interval in milliseconds, which can be
00868      * used for nonconnectable advertising type.
00869      *
00870      * @return Minimum Advertising interval in milliseconds for scannable
00871      * undirected and nonconnectable undirected event types.
00872      */
00873     uint16_t getMinNonConnectableAdvertisingInterval(void) const;
00874 
00875     /**
00876      * Get the maximum advertising interval in milliseconds.
00877      *
00878      * @return Maximum Advertising interval in milliseconds.
00879      */
00880     uint16_t getMaxAdvertisingInterval(void) const;
00881 
00882     /**
00883      * Stop the ongoing advertising procedure.
00884      *
00885      * @note The current advertising parameters remain in effect.
00886      *
00887      * @retval BLE_ERROR_NONE if the advertising procedure has been successfully
00888      * stopped.
00889      *
00890      * @deprecated Deprecated since addition of extended advertising support.
00891      * Use stopAdvertising(advertising_handle_t).
00892      */
00893     MBED_DEPRECATED_SINCE (
00894         "mbed-os-5.11.0",
00895         "Deprecated since addition of extended advertising support."
00896         "Use stopAdvertising(advertising_handle_t) instead."
00897     )
00898     ble_error_t stopAdvertising(void);
00899 #endif //BLE_ROLE_BROADCASTER
00900 #if BLE_ROLE_CENTRAL
00901     /**
00902      * Initiate a connection to a peer.
00903      *
00904      * Once the connection is established, a ConnectionCallbackParams_t event is
00905      * emitted to handlers that have been registered with onConnection().
00906      *
00907      * @param[in] peerAddr MAC address of the peer. It must be in LSB format.
00908      * @param[in] peerAddrType Address type of the peer. It is usually obtained
00909      * from advertising frames.
00910      * @param[in] connectionParams Connection parameters to use.
00911      * @param[in] scanParams Scan parameters used to find the peer.
00912      *
00913      * @return BLE_ERROR_NONE if connection establishment procedure is started
00914      * successfully. The connectionCallChain (if set) is invoked upon
00915      * a connection event.
00916      *
00917      * @deprecated Deprecated since addition of extended advertising support.
00918      * Use connect(target_peer_address_type_t, address_t, ConnectionParameters).
00919      */
00920     MBED_DEPRECATED_SINCE (
00921         "mbed-os-5.11.0",
00922         "Deprecated since addition of extended advertising support."
00923         "Use connect(target_peer_address_type_t, address_t, ConnectionParameters) instead."
00924     )
00925     ble_error_t connect(
00926         const BLEProtocol::AddressBytes_t peerAddr,
00927         PeerAddressType_t peerAddrType,
00928         const ConnectionParams_t *connectionParams,
00929         const GapScanningParams *scanParams
00930     );
00931 
00932     /**
00933      * Initiate a connection to a peer.
00934      *
00935      * Once the connection is established, a ConnectionCallbackParams_t event is
00936      * emitted to handlers that have been registered with onConnection().
00937      *
00938      * @param[in] peerAddr MAC address of the peer. It must be in LSB format.
00939      * @param[in] peerAddrType Address type of the peer.
00940      * @param[in] connectionParams Connection parameters to use.
00941      * @param[in] scanParams Scan parameters used to find the peer.
00942      *
00943      * @deprecated BLEProtocol::AddressType_t is not able to to carry accurate
00944      * meaning when privacy is in use. Please Uses the connect overload that
00945      * accept a PeerAddressType_t as the peer address type.
00946      *
00947      * @return BLE_ERROR_NONE if connection establishment procedure is started
00948      * successfully. The connectionCallChain (if set) is invoked upon
00949      * a connection event.
00950      */
00951     MBED_DEPRECATED_SINCE (
00952         "mbed-os-5.9.0",
00953         "This function won't work if privacy is enabled; You must use the overload "
00954         "accepting PeerAddressType_t."
00955     )
00956     ble_error_t connect(
00957         const BLEProtocol::AddressBytes_t peerAddr,
00958         BLEProtocol::AddressType_t peerAddrType,
00959         const ConnectionParams_t *connectionParams,
00960         const GapScanningParams *scanParams
00961     );
00962 
00963     /**
00964      * Initiate a connection to a peer.
00965      *
00966      * @see connect()
00967      *
00968      * @deprecated  This funtion overloads Gap::connect(
00969      *      const BLEProtocol::Address_t peerAddr,
00970      *      BLEProtocol::AddressType_t peerAddrType,
00971      *      const ConnectionParams_t *connectionParams,
00972      *      const GapScanningParams *scanParams
00973      * )
00974      * to maintain backward compatibility for changes from Gap::AddressType_t to
00975      * BLEProtocol::AddressType_t.
00976      */
00977     MBED_DEPRECATED("Gap::DeprecatedAddressType_t is deprecated, use BLEProtocol::AddressType_t instead")
00978     ble_error_t connect(
00979         const BLEProtocol::AddressBytes_t peerAddr,
00980         DeprecatedAddressType_t peerAddrType,
00981         const ConnectionParams_t *connectionParams,
00982         const GapScanningParams *scanParams
00983     );
00984 #endif // BLE_ROLE_CENTRAL
00985 
00986 #if BLE_FEATURE_CONNECTABLE
00987     /**
00988      * Initiate a disconnection procedure.
00989      *
00990      * Once the disconnection procedure has completed a
00991      * DisconnectionCallbackParams_t, the event is emitted to handlers that
00992      * have been registered with onDisconnection().
00993      *
00994      * @param[in] reason Reason of the disconnection transmitted to the peer.
00995      * @param[in] connectionHandle Handle of the connection to end.
00996      *
00997      * @return  BLE_ERROR_NONE if the disconnection procedure successfully
00998      * started.
00999      *
01000      * @deprecated Deprecated since addition of extended advertising support.
01001      * Use disconnect(connection_handle_t, local_disconnection_reason_t) instead.
01002      */
01003     MBED_DEPRECATED_SINCE (
01004         "mbed-os-5.11.0",
01005         "Deprecated since addition of extended advertising support."
01006         "Use disconnect(connection_handle_t, local_disconnection_reason_t) instead."
01007     )
01008     ble_error_t disconnect(
01009         Handle_t connectionHandle, DisconnectionReason_t reason
01010     );
01011 
01012     /**
01013      * Initiate a disconnection procedure.
01014      *
01015      * @deprecated This version of disconnect() doesn't take a connection handle.
01016      * It works reliably only for stacks that are limited to a single connection.
01017      * Use Gap::disconnect(Handle_t connectionHandle, DisconnectionReason_t reason)
01018      * instead.
01019      *
01020      * @param[in] reason The reason for disconnection; to be sent back to the peer.
01021      *
01022      * @return BLE_ERROR_NONE if disconnection was successful.
01023      */
01024     MBED_DEPRECATED("Use disconnect(Handle_t, DisconnectionReason_t) instead.")
01025     ble_error_t disconnect(DisconnectionReason_t reason);
01026 
01027 public:
01028 
01029     /**
01030      * Returned the preferred connection parameters exposed in the GATT Generic
01031      * Access Service.
01032      *
01033      * @param[out] params Structure where the parameters are stored.
01034      *
01035      * @return BLE_ERROR_NONE if the parameters were successfully filled into
01036      * @p params.
01037      */
01038     ble_error_t getPreferredConnectionParams(ConnectionParams_t *params);
01039 
01040     /**
01041      * Set the value of the preferred connection parameters exposed in the GATT
01042      * Generic Access Service.
01043      *
01044      * A connected peer may read the characteristic exposing these parameters
01045      * and request an update of the connection parameters to accommodate the
01046      * local device.
01047      *
01048      * @param[in] params Value of the preferred connection parameters.
01049      *
01050      * @return BLE_ERROR_NONE if the preferred connection params were set
01051      * correctly.
01052      */
01053     ble_error_t setPreferredConnectionParams(
01054         const ConnectionParams_t *params
01055     );
01056 
01057     /**
01058      * Update connection parameters of an existing connection.
01059      *
01060      * In the central role, this initiates a Link Layer connection parameter
01061      * update procedure. In the peripheral role, this sends the corresponding
01062      * L2CAP request and waits for the central to perform the procedure.
01063      *
01064      * @param[in] handle Connection Handle.
01065      * @param[in] params Pointer to desired connection parameters.
01066      *
01067      * @return BLE_ERROR_NONE if the connection parameters were updated correctly.
01068      *
01069      * @deprecated Deprecated since addition of extended advertising support.
01070      * Use updateConnectionParameters(connection_handle_t, conn_interval_t,
01071      * conn_interval_t, slave_latency_t, supervision_timeout_t,
01072      * conn_event_length_t, conn_event_length_t) instead.
01073      */
01074     MBED_DEPRECATED_SINCE (
01075         "mbed-os-5.11.0",
01076         "Deprecated since addition of extended advertising support."
01077         "Use updateConnectionParameters(connection_handle_t, conn_interval_t, "
01078         "conn_interval_t, slave_latency_t, supervision_timeout_t, "
01079         "conn_event_length_t, conn_event_length_t) instead."
01080     )
01081     ble_error_t updateConnectionParams(
01082         Handle_t handle,
01083         const ConnectionParams_t *params
01084     );
01085 #endif // BLE_FEATURE_CONNECTABLE
01086 #if BLE_FEATURE_GATT_SERVER
01087     /**
01088      * Set the value of the device name characteristic in the Generic Access
01089      * Service.
01090      *
01091      * @param[in] deviceName The new value for the device-name. This is a
01092      * UTF-8 encoded, <b>NULL-terminated</b> string.
01093      *
01094      * @return BLE_ERROR_NONE if the device name was set correctly.
01095      */
01096     ble_error_t setDeviceName(const uint8_t *deviceName);
01097 
01098     /**
01099      * Get the value of the device name characteristic in the Generic Access
01100      * Service.
01101      *
01102      * To obtain the length of the deviceName value, this function is
01103      * invoked with the @p deviceName parameter set to NULL.
01104      *
01105      * @param[out] deviceName Pointer to an empty buffer where the UTF-8
01106      * <b>non NULL-terminated</b> string is placed.
01107      *
01108      * @param[in,out] lengthP Length of the @p deviceName buffer. If the device
01109      * name is successfully copied, then the length of the device name
01110      * string (excluding the null terminator) replaces this value.
01111      *
01112      * @return BLE_ERROR_NONE if the device name was fetched correctly from the
01113      * underlying BLE stack.
01114      *
01115      * @note If the device name is longer than the size of the supplied buffer,
01116      * length returns the complete device name length and not the number of
01117      * bytes actually returned in deviceName. The application may use this
01118      * information to retry with a suitable buffer size.
01119      */
01120     ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP);
01121 
01122     /**
01123      * Set the value of the appearance characteristic in the GAP service.
01124      *
01125      * @param[in] appearance The new value for the device-appearance.
01126      *
01127      * @return BLE_ERROR_NONE if the new appearance was set correctly.
01128      */
01129     ble_error_t setAppearance(GapAdvertisingData::Appearance appearance);
01130 
01131     /**
01132      * Get the value of the appearance characteristic in the GAP service.
01133      *
01134      * @param[out] appearanceP The current device-appearance value.
01135      *
01136      * @return BLE_ERROR_NONE if the device-appearance was fetched correctly
01137      * from the underlying BLE stack.
01138      */
01139     ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP);
01140 #endif // BLE_FEATURE_GATT_SERVER
01141 
01142     /**
01143      * Set the radio's transmit power.
01144      *
01145      * @param[in] txPower Radio's transmit power in dBm.
01146      *
01147      * @return BLE_ERROR_NONE if the new radio's transmit power was set
01148      * correctly.
01149      *
01150      * @deprecated Deprecated since addition of extended advertising support.
01151      * See ble::AdvertisingParameters and setAdvertisingParameters.
01152      */
01153     MBED_DEPRECATED_SINCE (
01154         "mbed-os-5.11.0",
01155         "Deprecated since addition of extended advertising support."
01156         "See ble::AdvertisingParameters and setAdvertisingParameters."
01157     )
01158     ble_error_t setTxPower(int8_t txPower);
01159 
01160     /**
01161      * Query the underlying stack for allowed Tx power values.
01162      *
01163      * @param[out] valueArrayPP Receive the immutable array of Tx values.
01164      * @param[out] countP Receive the array's size.
01165      *
01166      * @deprecated Deprecated since addition of extended advertising support.
01167      */
01168     MBED_DEPRECATED_SINCE (
01169         "mbed-os-5.11.0",
01170         "Deprecated since addition of extended advertising support."
01171     )
01172     void getPermittedTxPowerValues(
01173         const int8_t **valueArrayPP, size_t *countP
01174     );
01175 
01176 #if BLE_FEATURE_WHITELIST
01177     /**
01178      * Get the maximum size of the whitelist.
01179      *
01180      * @return Maximum size of the whitelist.
01181      *
01182      * @note If using Mbed OS, you can configure the size of the whitelist by
01183      * setting the YOTTA_CFG_WHITELIST_MAX_SIZE macro in your yotta config file.
01184      */
01185     uint8_t getMaxWhitelistSize(void) const;
01186 
01187     /**
01188      * Get the Link Layer to use the internal whitelist when scanning,
01189      * advertising or initiating a connection depending on the filter policies.
01190      *
01191      * @param[in,out] whitelist Define the whitelist instance which is used
01192      * to store the whitelist requested. In input, the caller provisions memory.
01193      *
01194      * @return BLE_ERROR_NONE if the implementation's whitelist was successfully
01195      * copied into the supplied reference.
01196      */
01197     ble_error_t getWhitelist(Whitelist_t &whitelist) const;
01198 
01199     /**
01200      * Set the value of the whitelist to be used during GAP procedures.
01201      *
01202      * @param[in] whitelist A reference to a whitelist containing the addresses
01203      * to be copied to the internal whitelist.
01204      *
01205      * @return BLE_ERROR_NONE if the implementation's whitelist was successfully
01206      * populated with the addresses in the given whitelist.
01207      *
01208      * @note The whitelist must not contain addresses of type @ref
01209      * BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE. This
01210      * results in a @ref BLE_ERROR_INVALID_PARAM because the remote peer might
01211      * change its private address at any time, and it is not possible to resolve
01212      * it.
01213      *
01214      * @note If the input whitelist is larger than @ref getMaxWhitelistSize(),
01215      * then @ref BLE_ERROR_PARAM_OUT_OF_RANGE is returned.
01216      */
01217     ble_error_t setWhitelist(const Whitelist_t &whitelist);
01218 
01219     /**
01220      * Set the advertising policy filter mode to be used during the next
01221      * advertising procedure.
01222      *
01223      * @param[in] mode New advertising policy filter mode.
01224      *
01225      * @return BLE_ERROR_NONE if the specified policy filter mode was set
01226      * successfully.
01227      *
01228      * @deprecated Deprecated since addition of extended advertising support.
01229      * This setting is now part of ble::AdvertisingParameters.
01230      */
01231     MBED_DEPRECATED_SINCE (
01232         "mbed-os-5.11.0",
01233         "Deprecated since addition of extended advertising support."
01234         "This setting is now part of ble::AdvertisingParameters."
01235     )
01236     ble_error_t setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode);
01237 
01238     /**
01239      * Set the scan policy filter mode to be used during the next scan procedure.
01240      *
01241      * @param[in] mode New scan policy filter mode.
01242      *
01243      * @return BLE_ERROR_NONE if the specified policy filter mode was set
01244      * successfully.
01245      *
01246      * @deprecated Deprecated since addition of extended advertising support.
01247      * This setting is now part of ble::ScanParameters.
01248      */
01249     MBED_DEPRECATED_SINCE (
01250         "mbed-os-5.11.0",
01251         "Deprecated since addition of extended advertising support."
01252         "This setting is now part of ble::ScanParameters."
01253     )
01254     ble_error_t setScanningPolicyMode(ScanningPolicyMode_t mode);
01255 
01256     /**
01257      * Set the initiator policy filter mode to be used during the next connection
01258      * initiation.
01259      *
01260      * @param[in] mode New initiator policy filter mode.
01261      *
01262      * @return BLE_ERROR_NONE if the specified policy filter mode was set
01263      * successfully.
01264      *
01265      * @deprecated Deprecated since addition of extended advertising support.
01266      * This setting is now part of ble::ConnectionParameters.
01267      */
01268     MBED_DEPRECATED_SINCE (
01269         "mbed-os-5.11.0",
01270         "Deprecated since addition of extended advertising support."
01271         "This setting is now part of ble::ConnectionParameters."
01272     )
01273     ble_error_t setInitiatorPolicyMode(InitiatorPolicyMode_t mode);
01274 
01275     /**
01276      * Get the current advertising policy filter mode.
01277      *
01278      * @return The current advertising policy filter mode.
01279      *
01280      * @deprecated Deprecated since addition of extended advertising support.
01281      */
01282     MBED_DEPRECATED_SINCE (
01283         "mbed-os-5.11.0",
01284         "Deprecated since addition of extended advertising support."
01285     )
01286     AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const;
01287 
01288     /**
01289      * Get the current scan policy filter mode.
01290      *
01291      * @return The current scan policy filter mode.
01292      *
01293      * @deprecated Deprecated since addition of extended advertising support.
01294      */
01295     MBED_DEPRECATED_SINCE (
01296         "mbed-os-5.11.0",
01297         "Deprecated since addition of extended advertising support."
01298     )
01299     ScanningPolicyMode_t getScanningPolicyMode(void) const;
01300 
01301     /**
01302      * Get the current initiator policy filter mode.
01303      *
01304      * @return The current scan policy filter mode.
01305      *
01306      * @deprecated Deprecated since addition of extended advertising support.
01307      */
01308     MBED_DEPRECATED_SINCE (
01309         "mbed-os-5.11.0",
01310         "Deprecated since addition of extended advertising support."
01311     )
01312     InitiatorPolicyMode_t getInitiatorPolicyMode(void) const;
01313 #endif // BLE_FEATURE_WHITELIST
01314 
01315 protected:
01316 #if BLE_ROLE_OBSERVER
01317     /* Override the following in the underlying adaptation layer to provide the
01318       functionality of scanning. */
01319 
01320     /**
01321      * Start scanning procedure in the underlying BLE stack.
01322      *
01323      * @param[in] scanningParams Parameters of the scan procedure.
01324      *
01325      * @return BLE_ERROR_NONE if the scan procedure was successfully started.
01326      *
01327      * @deprecated Deprecated since addition of extended advertising support.
01328      * Vendors should use the Cordio HCI interface or the ble::pal or implement
01329      * startScan(duplicates_filter_t, scan_duration_t, period)
01330      */
01331     MBED_DEPRECATED_SINCE (
01332         "mbed-os-5.11.0",
01333         "Deprecated since addition of extended advertising support. "
01334         "Vendors should use the cordio hci interface or the ble::pal or "
01335         "implement startScan(duplicates_filter_t, scan_duration_t, period)"
01336     )
01337     ble_error_t startRadioScan(const GapScanningParams &scanningParams);
01338 #endif // BLE_ROLE_OBSERVER
01339 
01340     /*
01341      * APIs with nonvirtual implementations.
01342      */
01343 public:
01344     /**
01345      * Get the current advertising and connection states of the device.
01346      *
01347      * @return The current GAP state of the device.
01348      *
01349      * @deprecated Deprecated since addition of extended advertising support.
01350      * This is not meaningful when you use extended advertising; Please replace
01351      * getState().advertising with isAdvertisingActive(), and replace
01352      * getState().connected with your own record and update during callbacks.
01353      */
01354     MBED_DEPRECATED_SINCE (
01355         "mbed-os-5.11.0",
01356         "Deprecated since addition of extended advertising support. "
01357         "Replace getState().advertising with isAdvertisingActive()."
01358         "Replace getState().connected with your own record and update during callbacks."
01359     )
01360     GapState_t getState(void) const;
01361 
01362 #if BLE_ROLE_BROADCASTER
01363     /**
01364      * Set the advertising type to use during the advertising procedure.
01365      *
01366      * @param[in] advType New type of advertising to use.
01367      *
01368      * @deprecated Deprecated since addition of extended advertising support.
01369      * This option is now part of ble::AdvertisingParameters.
01370      */
01371     MBED_DEPRECATED_SINCE (
01372         "mbed-os-5.11.0",
01373         "Deprecated since addition of extended advertising support. "
01374         "This option is now part of ble::AdvertisingParameters"
01375     )
01376     void setAdvertisingType(GapAdvertisingParams::AdvertisingType_t advType);
01377 
01378     /**
01379      * Set the advertising interval.
01380      *
01381      * @param[in] interval Advertising interval in units of milliseconds.
01382      * Advertising is disabled if interval is 0. If interval is smaller than
01383      * the minimum supported value, then the minimum supported value is used
01384      * instead. This minimum value can be discovered using
01385      * getMinAdvertisingInterval().
01386      *
01387      * This field must be set to 0 if connectionMode is equal
01388      * to ADV_CONNECTABLE_DIRECTED.
01389      *
01390      * @note  Decreasing this value allows central devices to detect a
01391      * peripheral faster, at the expense of the radio using more power
01392      * due to the higher data transmit rate.
01393      *
01394      * @deprecated Deprecated since addition of extended advertising support.
01395      * This option is now part of ble::AdvertisingParameters.
01396      */
01397     MBED_DEPRECATED_SINCE (
01398         "mbed-os-5.11.0",
01399         "Deprecated since addition of extended advertising support. "
01400         "This option is now part of ble::AdvertisingParameters"
01401     )
01402     void setAdvertisingInterval(uint16_t interval);
01403 
01404     /**
01405      * Set the advertising duration.
01406      *
01407      * A timeout event is genenerated once the advertising period expired.
01408      *
01409      * @param[in] timeout Advertising timeout (in seconds) between 0x1 and 0x3FFF.
01410      * The special value 0 may be used to disable the advertising timeout.
01411      *
01412      * @deprecated Deprecated since addition of extended advertising support.
01413      * This option is now part of ble::AdvertisingParameters.
01414      */
01415     MBED_DEPRECATED_SINCE (
01416         "mbed-os-5.11.0",
01417         "Deprecated since addition of extended advertising support. "
01418         "This option is now part of ble::AdvertisingParameters"
01419     )
01420     void setAdvertisingTimeout(uint16_t timeout);
01421 
01422     /**
01423      * Start the advertising procedure.
01424      *
01425      * @return BLE_ERROR_NONE if the device started advertising successfully.
01426      *
01427      * @deprecated Deprecated since addition of extended advertising support.
01428      * Use startAdvertising(advertising_handle_t, adv_duration_t, uint8_t) instead.
01429      */
01430     MBED_DEPRECATED_SINCE (
01431         "mbed-os-5.11.0",
01432         "Deprecated since addition of extended advertising support. "
01433         "Use startAdvertising(advertising_handle_t, adv_duration_t, uint8_t) instead."
01434     )
01435     ble_error_t startAdvertising(void);
01436 
01437     /**
01438      * Reset the value of the advertising payload advertised.
01439      *
01440      * @deprecated Deprecated since addition of extended advertising support.
01441      * Use setAdvertisingPayload(ble::advertising_handle_t, Span<uint8_t>,
01442      * bool).
01443      */
01444     MBED_DEPRECATED_SINCE (
01445         "mbed-os-5.11.0",
01446         "Deprecated since addition of extended advertising support. "
01447         "Use setAdvertisingPayload(ble::advertising_handle_t, Span<uint8_t>,"
01448         "bool)."
01449     )
01450     void clearAdvertisingPayload(void);
01451 
01452     /**
01453      * Set gap flags in the advertising payload.
01454      *
01455      * A call to this function is equivalent to:
01456      *
01457      * @code
01458      * Gap &gap;
01459      *
01460      * GapAdvertisingData payload = gap.getAdvertisingPayload();
01461      * payload.addFlags(flags);
01462      * gap.setAdvertisingPayload(payload);
01463      * @endcode
01464      *
01465      * @param[in] flags The flags to be added.
01466      *
01467      * @return BLE_ERROR_NONE if the data was successfully added to the
01468      * advertising payload.
01469      *
01470      * @deprecated Deprecated since addition of extended advertising support.
01471      * Use ble::AdvertisingDataBuilder.
01472      */
01473     MBED_DEPRECATED_SINCE (
01474         "mbed-os-5.11.0",
01475         "Deprecated since addition of extended advertising support."
01476         "Use ble::AdvertisingDataBuilder instead."
01477     )
01478     ble_error_t accumulateAdvertisingPayload(uint8_t flags);
01479 
01480     /**
01481      * Set the appearance field in the advertising payload.
01482      *
01483      * A call to this function is equivalent to:
01484      *
01485      * @code
01486      * Gap &gap;
01487      *
01488      * GapAdvertisingData payload = gap.getAdvertisingPayload();
01489      * payload.addAppearance(app);
01490      * gap.setAdvertisingPayload(payload);
01491      * @endcode
01492      *
01493      * @param[in] app The appearance to advertise.
01494      *
01495      * @return BLE_ERROR_NONE if the data was successfully added to the
01496      * advertising payload.
01497      *
01498      * @deprecated Deprecated since addition of extended advertising support.
01499      * Use ble::AdvertisingDataBuilder instead.
01500      */
01501     MBED_DEPRECATED_SINCE (
01502         "mbed-os-5.11.0",
01503         "Deprecated since addition of extended advertising support. "
01504         "Use ble::AdvertisingDataBuilder instead."
01505     )
01506     ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app);
01507 
01508     /**
01509      * Set the Tx Power field in the advertising payload.
01510      *
01511      * A call to this function is equivalent to:
01512      *
01513      * @code
01514      * Gap &gap;
01515      *
01516      * GapAdvertisingData payload = gap.getAdvertisingPayload();
01517      * payload.addTxPower(power);
01518      * gap.setAdvertisingPayload(payload);
01519      * @endcode
01520      *
01521      * @param[in] power Transmit power in dBm used by the controller to advertise.
01522      *
01523      * @return BLE_ERROR_NONE if the data was successfully added to the
01524      * advertising payload.
01525      *
01526      * @deprecated Deprecated since addition of extended advertising support.
01527      * Use ble::AdvertisingDataBuilder instead.
01528      */
01529     MBED_DEPRECATED_SINCE (
01530         "mbed-os-5.11.0",
01531         "Deprecated since addition of extended advertising support. "
01532         "Use ble::AdvertisingDataBuilder instead."
01533     )
01534     ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power);
01535 
01536     /**
01537      * Add a new field in the advertising payload.
01538      *
01539      * A call to this function is equivalent to:
01540      *
01541      * @code
01542      * Gap &gap;
01543      *
01544      * GapAdvertisingData payload = gap.getAdvertisingPayload();
01545      * payload.addData(type, data, len);
01546      * gap.setAdvertisingPayload(payload);
01547      * @endcode
01548      *
01549      * @param[in] type Identity of the field being added.
01550      * @param[in] data Buffer containing the value of the field.
01551      * @param[in] len Length of the data buffer.
01552      *
01553      * @return BLE_ERROR_NONE if the advertisement payload was updated based on
01554      * matching AD type; otherwise, an appropriate error.
01555      *
01556      * @note When the specified AD type is INCOMPLETE_LIST_16BIT_SERVICE_IDS,
01557      * COMPLETE_LIST_16BIT_SERVICE_IDS, INCOMPLETE_LIST_32BIT_SERVICE_IDS,
01558      * COMPLETE_LIST_32BIT_SERVICE_IDS, INCOMPLETE_LIST_128BIT_SERVICE_IDS,
01559      * COMPLETE_LIST_128BIT_SERVICE_IDS or LIST_128BIT_SOLICITATION_IDS the
01560      * supplied value is appended to the values previously added to the payload.
01561      *
01562      * @deprecated Deprecated since addition of extended advertising support.
01563      * Use ble::AdvertisingDataBuilder instead.
01564      */
01565     MBED_DEPRECATED_SINCE (
01566         "mbed-os-5.11.0",
01567         "Deprecated since addition of extended advertising support. "
01568         "Use ble::AdvertisingDataBuilder instead."
01569     )
01570     ble_error_t accumulateAdvertisingPayload(
01571         GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len
01572     );
01573 
01574     /**
01575      * Update a particular field in the advertising payload.
01576      *
01577      * A call to this function is equivalent to:
01578      *
01579      * @code
01580      * Gap &gap;
01581      *
01582      * GapAdvertisingData payload = gap.getAdvertisingPayload();
01583      * payload.updateData(type, data, len);
01584      * gap.setAdvertisingPayload(payload);
01585      * @endcode
01586      *
01587      *
01588      * @param[in] type Id of the field to update.
01589      * @param[in] data data buffer containing the new value of the field.
01590      * @param[in] len Length of the data buffer.
01591      *
01592      * @note If advertisements are enabled, then the update takes effect
01593      * immediately.
01594      *
01595      * @return BLE_ERROR_NONE if the advertisement payload was updated based on
01596      * matching AD type; otherwise, an appropriate error.
01597      *
01598      * @deprecated Deprecated since addition of extended advertising support.
01599      * Use ble::AdvertisingDataBuilder instead.
01600      */
01601     MBED_DEPRECATED_SINCE (
01602         "mbed-os-5.11.0",
01603         "Deprecated since addition of extended advertising support. "
01604         " Use ble::AdvertisingDataBuilder instead."
01605     )
01606     ble_error_t updateAdvertisingPayload(
01607         GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len
01608     );
01609 
01610     /**
01611      * Set the value of the payload advertised.
01612      *
01613      * @param[in] payload A reference to a user constructed advertisement
01614      * payload to set.
01615      *
01616      * @return BLE_ERROR_NONE if the advertisement payload was successfully
01617      * set.
01618      *
01619      * @deprecated Deprecated since addition of extended advertising support.
01620      * Use ble::AdvertisingDataBuilder instead.
01621      */
01622     MBED_DEPRECATED_SINCE (
01623         "mbed-os-5.11.0",
01624         "Deprecated since addition of extended advertising support. "
01625         "Use ble::AdvertisingDataBuilder instead."
01626     )
01627     ble_error_t setAdvertisingPayload(const GapAdvertisingData &payload);
01628 
01629     /**
01630      * Get a reference to the current advertising payload.
01631      *
01632      * @return A reference to the current advertising payload.
01633      *
01634      * @deprecated Deprecated since addition of extended advertising support.
01635      */
01636     MBED_DEPRECATED_SINCE (
01637         "mbed-os-5.11.0",
01638         "Deprecated since addition of extended advertising support."
01639     )
01640     const GapAdvertisingData &getAdvertisingPayload(void) const;
01641 
01642     /**
01643      * Add a new field in the advertising payload.
01644      *
01645      * @param[in] type AD type identifier.
01646      * @param[in] data buffer containing AD data.
01647      * @param[in] len Length of the data buffer.
01648      *
01649      * @return BLE_ERROR_NONE if the data was successfully added to the scan
01650      * response payload.
01651      *
01652      * @deprecated Deprecated since addition of extended advertising support.
01653      * Use createAdvertisingSet().
01654      */
01655     MBED_DEPRECATED_SINCE (
01656         "mbed-os-5.11.0",
01657         "Deprecated since addition of extended advertising support."
01658         "Use ble::AdvertisingDataBuilder instead."
01659     )
01660     ble_error_t accumulateScanResponse(
01661         GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len
01662     );
01663 
01664     /**
01665      * Reset the content of the scan response.
01666      *
01667      * @note This should be followed by a call to Gap::setAdvertisingPayload()
01668      * or Gap::startAdvertising() before the update takes effect.
01669      *
01670      * @deprecated Deprecated since addition of extended advertising support.
01671      * Use setAdvertisingScanResponse().
01672      */
01673     MBED_DEPRECATED_SINCE (
01674         "mbed-os-5.11.0",
01675         "Deprecated since addition of extended advertising support. "
01676         "Use setAdvertisingScanResponse() instead."
01677     )
01678     void clearScanResponse(void);
01679 #endif // BLE_ROLE_BROADCASTER
01680 #if BLE_ROLE_OBSERVER
01681     /**
01682      * Set the parameters used during a scan procedure.
01683      *
01684      * @param[in] interval in ms between the start of two consecutive scan windows.
01685      * That value is greater or equal to the scan window value. The
01686      * maximum allowed value is 10.24ms.
01687      *
01688      * @param[in] window Period in ms during which the scanner listens to
01689      * advertising channels. That value is in the range 2.5ms to 10.24s.
01690      *
01691      * @param[in] timeout Duration in seconds of the scan procedure if any. The
01692      * special value 0 disable specific duration of the scan procedure.
01693      *
01694      * @param[in] activeScanning If set to true, then the scanner sends scan
01695      * requests to a scannable or connectable advertiser. If set to false, then the
01696      * scanner does not send any request during the scan procedure.
01697      *
01698      * @return BLE_ERROR_NONE if the scan parameters were correctly set.
01699      *
01700      * @note The scanning window divided by the interval determines the duty
01701      * cycle for scanning. For example, if the interval is 100ms and the window
01702      * is 10ms, then the controller scans for 10 percent of the time.
01703      *
01704      * @note If the interval and the window are set to the same value, then the
01705      * device scans continuously during the scan procedure. The scanning
01706      * frequency changes at every interval.
01707      *
01708      * @note Once the scanning parameters have been configured, scanning can be
01709      * enabled by using startScan().
01710      *
01711      * @note The scan interval and window are recommendations to the BLE stack.
01712      *
01713      * @deprecated Deprecated since addition of extended advertising support.
01714      * Use setScanParameters(const ScanParameters &) instead.
01715      */
01716     MBED_DEPRECATED_SINCE (
01717         "mbed-os-5.11.0",
01718         "Deprecated since addition of extended advertising support. "
01719         "Use setScanParameters(const ScanParameters &) instead."
01720     )
01721     ble_error_t setScanParams(
01722         uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX,
01723         uint16_t window = GapScanningParams::SCAN_WINDOW_MAX,
01724         uint16_t timeout = 0,
01725         bool activeScanning = false
01726     );
01727 
01728     /**
01729      * Set the parameters used during a scan procedure.
01730      *
01731      * @param[in] scanningParams Parameter struct containing the interval, period,
01732      * timeout and active scanning toggle.
01733      *
01734      * @return BLE_ERROR_NONE if the scan parameters were correctly set.
01735      *
01736      * @note All restrictions from setScanParams(uint16_t, uint16_t, uint16_t, bool) apply.
01737      *
01738      * @deprecated Deprecated since addition of extended advertising support.
01739      * Use setScanParameters(const ScanParameters &) instead.
01740      */
01741     MBED_DEPRECATED_SINCE (
01742         "mbed-os-5.11.0",
01743         "Deprecated since addition of extended advertising support. "
01744         "Use setScanParameters(const ScanParameters &) instead."
01745     )
01746     ble_error_t setScanParams(const GapScanningParams &scanningParams);
01747 
01748     /**
01749      * Set the interval parameter used during scanning procedures.
01750      *
01751      * @param[in] interval Interval in ms between the start of two consecutive
01752      * scan windows. That value is greater or equal to the scan window value.
01753      * The maximum allowed value is 10.24ms.
01754      *
01755      * @return BLE_ERROR_NONE if the scan interval was correctly set.
01756      *
01757      * @deprecated Deprecated since addition of extended advertising support.
01758      * Use setScanParameters(const ScanParameters &) instead.
01759      */
01760     MBED_DEPRECATED_SINCE (
01761         "mbed-os-5.11.0",
01762         "Deprecated since addition of extended advertising support. "
01763         "Use setScanParameters(const ScanParameters &) instead."
01764     )
01765     ble_error_t setScanInterval(uint16_t interval);
01766 
01767     /**
01768      * Set the window parameter used during scanning procedures.
01769      *
01770      * @param[in] window Period in ms during which the scanner listens to
01771      * advertising channels. That value is in the range 2.5ms to 10.24s.
01772      *
01773      * @return BLE_ERROR_NONE if the scan window was correctly set.
01774      *
01775      * @note If scanning is already active, the updated value of scanWindow
01776      * is propagated to the underlying BLE stack.
01777      *
01778      * @deprecated Deprecated since addition of extended advertising support.
01779      * Use setScanParameters(const ScanParameters &) instead.
01780      */
01781     MBED_DEPRECATED_SINCE (
01782         "mbed-os-5.11.0",
01783         "Deprecated since addition of extended advertising support. "
01784         "Use setScanParameters(const ScanParameters &) instead."
01785     )
01786     ble_error_t setScanWindow(uint16_t window);
01787 
01788     /**
01789      * Set the timeout parameter used during scanning procedures.
01790      *
01791      * @param[in] timeout Duration in seconds of the scan procedure if any. The
01792      * special value 0 disables specific duration of the scan procedure.
01793      *
01794      * @return BLE_ERROR_NONE if the scan timeout was correctly set.
01795      *
01796      * @note If scanning is already active, the updated value of scanTimeout
01797      * is propagated to the underlying BLE stack.
01798      *
01799      * @deprecated Deprecated since addition of extended advertising support.
01800      * Use setScanParameters(const ScanParameters &) instead.
01801      */
01802     MBED_DEPRECATED_SINCE (
01803         "mbed-os-5.11.0",
01804         "Deprecated since addition of extended advertising support. "
01805         "Use setScanParameters(const ScanParameters &) instead."
01806     )
01807     ble_error_t setScanTimeout(uint16_t timeout);
01808 
01809     /**
01810      * Enable or disable active scanning.
01811      *
01812      * @param[in] activeScanning If set to true, then the scanner sends scan
01813      * requests to a scannable or connectable advertiser. If set to false then the
01814      * scanner does not send any request during the scan procedure.
01815      *
01816      * @return BLE_ERROR_NONE if active scanning was successfully set.
01817      *
01818      * @note If scanning is already in progress, then active scanning is
01819      * enabled for the underlying BLE stack.
01820      *
01821      * @deprecated Deprecated since addition of extended advertising support.
01822      * Use setScanParameters(const ScanParameters &) instead.
01823      */
01824     MBED_DEPRECATED_SINCE (
01825         "mbed-os-5.11.0",
01826         "Deprecated since addition of extended advertising support. "
01827         "Use setScanParameters(const ScanParameters &) instead."
01828     )
01829     ble_error_t setActiveScanning(bool activeScanning);
01830 
01831     /**
01832      * Start the scanning procedure.
01833      *
01834      * Packets received during the scan procedure are forwarded to the
01835      * scan packet handler passed as argument to this function.
01836      *
01837      * @param[in] callback Advertisement packet event handler. Upon reception
01838      * of an advertising packet, the packet is forwarded to @p callback.
01839      *
01840      * @return BLE_ERROR_NONE if the device successfully started the scan
01841      *         procedure.
01842      *
01843      * @note The parameters used by the procedure are defined by setScanParams().
01844      *
01845      * @deprecated Deprecated since addition of extended advertising support.
01846      * Use startScan(duplicates_filter_t, scan_duration_t, scan_period_t) instead.
01847      */
01848     MBED_DEPRECATED_SINCE (
01849         "mbed-os-5.11.0",
01850         "Deprecated since addition of extended advertising support. "
01851         "Use startScan(duplicates_filter_t, scan_duration_t, scan_period_t) instead."
01852     )
01853     ble_error_t startScan(
01854         void (*callback)(const AdvertisementCallbackParams_t *params)
01855     );
01856 
01857     /**
01858      * Start the scanning procedure.
01859      *
01860      * Packets received during the scan procedure are forwarded to the
01861      * scan packet handler passed as argument to this function.
01862      *
01863      * @param[in] object Instance used to invoke @p callbackMember.
01864      *
01865      * @param[in] callbackMember Advertisement packet event handler. Upon
01866      * reception of an advertising packet, the packet is forwarded to @p
01867      * callback invoked from @p object.
01868      *
01869      * @return BLE_ERROR_NONE if the device successfully started the scan
01870      * procedure.
01871      *
01872      * @note The parameters used by the procedure are defined by setScanParams().
01873      *
01874      * @deprecated Deprecated since addition of extended advertising support.
01875      * Use createAdvertisingSet().
01876      *
01877      * @deprecated Deprecated since addition of extended advertising support.
01878      * Use startScan(duplicates_filter_t, scan_duration_t, scan_period_t) instead.
01879      */
01880     template<typename T>
01881     MBED_DEPRECATED_SINCE (
01882         "mbed-os-5.11.0",
01883         "Deprecated since addition of extended advertising support. "
01884         "Use startScan(duplicates_filter_t, scan_duration_t, scan_period_t) instead."
01885     )
01886     ble_error_t startScan(
01887         T *object,
01888         void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)
01889     );
01890 #endif // BLE_ROLE_OBSERVER
01891 
01892     /**
01893      * Enable radio-notification events.
01894      *
01895      * Radio Notification is a feature that notifies the application when the
01896      * radio is in use.
01897      *
01898      * The ACTIVE signal is sent before the radio event starts. The nACTIVE
01899      * signal is sent at the end of the radio event. The application programmer can
01900      * use these signals to synchronize application logic with radio
01901      * activity. For example, the ACTIVE signal can be used to shut off external
01902      * devices, to manage peak current drawn during periods when the radio is on
01903      * or to trigger sensor data collection for transmission in the Radio Event.
01904      *
01905      * @return BLE_ERROR_NONE on successful initialization, otherwise an error code.
01906      *
01907      * @deprecated Deprecated since addition of extended advertising support.
01908      */
01909     MBED_DEPRECATED_SINCE (
01910         "mbed-os-5.11.0",
01911         "Deprecated since addition of extended advertising support. "
01912     )
01913     ble_error_t initRadioNotification(void);
01914 
01915 private:
01916 #if BLE_ROLE_BROADCASTER
01917     /**
01918      * Set the advertising data and scan response in the vendor subsytem.
01919      *
01920      * @param[in] advData Advertising data to set.
01921      * @param[in] scanResponse Scan response to set.
01922      *
01923      * @return BLE_ERROR_NONE if the advertising data was set successfully.
01924      *
01925      * @note Must be implemented in vendor port.
01926      *
01927      * @deprecated Deprecated since addition of extended advertising support.
01928      * Implement setAdvertisingPayload() and setAdvertisingScanResponse() instead.
01929      */
01930     MBED_DEPRECATED_SINCE (
01931         "mbed-os-5.11.0",
01932         "Deprecated since addition of extended advertising support. "
01933         "Implement setAdvertisingPayload() and setAdvertisingScanResponse() instead."
01934     )
01935     ble_error_t setAdvertisingData(
01936         const GapAdvertisingData &advData,
01937         const GapAdvertisingData &scanResponse
01938     );
01939 
01940     /**
01941      * Start the advertising procedure.
01942      *
01943      * @param[in] params Advertising parameters to use.
01944      *
01945      * @return BLE_ERROR_NONE if the advertising procedure successfully
01946      * started.
01947      *
01948      * @note Must be implemented in vendor port.
01949      *
01950      * @deprecated Deprecated since addition of extended advertising support.
01951      * Implement startAdvertising(advertising_handle_t, adv_duration_t, uint8_t)
01952      * instead.
01953      */
01954     MBED_DEPRECATED_SINCE (
01955         "mbed-os-5.11.0",
01956         "Deprecated since addition of extended advertising support. "
01957         "Implement startAdvertising(advertising_handle_t, adv_duration_t, uint8_t)"
01958         "instead."
01959     )
01960     ble_error_t startAdvertising(const GapAdvertisingParams &params);
01961 
01962 public:
01963     /**
01964      * Get the current advertising parameters.
01965      *
01966      * @return A reference to the current advertising parameters.
01967      *
01968      * @deprecated Deprecated since addition of extended advertising support.
01969      */
01970     MBED_DEPRECATED_SINCE (
01971         "mbed-os-5.11.0",
01972         "Deprecated since addition of extended advertising support."
01973     )
01974     GapAdvertisingParams &getAdvertisingParams(void);
01975 
01976     /**
01977      * Const alternative to Gap::getAdvertisingParams().
01978      *
01979      * @return A const reference to the current advertising parameters.
01980      *
01981      * @deprecated Deprecated since addition of extended advertising support.
01982      */
01983     MBED_DEPRECATED_SINCE (
01984         "mbed-os-5.11.0",
01985         "Deprecated since addition of extended advertising support."
01986     )
01987     const GapAdvertisingParams &getAdvertisingParams(void) const;
01988 
01989     /**
01990      * Set the advertising parameters.
01991      *
01992      * @param[in] newParams The new advertising parameters.
01993      *
01994      * @deprecated Deprecated since addition of extended advertising support.
01995      * Use setAdvertisingParameters() instead.
01996      */
01997     MBED_DEPRECATED_SINCE (
01998         "mbed-os-5.11.0",
01999         "Deprecated since addition of extended advertising support."
02000         "Use setAdvertisingParameters() instead."
02001     )
02002     void setAdvertisingParams(const GapAdvertisingParams &newParams);
02003 #endif // BLE_ROLE_BROADCASTER
02004     /* Event handlers. */
02005 public:
02006 
02007     /**
02008      * Register a callback handling timeout events.
02009      *
02010      * @param[in] callback Event handler being registered.
02011      *
02012      * @note A callback may be unregistered using onTimeout().detach(callback).
02013      *
02014      * @see TimeoutSource_t
02015      *
02016      * @deprecated Deprecated since addition of extended advertising support.
02017      * Use setEventHandler() instead.
02018      */
02019     MBED_DEPRECATED_SINCE (
02020         "mbed-os-5.11.0",
02021         "Deprecated since addition of extended advertising support. "
02022         "Use setEventHandler() instead."
02023     )
02024     void onTimeout(TimeoutEventCallback_t callback);
02025 
02026     /**
02027      * Get the callchain of registered timeout event handlers.
02028      *
02029      * @note To register callbacks, use onTimeout().add(callback).
02030      *
02031      * @note To unregister callbacks, use onTimeout().detach(callback).
02032      *
02033      * @return A reference to the timeout event callbacks chain.
02034      *
02035      * @deprecated Deprecated since addition of extended advertising support.
02036      * Use setEventHandler() instead.
02037      */
02038     MBED_DEPRECATED_SINCE (
02039         "mbed-os-5.11.0",
02040         "Deprecated since addition of extended advertising support. "
02041         "Use setEventHandler() instead."
02042     )
02043     TimeoutEventCallbackChain_t &onTimeout();
02044 #if BLE_FEATURE_CONNECTABLE
02045     /**
02046      * Register a callback handling connection events.
02047      *
02048      * @param[in] callback Event handler being registered.
02049      *
02050      * @note A callback may be unregistered using onConnection().detach(callback).
02051      *
02052      * @deprecated Deprecated since addition of extended advertising support.
02053      * Use setEventHandler() instead.
02054      */
02055     MBED_DEPRECATED_SINCE (
02056         "mbed-os-5.11.0",
02057         "Deprecated since addition of extended advertising support. "
02058         "Use setEventHandler() instead."
02059     )
02060     void onConnection(ConnectionEventCallback_t callback);
02061 
02062     /**
02063      * Register a callback handling connection events.
02064      *
02065      * @param[in] tptr Instance used to invoke @p mptr.
02066      * @param[in] mptr Event handler being registered.
02067      *
02068      * @note A callback may be unregistered using onConnection().detach(callback).
02069      *
02070      * @deprecated Deprecated since addition of extended advertising support.
02071      * Use setEventHandler() instead.
02072      */
02073     template<typename T>
02074     MBED_DEPRECATED_SINCE (
02075         "mbed-os-5.11.0",
02076         "Deprecated since addition of extended advertising support. "
02077         "Use setEventHandler() instead."
02078     )
02079     void onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t *));
02080 
02081     /**
02082      * Get the callchain of registered connection event handlers.
02083      *
02084      * @note To register callbacks, use onConnection().add(callback).
02085      *
02086      * @note To unregister callbacks, use onConnection().detach(callback).
02087      *
02088      * @return A reference to the connection event callbacks chain.
02089      *
02090      * @deprecated Deprecated since addition of extended advertising support.
02091      * Use setEventHandler() instead.
02092      */
02093     MBED_DEPRECATED_SINCE (
02094         "mbed-os-5.11.0",
02095         "Deprecated since addition of extended advertising support. "
02096         "Use setEventHandler() instead."
02097     )
02098     ConnectionEventCallbackChain_t &onConnection();
02099 
02100     /**
02101      * Register a callback handling disconnection events.
02102      *
02103      * @param[in] callback Event handler being registered.
02104      *
02105      * @note A callback may be unregistered using onDisconnection().detach(callback).
02106      *
02107      * @deprecated Deprecated since addition of extended advertising support.
02108      * Use setEventHandler() instead.
02109      */
02110     MBED_DEPRECATED_SINCE (
02111         "mbed-os-5.11.0",
02112         "Deprecated since addition of extended advertising support. "
02113         "Use setEventHandler() instead."
02114     )
02115     void onDisconnection(DisconnectionEventCallback_t callback);
02116 
02117     /**
02118      * Register a callback handling disconnection events.
02119      *
02120      * @param[in] tptr Instance used to invoke mptr.
02121      * @param[in] mptr Event handler being registered.
02122      *
02123      * @note A callback may be unregistered using onDisconnection().detach(callback).
02124      *
02125      * @deprecated Deprecated since addition of extended advertising support.
02126      * Use setEventHandler() instead.
02127      */
02128     template<typename T>
02129     MBED_DEPRECATED_SINCE (
02130         "mbed-os-5.11.0",
02131         "Deprecated since addition of extended advertising support. "
02132         "Use setEventHandler() instead."
02133     )
02134     void onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t *));
02135 
02136     /**
02137      * Get the callchain of registered disconnection event handlers.
02138      *
02139      * @note To register callbacks use onDisconnection().add(callback).
02140      *
02141      * @note To unregister callbacks use onDisconnection().detach(callback).
02142      *
02143      * @return A reference to the disconnection event callbacks chain.
02144      *
02145      * @deprecated Deprecated since addition of extended advertising support.
02146      * Use setEventHandler() instead.
02147      */
02148     MBED_DEPRECATED_SINCE (
02149         "mbed-os-5.11.0",
02150         "Deprecated since addition of extended advertising support. "
02151         "Use setEventHandler() instead."
02152     )
02153     DisconnectionEventCallbackChain_t &onDisconnection();
02154 #endif //BLE_FEATURE_CONNECTABLE
02155     /**
02156      * Set the radio-notification events handler.
02157      *
02158      * Radio Notification is a feature that enables ACTIVE and INACTIVE
02159      * (nACTIVE) signals from the stack that notify the application when the
02160      * radio is in use.
02161      *
02162      * The ACTIVE signal is sent before the radio event starts. The nACTIVE
02163      * signal is sent at the end of the radio event. The application programmer can
02164      * use these signals to synchronize application logic with radio
02165      * activity. For example, the ACTIVE signal can be used to shut off external
02166      * devices, to manage peak current drawn during periods when the radio is on
02167      * or to trigger sensor data collection for transmission in the Radio Event.
02168      *
02169      * @param[in] callback Application handler to be invoked in response to a
02170      * radio ACTIVE/INACTIVE event.
02171      *
02172      * @deprecated Deprecated since addition of extended advertising support.
02173      */
02174     MBED_DEPRECATED_SINCE (
02175         "mbed-os-5.11.0",
02176         "Deprecated since addition of extended advertising support. "
02177     )
02178     void onRadioNotification(void (*callback)(bool param));
02179 
02180     /**
02181      * Set the radio-notification events handler.
02182      *
02183      * @param[in] tptr Instance to be used to invoke mptr.
02184      * @param[in] mptr Application handler to be invoked in response to a
02185      * radio ACTIVE/INACTIVE event.
02186      *
02187      * @deprecated Deprecated since addition of extended advertising support.
02188      * Use setEventHandler() instead.
02189      */
02190     template<typename T>
02191     MBED_DEPRECATED_SINCE (
02192         "mbed-os-5.11.0",
02193         "Deprecated since addition of extended advertising support. "
02194         "Use setEventHandler() instead."
02195     )
02196     void onRadioNotification(T *tptr, void (T::*mptr)(bool));
02197 
02198     /**
02199      * Register a Gap shutdown event handler.
02200      *
02201      * The handler is called when the Gap instance is about to shut down.
02202      * It is usually issued after a call to BLE::shutdown().
02203      *
02204      * @param[in] callback Shutdown event handler to register.
02205      *
02206      * @note To unregister a shutdown event handler, use
02207      * onShutdown().detach(callback).
02208      */
02209     void onShutdown(const GapShutdownCallback_t &callback);
02210 
02211     /**
02212      * Register a Gap shutdown event handler.
02213      *
02214      * @param[in] objPtr Instance used to invoke @p memberPtr.
02215      * @param[in] memberPtr Shutdown event handler to register.
02216      */
02217     template<typename T>
02218     void onShutdown(T *objPtr, void (T::*memberPtr)(const LegacyGap *))
02219     {
02220         shutdownCallChain.add(objPtr, memberPtr);
02221     }
02222 
02223     /**
02224      * Access the callchain of shutdown event handler.
02225      *
02226      * @note To register callbacks, use onShutdown().add(callback).
02227      *
02228      * @note To unregister callbacks, use onShutdown().detach(callback).
02229      *
02230      * @return A reference to the shutdown event callback chain.
02231      */
02232     GapShutdownCallbackChain_t &onShutdown();
02233 
02234 public:
02235     /**
02236      * Reset the Gap instance.
02237      *
02238      * Reset process starts by notifying all registered shutdown event handlers
02239      * that the Gap instance is about to be shut down. Then, it clears all Gap state
02240      * of the associated object and then cleans the state present in the vendor
02241      * implementation.
02242      *
02243      * This function is meant to be overridden in the platform-specific
02244      * subclass. Nevertheless, the subclass only resets its
02245      * state and not the data held in Gap members. This is achieved by a
02246      * call to Gap::reset() from the subclass' reset() implementation.
02247      *
02248      * @return BLE_ERROR_NONE on success.
02249      *
02250      * @note Currently, a call to reset() does not reset the advertising and
02251      * scan parameters to default values.
02252      */
02253     ble_error_t reset(void);
02254 
02255 protected:
02256     /**
02257      * Construct a Gap instance.
02258      */
02259     LegacyGap();
02260 
02261     /* Entry points for the underlying stack to report events back to the user. */
02262 public:
02263     /**
02264      * Notify all registered connection event handlers of a connection event.
02265      *
02266      * @attention This function is meant to be called from the BLE stack specific
02267      * implementation when a connection event occurs.
02268      *
02269      * @param[in] handle Handle of the new connection.
02270      * @param[in] role Role of this BLE device in the connection.
02271      * @param[in] peerAddrType Address type of the connected peer.
02272      * @param[in] peerAddr Address of the connected peer.
02273      * @param[in] ownAddrType Address type this device uses for this
02274      * connection.
02275      * @param[in] ownAddr Address this device uses for this connection. This
02276      * parameter may be NULL if the local address is not available.
02277      * @param[in] connectionParams Parameters of the connection.
02278      * @param[in] peerResolvableAddr Resolvable address used by the peer.
02279      * @param[in] localResolvableAddr resolvable address used by the local device.
02280      *
02281      * @deprecated Deprecated since addition of extended advertising support.
02282      * Use EventHandler::onConnectionComplete() instead.
02283      */
02284     MBED_DEPRECATED_SINCE (
02285         "mbed-os-5.11.0",
02286         "Deprecated since addition of extended advertising support. "
02287         "Use EventHandler::onConnectionComplete() instead"
02288     )
02289     void processConnectionEvent(
02290         Handle_t handle,
02291         Role_t role,
02292         PeerAddressType_t peerAddrType,
02293         const BLEProtocol::AddressBytes_t peerAddr,
02294         BLEProtocol::AddressType_t ownAddrType,
02295         const BLEProtocol::AddressBytes_t ownAddr,
02296         const ConnectionParams_t *connectionParams,
02297         const uint8_t *peerResolvableAddr = NULL,
02298         const uint8_t *localResolvableAddr = NULL
02299     );
02300 
02301     /**
02302      * Notify all registered connection event handlers of a connection event.
02303      *
02304      * @attention This function is meant to be called from the BLE stack specific
02305      * implementation when a connection event occurs.
02306      *
02307      * @param[in] handle Handle of the new connection.
02308      * @param[in] role Role of this BLE device in the connection.
02309      * @param[in] peerAddrType Address type of the connected peer.
02310      * @param[in] peerAddr Address of the connected peer.
02311      * @param[in] ownAddrType Address type this device uses for this
02312      * connection.
02313      * @param[in] ownAddr Address this device uses for this connection.
02314      * @param[in] connectionParams Parameters of the connection.
02315      * @param[in] peerResolvableAddr Resolvable address used by the peer.
02316      * @param[in] localResolvableAddr resolvable address used by the local device.
02317      *
02318      * @deprecated The type BLEProtocol::AddressType_t is not suitable when
02319      * privacy is enabled. Use the overload that accepts a PeerAddressType_t
02320      * instead.
02321      */
02322     MBED_DEPRECATED_SINCE (
02323         "mbed-os-5.9.0",
02324         "The type BLEProtocol::AddressType_t is not suitable when privacy is "
02325         "enabled. Use the overload that accepts a PeerAddressType_t instead."
02326     )
02327     void processConnectionEvent(
02328         Handle_t handle,
02329         Role_t role,
02330         BLEProtocol::AddressType_t peerAddrType,
02331         const BLEProtocol::AddressBytes_t peerAddr,
02332         BLEProtocol::AddressType_t ownAddrType,
02333         const BLEProtocol::AddressBytes_t ownAddr,
02334         const ConnectionParams_t *connectionParams,
02335         const uint8_t *peerResolvableAddr = NULL,
02336         const uint8_t *localResolvableAddr = NULL
02337     );
02338 
02339     /**
02340      * Notify all registered disconnection event handlers of a disconnection event.
02341      *
02342      * @attention This function is meant to be called from the BLE stack specific
02343      * implementation when a disconnection event occurs.
02344      *
02345      * @param[in] handle Handle of the terminated connection.
02346      * @param[in] reason Reason of the disconnection.
02347      *
02348      * @deprecated Deprecated since addition of extended advertising support.
02349      * Use EventHandler::onDisconnection() instead.
02350      */
02351     MBED_DEPRECATED_SINCE (
02352         "mbed-os-5.11.0",
02353         "Deprecated since addition of extended advertising support. "
02354         "Use EventHandler::onDisconnectionComplete() instead"
02355     )
02356     void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason);
02357 
02358     /**
02359      * Forward a received advertising packet to all registered event handlers
02360      * listening for scanned packet events.
02361      *
02362      * @attention This function is meant to be called from the BLE stack specific
02363      * implementation when a disconnection event occurs.
02364      *
02365      * @param[in] peerAddr Address of the peer that has emitted the packet.
02366      * @param[in] rssi Value of the RSSI measured for the received packet.
02367      * @param[in] isScanResponse If true, then the packet is a response to a scan
02368      * request.
02369      * @param[in] type Advertising type of the packet.
02370      * @param[in] advertisingDataLen Length of the advertisement data received.
02371      * @param[in] advertisingData Pointer to the advertisement packet's data.
02372      * @param[in] addressType Type of the address of the peer that has emitted
02373      * the packet.
02374      *
02375      * @deprecated Deprecated since addition of extended advertising support.
02376      * Use EventHandler::onAdvertisingReport() instead.
02377      */
02378     MBED_DEPRECATED_SINCE (
02379         "mbed-os-5.11.0",
02380         "Deprecated since addition of extended advertising support. "
02381         "Use EventHandler::onAdvertisingReport() instead"
02382     )
02383     void processAdvertisementReport(
02384         const BLEProtocol::AddressBytes_t peerAddr,
02385         int8_t rssi,
02386         bool isScanResponse,
02387         GapAdvertisingParams::AdvertisingType_t type,
02388         uint8_t advertisingDataLen,
02389         const uint8_t *advertisingData,
02390         PeerAddressType_t addressType
02391     );
02392 
02393     /**
02394      * Forward a received advertising packet to all registered event handlers
02395      * listening for scanned packet events.
02396      *
02397      * @attention This function is meant to be called from the BLE stack specific
02398      * implementation when a disconnection event occurs.
02399      *
02400      * @param[in] peerAddr Address of the peer that has emitted the packet.
02401      * @param[in] rssi Value of the RSSI measured for the received packet.
02402      * @param[in] isScanResponse If true, then the packet is a response to a scan
02403      * request.
02404      * @param[in] type Advertising type of the packet.
02405      * @param[in] advertisingDataLen Length of the advertisement data received.
02406      * @param[in] advertisingData Pointer to the advertisement packet's data.
02407      * @param[in] addressType Type of the address of the peer that has emitted the packet.
02408      *
02409      * @deprecated The type BLEProtocol::AddressType_t is not suitable when
02410      * privacy is enabled. Use the overload that accepts a PeerAddressType_t
02411      * instead.
02412      */
02413     MBED_DEPRECATED_SINCE (
02414         "mbed-os-5.9.0",
02415         "The type BLEProtocol::AddressType_t is not suitable when privacy is "
02416         "enabled. Use the overload that accepts a PeerAddressType_t instead."
02417     )
02418     void processAdvertisementReport(
02419         const BLEProtocol::AddressBytes_t peerAddr,
02420         int8_t rssi,
02421         bool isScanResponse,
02422         GapAdvertisingParams::AdvertisingType_t type,
02423         uint8_t advertisingDataLen,
02424         const uint8_t *advertisingData,
02425         BLEProtocol::AddressType_t addressType = BLEProtocol::AddressType::RANDOM_STATIC
02426     );
02427 
02428     /**
02429      * Notify the occurrence of a timeout event to all registered timeout events
02430      * handler.
02431      *
02432      * @attention This function is meant to be called from the BLE stack specific
02433      * implementation when a disconnection event occurs.
02434      *
02435      * @param[in] source Source of the timout event.
02436      *
02437      * @deprecated Deprecated since addition of extended advertising support.
02438      * Use EventHandler instead.
02439      */
02440     MBED_DEPRECATED_SINCE (
02441         "mbed-os-5.11.0",
02442         "Deprecated since addition of extended advertising support. "
02443         "Use EventHandler instead"
02444     )
02445     void processTimeoutEvent(TimeoutSource_t source);
02446 
02447 protected:
02448     /**
02449      * Current advertising parameters.
02450      */
02451     GapAdvertisingParams _advParams;
02452 
02453     /**
02454      * Current advertising data.
02455      */
02456     GapAdvertisingData _advPayload;
02457 
02458     /**
02459      * Current scanning parameters.
02460      */
02461     GapScanningParams _scanningParams;
02462 
02463     /**
02464      * Current scan response.
02465      */
02466     GapAdvertisingData _scanResponse;
02467 
02468     /**
02469      * Number of open connections.
02470      */
02471     uint8_t connectionCount;
02472 
02473     /**
02474      * Current GAP state.
02475      */
02476     GapState_t state;
02477 
02478     /**
02479      * Active scanning flag.
02480      */
02481     bool scanningActive;
02482 
02483 protected:
02484     /**
02485      * Callchain containing all registered callback handlers for timeout
02486      * events.
02487      */
02488     TimeoutEventCallbackChain_t timeoutCallbackChain;
02489 
02490     /**
02491      * The registered callback handler for radio notification events.
02492      */
02493     RadioNotificationEventCallback_t radioNotificationCallback;
02494 
02495     /**
02496      * The registered callback handler for scanned advertisement packet
02497      * notifications.
02498      */
02499     AdvertisementReportCallback_t onAdvertisementReport;
02500 
02501     /**
02502      * Callchain containing all registered callback handlers for connection
02503      * events.
02504      */
02505     ConnectionEventCallbackChain_t connectionCallChain;
02506 
02507     /**
02508      * Callchain containing all registered callback handlers for disconnection
02509      * events.
02510      */
02511     DisconnectionEventCallbackChain_t disconnectionCallChain;
02512 
02513 private:
02514     /**
02515      * Callchain containing all registered callback handlers for shutdown
02516      * events.
02517      */
02518     GapShutdownCallbackChain_t shutdownCallChain;
02519 
02520 private:
02521     /* Disallow copy and assignment. */
02522     LegacyGap(const LegacyGap &);
02523 
02524     LegacyGap &operator=(const LegacyGap &);
02525 
02526 
02527 protected:
02528     using ble::interface::Gap<Impl>::startAdvertising_;
02529     using ble::interface::Gap<Impl>::stopAdvertising_;
02530     using ble::interface::Gap<Impl>::connect_;
02531     using ble::interface::Gap<Impl>::disconnect_;
02532 
02533     /* --- Abstract calls with default implementation --- */
02534     uint16_t getMinAdvertisingInterval_(void) const;
02535 
02536     uint16_t getMinNonConnectableAdvertisingInterval_(void) const;
02537 
02538     uint16_t getMaxAdvertisingInterval_(void) const;
02539 
02540     /* Note: Implementation must call the base class reset_ */
02541     ble_error_t reset_(void);
02542 
02543     /* --- Abstract calls to override --- */
02544 
02545     uint8_t getMaxWhitelistSize_(void) const;
02546 
02547     ble_error_t getWhitelist_(Whitelist_t &whitelist) const;
02548 
02549     ble_error_t setWhitelist_(const Whitelist_t &whitelist);
02550 
02551     ble_error_t setAddress_(
02552         BLEProtocol::AddressType_t type,
02553         const BLEProtocol::AddressBytes_t address
02554     );
02555 
02556     ble_error_t getAddress_(
02557         BLEProtocol::AddressType_t *typeP,
02558         BLEProtocol::AddressBytes_t address
02559     );
02560 
02561     ble_error_t stopAdvertising_(void);
02562 
02563     ble_error_t connect_(
02564         const BLEProtocol::AddressBytes_t peerAddr,
02565         PeerAddressType_t peerAddrType,
02566         const ConnectionParams_t *connectionParams,
02567         const GapScanningParams *scanParams
02568     );
02569 
02570     ble_error_t connect_(
02571         const BLEProtocol::AddressBytes_t peerAddr,
02572         BLEProtocol::AddressType_t peerAddrType,
02573         const ConnectionParams_t *connectionParams,
02574         const GapScanningParams *scanParams
02575     );
02576 
02577     ble_error_t disconnect_(
02578         Handle_t connectionHandle, DisconnectionReason_t reason
02579     );
02580 
02581     ble_error_t disconnect_(DisconnectionReason_t reason);
02582 
02583     ble_error_t updateConnectionParams_(
02584         Handle_t handle,
02585         const ConnectionParams_t *params
02586     );
02587 
02588     ble_error_t setTxPower_(int8_t txPower);
02589 
02590     void getPermittedTxPowerValues_(
02591         const int8_t **valueArrayPP, size_t *countP
02592     );
02593 
02594     ble_error_t setAdvertisingPolicyMode_(AdvertisingPolicyMode_t mode);
02595 
02596     ble_error_t setScanningPolicyMode_(ScanningPolicyMode_t mode);
02597 
02598     ble_error_t setInitiatorPolicyMode_(InitiatorPolicyMode_t mode);
02599 
02600     AdvertisingPolicyMode_t getAdvertisingPolicyMode_(void) const;
02601 
02602     ScanningPolicyMode_t getScanningPolicyMode_(void) const;
02603 
02604     InitiatorPolicyMode_t getInitiatorPolicyMode_(void) const;
02605 
02606     ble_error_t startRadioScan_(const GapScanningParams &scanningParams);
02607 
02608     ble_error_t initRadioNotification_(void);
02609 
02610     ble_error_t getPreferredConnectionParams_(ConnectionParams_t *params);
02611 
02612     ble_error_t setPreferredConnectionParams_(
02613         const ConnectionParams_t *params
02614     );
02615 
02616     ble_error_t setDeviceName_(const uint8_t *deviceName);
02617 
02618     ble_error_t getDeviceName_(uint8_t *deviceName, unsigned *lengthP);
02619 
02620     ble_error_t setAppearance_(GapAdvertisingData::Appearance appearance);
02621 
02622     ble_error_t getAppearance_(GapAdvertisingData::Appearance *appearanceP);
02623 
02624     ble_error_t setAdvertisingData_(
02625         const GapAdvertisingData &advData,
02626         const GapAdvertisingData &scanResponse
02627     );
02628 
02629     ble_error_t startAdvertising_(const GapAdvertisingParams &params);
02630 };
02631 
02632 /**
02633  * @}
02634  * @}
02635  */
02636 
02637 /* -------- deprecated template implementation -------- */
02638 
02639 #if defined(__GNUC__) && !defined(__CC_ARM)
02640 #pragma GCC diagnostic push
02641 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
02642 #elif defined(__CC_ARM)
02643 #pragma push
02644 #pragma diag_suppress 1361
02645 #endif
02646 
02647 #if BLE_ROLE_OBSERVER
02648 template<class Impl>
02649 template<typename T>
02650 ble_error_t LegacyGap<Impl>::startScan(
02651     T *object,
02652     void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)
02653 )
02654 {
02655     ble_error_t err = BLE_ERROR_NONE;
02656     if (object && callbackMember) {
02657         if ((err = startRadioScan(_scanningParams)) == BLE_ERROR_NONE) {
02658             scanningActive = true;
02659             onAdvertisementReport.attach(object, callbackMember);
02660         }
02661     }
02662 
02663     return err;
02664 }
02665 #endif // BLE_ROLE_OBSERVER
02666 
02667 #if BLE_FEATURE_CONNECTABLE
02668 template<class Impl>
02669 template<typename T>
02670 void LegacyGap<Impl>::onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t *))
02671 {
02672     connectionCallChain.add(tptr, mptr);
02673 }
02674 
02675 template<class Impl>
02676 template<typename T>
02677 void LegacyGap<Impl>::onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t *))
02678 {
02679     disconnectionCallChain.add(tptr, mptr);
02680 }
02681 #endif //BLE_FEATURE_CONNECTABLE
02682 
02683 template<class Impl>
02684 template<typename T>
02685 void LegacyGap<Impl>::onRadioNotification(T *tptr, void (T::*mptr)(bool))
02686 {
02687     radioNotificationCallback.attach(tptr, mptr);
02688 }
02689 
02690 #if defined(__GNUC__) && !defined(__CC_ARM)
02691 #pragma GCC diagnostic pop
02692 #elif defined(__CC_ARM)
02693 #pragma pop
02694 #endif
02695 
02696 } // interface
02697 } // ble
02698 
02699 // import LegacyGap implementation into global namespace
02700 typedef ble::impl::LegacyGap Gap;
02701 
02702 // import Gap implementation into ble namespace
02703 namespace ble {
02704 typedef impl::Gap Gap;
02705 }
02706 
02707 
02708 #endif // ifndef MBED_BLE_GAP_H__