Skip to content

Commit f902f2a

Browse files
LingaoMjhedberg
authored andcommitted
Bluetooth: Host: Fix unnecessary random address update
The `bt_le_ext_adv_update_param` will set new random address when option not select `BT_LE_ADV_OPT_USE_IDENTITY`, But `bt_le_ext_adv_start` will also set random address again. This will be affect bluetooth mesh, after this change, will ensure address only change once for every advertising. Signed-off-by: Lingao Meng <[email protected]>
1 parent 433893e commit f902f2a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

subsys/bluetooth/host/adv.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,9 @@ static int le_ext_adv_param_set(struct bt_le_ext_adv *adv,
11761176
atomic_set_bit_to(adv->flags, BT_ADV_EXT_ADV,
11771177
param->options & BT_LE_ADV_OPT_EXT_ADV);
11781178

1179+
atomic_set_bit_to(adv->flags, BT_ADV_RANDOM_ADDR_UPDATED,
1180+
own_addr_type == BT_HCI_OWN_ADDR_RANDOM);
1181+
11791182
return 0;
11801183
}
11811184

@@ -1505,11 +1508,13 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv,
15051508

15061509
if (atomic_test_bit(adv->flags, BT_ADV_CONNECTABLE)) {
15071510
if (IS_ENABLED(CONFIG_BT_PRIVACY) &&
1508-
!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY)) {
1511+
!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY) &&
1512+
!atomic_test_and_clear_bit(adv->flags, BT_ADV_RANDOM_ADDR_UPDATED)) {
15091513
bt_id_set_adv_private_addr(adv);
15101514
}
15111515
} else {
1512-
if (!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY)) {
1516+
if (!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY) &&
1517+
!atomic_test_and_clear_bit(adv->flags, BT_ADV_RANDOM_ADDR_UPDATED)) {
15131518
bt_id_set_adv_private_addr(adv);
15141519
}
15151520
}

subsys/bluetooth/host/hci_core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ enum {
116116
BT_ADV_PARAMS_SET,
117117
/* Advertising data has been set in the controller. */
118118
BT_ADV_DATA_SET,
119+
/* Advertising random address has been updated in the controller before
120+
* enabling advertising.
121+
*/
122+
BT_ADV_RANDOM_ADDR_UPDATED,
119123
/* Advertising random address pending to be set in the controller. */
120124
BT_ADV_RANDOM_ADDR_PENDING,
121125
/* The private random address of the advertiser is valid for this cycle

0 commit comments

Comments
 (0)