Bluetooth: host: Scanner must be disabled to update to NRPA address

When advertiser is disabled we should update the random address for both
passive and active scanner back to an NRPA. But this command will fail
because the if the scanner is an active scanner, we must disable and
re-enabled the active scanner after setting the random address.
This behavior should not be there when scanner is configured to scan
with identity address.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-01-31 10:52:01 +01:00 committed by Johan Hedberg
commit d977282514

View file

@ -6179,13 +6179,17 @@ int bt_le_adv_stop(void)
return err;
}
if (!IS_ENABLED(CONFIG_BT_PRIVACY)) {
/* If active scan is ongoing set NRPA */
if (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING) &&
atomic_test_bit(bt_dev.flags, BT_DEV_ACTIVE_SCAN)) {
#if defined(CONFIG_BT_OBSERVER)
if (!IS_ENABLED(CONFIG_BT_PRIVACY) &&
!IS_ENABLED(CONFIG_BT_SCAN_WITH_IDENTITY)) {
/* If scan is ongoing set back NRPA */
if (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING)) {
set_le_scan_enable(BT_HCI_LE_SCAN_DISABLE);
le_set_private_addr(bt_dev.adv_id);
set_le_scan_enable(BT_HCI_LE_SCAN_ENABLE);
}
}
#endif /* defined(CONFIG_BT_OBSERVER) */
return 0;
}