From 9f6dd19033f1a744baf855f583cde0959adf6e19 Mon Sep 17 00:00:00 2001 From: lly Date: Sat, 4 Jan 2020 14:57:08 +0800 Subject: [PATCH] ble_mesh: Update lightness last state when actual state is changed --- .../bt/esp_ble_mesh/mesh_models/server/state_binding.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c b/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c index f45216a18..d13623232 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c @@ -192,6 +192,15 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, bt_mesh_server_stop_transition(&srv->actual_transition); srv->state->lightness_actual = value->light_lightness_actual.lightness; + /** + * Whenever the Light Lightness Actual state is changed with a non-transactional + * message or a completed sequence of transactional messages to a non-zero value, + * the value of the Light Lightness Last shall be set to the value of the Light + * Lightness Actual. + */ + if (srv->state->lightness_actual) { + srv->state->lightness_last = srv->state->lightness_actual; + } light_lightness_publish(model, BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS); break; }