فهرست منبع

Merge branch 'update/ble_mesh_set_hsl_states_v3.3' into 'release/v3.3'

ble_mesh: stack: Enable updating lighting hsl state (v3.3)

See merge request espressif/esp-idf!16213
liulinyan 4 سال پیش
والد
کامیت
94bbb4185c

+ 6 - 0
components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h

@@ -2154,6 +2154,11 @@ typedef union {
         uint16_t temperature;   /*!< The value of the Light CTL Temperature state */
         int16_t  delta_uv;      /*!< The value of the Light CTL Delta UV state */
     } light_ctl_temp_delta_uv;  /*!< The Light CTL Temperature & Delta UV states */
+    struct {
+        uint16_t lightness;     /*!< The value of the Light HSL Lightness state */
+        uint16_t hue;           /*!< The value of the Light HSL Hue state */
+        uint16_t saturation;    /*!< The value of the Light HSL Saturation state */
+    } light_hsl;                /*!< The Light HSL composite state */
     struct {
         uint16_t lightness;     /*!< The value of the Light HSL Lightness state */
     } light_hsl_lightness;      /*!< The Light HSL Lightness state */
@@ -2181,6 +2186,7 @@ typedef enum {
     ESP_BLE_MESH_LIGHT_LIGHTNESS_LINEAR_STATE,
     ESP_BLE_MESH_LIGHT_CTL_LIGHTNESS_STATE,
     ESP_BLE_MESH_LIGHT_CTL_TEMP_DELTA_UV_STATE,
+    ESP_BLE_MESH_LIGHT_HSL_STATE,
     ESP_BLE_MESH_LIGHT_HSL_LIGHTNESS_STATE,
     ESP_BLE_MESH_LIGHT_HSL_HUE_STATE,
     ESP_BLE_MESH_LIGHT_HSL_SATURATION_STATE,

+ 6 - 0
components/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h

@@ -24,6 +24,7 @@ typedef enum {
     LIGHT_LIGHTNESS_LINEAR_STATE,
     LIGHT_CTL_LIGHTNESS_STATE,
     LIGHT_CTL_TEMP_DELTA_UV_STATE,
+    LIGHT_HSL_STATE,
     LIGHT_HSL_LIGHTNESS_STATE,
     LIGHT_HSL_HUE_STATE,
     LIGHT_HSL_SATURATION_STATE,
@@ -58,6 +59,11 @@ typedef union {
         uint16_t temperature;
         int16_t  delta_uv;
     } light_ctl_temp_delta_uv;
+    struct {
+        uint16_t lightness;
+        uint16_t hue;
+        uint16_t saturation;
+    } light_hsl;
     struct {
         uint16_t lightness;
     } light_hsl_lightness;

+ 19 - 0
components/bt/esp_ble_mesh/mesh_models/server/state_binding.c

@@ -252,6 +252,25 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model,
         light_ctl_publish(model, BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS);
         break;
     }
+    case LIGHT_HSL_STATE: {
+        if (model->id != BLE_MESH_MODEL_ID_LIGHT_HSL_SRV) {
+            BT_ERR("Invalid Light HSL Server, model id 0x%04x", model->id);
+            return -EINVAL;
+        }
+
+        struct bt_mesh_light_hsl_srv *srv = model->user_data;
+        if (srv->state == NULL) {
+            BT_ERR("Invalid Light HSL Server state");
+            return -EINVAL;
+        }
+
+        bt_mesh_server_stop_transition(&srv->transition);
+        srv->state->lightness = value->light_hsl.lightness;
+        srv->state->hue = value->light_hsl.hue;
+        srv->state->saturation = value->light_hsl.saturation;
+        light_hsl_publish(model, BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS);
+        break;
+    }
     case LIGHT_HSL_LIGHTNESS_STATE: {
         if (model->id != BLE_MESH_MODEL_ID_LIGHT_HSL_SRV) {
             BT_ERR("Invalid Light HSL Server, model id 0x%04x", model->id);