Skip to content

Commit 2b05cc3

Browse files
HaavardReirlubos
authored andcommitted
Bluetooth: Mesh: fix NO_ACTIONS scheduling
If the Scheduler Setup Server receives a Scheduler Action Set message setting the next scheduled task to NO_ACTIONS, it will schedule the next task in line. Previously, the "canceled" task would be executed if it was first in line. Signed-off-by: Håvard Reierstad <[email protected]>
1 parent 6e4a44d commit 2b05cc3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

subsys/bluetooth/mesh/scheduler_srv.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ static void run_scheduler(struct bt_mesh_scheduler_srv *srv)
399399
uint8_t planned_idx = get_least_time_index(srv);
400400

401401
if (planned_idx == BT_MESH_SCHEDULER_ACTION_ENTRY_COUNT) {
402+
k_work_cancel_delayable(&srv->delayed_work);
402403
return;
403404
}
404405

@@ -639,6 +640,23 @@ static int action_set(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx
639640
run_scheduler(srv);
640641
}
641642

643+
if ((srv->sch_reg[idx].action == BT_MESH_SCHEDULER_NO_ACTIONS) &&
644+
(srv->active_bitmap & BIT(idx))) {
645+
WRITE_BIT(srv->active_bitmap, idx, 0);
646+
647+
bool reschedule = srv->idx == idx;
648+
649+
if (srv->active_bitmap == 0) {
650+
srv->idx = BT_MESH_SCHEDULER_ACTION_ENTRY_COUNT;
651+
srv->last_idx = BT_MESH_SCHEDULER_ACTION_ENTRY_COUNT;
652+
}
653+
654+
/* If the current action is set to NO_ACTIONS, schedule the next in line, if any */
655+
if (reschedule) {
656+
run_scheduler(srv);
657+
}
658+
}
659+
642660
if (srv->action_set_cb) {
643661
srv->action_set_cb(srv, ctx, idx, &srv->sch_reg[idx]);
644662
}

0 commit comments

Comments
 (0)