Skip to content

Commit

Permalink
Bluetoth: Mesh: Fixing Light LC SM conditions
Browse files Browse the repository at this point in the history
According to sections 6.2.3.5 of MshMDLd1.1r12, the value of the
Light LC Ambient LuxLevel state is set to 0 at power-up and when
the node is provisioned on the network.
According to sections 6.2.5.12 and 6.2.5.7 the Occupancy On should
not trigger any transition.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
  • Loading branch information
Balaklaka committed Aug 23, 2023
1 parent 850c7a7 commit d598a55
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
13 changes: 10 additions & 3 deletions include/bluetooth/mesh/light_ctrl_srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,18 @@ struct bt_mesh_light_ctrl_srv;

/** Light Lightness Control Server state */
enum bt_mesh_light_ctrl_srv_state {
/** Standby state */
/** Standby state, merges the Light LC State Machine states of OFF,
* STANDBY, FADE_STANDBY_AUTO and FADE_STANDBY_MANUAL in the Mesh Model
* Specification section 6.2.5.
*/
LIGHT_CTRL_STATE_STANDBY,
/** On state */
/** On state, merges the Light LC State Machine states of FADE_ON and
* RUN in the Mesh Model Specification section 6.2.5.
*/
LIGHT_CTRL_STATE_ON,
/** Prolong state */
/** Prolong state, merges the Light LC State Machine states of FADE and
* PROLONG in the Mesh Model Specification section 6.2.5.
*/
LIGHT_CTRL_STATE_PROLONG,

/** The number of states. */
Expand Down
30 changes: 23 additions & 7 deletions subsys/bluetooth/mesh/light_ctrl_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,13 +999,29 @@ static int handle_sensor_status(struct bt_mesh_model *model, struct bt_mesh_msg_

/* Occupancy sensor */

/* OCC_MODE must be enabled for the occupancy sensors to be
* able to turn on the light:
*/
if (srv->state == LIGHT_CTRL_STATE_STANDBY &&
!atomic_test_bit(&srv->flags, FLAG_OCC_MODE) &&
!(atomic_test_bit(&srv->flags, FLAG_TRANSITION) &&
!atomic_test_bit(&srv->flags, FLAG_MANUAL))) {
if ((srv->state == LIGHT_CTRL_STATE_STANDBY &&
/* According to the Mesh Model Specification section
* 6.2.5.6: When in the specifications STANDBY state,
* and the Auto Occupancy condition is false, the
* Occupancy On event should not be processed.
*/
((!atomic_test_bit(&srv->flags, FLAG_OCC_MODE) &&
!atomic_test_bit(&srv->flags, FLAG_TRANSITION) &&
!atomic_test_bit(&srv->flags, FLAG_MANUAL))
||
/* According to the Mesh Model Specification section
* 6.2.5.12: When in the specifications FADE STANDBY
* MANUAL state, the Occupancy On event should not be
* processed.
*/
(atomic_test_bit(&srv->flags, FLAG_TRANSITION) &&
atomic_test_bit(&srv->flags, FLAG_MANUAL)))) ||
/* According to the Mesh Model Specification section
* 6.2.5.7: When in the specifications FADE ON state, the
* Occupancy On event should not be processed.
*/
(srv->state == LIGHT_CTRL_STATE_ON &&
atomic_test_bit(&srv->flags, FLAG_TRANSITION))) {
continue;
}

Expand Down

0 comments on commit d598a55

Please sign in to comment.