BLE - Return supported feature based on compile time features.

pull/9790/head
Vincent Coubard 2019-02-28 14:23:19 +00:00
parent 04891b205c
commit 24f7f36f01
2 changed files with 52 additions and 0 deletions

View File

@ -22,6 +22,32 @@ namespace interface {
template<class Impl>
bool Gap<Impl>::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);
}

View File

@ -35,6 +35,32 @@ bool Gap<EventHandler>::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()));
}