Skip to content

Commit 0d88bcd

Browse files
committed
upgrade implementationof gap::connect in case of private address and whitelisting for SD API 3 and further
1 parent cbf9aba commit 0d88bcd

File tree

2 files changed

+18
-1
lines changed
  • features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source
  • targets/TARGET_NORDIC/TARGET_NRF5_SDK13

2 files changed

+18
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ ble_error_t nRF5xGap::connect(const Address_t peerAddr,
334334
connParams.conn_sup_timeout = 600;
335335
}
336336

337-
ble_gap_scan_params_t scanParams;
337+
ble_gap_scan_params_t scanParams ={0};
338338

339339
#if (NRF_SD_BLE_API_VERSION <= 2)
340340
/* Allocate the stack's whitelist statically */
@@ -363,6 +363,20 @@ ble_error_t nRF5xGap::connect(const Address_t peerAddr,
363363
if (err != BLE_ERROR_NONE) {
364364
return (ble_error_t)err;
365365
}
366+
367+
scanParams.use_whitelist = (whitelistAddressesSize) ? 1 : 0;
368+
369+
if (addr.addr_type == ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE || addr.addr_type == ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE) {
370+
/* If a device is using Resolvable Private Addresses Section 1.3.2.2 (Core spec v4.2 volume 6 part B),
371+
it shall also have an Identity Address that is either a Public or Random Static address type.”
372+
For connecting a static address must be provided by the application to the softdevice.
373+
The softdevice will resolve the address and connect to the right device if present. */
374+
addr.addr_id_peer = 1;
375+
addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
376+
} else {
377+
addr.addr_id_peer = 0;
378+
}
379+
366380
#endif
367381

368382
if (scanParamsIn != NULL) {

targets/TARGET_NORDIC/TARGET_NRF5_SDK13/us_ticker.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
#include "nrf_drv_common.h"
4343
#include "lp_ticker_api.h"
4444

45+
#if defined(NRF52_ERRATA_20)
46+
#include "softdevice_handler.h"
47+
#endif
4548

4649
//------------------------------------------------------------------------------
4750
// Common stuff used also by lp_ticker and rtc_api (see "common_rtc.h").

0 commit comments

Comments
 (0)