diff --git a/features/FEATURE_BLE/ble/gap/Gap.h b/features/FEATURE_BLE/ble/gap/Gap.h index b169544b28..3c3d4d9add 100644 --- a/features/FEATURE_BLE/ble/gap/Gap.h +++ b/features/FEATURE_BLE/ble/gap/Gap.h @@ -1265,15 +1265,6 @@ public: ble_error_t setRandomStaticAddress(const ble::address_t& address); protected: - /** Can only be called if use_non_deprecated_scan_api() hasn't been called. - * This guards against mixed use of deprecated and nondeprecated API. - */ - void useVersionOneAPI() const; - - /** Can only be called if use_deprecated_scan_api() hasn't been called. - * This guards against mixed use of deprecated and nondeprecated API. - */ - void useVersionTwoAPI() const; /** * Construct a Gap instance. @@ -1415,8 +1406,6 @@ protected: central_privay_configuration_t *configuration ); ble_error_t setRandomStaticAddress_(const ble::address_t& address); - void useVersionOneAPI_() const; - void useVersionTwoAPI_() const; protected: /** diff --git a/features/FEATURE_BLE/ble/generic/GenericGap.h b/features/FEATURE_BLE/ble/generic/GenericGap.h index f807d21307..585907bd84 100644 --- a/features/FEATURE_BLE/ble/generic/GenericGap.h +++ b/features/FEATURE_BLE/ble/generic/GenericGap.h @@ -99,8 +99,6 @@ class GenericGap : using ble::interface::Gap::getMaxAdvertisingDataLength; #endif // BLE_ROLE_BROADCASTER using ble::interface::Gap::isFeatureSupported; - using ble::interface::Gap::useVersionOneAPI; - using ble::interface::Gap::useVersionTwoAPI; // Imports from PalGap EventHandler using PalGapEventHandler::on_scan_timeout; @@ -642,10 +640,6 @@ private: void on_address_rotation_timeout(); - void useVersionOneAPI_() const; - - void useVersionTwoAPI_() const; - /* implements pal::Gap::EventHandler */ private: void on_read_phy_( @@ -828,8 +822,6 @@ private: BitArray _set_is_connectable; // deprecation flags - mutable bool _deprecated_scan_api_used : 1; - mutable bool _non_deprecated_scan_api_used : 1; bool _user_manage_connection_parameter_requests : 1; private: diff --git a/features/FEATURE_BLE/source/gap/Gap.tpp b/features/FEATURE_BLE/source/gap/Gap.tpp index 4053c3f771..c4481edb39 100644 --- a/features/FEATURE_BLE/source/gap/Gap.tpp +++ b/features/FEATURE_BLE/source/gap/Gap.tpp @@ -418,18 +418,6 @@ ble_error_t Gap::setPhy( } #endif // BLE_FEATURE_PHY_MANAGEMENT -template -void Gap::useVersionOneAPI() const -{ - return impl()->useVersionOneAPI_(); -} - -template -void Gap::useVersionTwoAPI() const -{ - return impl()->useVersionTwoAPI_(); -} - template Gap::Gap() : _eventHandler(NULL) { @@ -819,16 +807,6 @@ ble_error_t Gap::setPhy_( return BLE_ERROR_NOT_IMPLEMENTED; } -template -void Gap::useVersionOneAPI_() const -{ -} - -template -void Gap::useVersionTwoAPI_() const -{ -} - template ble_error_t Gap::enablePrivacy_(bool enable) { diff --git a/features/FEATURE_BLE/source/generic/GenericGap.tpp b/features/FEATURE_BLE/source/generic/GenericGap.tpp index d8f50b2f2c..b52df3d7d1 100644 --- a/features/FEATURE_BLE/source/generic/GenericGap.tpp +++ b/features/FEATURE_BLE/source/generic/GenericGap.tpp @@ -64,7 +64,6 @@ static const mbed_error_status_t mixed_scan_api_error = static const mbed_error_status_t illegal_state_error = MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_ILLEGAL_STATE); - /* * Return true if value is included in the range [lower_bound : higher_bound] */ @@ -440,8 +439,6 @@ GenericGap:: _scan_enabled(false), _advertising_timeout(), _scan_timeout(), - _deprecated_scan_api_used(false), - _non_deprecated_scan_api_used(false), _user_manage_connection_parameter_requests(false) { _pal_gap.initialize(); @@ -556,71 +553,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::connect_( - const BLEProtocol::AddressBytes_t peerAddr, - PeerAddressType_t peerAddrType, - const ConnectionParams_t *connectionParams, - const GapScanningParams *scanParams -) -{ - useVersionOneAPI(); - if (connectionParams == NULL) { - connectionParams = &default_connection_params; - } - - if (scanParams == NULL) { - scanParams = &default_scan_params; - } - - if (is_scan_params_valid(scanParams) == false) { - return BLE_ERROR_PARAM_OUT_OF_RANGE; - } - - if (is_connection_params_valid(connectionParams) == false) { - return BLE_ERROR_PARAM_OUT_OF_RANGE; - } - - // Force scan stop before initiating the scan used for connection - stopScan_(); - - return _pal_gap.create_connection( - scanParams->getInterval(), - scanParams->getWindow(), -#if BLE_FEATURE_WHITELIST - _initiator_policy_mode, -#else - pal::initiator_policy_t::NO_FILTER, -#endif - (pal::connection_peer_address_type_t::type) peerAddrType.value(), - ble::address_t(peerAddr), - get_own_address_type(CENTRAL_CONNECTION /* requires resolvable address */), - connectionParams->minConnectionInterval, - connectionParams->maxConnectionInterval, - connectionParams->slaveLatency, - connectionParams->connectionSupervisionTimeout, - /* minimum_connection_event_length */ 0, - /* maximum_connection_event_length */ 0 - ); -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::connect_( - const BLEProtocol::AddressBytes_t peerAddr, - LegacyAddressType_t peerAddrType, - const ConnectionParams_t *connectionParams, - const GapScanningParams *scanParams -) -{ - useVersionOneAPI(); - return connect_( - peerAddr, - to_peer_address_type(peerAddrType), - connectionParams, - scanParams - ); -} - template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::connect_( peer_address_type_t peerAddressType, @@ -628,8 +560,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::cancelConnect_() { - useVersionTwoAPI(); return _pal_gap.cancel_connection_creation(); } @@ -870,52 +793,9 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::disconnect_(Handle_t connectionHandle, DisconnectionReason_t reason) -{ - useVersionOneAPI(); - - if (is_disconnection_reason_valid(reason) == false) { - return BLE_ERROR_INVALID_PARAM; - } - return _pal_gap.disconnect( - connectionHandle, - (pal::disconnection_reason_t::type) reason - ); -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::disconnect_(DisconnectionReason_t reason) -{ - useVersionOneAPI(); - return BLE_ERROR_NOT_IMPLEMENTED; -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::updateConnectionParams_(Handle_t handle, const ConnectionParams_t *params) -{ - useVersionOneAPI(); - - if (is_connection_params_valid(params) == false) { - return BLE_ERROR_PARAM_OUT_OF_RANGE; - } - - return _pal_gap.connection_parameters_update( - handle, - params->minConnectionInterval, - params->maxConnectionInterval, - params->slaveLatency, - params->connectionSupervisionTimeout, - /* minimum_connection_event_length */ 0, - /* maximum_connection_event_length */ 0 - ); -} - template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::getPreferredConnectionParams_(ConnectionParams_t *params) { @@ -1121,127 +1001,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::setAdvertisingPolicyMode_(AdvertisingPolicyMode_t mode) -{ - useVersionOneAPI(); - - if (mode > LegacyGap::ADV_POLICY_FILTER_ALL_REQS) { - return BLE_ERROR_INVALID_PARAM; - } - - _advertising_filter_policy = (pal::advertising_filter_policy_t::type) mode; - return BLE_ERROR_NONE; -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::setScanningPolicyMode_(ScanningPolicyMode_t mode) -{ - useVersionOneAPI(); - - if (mode > LegacyGap::SCAN_POLICY_FILTER_ALL_ADV) { - return BLE_ERROR_INVALID_PARAM; - } - - _scanning_filter_policy = (pal::scanning_filter_policy_t::type) mode; - return BLE_ERROR_NONE; -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::setInitiatorPolicyMode_(InitiatorPolicyMode_t mode) -{ - useVersionOneAPI(); - - if (mode > LegacyGap::INIT_POLICY_FILTER_ALL_ADV) { - return BLE_ERROR_INVALID_PARAM; - } - - _initiator_policy_mode = (pal::initiator_policy_t::type) mode; - return BLE_ERROR_NONE; -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -typename GenericGap::LegacyGap::AdvertisingPolicyMode_t GenericGap::getAdvertisingPolicyMode_(void) const -{ - useVersionOneAPI(); - return (AdvertisingPolicyMode_t) _advertising_filter_policy.value(); -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -typename GenericGap::LegacyGap::ScanningPolicyMode_t GenericGap::getScanningPolicyMode_(void) const -{ - useVersionOneAPI(); - return (ScanningPolicyMode_t) _scanning_filter_policy.value(); -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -typename GenericGap::LegacyGap::InitiatorPolicyMode_t GenericGap::getInitiatorPolicyMode_(void) const -{ - useVersionOneAPI(); - return (InitiatorPolicyMode_t) _initiator_policy_mode.value(); -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::startRadioScan_(const GapScanningParams &scanningParams) -{ - useVersionOneAPI(); - - if (is_scan_params_valid(&scanningParams) == false) { - return BLE_ERROR_INVALID_PARAM; - } - -#if BLE_FEATURE_WHITELIST - if (_scanning_filter_policy == pal::scanning_filter_policy_t::FILTER_ADVERTISING && - _whitelist.size == 0) { - return BLE_ERROR_INVALID_STATE; - } -#endif // BLE_FEATURE_WHITELIST - - pal::own_address_type_t own_address_type = get_own_address_type(CENTRAL_SCAN /* central, can use non resolvable address for scan requests */); - -#if BLE_FEATURE_PRIVACY - if (_privacy_enabled && (own_address_type == pal::own_address_type_t::RANDOM)) { - // Use non-resolvable static random address - set_random_address_rotation(true); - } -#endif // BLE_FEATURE_PRIVACY - - ble_error_t err = _pal_gap.set_scan_parameters( - scanningParams.getActiveScanning(), - scanningParams.getInterval(), - scanningParams.getWindow(), - own_address_type, -#if BLE_FEATURE_WHITELIST - _scanning_filter_policy -#else - pal::scanning_filter_policy_t::NO_FILTER -#endif // BLE_FEATURE_WHITELIST - ); - - if (err) { - return err; - } - - err = _pal_gap.scan_enable(true, false); - - if (err) { - return err; - } - - _scan_enabled = true; - - _scan_timeout.detach(); - uint16_t timeout = scanningParams.getTimeout(); - if (timeout) { - _scan_timeout.attach_us( - mbed::callback(this, &GenericGap::on_scan_timeout_), - scanningParams.getTimeout() * 1000000U - ); - } - - return BLE_ERROR_NONE; -} - template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::initRadioNotification_(void) { @@ -1312,105 +1071,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::setAdvertisingData_(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse) -{ - useVersionOneAPI(); - - ble_error_t err = _pal_gap.set_advertising_data( - advData.getPayloadLen(), - pal::advertising_data_t(advData.getPayload(), advData.getPayloadLen()) - ); - if (err) { - return err; - } - - return _pal_gap.set_scan_response_data( - scanResponse.getPayloadLen(), - pal::advertising_data_t(scanResponse.getPayload(), scanResponse.getPayloadLen()) - ); -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -ble_error_t GenericGap::startAdvertising_(const GapAdvertisingParams ¶ms) -{ - useVersionOneAPI(); - - if (is_advertising_params_valid(params) == false) { - return BLE_ERROR_INVALID_PARAM; - } - - // We can only use non resolvable addresses if the device is non connectable - AddressUseType_t address_use_type = - ((params.getAdvertisingType() == GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED) || - (params.getAdvertisingType() == GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED)) ? - PERIPHERAL_NON_CONNECTABLE : - PERIPHERAL_CONNECTABLE; - - pal::own_address_type_t own_address_type = get_own_address_type(address_use_type); - -#if BLE_FEATURE_PRIVACY - if (_privacy_enabled && (own_address_type == pal::own_address_type_t::RANDOM)) { - // Use non-resolvable static random address - set_random_address_rotation(true); - } -#endif // BLE_FEATURE_PRIVACY - - // TODO: fix the high level API to have a min/max range - // Going against recommendations (The Advertising_Interval_Min and - // Advertising_Interval_Max should not be the same value to enable the - // Controller to determine the best advertising interval given other activities.) - // for now but not against specification: "The Advertising_Interval_Min - // shall be less than or equal to the Advertising_Interval_Max" - ble_error_t err = _pal_gap.set_advertising_parameters( - /* advertising_interval_min */ params.getIntervalInADVUnits(), - /* advertising_interval_max */ params.getIntervalInADVUnits(), - (pal::advertising_type_t::type) params.getAdvertisingType(), - own_address_type, - pal::advertising_peer_address_type_t::PUBLIC, - ble::address_t(), - pal::advertising_channel_map_t::ALL_ADVERTISING_CHANNELS, -#if BLE_FEATURE_WHITELIST - _advertising_filter_policy -#else - pal::advertising_filter_policy_t::NO_FILTER -#endif - ); - - if (err) { - return err; - } - -#if defined(TARGET_CORDIO_LL) - // TODO: fix advertising set creation in the link layer. - // The Cordio link layer implements legacy API on top of extended advertising - // and has an issue that no advertising set is created until we set parameters. - // As a workaround, set advertising data again to ensure it takes effect. - err = setAdvertisingData_(this->_advPayload, this->_scanResponse); - if (err) { - return err; - } -#endif - - err = _pal_gap.advertising_enable(true); - if (err) { - return err; - } - - state.advertising = true; - - _advertising_timeout.detach(); - uint16_t timeout = params.getTimeout(); - if (timeout) { - _advertising_timeout.attach_us( - mbed::callback(this, &GenericGap::on_advertising_timeout), - params.getTimeout() * 1000000U - ); - } - - return BLE_ERROR_NONE; -} - template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::reset_(void) { @@ -1423,10 +1083,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class Conn void GenericGap::on_disconnection_complete(const pal::GapDisconnectionCompleteEvent &e) { if (e.status == pal::hci_error_code_t::SUCCESS) { - // signal internal stack if (_connection_event_handler) { _connection_event_handler->on_disconnected( @@ -2085,7 +1730,6 @@ const uint8_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> uint8_t GenericGap::getMaxAdvertisingSetNumber_() { - useVersionTwoAPI(); #if BLE_FEATURE_EXTENDED_ADVERTISING if (is_extended_advertising_available()) { uint8_t set_number = _pal_gap.get_max_number_of_advertising_sets(); @@ -2100,21 +1744,18 @@ uint8_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> uint16_t GenericGap::getMaxAdvertisingDataLength_() { - useVersionTwoAPI(); return _pal_gap.get_maximum_advertising_data_length(); } template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> uint16_t GenericGap::getMaxConnectableAdvertisingDataLength_() { - useVersionTwoAPI(); return _pal_gap.get_maximum_connectable_advertising_data_length(); } template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> uint16_t GenericGap::getMaxActiveSetAdvertisingDataLength_() { - useVersionTwoAPI(); return _pal_gap.get_maximum_hci_advertising_data_length(); } @@ -2124,8 +1765,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::destroyAdvertisingSet_(advertising_handle_t handle) { - useVersionTwoAPI(); - if (is_extended_advertising_available() == false) { return BLE_ERROR_OPERATION_NOT_PERMITTED; } @@ -2202,8 +1839,6 @@ ble_error_t GenericGap= getMaxAdvertisingSetNumber_()) { return BLE_ERROR_INVALID_PARAM; @@ -2314,8 +1949,6 @@ ble_error_t GenericGap payload ) { - useVersionTwoAPI(); - return setAdvertisingData( handle, payload, @@ -2330,8 +1963,6 @@ ble_error_t GenericGap response ) { - useVersionTwoAPI(); - return setAdvertisingData( handle, response, @@ -2468,7 +2099,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::stopAdvertising_(advertising_handle_t handle) { - useVersionTwoAPI(); - ble_error_t status; #if BLE_FEATURE_EXTENDED_ADVERTISING @@ -2581,8 +2209,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> bool GenericGap::isAdvertisingActive_(advertising_handle_t handle) { - useVersionTwoAPI(); - if (handle >= getMaxAdvertisingSetNumber_()) { return false; } @@ -2598,8 +2224,6 @@ ble_error_t GenericGap periodicAdvertisingIntervalMax.value()) { return BLE_ERROR_INVALID_PARAM; } @@ -2630,8 +2254,6 @@ ble_error_t GenericGap payload ) { - useVersionTwoAPI(); - if (handle == LEGACY_ADVERTISING_HANDLE) { return BLE_ERROR_INVALID_PARAM; } @@ -2692,8 +2314,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::startPeriodicAdvertising_(advertising_handle_t handle) { - useVersionTwoAPI(); - if (handle == LEGACY_ADVERTISING_HANDLE) { return BLE_ERROR_INVALID_PARAM; } @@ -2726,8 +2346,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::stopPeriodicAdvertising_(advertising_handle_t handle) { - useVersionTwoAPI(); - if (handle == LEGACY_ADVERTISING_HANDLE) { return BLE_ERROR_INVALID_PARAM; } @@ -2756,8 +2374,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> bool GenericGap::isPeriodicAdvertisingActive_(advertising_handle_t handle) { - useVersionTwoAPI(); - if (handle >= getMaxAdvertisingSetNumber_()) { return false; } @@ -2830,63 +2446,28 @@ void GenericGaponAdvertisingReport( - AdvertisingReportEvent( - event_type, - address_type ? - (peer_address_type_t::type) address_type->value() : - peer_address_type_t::ANONYMOUS, - (BLEProtocol::AddressBytes_t &) address, - primary_phy, - secondary_phy ? *secondary_phy : phy_t::NONE, - advertising_sid, - tx_power, - rssi, - periodic_advertising_interval, - (ble::peer_address_type_t::type) direct_address_type.value(), - (BLEProtocol::AddressBytes_t &) direct_address, - make_Span(data, data_length) - ) - ); - } else { - if (event_type.legacy_advertising() == false) { - return; - } - - GapAdvertisingParams::AdvertisingType_t advertising_type; - - if (event_type.connectable() == false) { - if (event_type.scannable_advertising()) { - advertising_type = GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED; - } else { - advertising_type = GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED; - } - } else { - if (event_type.directed_advertising()) { - advertising_type = GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED; - } else { - advertising_type = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED; - } - } - - // This handler is not supposed to be called with V1 API as the extended - // scan is not called. However the Cordio LL stack doesn't act that way - // and use extended scan with V1 API. - LegacyGap::processAdvertisementReport( - address.data(), - rssi, - event_type.scan_response(), - advertising_type, - data_length, - data, - (peer_address_type_t::type) address_type->value() - ); + if (!_eventHandler) { + return; } + + _eventHandler->onAdvertisingReport( + AdvertisingReportEvent( + event_type, + address_type ? + (peer_address_type_t::type) address_type->value() : + peer_address_type_t::ANONYMOUS, + (BLEProtocol::AddressBytes_t &) address, + primary_phy, + secondary_phy ? *secondary_phy : phy_t::NONE, + advertising_sid, + tx_power, + rssi, + periodic_advertising_interval, + (ble::peer_address_type_t::type) direct_address_type.value(), + (BLEProtocol::AddressBytes_t &) direct_address, + make_Span(data, data_length) + ) + ); } template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> @@ -2917,7 +2498,6 @@ void GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> @@ -3065,8 +2645,6 @@ void GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::setScanParameters_(const ScanParameters ¶ms) { - useVersionTwoAPI(); - if (is_extended_advertising_available()) { bool active_scanning[] = { params.get1mPhyConfiguration().isActiveScanningSet(), @@ -3116,8 +2694,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::cancelCreateSync_() { - useVersionTwoAPI(); - if (is_extended_advertising_available() == false) { return BLE_ERROR_NOT_IMPLEMENTED; } @@ -3237,8 +2807,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::terminateSync_(periodic_sync_handle_t handle) { - useVersionTwoAPI(); - if (is_extended_advertising_available() == false) { return BLE_ERROR_NOT_IMPLEMENTED; } @@ -3253,8 +2821,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> ble_error_t GenericGap::clearPeriodicAdvertiserList_() { - useVersionTwoAPI(); - if (is_extended_advertising_available() == false) { return BLE_ERROR_NOT_IMPLEMENTED; } @@ -3321,8 +2883,6 @@ ble_error_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> uint8_t GenericGap::getMaxPeriodicAdvertiserListSize_() { - useVersionTwoAPI(); - if (is_extended_advertising_available() == false) { return BLE_ERROR_NOT_IMPLEMENTED; } @@ -3330,36 +2890,6 @@ uint8_t GenericGap class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -void GenericGap::useVersionOneAPI_() const -{ - if (_non_deprecated_scan_api_used) { - MBED_ERROR(mixed_scan_api_error, "Use of deprecated scan API with up to date API"); - } - _deprecated_scan_api_used = true; -} - -template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> -void GenericGap::useVersionTwoAPI_() const -{ - if (_deprecated_scan_api_used) { - MBED_ERROR(mixed_scan_api_error, "Use of up to date scan API with deprecated API"); - } - if (!_non_deprecated_scan_api_used) { - _non_deprecated_scan_api_used = true; -#if BLE_FEATURE_EXTENDED_ADVERTISING - if (const_cast(this)->is_extended_advertising_available()) { - const_cast(this)->setExtendedAdvertisingParameters( - LEGACY_ADVERTISING_HANDLE, - AdvertisingParameters() - ); - } - const_cast*>(&_existing_sets)->set(LEGACY_ADVERTISING_HANDLE); -#endif - } - -} - template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> bool GenericGap::is_extended_advertising_available() {