Skip to content

Commit ef585d6

Browse files
alexsvenkoffes
authored andcommitted
applications: nrf5340_audio: Use static address when privacy=n
- Add BT_LE_ADV_OPT_USE_IDENTITY when BT_PRIVACY=n - This ensures a static address for debugging/testing purposes - Removed old method of reading out FICR to set static addr manually - OCT-3152 Signed-off-by: Alexander Svensen <[email protected]>
1 parent cc1ca45 commit ef585d6

File tree

2 files changed

+8
-43
lines changed

2 files changed

+8
-43
lines changed

applications/nrf5340_audio/src/bluetooth/bt_management/advertising/bt_mgmt_adv.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,14 @@ int bt_mgmt_adv_start(uint8_t ext_adv_index, const struct bt_data *adv, size_t a
437437
per_adv_local[ext_adv_index] = per_adv;
438438
per_adv_local_size[ext_adv_index] = per_adv_size;
439439

440+
/* Only use fixed address if no privacy and it is the first ext adv set */
441+
if (!IS_ENABLED(CONFIG_BT_PRIVACY) && ext_adv_index == 0) {
442+
ext_adv_param.options |= BT_LE_ADV_OPT_USE_IDENTITY;
443+
} else {
444+
/* If privacy is enabled, use RPA */
445+
ext_adv_param.options &= ~BT_LE_ADV_OPT_USE_IDENTITY;
446+
}
447+
440448
if (connectable) {
441449
ret = bt_le_ext_adv_create(LE_AUDIO_EXTENDED_ADV_CONN_NAME, &adv_cb,
442450
&ext_adv[ext_adv_index]);

applications/nrf5340_audio/src/bluetooth/bt_management/bt_mgmt.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -231,42 +231,6 @@ static int bonding_clear_check(void)
231231
return 0;
232232
}
233233

234-
static int ficr_static_addr_set(void)
235-
{
236-
int ret;
237-
static bt_addr_le_t addr;
238-
239-
if ((NRF_FICR->INFO.DEVICEID[0] != UINT32_MAX) ||
240-
((NRF_FICR->INFO.DEVICEID[1] & UINT16_MAX) != UINT16_MAX)) {
241-
/* Put the device ID from FICR into address */
242-
sys_put_le32(NRF_FICR->INFO.DEVICEID[0], &addr.a.val[0]);
243-
sys_put_le16(NRF_FICR->INFO.DEVICEID[1], &addr.a.val[4]);
244-
245-
/* The FICR value is a just a random number, with no knowledge
246-
* of the Bluetooth Specification requirements for random
247-
* static addresses.
248-
*/
249-
BT_ADDR_SET_STATIC(&addr.a);
250-
251-
addr.type = BT_ADDR_LE_RANDOM;
252-
253-
ret = bt_id_create(&addr, NULL);
254-
if (ret < 0) {
255-
LOG_ERR("Failed to create ID %d", ret);
256-
return ret;
257-
}
258-
259-
return 0;
260-
}
261-
262-
/* If no address can be created (e.g. based on
263-
* FICR), then a random address is created
264-
*/
265-
LOG_WRN("Unable to read from FICR");
266-
267-
return 0;
268-
}
269-
270234
/* This function generates a random address for bonding testing */
271235
static int random_static_addr_set(void)
272236
{
@@ -373,13 +337,6 @@ int bt_mgmt_init(void)
373337
{
374338
int ret;
375339

376-
if (!IS_ENABLED(CONFIG_BT_PRIVACY)) {
377-
ret = ficr_static_addr_set();
378-
if (ret) {
379-
return ret;
380-
}
381-
}
382-
383340
ret = bt_enable(bt_enabled_cb);
384341
if (ret) {
385342
return ret;

0 commit comments

Comments
 (0)