Skip to content

Commit 1c87d31

Browse files
return error when cannot cancel
1 parent e4dd1bb commit 1c87d31

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

connectivity/FEATURE_BLE/include/ble/Gap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ class Gap {
10071007
* This call will attempt to cancel the most recently requested connection.
10081008
*
10091009
* @return BLE_ERROR_NONE if the connection attempt has been requested to be cancelled.
1010+
* Returns BLE_ERROR_OPERATION_NOT_PERMITTED if no ongoing connection for last used address found.
10101011
*/
10111012
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Defective API. Please use the cancelConnect that takes peer address as parameters.")
10121013
ble_error_t cancelConnect();
@@ -1019,6 +1020,7 @@ class Gap {
10191020
* @param peerAddress Address you want to cancel connection process for.
10201021
*
10211022
* @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.
10221024
*/
10231025
ble_error_t cancelConnect(
10241026
peer_address_type_t peerAddressType,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ ble_error_t PalGap::cancel_connection_creation(
335335
/* connection handle */ connection_id,
336336
/* reason - invalid (use success) */ 0x00
337337
);
338-
break;
338+
return BLE_ERROR_NONE;
339339
}
340340
}
341341

342-
return BLE_ERROR_NONE;
342+
return BLE_ERROR_OPERATION_NOT_PERMITTED;
343343
}
344344

345345

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ ble_error_t Gap::cancelConnect()
635635
if (_last_used_peer_address_type != peer_address_type_t::ANONYMOUS) {
636636
return cancelConnect(_last_used_peer_address_type, _last_used_peer_address);
637637
}
638-
return BLE_ERROR_NONE;
638+
return BLE_ERROR_OPERATION_NOT_PERMITTED;
639639
}
640640

641641
ble_error_t Gap::cancelConnect(

0 commit comments

Comments
 (0)