Commit 4835c0f2 authored by Vikrant More's avatar Vikrant More Committed by Johan Hedberg
Browse files

samples: mesh: removed bugs in on-off transition



If Node Lightness is in downward transition & received Generic
onoff message to set state equal to 1 then Node transaction get
stopped in between. Ideally it should reach to default lightness
value if it is non-zero. This commit has solved this bug.

Signed-off-by: default avatarVikrant More <vikrant8051@gmail.com>
parent 24304436
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -212,10 +212,15 @@ static void gen_onoff_set_unack(struct bt_mesh_model *model,

	if (state->target_onoff != state->onoff) {
		onoff_tt_values(state);
	} else {
		if (lightness != light_lightness_srv_user_data.def &&
		    state->onoff == STATE_ON) {
			onoff_tt_values(state);
		} else {
			gen_onoff_publish(model);
			return;
		}
	}

	/* For Instantaneous Transition */
	if (state->transition->counter == 0U) {
@@ -281,11 +286,16 @@ static void gen_onoff_set(struct bt_mesh_model *model,

	if (state->target_onoff != state->onoff) {
		onoff_tt_values(state);
	} else {
		if (lightness != light_lightness_srv_user_data.def &&
		    state->onoff == STATE_ON) {
			onoff_tt_values(state);
		} else {
			gen_onoff_get(model, ctx, buf);
			gen_onoff_publish(model);
			return;
		}
	}

	/* For Instantaneous Transition */
	if (state->transition->counter == 0U) {
@@ -2149,6 +2159,8 @@ static bool light_ctl_default_setunack(struct bt_mesh_model *model,
		state->temp_def = temp;
		state->delta_uv_def = delta_uv;

		light_lightness_srv_user_data.def = lightness;

		save_on_flash(LIGHTNESS_TEMP_DEF_STATE);
	}