mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			guard class fields with ifs
							parent
							
								
									33e8826361
								
							
						
					
					
						commit
						3e03c11832
					
				| 
						 | 
				
			
			@ -59,14 +59,20 @@ class LegacyGap :
 | 
			
		|||
    using ble::StaticInterface<Impl, ::ble::interface::LegacyGap>::impl;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    using ble::interface::Gap<Impl>::setAdvertisingParameters;
 | 
			
		||||
    using ble::interface::Gap<Impl>::setAdvertisingPayload;
 | 
			
		||||
    using ble::interface::Gap<Impl>::setAdvertisingScanResponse;
 | 
			
		||||
    using ble::interface::Gap<Impl>::startAdvertising;
 | 
			
		||||
    using ble::interface::Gap<Impl>::stopAdvertising;
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    using ble::interface::Gap<Impl>::connect;
 | 
			
		||||
    using ble::interface::Gap<Impl>::disconnect;
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    using ble::interface::Gap<Impl>::startScan;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Address-type for BLEProtocol addresses.
 | 
			
		||||
| 
						 | 
				
			
			@ -400,6 +406,7 @@ public:
 | 
			
		|||
        CENTRAL = 0x2,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /**
 | 
			
		||||
     * Representation of a scanned advertising packet.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -474,7 +481,9 @@ public:
 | 
			
		|||
     */
 | 
			
		||||
    typedef FunctionPointerWithContext<const AdvertisementCallbackParams_t *>
 | 
			
		||||
        AdvertisementReportCallback_t;
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    /**
 | 
			
		||||
     * Connection events.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -665,6 +674,7 @@ public:
 | 
			
		|||
        {
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @copydoc ble::peripheral_privacy_configuration_t
 | 
			
		||||
| 
						 | 
				
			
			@ -844,6 +854,7 @@ public:
 | 
			
		|||
        RandomAddressType_t *addressType
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the minimum advertising interval in milliseconds, which can be used
 | 
			
		||||
     * for connectable advertising types.
 | 
			
		||||
| 
						 | 
				
			
			@ -886,7 +897,8 @@ public:
 | 
			
		|||
        "Use stopAdvertising(advertising_handle_t) instead."
 | 
			
		||||
    )
 | 
			
		||||
    ble_error_t stopAdvertising(void);
 | 
			
		||||
 | 
			
		||||
#endif //BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    /**
 | 
			
		||||
     * Initiate a connection to a peer.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -1069,7 +1081,8 @@ public:
 | 
			
		|||
        Handle_t handle,
 | 
			
		||||
        const ConnectionParams_t *params
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
#if BLE_FEATURE_GATT_SERVER
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the value of the device name characteristic in the Generic Access
 | 
			
		||||
     * Service.
 | 
			
		||||
| 
						 | 
				
			
			@ -1123,7 +1136,8 @@ public:
 | 
			
		|||
     * from the underlying BLE stack.
 | 
			
		||||
     */
 | 
			
		||||
    ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP);
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_GATT_SERVER
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the radio's transmit power.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -1157,7 +1171,8 @@ public:
 | 
			
		|||
    void getPermittedTxPowerValues(
 | 
			
		||||
        const int8_t **valueArrayPP, size_t *countP
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the maximum size of the whitelist.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -1294,8 +1309,10 @@ public:
 | 
			
		|||
        "Deprecated since addition of extended advertising support."
 | 
			
		||||
    )
 | 
			
		||||
    InitiatorPolicyMode_t getInitiatorPolicyMode(void) const;
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    /* Override the following in the underlying adaptation layer to provide the
 | 
			
		||||
      functionality of scanning. */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1317,6 +1334,7 @@ protected:
 | 
			
		|||
        "implement startScan(duplicates_filter_t, scan_duration_t, period)"
 | 
			
		||||
    )
 | 
			
		||||
    ble_error_t startRadioScan(const GapScanningParams &scanningParams);
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * APIs with nonvirtual implementations.
 | 
			
		||||
| 
						 | 
				
			
			@ -1338,6 +1356,7 @@ public:
 | 
			
		|||
    )
 | 
			
		||||
    GapState_t getState(void) const;
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the advertising type to use during the advertising procedure.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -1654,7 +1673,8 @@ public:
 | 
			
		|||
        "Use setAdvertisingScanResponse() instead."
 | 
			
		||||
    )
 | 
			
		||||
    void clearScanResponse(void);
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the parameters used during a scan procedure.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -1864,6 +1884,7 @@ public:
 | 
			
		|||
        T *object,
 | 
			
		||||
        void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)
 | 
			
		||||
    );
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Enable radio-notification events.
 | 
			
		||||
