diff --git a/components/esp_matter/CMakeLists.txt b/components/esp_matter/CMakeLists.txt index 46bbe12e6..cebc19452 100644 --- a/components/esp_matter/CMakeLists.txt +++ b/components/esp_matter/CMakeLists.txt @@ -23,6 +23,7 @@ set(SRC_DIRS_LIST "." "${MATTER_SDK_PATH}/src/app/clusters/diagnostic-logs-server" "${MATTER_SDK_PATH}/src/app/clusters/door-lock-server" "${MATTER_SDK_PATH}/src/app/clusters/ethernet-network-diagnostics-server" + "${MATTER_SDK_PATH}/src/app/clusters/fan-control-server" "${MATTER_SDK_PATH}/src/app/clusters/fixed-label-server" "${MATTER_SDK_PATH}/src/app/clusters/general-commissioning-server" "${MATTER_SDK_PATH}/src/app/clusters/general-diagnostics-server" diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index 646529377..e3410fb88 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -1198,10 +1198,17 @@ attribute_t *create_primary_n_intensity(cluster_t *cluster, nullable va namespace fan_control { namespace attribute { -attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value) +attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { - return esp_matter::attribute::create(cluster, FanControl::Attributes::FanMode::Id, - ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value)); + attribute_t *attribute = + esp_matter::attribute::create(cluster, FanControl::Attributes::FanMode::Id, + ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value)); + if (!attribute) { + ESP_LOGE(TAG, "Could not create attribute"); + return NULL; + } + esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); + return attribute; } attribute_t *create_fan_mode_sequence(cluster_t *cluster, uint8_t value) diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index 567e033d9..69dfb18ec 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -309,7 +309,7 @@ attribute_t *create_primary_n_intensity(cluster_t * cluster, nullable v namespace fan_control { namespace attribute { -attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value); +attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max); attribute_t *create_fan_mode_sequence(cluster_t *cluster, uint8_t value); attribute_t *create_percent_setting(cluster_t *cluster, nullable value); attribute_t *create_percent_current(cluster_t *cluster, uint8_t value); diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index e7106ce6c..f1c625ade 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -1214,9 +1214,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ } /* color_control */ namespace fan_control { -const function_generic_t *function_list = NULL; -const int function_flags = CLUSTER_FLAG_NONE; - +const function_generic_t function_list[] = { + (function_generic_t)MatterFanControlClusterServerAttributeChangedCallback, + (function_generic_t)MatterFanControlClusterServerPreAttributeChangedCallback, +}; +const int function_flags = CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; + cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, FanControl::Id, flags); @@ -1226,8 +1229,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } if (flags & CLUSTER_FLAG_SERVER) { - /* not implemented: Setting NULL since the MatterFanControlPluginServerInitCallback is not implemented */ - set_plugin_server_init_callback(cluster, NULL); + set_plugin_server_init_callback(cluster, MatterFanControlPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } if (flags & CLUSTER_FLAG_CLIENT) { @@ -1243,7 +1245,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Attributes not managed internally */ if (config) { global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_fan_mode(cluster, config->fan_mode); + attribute::create_fan_mode(cluster, config->fan_mode, 0, 6); attribute::create_fan_mode_sequence(cluster, config->fan_mode_sequence); attribute::create_percent_setting(cluster, config->percent_setting); attribute::create_percent_current(cluster, config->percent_current);