Skip to content

Commit b008691

Browse files
paul-szczepanek-armpan-
authored andcommitted
scan forever and allow cancellation
1 parent 18c218b commit b008691

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

connectivity/FEATURE_BLE/source/generic/GapImpl.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ ble_error_t Gap::connect(
557557
#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
558558
if (_connect_to_address_type != peer_address_type_t::ANONYMOUS) {
559559
ret = startScan(
560-
(scan_duration_t)connectionParams.getConnectionSupervisionTimeoutArray()[0],
560+
scan_duration_t::forever(),
561561
duplicates_filter_t::ENABLE,
562562
(scan_period_t)0
563563
);
@@ -710,6 +710,14 @@ ble_error_t Gap::rejectConnectionParametersUpdate(
710710
#if BLE_ROLE_CENTRAL
711711
ble_error_t Gap::cancelConnect()
712712
{
713+
#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
714+
if (_ready_to_connect_to_host_resolved_address) {
715+
connecting_to_host_resolved_address_failed(false);
716+
stopScan();
717+
return BLE_ERROR_NONE;
718+
}
719+
#endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
720+
713721
if (!_initiating) {
714722
return BLE_ERROR_NONE;
715723
}
@@ -1183,9 +1191,9 @@ void Gap::on_scan_stopped(bool success)
11831191
}
11841192

11851193
#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1186-
void Gap::connecting_to_host_resolved_address_failed()
1194+
void Gap::connecting_to_host_resolved_address_failed(bool inform_user)
11871195
{
1188-
if (_event_handler) {
1196+
if (inform_user && _event_handler) {
11891197
_event_handler->onConnectionComplete(
11901198
ConnectionCompleteEvent(
11911199
BLE_ERROR_NOT_FOUND,
@@ -1219,13 +1227,6 @@ void Gap::on_scan_timeout()
12191227
_scan_enabled = false;
12201228
_scan_pending = false;
12211229

1222-
#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1223-
if (_ready_to_connect_to_host_resolved_address) {
1224-
connecting_to_host_resolved_address_failed();
1225-
return;
1226-
}
1227-
#endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1228-
12291230
if (_event_handler) {
12301231
_event_handler->onScanTimeout(ScanTimeoutEvent());
12311232
}
@@ -1241,13 +1242,6 @@ void Gap::process_legacy_scan_timeout()
12411242
/* legacy scanning timed out is based on timer so we need to stop the scan manually */
12421243
_pal_gap.scan_enable(false, false);
12431244

1244-
#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1245-
if (_ready_to_connect_to_host_resolved_address) {
1246-
connecting_to_host_resolved_address_failed();
1247-
return;
1248-
}
1249-
#endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1250-
12511245
if (_event_handler) {
12521246
_event_handler->onScanTimeout(ScanTimeoutEvent());
12531247
}

connectivity/FEATURE_BLE/source/generic/GapImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ class Gap :
799799
const address_t *get_random_address(controller_operation_t operation, size_t advertising_set = 0);
800800

801801
#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
802-
void connecting_to_host_resolved_address_failed();
802+
void connecting_to_host_resolved_address_failed(bool inform_user = true);
803803
#endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
804804

805805
private:

0 commit comments

Comments
 (0)