Skip to content

Commit c78afe2

Browse files
remove address from api to cancel connect
1 parent 890f056 commit c78afe2

File tree

6 files changed

+10
-68
lines changed

6 files changed

+10
-68
lines changed

connectivity/FEATURE_BLE/include/ble/Gap.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,30 +1002,11 @@ class Gap {
10021002
/** Cancel the connection attempt. This is not guaranteed to succeed. As a result
10031003
* onConnectionComplete in the event handler will be called. Check the success parameter
10041004
* to see if the connection was created.
1005-
* @depreacted This version has a defective API. You must provide the address of the peer.
1006-
* Please use the cancelConnect that takes peer address as parameters.
1007-
* This call will attempt to cancel the most recently requested connection.
10081005
*
10091006
* @return BLE_ERROR_NONE if the connection attempt has been requested to be cancelled.
10101007
* Returns BLE_ERROR_OPERATION_NOT_PERMITTED if no ongoing connection for last used address found.
10111008
*/
1012-
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Defective API. Please use the cancelConnect that takes peer address as parameters.")
10131009
ble_error_t cancelConnect();
1014-
1015-
/** Cancel the connection attempt. This is not guaranteed to succeed. As a result
1016-
* onConnectionComplete in the event handler will be called. Check the success parameter
1017-
* to see if the connection was created.
1018-
*
1019-
* @param peerAddressType Address type you want to cancel connection process for.
1020-
* @param peerAddress Address you want to cancel connection process for.
1021-
*
1022-
* @return BLE_ERROR_NONE if the connection attempt has been requested to be cancelled.
1023-
* Returns BLE_ERROR_OPERATION_NOT_PERMITTED if no ongoing connection for address found.
1024-
*/
1025-
ble_error_t cancelConnect(
1026-
peer_address_type_t peerAddressType,
1027-
const address_t &peerAddress
1028-
);
10291010
#endif // BLE_ROLE_CENTRAL
10301011

10311012
#if BLE_FEATURE_CONNECTABLE

connectivity/FEATURE_BLE/include/ble/internal/PalGap.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,22 +1298,13 @@ class PalGap {
12981298
/**
12991299
* Cancel the ongoing connection creation process.
13001300
*
1301-
* @param peer_address_type Type of address used by the advertiser. Not used
1302-
* if initiator_policy use the whitelist.
1303-
*
1304-
* @param Address used by the advertiser in its advertising packets. Not
1305-
* used if initiator_policy use the whitelist.
1306-
*
13071301
* @return BLE_ERROR_NONE if the request has been successfully sent or the
13081302
* appropriate error otherwise.
13091303
*
13101304
* @note: See Bluetooth 5 Vol 2 PartE: 7.8.13 LE create connection cancel
13111305
* command.
13121306
*/
1313-
virtual ble_error_t cancel_connection_creation(
1314-
peer_address_type_t peerAddressType,
1315-
const ble::address_t &peerAddress
1316-
) = 0;
1307+
virtual ble_error_t cancel_connection_creation() = 0;
13171308

13181309
/**
13191310
* Return the number of total whitelist entries that can be stored in the

connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalGapImpl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ class PalGap : public interface::PalGap {
9797
uint16_t maximum_connection_event_length
9898
);
9999

100-
ble_error_t cancel_connection_creation(
101-
peer_address_type_t peerAddressType,
102-
const ble::address_t &peerAddress
103-
);
100+
ble_error_t cancel_connection_creation();
104101

105102
uint8_t read_white_list_capacity();
106103

connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/source/PalGapImpl.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,25 +322,23 @@ ble_error_t PalGap::create_connection(
322322
}
323323

324324

325-
ble_error_t PalGap::cancel_connection_creation(
326-
peer_address_type_t peerAddressType,
327-
const ble::address_t &peerAddress
328-
)
325+
ble_error_t PalGap::cancel_connection_creation()
329326
{
327+
ble_error_t error = BLE_ERROR_OPERATION_NOT_PERMITTED;
328+
330329
for (uint8_t connection_id = 0; connection_id < DM_CONN_MAX; connection_id++) {
331330
if (dmConnCb.ccb[connection_id].inUse &&
332-
dmConnCb.ccb[connection_id].state == DM_CONN_SM_ST_CONNECTING &&
333-
BdaCmp(dmConnCb.ccb[connection_id].peerAddr, peerAddress.data())) {
331+
dmConnCb.ccb[connection_id].state == DM_CONN_SM_ST_CONNECTING) {
334332
DmConnClose(
335333
DM_CLIENT_ID_APP,
336334
/* connection handle */ connection_id + 1 /* connection IDs start at 1 */,
337335
/* reason - invalid (use success) */ 0x00
338336
);
339-
return BLE_ERROR_NONE;
340337
}
338+
error = BLE_ERROR_NONE;
341339
}
342340

