Bluetooth: Fix scan failed to start due to RPA timeout
Updating the Resolvable Private Address when advertising and active scanning in progress fails and clears the RPA_VALID flag; making the next bt_le_scan_start while continuing to advertise to fail. This is fixed by keeping the RPA_VALID flag remain set. Stopping and starting active scanning to update RPA can be implemented in a separate commit. Fixes #9463. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
436c4262da
commit
3353c9f3c8
1 changed files with 15 additions and 2 deletions
|
@ -438,6 +438,8 @@ static int le_set_private_addr(u8_t id)
|
|||
|
||||
static void rpa_timeout(struct k_work *work)
|
||||
{
|
||||
int err_adv = 0, err_scan = 0;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
/* Invalidate RPA */
|
||||
|
@ -450,13 +452,24 @@ static void rpa_timeout(struct k_work *work)
|
|||
if (atomic_test_bit(bt_dev.flags, BT_DEV_ADVERTISING)) {
|
||||
/* make sure new address is used */
|
||||
set_advertise_enable(false);
|
||||
le_set_private_addr(bt_dev.adv_id);
|
||||
err_adv = le_set_private_addr(bt_dev.adv_id);
|
||||
set_advertise_enable(true);
|
||||
}
|
||||
|
||||
if (atomic_test_bit(bt_dev.flags, BT_DEV_ACTIVE_SCAN)) {
|
||||
/* TODO do we need to toggle scan? */
|
||||
le_set_private_addr(BT_ID_DEFAULT);
|
||||
err_scan = le_set_private_addr(BT_ID_DEFAULT);
|
||||
}
|
||||
|
||||
/* If both advertising and scanning is active, le_set_private_addr
|
||||
* will fail. In this case, set back RPA_VALID so that if either of
|
||||
* advertising or scanning was restarted by application then
|
||||
* le_set_private_addr in the public API call path will not retry
|
||||
* set_random_address. This is needed so as to be able to stop and
|
||||
* restart either of the role by the application after rpa_timeout.
|
||||
*/
|
||||
if (err_adv || err_scan) {
|
||||
atomic_set_bit(bt_dev.flags, BT_DEV_RPA_VALID);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue