mirror of https://github.com/ARMmbed/mbed-os.git
Add to Gap/GenericGap non-deprecated APIs originally in LegacyGap
parent
2989466b01
commit
c17cf0f3f3
|
@ -20,6 +20,7 @@
|
|||
#include "BLERoles.h"
|
||||
#include "ble/common/StaticInterface.h"
|
||||
#include "ble/BLETypes.h"
|
||||
#include "ble/CallChainOfFunctionPointersWithContext.h"
|
||||
#include "ble/gap/AdvertisingDataBuilder.h"
|
||||
#include "ble/gap/AdvertisingDataSimpleBuilder.h"
|
||||
#include "ble/gap/ConnectionParameters.h"
|
||||
|
@ -278,6 +279,21 @@ class Gap : public StaticInterface<Impl, Gap> {
|
|||
#endif
|
||||
using StaticInterface<Impl, ::ble::interface::Gap>::impl;
|
||||
|
||||
/**
|
||||
* Gap shutdown event handler.
|
||||
*
|
||||
* @see Gap::onShutdown().
|
||||
*/
|
||||
typedef FunctionPointerWithContext<const Gap *> GapShutdownCallback_t;
|
||||
|
||||
/**
|
||||
* Callchain of gap shutdown event handler.
|
||||
*
|
||||
* @see Gap::onShutdown().
|
||||
*/
|
||||
typedef CallChainOfFunctionPointersWithContext<const Gap *>
|
||||
GapShutdownCallbackChain_t;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -531,6 +547,53 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameters of a BLE connection.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* Minimum interval between two connection events allowed for a
|
||||
* connection.
|
||||
*
|
||||
* It shall be less than or equal to maxConnectionInterval. This value,
|
||||
* in units of 1.25ms, is included in the range [0x0006 : 0x0C80].
|
||||
*/
|
||||
uint16_t minConnectionInterval;
|
||||
|
||||
/**
|
||||
* Maximum interval between two connection events allowed for a
|
||||
* connection.
|
||||
*
|
||||
* It shall be greater than or equal to minConnectionInterval. This
|
||||
* value is in unit of 1.25ms and is in the range [0x0006 : 0x0C80].
|
||||
*/
|
||||
uint16_t maxConnectionInterval;
|
||||
|
||||
/**
|
||||
* Number of connection events the slave can drop if it has nothing to
|
||||
* communicate to the master.
|
||||
*
|
||||
* This value shall be in the range [0x0000 : 0x01F3].
|
||||
*/
|
||||
uint16_t slaveLatency;
|
||||
|
||||
/**
|
||||
* Link supervision timeout for the connection.
|
||||
*
|
||||
* Time after which the connection is considered lost if the device
|
||||
* didn't receive a packet from its peer.
|
||||
*
|
||||
* It is larger than:
|
||||
* (1 + slaveLatency) * maxConnectionInterval * 2
|
||||
*
|
||||
* This value is in the range [0x000A : 0x0C80] and is in unit of
|
||||
* 10 ms.
|
||||
*
|
||||
* @note maxConnectionInterval is in ms in the formulae above.
|
||||
*/
|
||||
uint16_t connectionSupervisionTimeout;
|
||||
} ConnectionParams_t;
|
||||
|
||||
/**
|
||||
* Assign the event handler implementation that will be used by the gap
|
||||
* module to signal events back to the application.
|
||||
|
@ -1164,7 +1227,7 @@ public:
|
|||
/**
|
||||
* Default peripheral privacy configuration.
|
||||
*/
|
||||
static const central_privay_configuration_t
|
||||
static const central_privacy_configuration_t
|
||||
default_central_privacy_configuration;
|
||||
|
||||
|
||||
|
@ -1238,7 +1301,7 @@ public:
|
|||
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
|
||||
*/
|
||||
ble_error_t setCentralPrivacyConfiguration(
|
||||
const central_privay_configuration_t *configuration
|
||||
const central_privacy_configuration_t *configuration
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -1250,7 +1313,7 @@ public:
|
|||
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
|
||||
*/
|
||||
ble_error_t getCentralPrivacyConfiguration(
|
||||
central_privay_configuration_t *configuration
|
||||
central_privacy_configuration_t *configuration
|
||||
);
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
#endif // BLE_FEATURE_PRIVACY
|
||||
|
@ -1297,6 +1360,94 @@ public:
|
|||
|
||||
#endif // BLE_FEATURE_WHITELIST
|
||||
|
||||
/**
|
||||
* Fetch the current address and its type.
|
||||
*
|
||||
* @param[out] typeP Type of the current address set.
|
||||
* @param[out] address Value of the current address.
|
||||
*
|
||||
* @note If privacy is enabled the device address may be unavailable to
|
||||
* application code.
|
||||
*
|
||||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
ble_error_t getAddress(
|
||||
BLEProtocol::AddressType_t *typeP,
|
||||
BLEProtocol::AddressBytes_t address
|
||||
);
|
||||
|
||||
/**
|
||||
* Return the type of a random address.
|
||||
*
|
||||
* @param[in] address The random address to retrieve the type from. The
|
||||
* address must be ordered in little endian.
|
||||
*
|
||||
* @param[out] addressType Type of the address to fill.
|
||||
*
|
||||
* @return BLE_ERROR_NONE in case of success or BLE_ERROR_INVALID_PARAM if
|
||||
* the address in input was not identifiable as a random address.
|
||||
*/
|
||||
static ble_error_t getRandomAddressType(
|
||||
const BLEProtocol::AddressBytes_t address,
|
||||
ble::random_address_type_t *addressType
|
||||
);
|
||||
|
||||
/**
|
||||
* Reset the Gap instance.
|
||||
*
|
||||
* Reset process starts by notifying all registered shutdown event handlers
|
||||
* that the Gap instance is about to be shut down. Then, it clears all Gap state
|
||||
* of the associated object and then cleans the state present in the vendor
|
||||
* implementation.
|
||||
*
|
||||
* This function is meant to be overridden in the platform-specific
|
||||
* subclass. Nevertheless, the subclass only resets its
|
||||
* state and not the data held in Gap members. This is achieved by a
|
||||
* call to Gap::reset() from the subclass' reset() implementation.
|
||||
*
|
||||
* @return BLE_ERROR_NONE on success.
|
||||
*
|
||||
* @note Currently, a call to reset() does not reset the advertising and
|
||||
* scan parameters to default values.
|
||||
*/
|
||||
ble_error_t reset(void);
|
||||
|
||||
/**
|
||||
* Register a Gap shutdown event handler.
|
||||
*
|
||||
* The handler is called when the Gap instance is about to shut down.
|
||||
* It is usually issued after a call to BLE::shutdown().
|
||||
*
|
||||
* @param[in] callback Shutdown event handler to register.
|
||||
*
|
||||
* @note To unregister a shutdown event handler, use
|
||||
* onShutdown().detach(callback).
|
||||
*/
|
||||
void onShutdown(const GapShutdownCallback_t &callback);
|
||||
|
||||
/**
|
||||
* Register a Gap shutdown event handler.
|
||||
*
|
||||
* @param[in] objPtr Instance used to invoke @p memberPtr.
|
||||
* @param[in] memberPtr Shutdown event handler to register.
|
||||
*/
|
||||
template<typename T>
|
||||
void onShutdown(T *objPtr, void (T::*memberPtr)(const Gap *))
|
||||
{
|
||||
shutdownCallChain.add(objPtr, memberPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the callchain of shutdown event handler.
|
||||
*
|
||||
* @note To register callbacks, use onShutdown().add(callback).
|
||||
*
|
||||
* @note To unregister callbacks, use onShutdown().detach(callback).
|
||||
*
|
||||
* @return A reference to the shutdown event callback chain.
|
||||
*/
|
||||
GapShutdownCallbackChain_t &onShutdown();
|
||||
|
||||
#if !defined(DOXYGEN_ONLY)
|
||||
/*
|
||||
* API reserved for the controller driver to set the random static address.
|
||||
|
@ -1312,6 +1463,7 @@ protected:
|
|||
*/
|
||||
Gap();
|
||||
|
||||
|
||||
/* ----------------- API to override in derived class -------------- */
|
||||
|
||||
bool isFeatureSupported_(controller_supported_features_t feature);
|
||||
|
@ -1441,17 +1593,32 @@ protected:
|
|||
peripheral_privacy_configuration_t *configuration
|
||||
);
|
||||
ble_error_t setCentralPrivacyConfiguration_(
|
||||
const central_privay_configuration_t *configuration
|
||||
const central_privacy_configuration_t *configuration
|
||||
);
|
||||
ble_error_t getCentralPrivacyConfiguration_(
|
||||
central_privay_configuration_t *configuration
|
||||
central_privacy_configuration_t *configuration
|
||||
);
|
||||
ble_error_t setRandomStaticAddress_(const ble::address_t& address);
|
||||
uint8_t getMaxWhitelistSize_(void) const;
|
||||
ble_error_t getWhitelist_(whitelist_t &whitelist) const;
|
||||
ble_error_t setWhitelist_(const whitelist_t &whitelist);
|
||||
|
||||
ble_error_t getAddress_(
|
||||
BLEProtocol::AddressType_t *typeP,
|
||||
BLEProtocol::AddressBytes_t address
|
||||
);
|
||||
|
||||
/* Note: Implementation must call the base class reset_ */
|
||||
ble_error_t reset_(void);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Callchain containing all registered callback handlers for shutdown
|
||||
* events.
|
||||
*/
|
||||
GapShutdownCallbackChain_t shutdownCallChain;
|
||||
|
||||
/**
|
||||
* Event handler provided by the application.
|
||||
*/
|
||||
|
|
|
@ -49,7 +49,7 @@ template<
|
|||
class ConnectionEventMonitorEventHandler
|
||||
>
|
||||
class GenericGap :
|
||||
public interface::LegacyGap<
|
||||
public interface::Gap<
|
||||
GenericGap<TPalGap, PalSecurityManager, ConnectionEventMonitorEventHandler>
|
||||
>,
|
||||
public pal::ConnectionEventMonitor<
|
||||
|
@ -60,38 +60,28 @@ class GenericGap :
|
|||
>
|
||||
{
|
||||
// Typedef of base and companion classes .
|
||||
typedef ::ble::interface::LegacyGap<GenericGap> LegacyGap;
|
||||
// typedef ::ble::interface::LegacyGap<GenericGap> LegacyGap;
|
||||
typedef ::ble::interface::Gap<GenericGap> Gap;
|
||||
typedef pal::ConnectionEventMonitor<ConnectionEventMonitorEventHandler> ConnectionEventMonitor;
|
||||
typedef TPalGap<GenericGap> PalGap;
|
||||
typedef pal::GapEventHandler<GenericGap> PalGapEventHandler;
|
||||
|
||||
// Friendship with base classes
|
||||
friend LegacyGap;
|
||||
// friend LegacyGap;
|
||||
friend Gap;
|
||||
friend ConnectionEventMonitor;
|
||||
friend pal::GapEventHandler<GenericGap>;
|
||||
friend PalGap;
|
||||
|
||||
// Imports from LegacyGap
|
||||
using LegacyGap::_eventHandler;
|
||||
using LegacyGap::default_peripheral_privacy_configuration;
|
||||
using LegacyGap::default_central_privacy_configuration;
|
||||
using LegacyGap::state;
|
||||
using Gap::_eventHandler;
|
||||
using Gap::default_peripheral_privacy_configuration;
|
||||
using Gap::default_central_privacy_configuration;
|
||||
// using Gap::state;
|
||||
|
||||
typedef typename BLEProtocol::AddressBytes_t Address_t;
|
||||
typedef typename ble::whitelist_t whitelist_t;
|
||||
typedef typename LegacyGap::PeerAddressType_t PeerAddressType_t;
|
||||
typedef typename LegacyGap::ConnectionParams_t ConnectionParams_t;
|
||||
typedef typename LegacyGap::Handle_t Handle_t;
|
||||
typedef typename LegacyGap::CodedSymbolPerBit_t CodedSymbolPerBit_t;
|
||||
typedef typename LegacyGap::DisconnectionReason_t DisconnectionReason_t;
|
||||
typedef typename LegacyGap::AdvertisingPolicyMode_t AdvertisingPolicyMode_t;
|
||||
typedef typename LegacyGap::ScanningPolicyMode_t ScanningPolicyMode_t;
|
||||
typedef typename LegacyGap::InitiatorPolicyMode_t InitiatorPolicyMode_t;
|
||||
typedef typename LegacyGap::PeripheralPrivacyConfiguration_t PeripheralPrivacyConfiguration_t;
|
||||
typedef typename LegacyGap::CentralPrivacyConfiguration_t CentralPrivacyConfiguration_t;
|
||||
typedef typename LegacyGap::Role_t Role_t;
|
||||
typedef typename Gap::ConnectionParams_t ConnectionParams_t;
|
||||
|
||||
// Imports from Gap
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
|
@ -309,46 +299,11 @@ public:
|
|||
BLEProtocol::AddressBytes_t address
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::getMinAdvertisingInterval
|
||||
*/
|
||||
uint16_t getMinAdvertisingInterval_() const;
|
||||
|
||||
/**
|
||||
* @see Gap::getMinNonConnectableAdvertisingInterval
|
||||
*/
|
||||
uint16_t getMinNonConnectableAdvertisingInterval_() const;
|
||||
|
||||
/**
|
||||
* @see Gap::getMaxAdvertisingInterval
|
||||
*/
|
||||
uint16_t getMaxAdvertisingInterval_() const;
|
||||
|
||||
/**
|
||||
* @see Gap::stopScan
|
||||
*/
|
||||
ble_error_t stopScan_();
|
||||
|
||||
/**
|
||||
* @see Gap::connect
|
||||
*/
|
||||
ble_error_t connect_(
|
||||
const BLEProtocol::AddressBytes_t peerAddr,
|
||||
PeerAddressType_t peerAddrType,
|
||||
const ConnectionParams_t *connectionParams,
|
||||
const GapScanningParams *scanParams
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::connect
|
||||
*/
|
||||
ble_error_t connect_(
|
||||
const BLEProtocol::AddressBytes_t peerAddr,
|
||||
BLEProtocol::AddressType_t peerAddrType,
|
||||
const ConnectionParams_t *connectionParams,
|
||||
const GapScanningParams *scanParams
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::connect
|
||||
*/
|
||||
|
@ -394,7 +349,7 @@ public:
|
|||
/**
|
||||
* @see Gap::readPhy
|
||||
*/
|
||||
ble_error_t readPhy_(Handle_t connection);
|
||||
ble_error_t readPhy_(connection_handle_t connection);
|
||||
|
||||
/**
|
||||
* @see Gap::setPreferredPhys
|
||||
|
@ -408,10 +363,10 @@ public:
|
|||
* @see Gap::setPhy
|
||||
*/
|
||||
ble_error_t setPhy_(
|
||||
Handle_t connection,
|
||||
connection_handle_t connection,
|
||||
const phy_set_t *txPhys,
|
||||
const phy_set_t *rxPhys,
|
||||
CodedSymbolPerBit_t codedSymbol
|
||||
ble::coded_symbol_per_bit_t codedSymbol
|
||||
);
|
||||
|
||||
ble_error_t disconnect_(
|
||||
|
@ -419,71 +374,6 @@ public:
|
|||
local_disconnection_reason_t reason
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::disconnect
|
||||
*/
|
||||
ble_error_t disconnect_(
|
||||
Handle_t connectionHandle,
|
||||
DisconnectionReason_t reason
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::disconnect
|
||||
*/
|
||||
ble_error_t disconnect_(DisconnectionReason_t reason);
|
||||
|
||||
/**
|
||||
* @see Gap::updateConnectionParams
|
||||
*/
|
||||
ble_error_t updateConnectionParams_(
|
||||
Handle_t handle,
|
||||
const ConnectionParams_t *params
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::getPreferredConnectionParams
|
||||
*/
|
||||
ble_error_t getPreferredConnectionParams_(
|
||||
ConnectionParams_t *params
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::setPreferredConnectionParams
|
||||
*/
|
||||
ble_error_t setPreferredConnectionParams_(
|
||||
const ConnectionParams_t *params
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::setDeviceName
|
||||
*/
|
||||
ble_error_t setDeviceName_(const uint8_t *deviceName);
|
||||
|
||||
/**
|
||||
* @see Gap::getDeviceName
|
||||
*/
|
||||
ble_error_t getDeviceName_(uint8_t *deviceName, unsigned *lengthP);
|
||||
|
||||
/**
|
||||
* @see Gap::setAppearance
|
||||
*/
|
||||
ble_error_t setAppearance_(GapAdvertisingData::Appearance appearance);
|
||||
|
||||
/**
|
||||
* @see Gap::getAppearance
|
||||
*/
|
||||
ble_error_t getAppearance_(GapAdvertisingData::Appearance *appearanceP);
|
||||
|
||||
/**
|
||||
* @see Gap::setTxPower
|
||||
*/
|
||||
ble_error_t setTxPower_(int8_t txPower);
|
||||
|
||||
/**
|
||||
* @see Gap::getPermittedTxPowerValues
|
||||
*/
|
||||
void getPermittedTxPowerValues_(const int8_t **valueArrayPP, size_t *countP);
|
||||
|
||||
/**
|
||||
* @see Gap::getMaxWhitelistSize
|
||||
*/
|
||||
|
@ -499,91 +389,34 @@ public:
|
|||
*/
|
||||
ble_error_t setWhitelist_(const whitelist_t &whitelist);
|
||||
|
||||
/**
|
||||
* @see Gap::setAdvertisingPolicyMode
|
||||
*/
|
||||
ble_error_t setAdvertisingPolicyMode_(AdvertisingPolicyMode_t mode);
|
||||
|
||||
/**
|
||||
* @see Gap::setScanningPolicyMode
|
||||
*/
|
||||
ble_error_t setScanningPolicyMode_(ScanningPolicyMode_t mode);
|
||||
|
||||
/**
|
||||
* @see Gap::setInitiatorPolicyMode
|
||||
*/
|
||||
ble_error_t setInitiatorPolicyMode_(InitiatorPolicyMode_t mode);
|
||||
|
||||
/**
|
||||
* @see Gap::getAdvertisingPolicyMode
|
||||
*/
|
||||
AdvertisingPolicyMode_t getAdvertisingPolicyMode_(void) const;
|
||||
|
||||
/**
|
||||
* @see Gap::getScanningPolicyMode
|
||||
*/
|
||||
ScanningPolicyMode_t getScanningPolicyMode_(void) const;
|
||||
|
||||
/**
|
||||
* @see Gap::getInitiatorPolicyMode
|
||||
*/
|
||||
InitiatorPolicyMode_t getInitiatorPolicyMode_(void) const;
|
||||
|
||||
/**
|
||||
* @see Gap::startRadioScan
|
||||
*/
|
||||
ble_error_t startRadioScan_(const GapScanningParams &scanningParams);
|
||||
|
||||
/**
|
||||
* @see Gap::initRadioNotification
|
||||
*/
|
||||
ble_error_t initRadioNotification_(void);
|
||||
|
||||
/**
|
||||
* @see Gap::enablePrivacy
|
||||
*/
|
||||
ble_error_t enablePrivacy_(bool enable);
|
||||
|
||||
/**
|
||||
* @see Gap::setPeripheralPrivacyConfiguration
|
||||
*/
|
||||
|
||||
ble_error_t setPeripheralPrivacyConfiguration_(
|
||||
const PeripheralPrivacyConfiguration_t *configuration
|
||||
const peripheral_privacy_configuration_t *configuration
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::getPeripheralPrivacyConfiguration
|
||||
*/
|
||||
ble_error_t getPeripheralPrivacyConfiguration_(
|
||||
PeripheralPrivacyConfiguration_t *configuration
|
||||
peripheral_privacy_configuration_t *configuration
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::setCentralPrivacyConfiguration
|
||||
*/
|
||||
ble_error_t setCentralPrivacyConfiguration_(
|
||||
const CentralPrivacyConfiguration_t *configuration
|
||||
const central_privacy_configuration_t *configuration
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::getCentralPrivacyConfiguration
|
||||
*/
|
||||
ble_error_t getCentralPrivacyConfiguration_(
|
||||
CentralPrivacyConfiguration_t *configuration
|
||||
central_privacy_configuration_t *configuration
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::setAdvertisingData
|
||||
*/
|
||||
ble_error_t setAdvertisingData_(
|
||||
const GapAdvertisingData &advData,
|
||||
const GapAdvertisingData &scanResponse
|
||||
ble_error_t getAddress(
|
||||
BLEProtocol::AddressType_t *typeP,
|
||||
BLEProtocol::AddressBytes_t address
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::startAdvertising
|
||||
*/
|
||||
ble_error_t startAdvertising_(const GapAdvertisingParams ¶ms);
|
||||
static ble_error_t getRandomAddressType(
|
||||
const BLEProtocol::AddressBytes_t address,
|
||||
ble::random_address_type_t *addressType
|
||||
);
|
||||
|
||||
/**
|
||||
* @see Gap::reset
|
||||
|
@ -644,7 +477,7 @@ private:
|
|||
private:
|
||||
void on_read_phy_(
|
||||
pal::hci_error_code_t hci_status,
|
||||
Handle_t connection_handle,
|
||||
connection_handle_t connection_handle,
|
||||
phy_t tx_phy,
|
||||
phy_t rx_phy
|
||||
);
|
||||
|
@ -657,7 +490,7 @@ private:
|
|||
|
||||
void on_phy_update_complete_(
|
||||
pal::hci_error_code_t hci_status,
|
||||
Handle_t connection_handle,
|
||||
connection_handle_t connection_handle,
|
||||
phy_t tx_phy,
|
||||
phy_t rx_phy
|
||||
);
|
||||
|
@ -759,8 +592,8 @@ private:
|
|||
mutable whitelist_t _whitelist;
|
||||
|
||||
bool _privacy_enabled;
|
||||
PeripheralPrivacyConfiguration_t _peripheral_privacy_configuration;
|
||||
CentralPrivacyConfiguration_t _central_privacy_configuration;
|
||||
peripheral_privacy_configuration_t _peripheral_privacy_configuration;
|
||||
central_privacy_configuration_t _central_privacy_configuration;
|
||||
ble::address_t _random_static_identity_address;
|
||||
bool _random_address_rotating;
|
||||
|
||||
|
|
|
@ -315,6 +315,7 @@ ble_error_t Gap<Impl>::cancelConnect()
|
|||
#endif
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::updateConnectionParameters(
|
||||
connection_handle_t connectionHandle,
|
||||
|
@ -433,9 +434,9 @@ const peripheral_privacy_configuration_t Gap<Impl>::default_peripheral_privacy_c
|
|||
};
|
||||
|
||||
template<class Impl>
|
||||
const central_privay_configuration_t Gap<Impl>::default_central_privacy_configuration = {
|
||||
const central_privacy_configuration_t Gap<Impl>::default_central_privacy_configuration = {
|
||||
/* use_non_resolvable_random_address */ false,
|
||||
/* resolution_strategy */ central_privay_configuration_t::RESOLVE_AND_FORWARD
|
||||
/* resolution_strategy */ central_privacy_configuration_t::RESOLVE_AND_FORWARD
|
||||
};
|
||||
|
||||
#if BLE_FEATURE_PRIVACY
|
||||
|
@ -466,7 +467,7 @@ ble_error_t Gap<Impl>::getPeripheralPrivacyConfiguration(
|
|||
#if BLE_ROLE_OBSERVER
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::setCentralPrivacyConfiguration(
|
||||
const central_privay_configuration_t *configuration
|
||||
const central_privacy_configuration_t *configuration
|
||||
)
|
||||
{
|
||||
return impl()->setCentralPrivacyConfiguration_(configuration);
|
||||
|
@ -474,7 +475,7 @@ ble_error_t Gap<Impl>::setCentralPrivacyConfiguration(
|
|||
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::getCentralPrivacyConfiguration(
|
||||
central_privay_configuration_t *configuration
|
||||
central_privacy_configuration_t *configuration
|
||||
)
|
||||
{
|
||||
return impl()->getCentralPrivacyConfiguration_(configuration);
|
||||
|
@ -506,6 +507,12 @@ ble_error_t Gap<Impl>::setWhitelist(const whitelist_t &whitelist) {
|
|||
}
|
||||
#endif // BLE_FEATURE_WHITELIST
|
||||
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::reset(void)
|
||||
{
|
||||
return impl()->reset_();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/* ------------------------- Default implementations ------------------------ */
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -849,7 +856,7 @@ ble_error_t Gap<Impl>::getPeripheralPrivacyConfiguration_(
|
|||
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::setCentralPrivacyConfiguration_(
|
||||
const central_privay_configuration_t *configuration
|
||||
const central_privacy_configuration_t *configuration
|
||||
)
|
||||
{
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -857,12 +864,32 @@ ble_error_t Gap<Impl>::setCentralPrivacyConfiguration_(
|
|||
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::getCentralPrivacyConfiguration_(
|
||||
central_privay_configuration_t *configuration
|
||||
central_privacy_configuration_t *configuration
|
||||
)
|
||||
{
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::getAddress(
|
||||
BLEProtocol::AddressType_t *typeP,
|
||||
BLEProtocol::AddressBytes_t address
|
||||
) {
|
||||
return impl()->getAddress_(typeP, address);
|
||||
}
|
||||
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::reset_(void)
|
||||
{
|
||||
/* Notify that the instance is about to shut down */
|
||||
shutdownCallChain.call(this);
|
||||
shutdownCallChain.clear();
|
||||
|
||||
this->_eventHandler = NULL;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
template<class Impl>
|
||||
ble_error_t Gap<Impl>::setRandomStaticAddress_(const ble::address_t& address)
|
||||
{
|
||||
|
|
|
@ -49,15 +49,6 @@ static const uint16_t advertising_interval_max = 0x4000;
|
|||
static const uint16_t supervision_timeout_min = 0x000A;
|
||||
static const uint16_t supervision_timeout_max = 0x0C80;
|
||||
|
||||
static const ::Gap::ConnectionParams_t default_connection_params = {
|
||||
/* min conn interval */ 50,
|
||||
/* max conn interval */ 100,
|
||||
/* slave latency */ 0,
|
||||
/* supervision timeout */ 600
|
||||
};
|
||||
|
||||
static const GapScanningParams default_scan_params;
|
||||
|
||||
static const mbed_error_status_t mixed_scan_api_error =
|
||||
MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_USE_INCOMPATIBLE_API);
|
||||
|
||||
|
@ -76,26 +67,6 @@ static bool is_in_range(T value, T lower_bound, T higher_bound)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if the scan parameters are valid or false otherwise.
|
||||
*/
|
||||
static bool is_scan_params_valid(const GapScanningParams *params)
|
||||
{
|
||||
if (params == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_in_range(params->getInterval(), scan_interval_min, scan_interval_max) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_in_range(params->getWindow(), scan_interval_min, params->getInterval()) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if the connection parameters are valid or false otherwise.
|
||||
*/
|
||||
|
@ -291,9 +262,9 @@ static bool is_random_address(const BLEProtocol::AddressBytes_t address)
|
|||
/*
|
||||
* Check disconnection reason validity.
|
||||
*/
|
||||
static bool is_disconnection_reason_valid(::Gap::DisconnectionReason_t reason)
|
||||
static bool is_disconnection_reason_valid(disconnection_reason_t reason)
|
||||
{
|
||||
switch (reason) {
|
||||
switch (reason.value()) {
|
||||
/**
|
||||
* Note: accepted reasons are:
|
||||
typedef pal::disconnection_reason_t reason_t;
|
||||
|
@ -307,10 +278,10 @@ static bool is_disconnection_reason_valid(::Gap::DisconnectionReason_t reason)
|
|||
*/
|
||||
|
||||
// TODO Fix Disconnectionreason_t which expose invalid value
|
||||
case ::Gap::REMOTE_USER_TERMINATED_CONNECTION:
|
||||
case ::Gap::REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES:
|
||||
case ::Gap::REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF:
|
||||
case ::Gap::CONN_INTERVAL_UNACCEPTABLE:
|
||||
case disconnection_reason_t::REMOTE_USER_TERMINATED_CONNECTION:
|
||||
case disconnection_reason_t::REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES:
|
||||
case disconnection_reason_t::REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF:
|
||||
case disconnection_reason_t::UNACCEPTABLE_CONNECTION_PARAMETERS:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -388,23 +359,6 @@ static peer_address_type_t to_peer_address_type(
|
|||
peer_address_type_t::RANDOM;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return true if the advertising parameters are valid.
|
||||
*/
|
||||
static bool is_advertising_params_valid(const GapAdvertisingParams ¶ms)
|
||||
{
|
||||
if (is_in_range(params.getIntervalInADVUnits(), advertising_interval_min, advertising_interval_max) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params.getAdvertisingType() > GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
microsecond_t minSupervisionTimeout(
|
||||
const conn_interval_t &maxConnectionInterval,
|
||||
const slave_latency_t &slaveLatency
|
||||
|
@ -504,21 +458,25 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
uint16_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getMinAdvertisingInterval_() const
|
||||
{
|
||||
return GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN;
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
uint16_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getMinNonConnectableAdvertisingInterval_() const
|
||||
{
|
||||
return GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN_NONCON;
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
uint16_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getMaxAdvertisingInterval_() const
|
||||
{
|
||||
return GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX;
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getRandomAddressType(
|
||||
const BLEProtocol::AddressBytes_t address,
|
||||
ble::random_address_type_t* type
|
||||
) {
|
||||
// see section Device address in Bluetooth Link Layer specification
|
||||
// (Vol 6 - Part B)
|
||||
switch (address[5] >> 6) {
|
||||
case 0x03:
|
||||
*type = random_address_type_t::STATIC;
|
||||
return BLE_ERROR_NONE;
|
||||
case 0x00:
|
||||
*type = random_address_type_t::NON_RESOLVABLE_PRIVATE;
|
||||
return BLE_ERROR_NONE;
|
||||
case 0x01:
|
||||
*type = random_address_type_t::RESOLVABLE_PRIVATE;
|
||||
return BLE_ERROR_NONE;
|
||||
default:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
|
@ -710,7 +668,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::readPhy_(Handle_t connection)
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::readPhy_(ble::connection_handle_t connection)
|
||||
{
|
||||
return _pal_gap.read_phy(connection);
|
||||
}
|
||||
|
@ -728,10 +686,10 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setPhy_(
|
||||
Handle_t connection,
|
||||
ble::connection_handle_t connection,
|
||||
const phy_set_t *txPhys,
|
||||
const phy_set_t *rxPhys,
|
||||
CodedSymbolPerBit_t codedSymbol
|
||||
ble::coded_symbol_per_bit_t codedSymbol
|
||||
)
|
||||
{
|
||||
phy_set_t tx_phys(txPhys ? txPhys->value() : 0);
|
||||
|
@ -742,7 +700,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_read_phy_(
|
||||
pal::hci_error_code_t hci_status,
|
||||
Handle_t connection_handle,
|
||||
ble::connection_handle_t connection_handle,
|
||||
phy_t tx_phy,
|
||||
phy_t rx_phy
|
||||
)
|
||||
|
@ -772,7 +730,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
|||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_phy_update_complete_(
|
||||
pal::hci_error_code_t hci_status,
|
||||
Handle_t connection_handle,
|
||||
ble::connection_handle_t connection_handle,
|
||||
phy_t tx_phy,
|
||||
phy_t rx_phy
|
||||
)
|
||||
|
@ -796,79 +754,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
return _pal_gap.disconnect(connectionHandle, reason);
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getPreferredConnectionParams_(ConnectionParams_t *params)
|
||||
{
|
||||
if (params == NULL) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return _gap_service.get_peripheral_prefered_connection_parameters(
|
||||
*params
|
||||
);
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setPreferredConnectionParams_(const ConnectionParams_t *params)
|
||||
{
|
||||
if (is_preferred_connection_params_valid(params) == false) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
return _gap_service.set_peripheral_prefered_connection_parameters(
|
||||
*params
|
||||
);
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setDeviceName_(const uint8_t *deviceName)
|
||||
{
|
||||
return _gap_service.set_device_name(deviceName);
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getDeviceName_(uint8_t *deviceName, unsigned *lengthP)
|
||||
{
|
||||
if (lengthP == NULL) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
uint8_t length = 0;
|
||||
ble_error_t err = _gap_service.get_device_name_length(length);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (deviceName != NULL) {
|
||||
if (*lengthP < length) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
Span<uint8_t> name(deviceName, *lengthP);
|
||||
err = _gap_service.get_device_name(name);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
*lengthP = length;
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAppearance_(GapAdvertisingData::Appearance appearance)
|
||||
{
|
||||
return _gap_service.set_appearance(appearance);
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getAppearance_(GapAdvertisingData::Appearance *appearanceP)
|
||||
{
|
||||
if (appearanceP == NULL) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
return _gap_service.get_appearance(*appearanceP);
|
||||
}
|
||||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setTxPower_(int8_t txPower)
|
||||
{
|
||||
|
@ -1029,7 +914,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setPeripheralPrivacyConfiguration_(
|
||||
const PeripheralPrivacyConfiguration_t *configuration
|
||||
const peripheral_privacy_configuration_t *configuration
|
||||
)
|
||||
{
|
||||
_peripheral_privacy_configuration = *configuration;
|
||||
|
@ -1041,7 +926,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getPeripheralPrivacyConfiguration_(
|
||||
PeripheralPrivacyConfiguration_t *configuration
|
||||
peripheral_privacy_configuration_t *configuration
|
||||
)
|
||||
{
|
||||
*configuration = _peripheral_privacy_configuration;
|
||||
|
@ -1051,7 +936,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setCentralPrivacyConfiguration_(
|
||||
const CentralPrivacyConfiguration_t *configuration
|
||||
const central_privacy_configuration_t *configuration
|
||||
)
|
||||
{
|
||||
_central_privacy_configuration = *configuration;
|
||||
|
@ -1063,7 +948,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
|
||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getCentralPrivacyConfiguration_(
|
||||
CentralPrivacyConfiguration_t *configuration
|
||||
central_privacy_configuration_t *configuration
|
||||
)
|
||||
{
|
||||
*configuration = _central_privacy_configuration;
|
||||
|
@ -1074,7 +959,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::reset_(void)
|
||||
{
|
||||
LegacyGap::reset_();
|
||||
Gap::reset_();
|
||||
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
_advertising_timeout.detach();
|
||||
|
@ -1240,7 +1125,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
|||
#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 &&
|
||||
_central_privacy_configuration.resolution_strategy == central_privacy_configuration_t::RESOLVE_AND_FILTER &&
|
||||
advertising.address_type == pal::connection_peer_address_type_t::RANDOM_ADDRESS &&
|
||||
is_random_private_resolvable_address(advertising.address.data())
|
||||
) {
|
||||
|
@ -1334,7 +1219,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
|||
) {
|
||||
// Apply privacy policy if in peripheral mode for non-resolved addresses
|
||||
ble::random_address_type_t random_address_type(ble::random_address_type_t::RESOLVABLE_PRIVATE);
|
||||
ble_error_t err = LegacyGap::getRandomAddressType(e.peer_address.data(), &random_address_type);
|
||||
ble_error_t err = getRandomAddressType(e.peer_address.data(), &random_address_type);
|
||||
if (err) {
|
||||
// FIXME: return for now; needs to report the error ?
|
||||
return;
|
||||
|
@ -1342,19 +1227,19 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
|||
|
||||
if (random_address_type == ble::random_address_type_t::RESOLVABLE_PRIVATE) {
|
||||
switch (_peripheral_privacy_configuration.resolution_strategy) {
|
||||
case PeripheralPrivacyConfiguration_t::REJECT_NON_RESOLVED_ADDRESS:
|
||||
case peripheral_privacy_configuration_t::REJECT_NON_RESOLVED_ADDRESS:
|
||||
// Reject connection request - the user will get notified through a callback
|
||||
_pal_gap.disconnect(
|
||||
e.connection_handle,
|
||||
pal::disconnection_reason_t::AUTHENTICATION_FAILURE
|
||||
pal::local_disconnection_reason_t::AUTHENTICATION_FAILURE
|
||||
);
|
||||
return;
|
||||
|
||||
case PeripheralPrivacyConfiguration_t::PERFORM_PAIRING_PROCEDURE:
|
||||
case peripheral_privacy_configuration_t::PERFORM_PAIRING_PROCEDURE:
|
||||
needs_pairing = true;
|
||||
break;
|
||||
|
||||
case PeripheralPrivacyConfiguration_t::PERFORM_AUTHENTICATION_PROCEDURE:
|
||||
case peripheral_privacy_configuration_t::PERFORM_AUTHENTICATION_PROCEDURE:
|
||||
needs_authentication = true;
|
||||
break;
|
||||
|
||||
|
@ -1396,7 +1281,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
|||
if (_connection_event_handler) {
|
||||
_connection_event_handler->on_connected(
|
||||
e.connection_handle,
|
||||
e.role.value() == e.role.CENTRAL ? LegacyGap::CENTRAL : LegacyGap::PERIPHERAL,
|
||||
e.role,
|
||||
e.peer_address_type,
|
||||
e.peer_address.data(),
|
||||
_address_type,
|
||||
|
@ -1444,8 +1329,8 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
|||
// signal internal stack
|
||||
if (_connection_event_handler) {
|
||||
_connection_event_handler->on_disconnected(
|
||||
(Handle_t) e.connection_handle,
|
||||
(DisconnectionReason_t) e.reason
|
||||
(connection_handle_t) e.connection_handle,
|
||||
disconnection_reason_t(e.reason)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1589,12 +1474,12 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
|
||||
if (_privacy_enabled) {
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
if (_peripheral_privacy_configuration.resolution_strategy != PeripheralPrivacyConfiguration_t::DO_NOT_RESOLVE) {
|
||||
if (_peripheral_privacy_configuration.resolution_strategy != peripheral_privacy_configuration_t::DO_NOT_RESOLVE) {
|
||||
enable = true;
|
||||
}
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
#if BLE_ROLE_OBSERVER
|
||||
if (_central_privacy_configuration.resolution_strategy != CentralPrivacyConfiguration_t::DO_NOT_RESOLVE) {
|
||||
if (_central_privacy_configuration.resolution_strategy != central_privacy_configuration_t::DO_NOT_RESOLVE) {
|
||||
enable = true;
|
||||
}
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
@ -1995,8 +1880,6 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
prepare_legacy_advertising_set();
|
||||
|
||||
if (!_existing_sets.get(handle)) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
@ -2008,7 +1891,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (payload.size() > GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
|
||||
if (payload.size() > LEGACY_ADVERTISING_MAX_SIZE) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
|
@ -2436,7 +2319,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
|||
#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 &&
|
||||
_central_privacy_configuration.resolution_strategy == central_privacy_configuration_t::RESOLVE_AND_FILTER &&
|
||||
address_type != NULL &&
|
||||
*address_type == pal::connection_peer_address_type_t::RANDOM_ADDRESS &&
|
||||
is_random_private_resolvable_address(address.data())
|
||||
|
@ -2824,8 +2707,8 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (peerAddressType != PeerAddressType_t::PUBLIC ||
|
||||
peerAddressType != PeerAddressType_t::RANDOM
|
||||
if (peerAddressType != peer_address_type_t::PUBLIC ||
|
||||
peerAddressType != peer_address_type_t::RANDOM
|
||||
) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
@ -2852,8 +2735,8 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
|||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (peerAddressType != PeerAddressType_t::PUBLIC ||
|
||||
peerAddressType != PeerAddressType_t::RANDOM
|
||||
if (peerAddressType != peer_address_type_t::PUBLIC ||
|
||||
peerAddressType != peer_address_type_t::RANDOM
|
||||
) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue