diff --git a/features/FEATURE_BLE/ble/pal/PalGap.h b/features/FEATURE_BLE/ble/pal/PalGap.h index aec629a587..0df5756e5d 100644 --- a/features/FEATURE_BLE/ble/pal/PalGap.h +++ b/features/FEATURE_BLE/ble/pal/PalGap.h @@ -32,6 +32,33 @@ namespace pal { * by that layer. */ struct Gap { + /** @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 6, Part B - 4.6 */ + struct ControllerSupportedFeatures_t : SafeEnum { + enum type { + LE_ENCRYPTION = 0, + CONNECTION_PARAMETERS_REQUEST_PROCEDURE, + EXTENDED_REJECT_INDICATION, + SLAVE_INITIATED_FEATURES_EXCHANGE, + LE_PING, + LE_DATA_PACKET_LENGTH_EXTENSION, + LL_PRIVACY, + EXTENDED_SCANNER_FILTER_POLICIES, + LE_2M_PHY, + STABLE_MODULATION_INDEX_TRANSMITTER, + STABLE_MODULATION_INDEX_RECEIVER, + LE_CODED_PHY, + LE_EXTENDED_ADVERTISING, + LE_PERIODIC_ADVERTISING, + CHANNEL_SELECTION_ALGORITHM_2, + LE_POWER_CLASS + }; + + /** + * Construct a new instance of ControllerSupportedFeatures_t. + */ + ControllerSupportedFeatures_t(type value) : SafeEnum(value) { } + }; + /** * Initialisation of the instance. An implementation can use this function * to initialise the subsystems needed to realize the operations of this @@ -670,6 +697,16 @@ struct Gap { bool enable ) = 0; + /** + * Checked support for a feature in the link controller. + * + * @param feature feature to be checked. + * @return TRUE if feature is supported. + */ + virtual bool is_feature_supported( + ControllerSupportedFeatures_t feature + ) = 0; + /** * Register a callback which will handle Gap events. * diff --git a/features/FEATURE_BLE/source/generic/GenericGap.cpp b/features/FEATURE_BLE/source/generic/GenericGap.cpp index dc7e8c058a..1a4d061e13 100644 --- a/features/FEATURE_BLE/source/generic/GenericGap.cpp +++ b/features/FEATURE_BLE/source/generic/GenericGap.cpp @@ -417,6 +417,8 @@ GenericGap::GenericGap( _scan_timeout(), _connection_event_handler(NULL) { + _pal_gap.initialize(); + _pal_gap.when_gap_event_received( mbed::callback(this, &GenericGap::on_gap_event_received) ); diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/CordioPalGap.h b/features/FEATURE_BLE/targets/TARGET_CORDIO/CordioPalGap.h index 52fae1eed3..022941ee38 100644 --- a/features/FEATURE_BLE/targets/TARGET_CORDIO/CordioPalGap.h +++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/CordioPalGap.h @@ -13,8 +13,13 @@ namespace cordio { * Implementation of ble::pal::Gap for the Cordio stack. */ class Gap : public ::ble::pal::Gap { - public: + virtual bool is_feature_supported( + Gap::ControllerSupportedFeatures_t feature + ) { + return (HciGetLeSupFeat() & (1 << feature.value())); + } + virtual ble_error_t initialize() { return BLE_ERROR_NONE; }