From 24f7f36f01dfebf986c0068e33bf8e5bff4087f8 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Thu, 28 Feb 2019 14:23:19 +0000 Subject: [PATCH] BLE - Return supported feature based on compile time features. --- features/FEATURE_BLE/source/gap/Gap.tpp | 26 +++++++++++++++++++ .../TARGET_CORDIO/source/CordioPalGap.tpp | 26 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/features/FEATURE_BLE/source/gap/Gap.tpp b/features/FEATURE_BLE/source/gap/Gap.tpp index a0c2084f14..9526eb51bd 100644 --- a/features/FEATURE_BLE/source/gap/Gap.tpp +++ b/features/FEATURE_BLE/source/gap/Gap.tpp @@ -22,6 +22,32 @@ namespace interface { template bool Gap::isFeatureSupported(controller_supported_features_t feature) { +#if !BLE_FEATURE_PHY_MANAGEMENT + if (feature == ble::controller_supported_features_t::LE_CODED_PHY || + feature == ble::controller_supported_features_t::LE_2M_PHY + ) { + return false; + } +#endif + +#if !BLE_FEATURE_EXTENDED_ADVERTISING + if (feature == ble::controller_supported_features_t::LE_EXTENDED_ADVERTISING) { + return false; + } +#endif + +#if !BLE_FEATURE_PERIODIC_ADVERTISING + if (feature == ble::controller_supported_features_t::LE_PERIODIC_ADVERTISING) { + return false; + } +#endif + +#if !BLE_FEATURE_PRIVACY + if (feature == ble::controller_supported_features_t::LL_PRIVACY) { + return false; + } +#endif + return impl()->isFeatureSupported_(feature); } diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalGap.tpp b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalGap.tpp index 97c9c05e4d..1407d62f85 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalGap.tpp +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalGap.tpp @@ -35,6 +35,32 @@ bool Gap::is_feature_supported_( ble::controller_supported_features_t feature ) { +#if !BLE_FEATURE_PHY_MANAGEMENT + if (feature == ble::controller_supported_features_t::LE_CODED_PHY || + feature == ble::controller_supported_features_t::LE_2M_PHY + ) { + return false; + } +#endif + +#if !BLE_FEATURE_EXTENDED_ADVERTISING + if (feature == ble::controller_supported_features_t::LE_EXTENDED_ADVERTISING) { + return false; + } +#endif + +#if !BLE_FEATURE_PERIODIC_ADVERTISING + if (feature == ble::controller_supported_features_t::LE_PERIODIC_ADVERTISING) { + return false; + } +#endif + +#if !BLE_FEATURE_PRIVACY + if (feature == ble::controller_supported_features_t::LL_PRIVACY) { + return false; + } +#endif + return (HciGetLeSupFeat() & (1 << feature.value())); }