Skip to content

Commit

Permalink
Merge pull request #6 from paul-szczepanek-arm/feature-support
Browse files Browse the repository at this point in the history
support for controller features
  • Loading branch information
paul-szczepanek-arm authored and pan- committed Aug 29, 2018
1 parent 954f004 commit d5c675e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
37 changes: 37 additions & 0 deletions features/FEATURE_BLE/ble/pal/PalGap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ControllerSupportedFeatures_t, uint8_t> {
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<ControllerSupportedFeatures_t, uint8_t>(value) { }
};

/**
* Initialisation of the instance. An implementation can use this function
* to initialise the subsystems needed to realize the operations of this
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 2 additions & 0 deletions features/FEATURE_BLE/source/generic/GenericGap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down
7 changes: 6 additions & 1 deletion features/FEATURE_BLE/targets/TARGET_CORDIO/CordioPalGap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d5c675e

Please sign in to comment.