| 
						 | 
				
			
			@ -1889,6 +1910,7 @@ public:
 | 
			
		|||
    ble_error_t initRadioNotification(void);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the advertising data and scan response in the vendor subsytem.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -1975,7 +1997,7 @@ public:
 | 
			
		|||
        "Use setAdvertisingParameters() instead."
 | 
			
		||||
    )
 | 
			
		||||
    void setAdvertisingParams(const GapAdvertisingParams &newParams);
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
    /* Event handlers. */
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2016,7 +2038,7 @@ public:
 | 
			
		|||
        "Use setEventHandler() instead."
 | 
			
		||||
    )
 | 
			
		||||
    TimeoutEventCallbackChain_t &onTimeout();
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    /**
 | 
			
		||||
     * Register a callback handling connection events.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -2126,7 +2148,7 @@ public:
 | 
			
		|||
        "Use setEventHandler() instead."
 | 
			
		||||
    )
 | 
			
		||||
    DisconnectionEventCallbackChain_t &onDisconnection();
 | 
			
		||||
 | 
			
		||||
#endif //BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    /**
 | 
			
		||||
     * Set the radio-notification events handler.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -2235,6 +2257,7 @@ protected:
 | 
			
		|||
 | 
			
		||||
    /* Entry points for the underlying stack to report events back to the user. */
 | 
			
		||||
public:
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    /**
 | 
			
		||||
     * Notify all registered connection event handlers of a connection event.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -2329,7 +2352,8 @@ public:
 | 
			
		|||
        "Use EventHandler::onDisconnectionComplete() instead"
 | 
			
		||||
    )
 | 
			
		||||
    void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason);
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    /**
 | 
			
		||||
     * Forward a received advertising packet to all registered event handlers
 | 
			
		||||
     * listening for scanned packet events.
 | 
			
		||||
| 
						 | 
				
			
			@ -2399,7 +2423,7 @@ public:
 | 
			
		|||
        const uint8_t *advertisingData,
 | 
			
		||||
        BLEProtocol::AddressType_t addressType = BLEProtocol::AddressType::RANDOM_STATIC
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
    /**
 | 
			
		||||
     * Notify the occurrence of a timeout event to all registered timeout events
 | 
			
		||||
     * handler.
 | 
			
		||||
| 
						 | 
				
			
			@ -2420,6 +2444,7 @@ public:
 | 
			
		|||
    void processTimeoutEvent(TimeoutSource_t source);
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /**
 | 
			
		||||
     * Current advertising parameters.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -2429,31 +2454,36 @@ protected:
 | 
			
		|||
     * Current advertising data.
 | 
			
		||||
     */
 | 
			
		||||
    GapAdvertisingData _advPayload;
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    /**
 | 
			
		||||
     * Current scanning parameters.
 | 
			
		||||
     */
 | 
			
		||||
    GapScanningParams _scanningParams;
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /**
 | 
			
		||||
     * Current scan response.
 | 
			
		||||
     */
 | 
			
		||||
    GapAdvertisingData _scanResponse;
 | 
			
		||||
 | 
			
		||||
