Skip to content

Commit 260beb6

Browse files
committed
Bluetooth: Mesh: Immediately complete scene transitions to current scene
When receiving a scene set message where the target scene matches the current scene, the transition should just complete immediately. Signed-off-by: Trond Einar Snekvik <[email protected]>
1 parent 19793ee commit 260beb6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

subsys/bluetooth/mesh/scene_srv.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ int bt_mesh_scene_srv_set(struct bt_mesh_scene_srv *srv, uint16_t scene,
868868
struct bt_mesh_model_transition *transition)
869869
{
870870
int32_t transition_time;
871+
uint16_t curr;
871872
char path[25];
872873
int err;
873874

@@ -881,10 +882,21 @@ int bt_mesh_scene_srv_set(struct bt_mesh_scene_srv *srv, uint16_t scene,
881882
return -ENOENT;
882883
}
883884

885+
curr = current_scene(srv);
886+
if (scene == curr) {
887+
srv->prev = scene;
888+
srv->next = BT_MESH_SCENE_NONE;
889+
srv->transition.time = 0;
890+
srv->transition.delay = 0;
891+
/* We're checking srv->next in the handler, so failure to cancel is okay: */
892+
(void)k_work_cancel_delayable(&srv->work);
893+
return 0;
894+
}
895+
884896
transition_time = bt_mesh_model_transition_time(transition);
885897
if (transition_time) {
886898
srv->transition = *transition;
887-
srv->prev = current_scene(srv);
899+
srv->prev = curr;
888900
srv->next = scene;
889901
k_work_reschedule(&srv->work, K_MSEC(transition_time));
890902
} else {

0 commit comments

Comments
 (0)