more gap ifdefs

pull/9790/head
paul-szczepanek-arm 2019-02-21 15:36:01 +00:00 committed by Vincent Coubard
parent 1d5b7d4056
commit 630b2fe792
2 changed files with 78 additions and 22 deletions

View File

@ -424,14 +424,18 @@ microsecond_t minSupervisionTimeout(
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::GenericGap(
pal::EventQueue &event_queue,
PalGapImpl<GenericGap> &pal_gap,
pal::GenericAccessService &generic_access_service
PalGapImpl<GenericGap> &pal_gap
#if BLE_FEATURE_GATT_SERVER
,pal::GenericAccessService &generic_access_service
#endif
#if BLE_FEATURE_SECURITY
, PalSecurityManager &pal_sm
#endif
) : _event_queue(event_queue),
_pal_gap(pal_gap),
#if BLE_FEATURE_GATT_SERVER
_gap_service(generic_access_service),
#endif
#if BLE_FEATURE_SECURITY
_pal_sm(pal_sm),
#endif
@ -446,8 +450,8 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
_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),
#endif //BLE_FEATURE_PRIVACY
_scan_enabled(false),
#if BLE_ROLE_BROADCASTER
_advertising_timeout(),
@ -554,6 +558,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#if BLE_ROLE_BROADCASTER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
uint16_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getMinAdvertisingInterval_() const
{
@ -588,7 +593,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::stopScan_()
{
@ -618,7 +625,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_ROLE_OBSERVER
#if BLE_ROLE_CENTRAL
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::connect_(
const BLEProtocol::AddressBytes_t peerAddr,
@ -765,7 +774,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
connectionParams.getMaxEventLengthArray()
);
}
#endif // BLE_ROLE_CENTRAL
#if BLE_FEATURE_CONNECTABLE
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::manageConnectionParametersUpdateRequest_(bool flag)
{
@ -848,7 +859,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
useVersionTwoAPI();
return _pal_gap.cancel_connection_creation();
}
#endif // BLE_FEATURE_CONNECTABLE
#if BLE_FEATURE_PHY_MANAGEMENT
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::readPhy_(Handle_t connection)
{
@ -896,6 +909,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
_eventHandler->onPhyUpdateComplete(status, connection_handle, tx_phy, rx_phy);
}
}
#endif // BLE_FEATURE_PHY_MANAGEMENT
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_data_length_change_(
@ -909,6 +923,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
}
}
#if BLE_FEATURE_PHY_MANAGEMENT
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,
@ -926,7 +941,9 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
_eventHandler->onPhyUpdateComplete(status, connection_handle, tx_phy, rx_phy);
}
}
#endif // BLE_FEATURE_PHY_MANAGEMENT
#if BLE_FEATURE_CONNECTABLE
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::disconnect_(
connection_handle_t connectionHandle,
@ -1002,7 +1019,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
*params
);
}
#endif // BLE_FEATURE_CONNECTABLE
#if BLE_FEATURE_GATT_SERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setDeviceName_(const uint8_t *deviceName)
{
@ -1051,6 +1070,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
}
return _gap_service.get_appearance(*appearanceP);
}
#endif // BLE_FEATURE_GATT_SERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setTxPower_(int8_t txPower)
@ -1066,6 +1086,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
*countP = 0;
}
#if BLE_FEATURE_WHITELIST
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
uint8_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getMaxWhitelistSize_(void) const
{
@ -1183,7 +1204,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_FEATURE_WHITELIST
#if BLE_ROLE_BROADCASTER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingPolicyMode_(AdvertisingPolicyMode_t mode)
{
@ -1197,6 +1220,15 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
typename GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::LegacyGap::AdvertisingPolicyMode_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getAdvertisingPolicyMode_(void) const
{
useVersionOneAPI();
return (AdvertisingPolicyMode_t) _advertising_filter_policy.value();
}
#endif //BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setScanningPolicyMode_(ScanningPolicyMode_t mode)
{
@ -1210,6 +1242,15 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
typename GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::LegacyGap::ScanningPolicyMode_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getScanningPolicyMode_(void) const
{
useVersionOneAPI();
return (ScanningPolicyMode_t) _scanning_filter_policy.value();
}
#endif // BLE_ROLE_OBSERVER
#if BLE_ROLE_CENTRAL
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setInitiatorPolicyMode_(InitiatorPolicyMode_t mode)
{
@ -1223,27 +1264,15 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
typename GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::LegacyGap::AdvertisingPolicyMode_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getAdvertisingPolicyMode_(void) const
{
useVersionOneAPI();
return (AdvertisingPolicyMode_t) _advertising_filter_policy.value();
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
typename GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::LegacyGap::ScanningPolicyMode_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getScanningPolicyMode_(void) const
{
useVersionOneAPI();
return (ScanningPolicyMode_t) _scanning_filter_policy.value();
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
typename GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::LegacyGap::InitiatorPolicyMode_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getInitiatorPolicyMode_(void) const
{
useVersionOneAPI();
return (InitiatorPolicyMode_t) _initiator_policy_mode.value();
}
#endif // BLE_ROLE_CENTRAL
#if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::startRadioScan_(const GapScanningParams &scanningParams)
{
@ -1304,6 +1333,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::initRadioNotification_(void)
@ -1311,6 +1341,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NOT_IMPLEMENTED;
}
#if BLE_FEATURE_PRIVACY
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::enablePrivacy_(bool enable)
{
@ -1331,6 +1362,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#if BLE_ROLE_BROADCASTER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setPeripheralPrivacyConfiguration_(
const PeripheralPrivacyConfiguration_t *configuration
@ -1352,7 +1384,9 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_ROLE_BROADCASTER
#if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setCentralPrivacyConfiguration_(
const CentralPrivacyConfiguration_t *configuration
@ -1374,7 +1408,10 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_ROLE_OBSERVER
#endif // BLE_FEATURE_PRIVACY
#if BLE_ROLE_BROADCASTER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setAdvertisingData_(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse)
{
@ -1462,6 +1499,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
return BLE_ERROR_NONE;
}
#endif // BLE_ROLE_BROADCASTER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::reset_(void)
@ -1474,7 +1512,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
#if BLE_ROLE_OBSERVER
_scan_timeout.detach();
#endif
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) {
/* stop all advertising sets */
for (size_t i = 0; i < MAX_ADVERTISING_SETS; ++i) {
@ -1510,12 +1548,14 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
AdvertisingParameters()
);
}
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
_existing_sets.set(LEGACY_ADVERTISING_HANDLE);
return BLE_ERROR_NONE;
}
#if BLE_FEATURE_CONNECTABLE
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::processConnectionEvent(
Handle_t handle,
@ -1585,7 +1625,9 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
);
BLE_DEPRECATED_API_USE_END()
}
#endif // BLE_FEATURE_CONNECTABLE
#if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_scan_timeout_()
{
@ -1619,7 +1661,9 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
LegacyGap::processTimeoutEvent(LegacyGap::TIMEOUT_SRC_SCAN);
BLE_DEPRECATED_API_USE_END()
}
#endif // BLE_ROLE_OBSERVER
#if BLE_ROLE_BROADCASTER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_advertising_timeout()
{
@ -1641,15 +1685,18 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
LegacyGap::processTimeoutEvent(LegacyGap::TIMEOUT_SRC_ADVERTISING);
BLE_DEPRECATED_API_USE_END()
}
#endif // BLE_ROLE_BROADCASTER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_gap_event_received(const pal::GapEvent &e)
{
switch (e.type.value()) {
#if BLE_ROLE_OBSERVER
case pal::GapEventType::ADVERTISING_REPORT:
on_advertising_report(static_cast<const pal::GapAdvertisingReportEvent &>(e));
break;
#endif // BLE_ROLE_OBSERVER
#if BLE_FEATURE_CONNECTABLE
case pal::GapEventType::CONNECTION_COMPLETE:
on_connection_complete(static_cast<const pal::GapConnectionCompleteEvent &>(e));
break;
@ -1665,7 +1712,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
case pal::GapEventType::REMOTE_CONNECTION_PARAMETER_REQUEST:
on_connection_parameter_request(static_cast<const pal::GapRemoteConnectionParameterRequestEvent &>(e));
break;
#endif // BLE_FEATURE_CONNECTABLE
case pal::GapEventType::UNEXPECTED_ERROR:
on_unexpected_error(static_cast<const pal::GapUnexpectedErrorEvent &>(e));
break;
@ -1674,7 +1721,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
break;
}
}
#if BLE_ROLE_OBSERVER
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_advertising_report(const pal::GapAdvertisingReportEvent &e)
{
@ -1753,7 +1800,9 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
BLE_DEPRECATED_API_USE_END()
}
}
#endif // BLE_ROLE_OBSERVER
#if BLE_FEATURE_CONNECTABLE
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_connection_complete(const pal::GapConnectionCompleteEvent &e)
{
@ -1958,6 +2007,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
)
);
}
#endif // BLE_FEATURE_CONNECTABLE
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_unexpected_error(const pal::GapUnexpectedErrorEvent &e)
@ -2000,6 +2050,7 @@ pal::own_address_type_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEve
}
}
#if BLE_FEATURE_WHITELIST
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
bool GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::initialize_whitelist() const
{
@ -2023,7 +2074,9 @@ bool GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
return true;
}
#endif // BLE_FEATURE_WHITELIST
#if BLE_FEATURE_PRIVACY
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::update_address_resolution_setting()
{
@ -2113,6 +2166,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
_address_type = LegacyAddressType::RANDOM_PRIVATE_NON_RESOLVABLE;
_address = address;
}
#endif // BLE_FEATURE_PRIVACY
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
bool GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getUnresolvableRandomAddress(ble::address_t &address)
@ -2150,11 +2204,13 @@ bool GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
return true;
}
#if BLE_FEATURE_PRIVACY
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::on_address_rotation_timeout()
{
_event_queue.post(mbed::callback(this, &GenericGap::update_random_address));
}
#endif // BLE_FEATURE_PRIVACY
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
const uint8_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::MAX_ADVERTISING_SETS;

View File

@ -38,7 +38,7 @@
#include "CordioPalAttClient.h"
#if BLE_FEATURE_SECURITY
#include "CordioPalSecurityManager.h"
#endif BLE_FEATURE_SECURITY
#endif // BLE_FEATURE_SECURITY
/*! WSF handler ID */
wsfHandlerId_t stack_handler_id;