#endif BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    /**
 | 
			
		||||
     * Number of open connections.
 | 
			
		||||
     */
 | 
			
		||||
    uint8_t connectionCount;
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Current GAP state.
 | 
			
		||||
     */
 | 
			
		||||
    GapState_t state;
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    /**
 | 
			
		||||
     * Active scanning flag.
 | 
			
		||||
     */
 | 
			
		||||
    bool scanningActive;
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -2467,12 +2497,14 @@ protected:
 | 
			
		|||
     */
 | 
			
		||||
    RadioNotificationEventCallback_t radioNotificationCallback;
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    /**
 | 
			
		||||
     * The registered callback handler for scanned advertisement packet
 | 
			
		||||
     * notifications.
 | 
			
		||||
     */
 | 
			
		||||
    AdvertisementReportCallback_t onAdvertisementReport;
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    /**
 | 
			
		||||
     * Callchain containing all registered callback handlers for connection
 | 
			
		||||
     * events.
 | 
			
		||||
| 
						 | 
				
			
			@ -2484,7 +2516,7 @@ protected:
 | 
			
		|||
     * events.
 | 
			
		||||
     */
 | 
			
		||||
    DisconnectionEventCallbackChain_t disconnectionCallChain;
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
private:
 | 
			
		||||
    /**
 | 
			
		||||
     * Callchain containing all registered callback handlers for shutdown
 | 
			
		||||
| 
						 | 
				
			
			@ -2619,6 +2651,7 @@ protected:
 | 
			
		|||
#pragma diag_suppress 1361
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
template<class Impl>
 | 
			
		||||
template<typename T>
 | 
			
		||||
ble_error_t LegacyGap<Impl>::startScan(
 | 
			
		||||
| 
						 | 
				
			
			@ -2636,7 +2669,9 @@ ble_error_t LegacyGap<Impl>::startScan(
 | 
			
		|||
 | 
			
		||||
    return err;
 | 
			
		||||
}
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
template<class Impl>
 | 
			
		||||
template<typename T>
 | 
			
		||||
void LegacyGap<Impl>::onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t *))
 | 
			
		||||
| 
						 | 
				
			
			@ -2650,6 +2685,7 @@ void LegacyGap<Impl>::onDisconnection(T *tptr, void (T::*mptr)(const Disconnecti
 | 
			
		|||
{
 | 
			
		||||
    disconnectionCallChain.add(tptr, mptr);
 | 
			
		||||
}
 | 
			
		||||
#endif //BLE_FEATURE_CONNECTABLE
 | 
			
		||||
 | 
			
		||||
template<class Impl>
 | 
			
		||||
template<typename T>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -319,7 +319,6 @@ public:
 | 
			
		|||
        return _channel37;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** Check if channel 38 is used for primary advertising.
 | 
			
		||||
     *
 | 
			
		||||
     * @return True if channel used.
 | 
			
		||||
| 
						 | 
				
			
			@ -329,7 +328,6 @@ public:
 | 
			
		|||
        return _channel38;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** Check if channel 39 is used for primary advertising.
 | 
			
		||||
     *
 | 
			
		||||
     * @return True if channel used.
 | 
			
		||||
| 
						 | 
				
			
			@ -394,7 +392,6 @@ public:
 | 
			
		|||
        return _peerAddressType;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
    /** Set the filter policy of whitelist use during advertising;
 | 
			
		||||
     *
 | 
			
		||||
     * @param mode Policy to use.
 | 
			
		||||
| 
						 | 
				
			
			@ -403,8 +400,12 @@ public:
 | 
			
		|||
     */
 | 
			
		||||
    AdvertisingParameters &setFilter(advertising_filter_policy_t mode)
 | 
			
		||||
    {
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
        _policy = mode;
 | 
			
		||||
        return *this;
 | 
			
		||||
#else
 | 
			
		||||
#error "Whitelist feature disabled"
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** Get the filter policy of whitelist use during advertising;
 | 
			
		||||
| 
						 | 
				
			
			@ -413,23 +414,15 @@ public:
 | 
			
		|||
     */
 | 
			
		||||
    advertising_filter_policy_t getFilter() const
 | 
			
		||||
    {
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
        return _policy;
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    AdvertisingParameters &setFilter(advertising_filter_policy_t mode)
 | 
			
		||||
    {
 | 
			
		||||
#error "Whitelist feature disabled"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    advertising_filter_policy_t getFilter() const
 | 
			
		||||
    {
 | 
			
		||||
        return advertising_filter_policy_t::NO_FILTER;
 | 
			
		||||
    }
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Extended advertising parameters */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** Get PHYs used on primary and secondary advertising channels.
 | 
			
		||||
     *
 | 
			
		||||
     * @param primaryPhy Primary advertising channels PHY.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,7 @@
 | 
			
		|||
#include "ble/gap/ScanParameters.h"
 | 
			
		||||
#include "ble/gap/AdvertisingParameters.h"
 | 
			
		||||
#include "ble/gap/Events.h"
 | 
			
		||||
#include "BLERoles.h"
 | 
			
		||||
 | 
			
		||||
namespace ble {
 | 
			
		||||
#if !defined(DOXYGEN_ONLY)
 | 
			
		||||
| 
						 | 
				
			
			@ -284,6 +285,7 @@ public:
 | 
			
		|||
     * Definition of the general handler of Gap related events.
 | 
			
		||||
     */
 | 
			
		||||
    struct EventHandler {
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
        /**
 | 
			
		||||
         * Called when an advertising device receive a scan response.
 | 
			
		||||
         *
 | 
			
		||||
| 
						 | 
				
			
			@ -312,7 +314,8 @@ public:
 | 
			
		|||
        virtual void onAdvertisingEnd(const AdvertisingEndEvent &event)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
        /**
 | 
			
		||||
         * Called when a scanner receives an advertising or a scan response packet.
 | 
			
		||||
         *
 | 
			
		||||
| 
						 | 
				
			
			@ -334,7 +337,8 @@ public:
 | 
			
		|||
        virtual void onScanTimeout(const ScanTimeoutEvent &event)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
        /**
 | 
			
		||||
         * Called when first advertising packet in periodic advertising is received.
 | 
			
		||||
         *
 | 
			
		||||
| 
						 | 
				
			
			@ -379,7 +383,8 @@ public:
 | 
			
		|||
        )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
        /**
 | 
			
		||||
         * Called when connection attempt ends or an advertising device has been
 | 
			
		||||
         * connected.
 | 
			
		||||
| 
						 | 
				
			
			@ -440,7 +445,8 @@ public:
 | 
			
		|||
        virtual void onDisconnectionComplete(const DisconnectionCompleteEvent &event)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
#if BLE_FEATURE_PHY_MANAGEMENT
 | 
			
		||||
        /**
 | 
			
		||||
         * Function invoked when the current transmitter and receiver PHY have
 | 
			
		||||
         * been read for a given connection.
 | 
			
		||||
| 
						 | 
				
			
			@ -521,7 +527,7 @@ public:
 | 
			
		|||
        )
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
 | 
			
		||||
    protected:
 | 
			
		||||
        /**
 | 
			
		||||
         * Prevent polymorphic deletion and avoid unnecessary virtual destructor
 | 
			
		||||
| 
						 | 
				
			
			@ -551,7 +557,7 @@ public:
 | 
			
		|||
    bool isFeatureSupported(controller_supported_features_t feature);
 | 
			
		||||
 | 
			
		||||
    /*                                     advertising                                           */
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /** Return currently available number of supported advertising sets.
 | 
			
		||||
     *  This may change at runtime.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -689,7 +695,8 @@ public:
 | 
			
		|||
     * @return True if advertising is active on this set.
 | 
			
		||||
     */
 | 
			
		||||
    bool isAdvertisingActive(advertising_handle_t handle);
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
    /** Set periodic advertising parameters for a given advertising set.
 | 
			
		||||
     *
 | 
			
		||||
     * @param handle Advertising set handle.
 | 
			
		||||
| 
						 | 
				
			
			@ -754,9 +761,9 @@ public:
 | 
			
		|||
     * @version 5+
 | 
			
		||||
     */
 | 
			
		||||
    bool isPeriodicAdvertisingActive(advertising_handle_t handle);
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
    /*                                     scanning                                              */
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    /** Set new scan parameters.
 | 
			
		||||
     *
 | 
			
		||||
     * @param params Scan parameters, @see GapScanParameters for details.
 | 
			
		||||
| 
						 | 
				
			
			@ -794,7 +801,8 @@ public:
 | 
			
		|||
     * @retval BLE_ERROR_NONE if successfully stopped scanning procedure.
 | 
			
		||||
     */
 | 
			
		||||
    ble_error_t stopScan();
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
    /** Synchronize with periodic advertising from an advertiser and begin receiving periodic
 | 
			
		||||
     *  advertising packets.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -896,7 +904,8 @@ public:
 | 
			
		|||
     * @return Number of devices that can be added to the periodic advertiser list.
 | 
			
		||||
     */
 | 
			
		||||
    uint8_t getMaxPeriodicAdvertiserListSize();
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    /**
 | 
			
		||||
     * Initiate a connection to a peer.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -1069,7 +1078,8 @@ public:
 | 
			
		|||
        connection_handle_t connectionHandle,
 | 
			
		||||
        local_disconnection_reason_t reason
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
#if BLE_FEATURE_PHY_MANAGEMENT
 | 
			
		||||
    /**
 | 
			
		||||
     * Read the PHY used by the transmitter and the receiver on a connection.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			@ -1138,7 +1148,8 @@ public:
 | 
			
		|||
        const phy_set_t *rxPhys,
 | 
			
		||||
        coded_symbol_per_bit_t codedSymbol
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
    /**
 | 
			
		||||
     * Default peripheral privacy configuration.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -1231,14 +1242,10 @@ public:
 | 
			
		|||
    ble_error_t getCentralPrivacyConfiguration(
 | 
			
		||||
        central_privay_configuration_t *configuration
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
 | 
			
		||||
#if !defined(DOXYGEN_ONLY)
 | 
			
		||||
 | 
			
		||||
    /* Override the following in the underlying adaptation layer to provide the
 | 
			
		||||
     * functionality of scanning. */
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    /** Can only be called if use_non_deprecated_scan_api() hasn't been called.
 | 
			
		||||
     *  This guards against mixed use of deprecated and nondeprecated API.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -1249,12 +1256,6 @@ protected:
 | 
			
		|||
     */
 | 
			
		||||
    void useVersionTwoAPI() const;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
 | 
			
		||||
#if !defined(DOXYGEN_ONLY)
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Construct a Gap instance.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -1396,13 +1397,13 @@ protected:
 | 
			
		|||
    );
 | 
			
		||||
    void useVersionOneAPI_() const;
 | 
			
		||||
    void useVersionTwoAPI_() const;
 | 
			
		||||
#endif // !defined(DOXYGEN_ONLY)
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    /**
 | 
			
		||||
     * Event handler provided by the application.
 | 
			
		||||
     */
 | 
			
		||||
    EventHandler *_eventHandler;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -389,7 +389,7 @@ struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8
 | 
			
		|||
         * not used.
 | 
			
		||||
         */
 | 
			
		||||
        NO_FILTER = 0x00,
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
        /**
 | 
			
		||||
         * Process connection requests from all devices but filter out scan requests
 | 
			
		||||
         * of devices that are not in the whitelist.
 | 
			
		||||
| 
						 | 
				
			
			@ -407,6 +407,7 @@ struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8
 | 
			
		|||
         * whitelist.
 | 
			
		||||
         */
 | 
			
		||||
        FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -431,7 +432,7 @@ struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
 | 
			
		|||
        * addressed to this device.
 | 
			
		||||
        */
 | 
			
		||||
        NO_FILTER = 0x00,
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
        /**
 | 
			
		||||
        * Accept only advertising packets from devices in the whitelist except
 | 
			
		||||
        * directed advertising packets not addressed to this device.
 | 
			
		||||
| 
						 | 
				
			
			@ -458,6 +459,7 @@ struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
 | 
			
		|||
         * resolvable private address that cannot be resolved are also accepted.
 | 
			
		||||
         */
 | 
			
		||||
        FILTER_ADVERTISING_INCLUDE_UNRESOLVABLE_DIRECTED = 3
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -480,11 +482,12 @@ struct initiator_filter_policy_t : SafeEnum<initiator_filter_policy_t, uint8_t>
 | 
			
		|||
        * The whitelist is not used to determine which advertiser to connect to.
 | 
			
		||||
        */
 | 
			
		||||
        NO_FILTER,
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
        /**
 | 
			
		||||
        * The whitelist is used to determine which advertiser to connect to.
 | 
			
		||||
        */
 | 
			
		||||
        USE_WHITE_LIST
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -785,31 +785,39 @@ private:
 | 
			
		|||
 | 
			
		||||
private:
 | 
			
		||||
    pal::EventQueue &_event_queue;
 | 
			
		||||
#if BLE_FEATURE_GATT_SERVER
 | 
			
		||||
    PalGap &_pal_gap;
 | 
			
		||||
    pal::GenericAccessService &_gap_service;
 | 
			
		||||
#endif
 | 
			
		||||
#if BLE_FEATURE_SECURITY
 | 
			
		||||
    PalSecurityManager &_pal_sm;
 | 
			
		||||
#endif
 | 
			
		||||
    BLEProtocol::AddressType_t _address_type;
 | 
			
		||||
    ble::address_t _address;
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
    pal::initiator_policy_t _initiator_policy_mode;
 | 
			
		||||
    pal::scanning_filter_policy_t _scanning_filter_policy;
 | 
			
		||||
    pal::advertising_filter_policy_t _advertising_filter_policy;
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
    mutable Whitelist_t _whitelist;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
    bool _privacy_enabled;
 | 
			
		||||
    PeripheralPrivacyConfiguration_t _peripheral_privacy_configuration;
 | 
			
		||||
    CentralPrivacyConfiguration_t _central_privacy_configuration;
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
    ble::address_t _random_static_identity_address;
 | 
			
		||||
    bool _random_address_rotating;
 | 
			
		||||
 | 
			
		||||
    bool _scan_enabled;
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    mbed::Timeout _advertising_timeout;
 | 
			
		||||
#endif
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    mbed::Timeout _scan_timeout;
 | 
			
		||||
#endif
 | 
			
		||||
    mbed::Ticker _address_rotation_ticker;
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
 | 
			
		||||
    template<size_t bit_size>
 | 
			
		||||
    struct BitArray {
 | 
			
		||||
        BitArray() : data()
 | 
			
		||||
| 
						 | 
				
			
			@ -861,6 +869,7 @@ private:
 | 
			
		|||
    BitArray<MAX_ADVERTISING_SETS> _active_periodic_sets;
 | 
			
		||||
    BitArray<MAX_ADVERTISING_SETS> _connectable_payload_size_exceeded;
 | 
			
		||||
    BitArray<MAX_ADVERTISING_SETS> _set_is_connectable;
 | 
			
		||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
 | 
			
		||||
 | 
			
		||||
    // deprecation flags
 | 
			
		||||
    mutable bool _deprecated_scan_api_used : 1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -906,18 +906,32 @@ ble_error_t LegacyGap<Impl>::reset(void)
 | 
			
		|||
 | 
			
		||||
template<class Impl>
 | 
			
		||||
LegacyGap<Impl>::LegacyGap() :
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    _advParams(),
 | 
			
		||||
    _advPayload(),
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    _scanningParams(),
 | 
			
		||||
#endif
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    _scanResponse(),
 | 
			
		||||
#endif
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    connectionCount(0),
 | 
			
		||||
#endif
 | 
			
		||||
    state(),
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    scanningActive(false),
 | 
			
		||||
#endif
 | 
			
		||||
    timeoutCallbackChain(),
 | 
			
		||||
    radioNotificationCallback(),
 | 
			
		||||
    onAdvertisementReport(),
 | 
			
		||||
    connectionCallChain(),
 | 
			
		||||
    disconnectionCallChain()
 | 
			
		||||
    radioNotificationCallback()
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    , onAdvertisementReport()
 | 
			
		||||
#endif
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    , connectionCallChain()
 | 
			
		||||
    , disconnectionCallChain()
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
{
 | 
			
		||||
    _advPayload.clear();
 | 
			
		||||
    _scanResponse.clear();
 | 
			
		||||
| 
						 | 
				
			
			@ -977,19 +991,28 @@ ble_error_t LegacyGap<Impl>::reset_(void)
 | 
			
		|||
    /* Clear Gap state */
 | 
			
		||||
    state.advertising = 0;
 | 
			
		||||
    state.connected = 0;
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    connectionCount = 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /* Clear scanning state */
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    scanningActive = false;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    /* Clear advertising and scanning data */
 | 
			
		||||
    _advPayload.clear();
 | 
			
		||||
    _scanResponse.clear();
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
 | 
			
		||||
    /* Clear callbacks */
 | 
			
		||||
    timeoutCallbackChain.clear();
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    connectionCallChain.clear();
 | 
			
		||||
    disconnectionCallChain.clear();
 | 
			
		||||
#endif // BLE_FEATURE_CONNECTABLE
 | 
			
		||||
    radioNotificationCallback = NULL;
 | 
			
		||||
    onAdvertisementReport = NULL;
 | 
			
		||||
    ble::interface::Gap<Impl>::_eventHandler = NULL;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,7 +112,9 @@ bool Gap<Impl>::isAdvertisingActive(advertising_handle_t handle)
 | 
			
		|||
{
 | 
			
		||||
    return impl()->isAdvertisingActive_(handle);
 | 
			
		||||
}
 | 
			
		||||
#endif // BLE_ROLE_BROADCASTER
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
template<class Impl>
 | 
			
		||||
ble_error_t Gap<Impl>::setPeriodicAdvertisingParameters(
 | 
			
		||||
    advertising_handle_t handle,
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +157,9 @@ bool Gap<Impl>::isPeriodicAdvertisingActive(advertising_handle_t handle)
 | 
			
		|||
{
 | 
			
		||||
    return impl()->isPeriodicAdvertisingActive_(handle);
 | 
			
		||||
}
 | 
			
		||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
template<class Impl>
 | 
			
		||||
ble_error_t Gap<Impl>::setScanParameters(const ScanParameters ¶ms)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -177,7 +181,8 @@ ble_error_t Gap<Impl>::stopScan()
 | 
			
		|||
{
 | 
			
		||||
    return impl()->stopScan_();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // BLE_ROLE_OBSERVER
 | 
			
		||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
template<class Impl>
 | 
			
		||||
ble_error_t Gap<Impl>::createSync(
 | 
			
		||||
    peer_address_type_t peerAddressType,
 | 
			
		||||
| 
						 | 
				
			
			@ -256,7 +261,9 @@ uint8_t Gap<Impl>::getMaxPeriodicAdvertiserListSize()
 | 
			
		|||
{
 | 
			
		||||
    return impl()->getMaxPeriodicAdvertiserListSize_();
 | 
			
		||||
}
 | 
			
		||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_CONNECTABLE
 | 
			
		||||
template<class Impl>
 | 
			
		||||
ble_error_t Gap<Impl>::connect(
 | 
			
		||||
    peer_address_type_t peerAddressType,
 | 
			
		||||
| 
						 | 
				
			
			@ -345,7 +352,9 @@ ble_error_t Gap<Impl>::disconnect(
 | 
			
		|||
{
 | 
			
		||||
    return impl()->disconnect_(connectionHandle, reason);
 | 
			
		||||
}
 | 
			
		||||
#endif BLE_FEATURE_CONNECTABLE
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_PHY_MANAGEMENT
 | 
			
		||||
template<class Impl>
 | 
			
		||||
ble_error_t Gap<Impl>::readPhy(connection_handle_t connection)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -393,6 +402,7 @@ template<class Impl>
 | 
			
		|||
Gap<Impl>::Gap() : _eventHandler(NULL)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
 | 
			
		||||
 | 
			
		||||
/* -------------------- Future deprecation ------------------------- */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -408,6 +418,7 @@ const central_privay_configuration_t Gap<Impl>::default_central_privacy_configur
 | 
			
		|||
    /* resolution_strategy */ central_privay_configuration_t::RESOLVE_AND_FORWARD
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
template<class Impl>
 | 
			
		||||
ble_error_t Gap<Impl>::enablePrivacy(bool enable)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -445,6 +456,7 @@ ble_error_t Gap<Impl>::getCentralPrivacyConfiguration(
 | 
			
		|||
{
 | 
			
		||||
    return impl()->getCentralPrivacyConfiguration_(configuration);
 | 
			
		||||
}
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
/* ------------------------- Default implementations ------------------------ */
 | 
			
		||||
| 
						 | 
				
			
			@ -456,6 +468,7 @@ bool Gap<Impl>::isFeatureSupported_(controller_supported_features_t feature)
 | 
			
		|||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
template<class Impl>
 | 
			
		||||
uint8_t Gap<Impl>::getMaxAdvertisingSetNumber_()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -436,17 +436,25 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
 | 
			
		|||
    _pal_sm(pal_sm),
 | 
			
		||||
#endif
 | 
			
		||||
    _address_type(LegacyAddressType::PUBLIC),
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
    _initiator_policy_mode(pal::initiator_policy_t::NO_FILTER),
 | 
			
		||||
    _scanning_filter_policy(pal::scanning_filter_policy_t::NO_FILTER),
 | 
			
		||||
    _advertising_filter_policy(pal::advertising_filter_policy_t::NO_FILTER),
 | 
			
		||||
    _whitelist(),
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
    _privacy_enabled(false),
 | 
			
		||||
    _peripheral_privacy_configuration(default_peripheral_privacy_configuration),
 | 
			
		||||
    _central_privacy_configuration(default_central_privacy_configuration),
 | 
			
		||||
#endif //BLE_FEATURE_PRIVACY
 | 
			
		||||
    _random_address_rotating(false),
 | 
			
		||||
    _scan_enabled(false),
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    _advertising_timeout(),
 | 
			
		||||
#endif
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    _scan_timeout(),
 | 
			
		||||
#endif
 | 
			
		||||
    _deprecated_scan_api_used(false),
 | 
			
		||||
    _non_deprecated_scan_api_used(false),
 | 
			
		||||
    _user_manage_connection_parameter_requests(false)
 | 
			
		||||
| 
						 | 
				
			
			@ -639,7 +647,11 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
 | 
			
		|||
    return _pal_gap.create_connection(
 | 
			
		||||
        scanParams->getInterval(),
 | 
			
		||||
        scanParams->getWindow(),
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
        _initiator_policy_mode,
 | 
			
		||||
#else
 | 
			
		||||
        pal::initiator_policy_t::NO_FILTER,
 | 
			
		||||
#endif
 | 
			
		||||
        (pal::connection_peer_address_type_t::type) peerAddrType.value(),
 | 
			
		||||
        ble::address_t(peerAddr),
 | 
			
		||||
        get_own_address_type(CENTRAL_CONNECTION /* requires resolvable address */),
 | 
			
		||||
| 
						 | 
				
			
			@ -1187,8 +1199,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
 | 
			
		|||
{
 | 
			
		||||
    useVersionOneAPI();
 | 
			
		||||
 | 
			
		||||
    useVersionOneAPI();
 | 
			
		||||
 | 
			
		||||
    if (mode > LegacyGap::SCAN_POLICY_FILTER_ALL_ADV) {
 | 
			
		||||
        return BLE_ERROR_INVALID_PARAM;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -1240,24 +1250,32 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
 | 
			
		|||
        return BLE_ERROR_INVALID_PARAM;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
    if (_scanning_filter_policy == pal::scanning_filter_policy_t::FILTER_ADVERTISING &&
 | 
			
		||||
        _whitelist.size == 0) {
 | 
			
		||||
        return BLE_ERROR_INVALID_STATE;
 | 
			
		||||
    }
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
 | 
			
		||||
    pal::own_address_type_t own_address_type = get_own_address_type(CENTRAL_SCAN /* central, can use non resolvable address for scan requests */);
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
    if (_privacy_enabled && (own_address_type == pal::own_address_type_t::RANDOM)) {
 | 
			
		||||
        // Use non-resolvable static random address
 | 
			
		||||
        set_random_address_rotation(true);
 | 
			
		||||
    }
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
 | 
			
		||||
    ble_error_t err = _pal_gap.set_scan_parameters(
 | 
			
		||||
        scanningParams.getActiveScanning(),
 | 
			
		||||
        scanningParams.getInterval(),
 | 
			
		||||
        scanningParams.getWindow(),
 | 
			
		||||
        own_address_type,
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
        _scanning_filter_policy
 | 
			
		||||
#else
 | 
			
		||||
        pal::scanning_filter_policy_t::NO_FILTER
 | 
			
		||||
#endif // BLE_FEATURE_WHITELIST
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    if (err) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1391,10 +1409,12 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
 | 
			
		|||
 | 
			
		||||
    pal::own_address_type_t own_address_type = get_own_address_type(address_use_type);
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
    if (_privacy_enabled && (own_address_type == pal::own_address_type_t::RANDOM)) {
 | 
			
		||||
        // Use non-resolvable static random address
 | 
			
		||||
        set_random_address_rotation(true);
 | 
			
		||||
    }
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
 | 
			
		||||
    // TODO: fix the high level API to have a min/max range
 | 
			
		||||
    // Going against recommendations (The Advertising_Interval_Min and
 | 
			
		||||
| 
						 | 
				
			
			@ -1410,7 +1430,11 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
 | 
			
		|||
        pal::advertising_peer_address_type_t::PUBLIC,
 | 
			
		||||
        ble::address_t(),
 | 
			
		||||
        pal::advertising_channel_map_t::ALL_ADVERTISING_CHANNELS,
 | 
			
		||||
#if BLE_FEATURE_WHITELIST
 | 
			
		||||
        _advertising_filter_policy
 | 
			
		||||
#else
 | 
			
		||||
        pal::advertising_filter_policy_t::NO_FILTER
 | 
			
		||||
#endif
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    if (err) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1441,8 +1465,12 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
 | 
			
		|||
{
 | 
			
		||||
    LegacyGap::reset_();
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_BROADCASTER
 | 
			
		||||
    _advertising_timeout.detach();
 | 
			
		||||
#endif
 | 
			
		||||
#if BLE_ROLE_OBSERVER
 | 
			
		||||
    _scan_timeout.detach();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if (is_extended_advertising_available()) {
 | 
			
		||||
        /* stop all advertising sets */
 | 
			
		||||
| 
						 | 
				
			
			@ -1650,6 +1678,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
 | 
			
		|||
    for (size_t i = 0; i < e.size(); ++i) {
 | 
			
		||||
        pal::GapAdvertisingReportEvent::advertising_t advertising = e[i];
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
        // Check if the address hasn't been resolved
 | 
			
		||||
        if (_privacy_enabled &&
 | 
			
		||||
            _central_privacy_configuration.resolution_strategy == CentralPrivacyConfiguration_t::RESOLVE_AND_FILTER &&
 | 
			
		||||
| 
						 | 
				
			
			@ -1659,6 +1688,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
 | 
			
		|||
            // Filter it out
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
 | 
			
		||||
        // note 1-to-1 conversion between connection_peer_address_type_t and
 | 
			
		||||
        // peer_address_type_t
 | 
			
		||||
| 
						 | 
				
			
			@ -1756,6 +1786,8 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
 | 
			
		|||
    bool needs_pairing = false;
 | 
			
		||||
    bool needs_authentication = false;
 | 
			
		||||
 | 
			
		||||
#if BLE_ROLE_PERIPHERAL
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
    if (_privacy_enabled &&
 | 
			
		||||
        e.role.value() == e.role.PERIPHERAL &&
 | 
			
		||||
        e.peer_address_type == peer_address_type_t::RANDOM
 | 
			
		||||
| 
						 | 
				
			
			@ -1791,6 +1823,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
 | 
			
		||||
    if (e.role.value() == e.role.PERIPHERAL) {
 | 
			
		||||
        _advertising_timeout.detach();
 | 
			
		||||
| 
						 | 
				
			
			@ -1799,6 +1832,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
 | 
			
		|||
        // Stop address rotation if required
 | 
			
		||||
        set_random_address_rotation(false);
 | 
			
		||||
    }
 | 
			
		||||
#endif // BLE_ROLE_PERIPHERAL
 | 
			
		||||
 | 
			
		||||
    // using these parameters if stupid, there is no range for the
 | 
			
		||||
    // connection interval when the connection is established
 | 
			
		||||
| 
						 | 
				
			
			@ -1932,6 +1966,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
 | 
			
		|||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
 | 
			
		||||
pal::own_address_type_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::get_own_address_type(AddressUseType_t address_use_type)
 | 
			
		||||
{
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
    if (_privacy_enabled) {
 | 
			
		||||
        bool use_non_resolvable_address = false;
 | 
			
		||||
        if (address_use_type == CENTRAL_SCAN) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1952,6 +1987,7 @@ pal::own_address_type_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEve
 | 
			
		|||
                return pal::own_address_type_t::RESOLVABLE_PRIVATE_ADDRESS_RANDOM_FALLBACK;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
 | 
			
		||||
    switch (_address_type) {
 | 
			
		||||
        case BLEProtocol::AddressType::PUBLIC:
 | 
			
		||||
| 
						 | 
				
			
			@ -3092,9 +3128,11 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
 | 
			
		|||
{
 | 
			
		||||
    useVersionTwoAPI();
 | 
			
		||||
 | 
			
		||||
#if BLE_FEATURE_PRIVACY
 | 
			
		||||
    if (_privacy_enabled && _central_privacy_configuration.use_non_resolvable_random_address) {
 | 
			
		||||
        set_random_address_rotation(true);
 | 
			
		||||
    }
 | 
			
		||||
#endif // BLE_FEATURE_PRIVACY
 | 
			
		||||
 | 
			
		||||
    if (is_extended_advertising_available()) {
 | 
			
		||||
        ble_error_t err = _pal_gap.extended_scan_enable(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue