From c78afe249ca3f47bb8cbab75fb3bb3be40a2b3b6 Mon Sep 17 00:00:00 2001 From: Paul Szczeanek Date: Tue, 18 Aug 2020 18:07:16 +0100 Subject: [PATCH] remove address from api to cancel connect --- connectivity/FEATURE_BLE/include/ble/Gap.h | 19 ------------------ .../FEATURE_BLE/include/ble/internal/PalGap.h | 11 +--------- .../include/ble/internal/PalGapImpl.h | 5 +---- .../TARGET_CORDIO/source/PalGapImpl.cpp | 14 ++++++------- .../include/ble/internal/GapImpl.h | 9 --------- .../ble-api-implementation/source/GapImpl.cpp | 20 ++----------------- 6 files changed, 10 insertions(+), 68 deletions(-) diff --git a/connectivity/FEATURE_BLE/include/ble/Gap.h b/connectivity/FEATURE_BLE/include/ble/Gap.h index 32688fcfe6..6caf0df0b1 100644 --- a/connectivity/FEATURE_BLE/include/ble/Gap.h +++ b/connectivity/FEATURE_BLE/include/ble/Gap.h @@ -1002,30 +1002,11 @@ public: /** Cancel the connection attempt. This is not guaranteed to succeed. As a result * onConnectionComplete in the event handler will be called. Check the success parameter * to see if the connection was created. - * @depreacted This version has a defective API. You must provide the address of the peer. - * Please use the cancelConnect that takes peer address as parameters. - * This call will attempt to cancel the most recently requested connection. * * @return BLE_ERROR_NONE if the connection attempt has been requested to be cancelled. * Returns BLE_ERROR_OPERATION_NOT_PERMITTED if no ongoing connection for last used address found. */ - MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Defective API. Please use the cancelConnect that takes peer address as parameters.") ble_error_t cancelConnect(); - - /** Cancel the connection attempt. This is not guaranteed to succeed. As a result - * onConnectionComplete in the event handler will be called. Check the success parameter - * to see if the connection was created. - * - * @param peerAddressType Address type you want to cancel connection process for. - * @param peerAddress Address you want to cancel connection process for. - * - * @return BLE_ERROR_NONE if the connection attempt has been requested to be cancelled. - * Returns BLE_ERROR_OPERATION_NOT_PERMITTED if no ongoing connection for address found. - */ - ble_error_t cancelConnect( - peer_address_type_t peerAddressType, - const address_t &peerAddress - ); #endif // BLE_ROLE_CENTRAL #if BLE_FEATURE_CONNECTABLE diff --git a/connectivity/FEATURE_BLE/include/ble/internal/PalGap.h b/connectivity/FEATURE_BLE/include/ble/internal/PalGap.h index de98fa8842..c602bb8bcb 100644 --- a/connectivity/FEATURE_BLE/include/ble/internal/PalGap.h +++ b/connectivity/FEATURE_BLE/include/ble/internal/PalGap.h @@ -1298,22 +1298,13 @@ public: /** * Cancel the ongoing connection creation process. * - * @param peer_address_type Type of address used by the advertiser. Not used - * if initiator_policy use the whitelist. - * - * @param Address used by the advertiser in its advertising packets. Not - * used if initiator_policy use the whitelist. - * * @return BLE_ERROR_NONE if the request has been successfully sent or the * appropriate error otherwise. * * @note: See Bluetooth 5 Vol 2 PartE: 7.8.13 LE create connection cancel * command. */ - virtual ble_error_t cancel_connection_creation( - peer_address_type_t peerAddressType, - const ble::address_t &peerAddress - ) = 0; + virtual ble_error_t cancel_connection_creation() = 0; /** * Return the number of total whitelist entries that can be stored in the diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGapImpl.h b/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGapImpl.h index e90dfe21be..f5bf251f3c 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGapImpl.h +++ b/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGapImpl.h @@ -97,10 +97,7 @@ public: uint16_t maximum_connection_event_length ); - ble_error_t cancel_connection_creation( - peer_address_type_t peerAddressType, - const ble::address_t &peerAddress - ); + ble_error_t cancel_connection_creation(); uint8_t read_white_list_capacity(); diff --git a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGapImpl.cpp b/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGapImpl.cpp index 239334b083..38af171037 100644 --- a/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGapImpl.cpp +++ b/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGapImpl.cpp @@ -322,25 +322,23 @@ ble_error_t PalGap::create_connection( } -ble_error_t PalGap::cancel_connection_creation( - peer_address_type_t peerAddressType, - const ble::address_t &peerAddress -) +ble_error_t PalGap::cancel_connection_creation() { + ble_error_t error = BLE_ERROR_OPERATION_NOT_PERMITTED; + for (uint8_t connection_id = 0; connection_id < DM_CONN_MAX; connection_id++) { if (dmConnCb.ccb[connection_id].inUse && - dmConnCb.ccb[connection_id].state == DM_CONN_SM_ST_CONNECTING && - BdaCmp(dmConnCb.ccb[connection_id].peerAddr, peerAddress.data())) { + dmConnCb.ccb[connection_id].state == DM_CONN_SM_ST_CONNECTING) { DmConnClose( DM_CLIENT_ID_APP, /* connection handle */ connection_id + 1 /* connection IDs start at 1 */, /* reason - invalid (use success) */ 0x00 ); - return BLE_ERROR_NONE; } + error = BLE_ERROR_NONE; } - return BLE_ERROR_OPERATION_NOT_PERMITTED; + return error; } diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GapImpl.h b/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GapImpl.h index 75a9a52be9..a89c8ba5ba 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GapImpl.h +++ b/connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GapImpl.h @@ -209,11 +209,6 @@ public: const ConnectionParameters &connectionParams ); - ble_error_t cancelConnect( - peer_address_type_t peerAddressType, - const address_t &peerAddress - ); - ble_error_t cancelConnect(); #endif // BLE_ROLE_CENTRAL @@ -601,10 +596,6 @@ private: BitArray _set_is_connectable; bool _user_manage_connection_parameter_requests : 1; - - /* these need be removed when the deprecated cancelConnect() is removed */ - peer_address_type_t _last_used_peer_address_type = peer_address_type_t::ANONYMOUS; - ble::address_t _last_used_peer_address; }; } // namespace ble diff --git a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GapImpl.cpp b/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GapImpl.cpp index 214a675289..593ee3aca3 100644 --- a/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GapImpl.cpp +++ b/connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GapImpl.cpp @@ -507,9 +507,6 @@ ble_error_t Gap::connect( return BLE_ERROR_INVALID_PARAM; } - _last_used_peer_address_type = peerAddressType; - _last_used_peer_address = peerAddress; - // ensure scan is stopped. _pal_gap.scan_enable(false, false); @@ -541,9 +538,6 @@ ble_error_t Gap::connect( adjusted_address_type = peer_address_type_t::RANDOM; } - _last_used_peer_address_type = adjusted_address_type; - _last_used_peer_address = peerAddress; - return _pal_gap.extended_create_connection( connectionParams.getFilter(), connectionParams.getOwnAddressType(), @@ -631,20 +625,10 @@ ble_error_t Gap::rejectConnectionParametersUpdate( ); } + ble_error_t Gap::cancelConnect() { - if (_last_used_peer_address_type != peer_address_type_t::ANONYMOUS) { - return cancelConnect(_last_used_peer_address_type, _last_used_peer_address); - } - return BLE_ERROR_OPERATION_NOT_PERMITTED; -} - -ble_error_t Gap::cancelConnect( - peer_address_type_t peerAddressType, - const ble::address_t &peerAddress -) -{ - return _pal_gap.cancel_connection_creation(peerAddressType, peerAddress); + return _pal_gap.cancel_connection_creation(); } ble_error_t Gap::readPhy(ble::connection_handle_t connection)