343-
return BLE_ERROR_OPERATION_NOT_PERMITTED;
341+
return error;
344342
}
345343

346344

connectivity/FEATURE_BLE/libraries/ble-api-implementation/include/ble/internal/GapImpl.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,6 @@ class Gap :
209209
const ConnectionParameters &connectionParams
210210
);
211211

212-
ble_error_t cancelConnect(
213-
peer_address_type_t peerAddressType,
214-
const address_t &peerAddress
215-
);
216-
217212
ble_error_t cancelConnect();
218213
#endif // BLE_ROLE_CENTRAL
219214

@@ -601,10 +596,6 @@ class Gap :
601596
BitArray<BLE_GAP_MAX_ADVERTISING_SETS> _set_is_connectable;
602597

603598
bool _user_manage_connection_parameter_requests : 1;
604-
605-
/* these need be removed when the deprecated cancelConnect() is removed */
606-
peer_address_type_t _last_used_peer_address_type = peer_address_type_t::ANONYMOUS;
607-
ble::address_t _last_used_peer_address;
608599
};
609600

610601
} // namespace ble

connectivity/FEATURE_BLE/libraries/ble-api-implementation/source/GapImpl.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,6 @@ ble_error_t Gap::connect(
507507
return BLE_ERROR_INVALID_PARAM;
508508
}
509509

510-
_last_used_peer_address_type = peerAddressType;
511-
_last_used_peer_address = peerAddress;
512-
513510
// ensure scan is stopped.
514511
_pal_gap.scan_enable(false, false);
515512

@@ -541,9 +538,6 @@ ble_error_t Gap::connect(
541538
adjusted_address_type = peer_address_type_t::RANDOM;
542539
}
543540

544-
_last_used_peer_address_type = adjusted_address_type;
545-
_last_used_peer_address = peerAddress;
546-
547541
return _pal_gap.extended_create_connection(
548542
connectionParams.getFilter(),
549543
connectionParams.getOwnAddressType(),
@@ -631,20 +625,10 @@ ble_error_t Gap::rejectConnectionParametersUpdate(
631625
);
632626
}
633627

634-
ble_error_t Gap::cancelConnect()
635-
{
636-
if (_last_used_peer_address_type != peer_address_type_t::ANONYMOUS) {
637-
return cancelConnect(_last_used_peer_address_type, _last_used_peer_address);
638-
}
639-
return BLE_ERROR_OPERATION_NOT_PERMITTED;
640-
}
641628

642-
ble_error_t Gap::cancelConnect(
643-
peer_address_type_t peerAddressType,
644-
const ble::address_t &peerAddress
645-
)
629+
ble_error_t Gap::cancelConnect()
646630
{
647-
return _pal_gap.cancel_connection_creation(peerAddressType, peerAddress);
631+
return _pal_gap.cancel_connection_creation();
648632
}
649633

650634
ble_error_t Gap::readPhy(ble::connection_handle_t connection)

0 commit comments

Comments
 (0)