@@ -501,7 +501,11 @@ ble_error_t nRF5xGap::connect(
501
501
return BLE_ERROR_INVALID_PARAM;
502
502
}
503
503
504
- return connect (peerAddr, legacy_address, connectionParams, scanParamsIn);
504
+ bool identity =
505
+ peerAddrType == peer_address_type_t ::PUBLIC_IDENTITY ||
506
+ peerAddrType == peer_address_type_t ::RANDOM_STATIC_IDENTITY;
507
+
508
+ return connect (peerAddr, legacy_address, connectionParams, scanParamsIn, identity);
505
509
}
506
510
507
511
@@ -510,6 +514,16 @@ ble_error_t nRF5xGap::connect(
510
514
LegacyAddressType_t peerAddrType,
511
515
const ConnectionParams_t *connectionParams,
512
516
const GapScanningParams *scanParamsIn
517
+ ) {
518
+ return connect (peerAddr, peerAddrType, connectionParams, scanParamsIn, false );
519
+ }
520
+
521
+ ble_error_t nRF5xGap::connect (
522
+ const Address_t peerAddr,
523
+ LegacyAddressType_t peerAddrType,
524
+ const ConnectionParams_t *connectionParams,
525
+ const GapScanningParams *scanParamsIn,
526
+ bool identity
513
527
) {
514
528
ble_gap_addr_t addr;
515
529
ble_gap_addr_t * addr_ptr = &addr;
@@ -585,23 +599,16 @@ ble_error_t nRF5xGap::connect(
585
599
586
600
scanParams.use_whitelist = (whitelistAddressesSize) ? 1 : 0 ;
587
601
588
- if ((addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE)
589
- || (addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE)) {
590
- /* If a device is using Resolvable Private Addresses Section 1.3.2.2 (Core spec v4.2 volume 6 part B),
591
- it shall also have an Identity Address that is either a Public or Random Static address type.”
592
- To establish a connection, a static address must be provided by the application to the SoftDevice.
593
- The SoftDevice resolves the address and connects to the right device if it is available. */
594
- addr.addr_id_peer = 1 ;
595
- addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
596
- } else {
597
- addr.addr_id_peer = 0 ;
598
- }
599
-
600
602
if (_privacy_enabled) {
601
603
bool enable_resolution =
602
604
_central_privacy_configuration.resolution_strategy != CentralPrivacyConfiguration_t::DO_NOT_RESOLVE;
603
605
604
606
update_identities_list (enable_resolution);
607
+
608
+ if (enable_resolution && identity) {
609
+ addr.addr_id_peer = 1 ;
610
+ }
611
+
605
612
set_private_resolvable_address ();
606
613
}
607
614
@@ -1333,6 +1340,9 @@ void nRF5xGap::on_connection(Gap::Handle_t handle, const ble_gap_evt_connected_t
1333
1340
memcpy (own_address, evt.own_addr .addr , sizeof (own_address));
1334
1341
#else
1335
1342
getAddress (&own_addr_type, own_address.data ());
1343
+ if (_privacy_enabled) {
1344
+ own_addr_type = LegacyAddressType::RANDOM_PRIVATE_RESOLVABLE;
1345
+ }
1336
1346
#endif
1337
1347
1338
1348
#if (NRF_SD_BLE_API_VERSION <= 2)
@@ -1422,7 +1432,9 @@ void nRF5xGap::on_advertising_packet(const ble_gap_evt_adv_report_t &evt) {
1422
1432
bool peer_address_resolved = evt.peer_addr .addr_id_peer ;
1423
1433
1424
1434
if (_privacy_enabled &&
1425
- peer_address_resolved == false &&
1435
+ evt.peer_addr .addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE &&
1436
+ peer_address_resolved == false &&
1437
+ get_sm ().get_resolving_list ().size () > 0 &&
1426
1438
_central_privacy_configuration.resolution_strategy == CentralPrivacyConfiguration_t::RESOLVE_AND_FILTER
1427
1439
) {
1428
1440
return ;
0 commit comments