Skip to content

Commit 30dac7c

Browse files
committed
BLE NRF52: Fix identity address flag in connection request.
1 parent de41355 commit 30dac7c

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xGap.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,11 @@ ble_error_t nRF5xGap::connect(
501501
return BLE_ERROR_INVALID_PARAM;
502502
}
503503

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);
505509
}
506510

507511

@@ -510,6 +514,16 @@ ble_error_t nRF5xGap::connect(
510514
LegacyAddressType_t peerAddrType,
511515
const ConnectionParams_t *connectionParams,
512516
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
513527
) {
514528
ble_gap_addr_t addr;
515529
ble_gap_addr_t* addr_ptr = &addr;
@@ -585,23 +599,16 @@ ble_error_t nRF5xGap::connect(
585599

586600
scanParams.use_whitelist = (whitelistAddressesSize) ? 1 : 0;
587601

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-
600602
if (_privacy_enabled) {
601603
bool enable_resolution =
602604
_central_privacy_configuration.resolution_strategy != CentralPrivacyConfiguration_t::DO_NOT_RESOLVE;
603605

604606
update_identities_list(enable_resolution);
607+
608+
if (enable_resolution && identity) {
609+
addr.addr_id_peer = 1;
610+
}
611+
605612
set_private_resolvable_address();
606613
}
607614

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xGap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class nRF5xGap : public ::Gap, public ble::pal::ConnectionEventMonitor {
8888
virtual ble_error_t stopAdvertising(void);
8989
virtual ble_error_t connect(const Address_t, ble::peer_address_type_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams);
9090
virtual ble_error_t connect(const Address_t, BLEProtocol::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams);
91+
ble_error_t connect(const Address_t, BLEProtocol::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams, bool identity);
9192
virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason);
9293
virtual ble_error_t disconnect(DisconnectionReason_t reason);
9394

0 commit comments

Comments
 (0)