Skip to content

Commit 6a11c51

Browse files
committed
[nrf fromtree] bluetooth: mesh: adv_ext: Fix scheduling with multiple relay adv sets
When multiple relay adv sets are used, the bt_mesh_adv_send function calls bt_mesh_adv_relay_ready which should distribute relayed advertisements across all relay adv sets. Until the submitted relay adv set work is started, the ADV_FLAG_ACTIVE is not set. Therefore, next call to bt_mesh_adv_send will try to re-submit the same relay adv set work, instead of picking up another relay set which is actually free and ready to send an advertisement. This commit adds a check that checks if the adv set work is already pending to be executed. And if so, schedule_send returns false to make bt_mesh_adv_relay_ready pick next relay adv set. This shouldn't brake advertising because once adv set is done transmitting advertisment, it will pick up a next one. The ADV_FLAG_PROXY check is added to do re-submit for adv set which was used for proxy advertisement since we need to prioritize mesh messages over proxy advertisements when those are running on the same adv set. Signed-off-by: Pavel Vasilyev <[email protected]> (cherry picked from commit 1a4f113) Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent 14a9413 commit 6a11c51

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

subsys/bluetooth/mesh/adv_ext.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ static bool schedule_send(struct bt_mesh_ext_adv *ext_adv)
416416
if (!atomic_test_bit(ext_adv->flags, ADV_FLAG_PROXY)) {
417417
return false;
418418
}
419+
} else if (k_work_is_pending(&ext_adv->work) &&
420+
!atomic_test_bit(ext_adv->flags, ADV_FLAG_PROXY)) {
421+
/* This can happen if we try to schedule a send while a previous send is still
422+
* pending in the work queue. There is nothing wrong with resubmitting the same
423+
* work to the work queue, but in this case won't have a change to try a work from
424+
* another advertising set which can be ready for sending.
425+
*
426+
* If, however, ADV_FLAG_PROXY is set, we want to stop the proxy advertising.
427+
*/
428+
return false;
419429
}
420430

421431
bt_mesh_wq_submit(&ext_adv->work);

0 commit comments

Comments
 (0)