@@ -554,7 +554,7 @@ ble_error_t Gap::connect(
554554#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
555555 if (_connect_to_address_type != peer_address_type_t ::ANONYMOUS) {
556556 ret = startScan (
557- ( scan_duration_t )connectionParams. getConnectionSupervisionTimeoutArray ()[ 0 ] ,
557+ scan_duration_t::forever () ,
558558 duplicates_filter_t ::ENABLE,
559559 (scan_period_t )0
560560 );
@@ -697,6 +697,14 @@ ble_error_t Gap::rejectConnectionParametersUpdate(
697697
698698ble_error_t Gap::cancelConnect ()
699699{
700+ #if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
701+ if (_ready_to_connect_to_host_resolved_address) {
702+ connecting_to_host_resolved_address_failed (false );
703+ stopScan ();
704+ return BLE_ERROR_NONE;
705+ }
706+ #endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
707+
700708 if (!_initiating) {
701709 return BLE_ERROR_NONE;
702710 }
@@ -1121,9 +1129,9 @@ void Gap::on_scan_stopped(bool success)
11211129}
11221130
11231131#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1124- void Gap::connecting_to_host_resolved_address_failed ()
1132+ void Gap::connecting_to_host_resolved_address_failed (bool inform_user )
11251133{
1126- if (_event_handler) {
1134+ if (inform_user && _event_handler) {
11271135 _event_handler->onConnectionComplete (
11281136 ConnectionCompleteEvent (
11291137 BLE_ERROR_NOT_FOUND,
@@ -1157,13 +1165,6 @@ void Gap::on_scan_timeout()
11571165 _scan_enabled = false ;
11581166 _scan_pending = false ;
11591167
1160- #if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1161- if (_ready_to_connect_to_host_resolved_address) {
1162- connecting_to_host_resolved_address_failed ();
1163- return ;
1164- }
1165- #endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1166-
11671168 if (_event_handler) {
11681169 _event_handler->onScanTimeout (ScanTimeoutEvent ());
11691170 }
@@ -1179,13 +1180,6 @@ void Gap::process_legacy_scan_timeout()
11791180 /* legacy scanning timed out is based on timer so we need to stop the scan manually */
11801181 _pal_gap.scan_enable (false , false );
11811182
1182- #if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1183- if (_ready_to_connect_to_host_resolved_address) {
1184- connecting_to_host_resolved_address_failed ();
1185- return ;
1186- }
1187- #endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
1188-
11891183 if (_event_handler) {
11901184 _event_handler->onScanTimeout (ScanTimeoutEvent ());
11911185 }
0 commit comments