Bluetooth: Mesh: Rework publication timer
Periodic publication would previously build and send the first publication inside the bt_mesh_model_pub() function, before cancelling and rescheduling the next publication. The timer handler would only handle retransmissions, and would abandon the rest of the publication event if one of the packets failed to send. This design has three issues: - If the initial timer cancel fails, the publication would interfer with the periodic publication management, which might skip an event or send too many packets. - If any of the messages fail to publish, the full publication event would be abandoned. This is not predictable or expected from the API. - bt_mesh_model_pub() required 384 bytes of stack to build the message, which has to be factored into all calling threads. This patch moves all transmission into the publication timer by replacing k_work_cancel with a single k_work_reschedule(K_NO_WAIT). It also changes the error recovery behavior to attempt to finish the full publication event even if some of the transmissions fail. Split out from #33782. Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
parent
fe3fcede10
commit
820cfc52ad
4 changed files with 100 additions and 121 deletions
|
@ -201,7 +201,10 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
|
|||
model->pub->count = 0U;
|
||||
|
||||
if (model->pub->update) {
|
||||
k_delayed_work_cancel(&model->pub->timer);
|
||||
/* If this fails, the timer will check pub->addr and
|
||||
* exit without transmitting.
|
||||
*/
|
||||
(void)k_work_cancel_delayable(&model->pub->timer);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_SETTINGS) && store) {
|
||||
|
@ -239,10 +242,13 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
|
|||
BT_DBG("period %u ms", period_ms);
|
||||
|
||||
if (period_ms > 0) {
|
||||
k_delayed_work_submit(&model->pub->timer,
|
||||
K_MSEC(period_ms));
|
||||
k_work_reschedule(&model->pub->timer,
|
||||
K_MSEC(period_ms));
|
||||
} else {
|
||||
k_delayed_work_cancel(&model->pub->timer);
|
||||
/* If this fails, publication will stop after the
|
||||
* ongoing set of retransmits.
|
||||
*/
|
||||
(void)k_work_cancel_delayable(&model->pub->timer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue