diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index ab4f686575..77328eb966 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -1537,10 +1537,10 @@ attribute_t *create_current_position_tilt_percentage(cluster_t *cluster, nullabl esp_matter_nullable_uint8(value)); } -attribute_t *create_operational_status(cluster_t *cluster, nullable value) +attribute_t *create_operational_status(cluster_t *cluster, uint8_t value) { return esp_matter::attribute::create(cluster, WindowCovering::Attributes::OperationalStatus::Id, - ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint8(value)); + ATTRIBUTE_FLAG_NONE, esp_matter_bitmap8(value)); } attribute_t *create_target_position_lift_percent_100ths(cluster_t *cluster, nullable value) @@ -1555,7 +1555,7 @@ attribute_t *create_target_position_tilt_percent_100ths(cluster_t *cluster, null ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); } -attribute_t *create_end_product_type(cluster_t *cluster, uint8_t value) +attribute_t *create_end_product_type(cluster_t *cluster, const uint8_t value) { return esp_matter::attribute::create(cluster, WindowCovering::Attributes::EndProductType::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); @@ -1599,10 +1599,10 @@ attribute_t *create_installed_closed_limit_tilt(cluster_t *cluster, uint16_t val ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint16(value)); } -attribute_t *create_mode(cluster_t *cluster, uint16_t value) +attribute_t *create_mode(cluster_t *cluster, uint8_t value) { - return esp_matter::attribute::create(cluster, WindowCovering::Attributes::Mode::Id, ATTRIBUTE_FLAG_NONVOLATILE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, WindowCovering::Attributes::Mode::Id, ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, + esp_matter_bitmap8(value)); } attribute_t *create_safety_status(cluster_t *cluster, uint16_t value) diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index 3c5b4daa20..192a67286a 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -373,17 +373,17 @@ attribute_t *create_number_of_actuations_tilt(cluster_t *cluster, uint16_t value attribute_t *create_config_status(cluster_t *cluster, uint8_t value); attribute_t *create_current_position_lift_percentage(cluster_t *cluster, nullable value); attribute_t *create_current_position_tilt_percentage(cluster_t *cluster, nullable value); -attribute_t *create_operational_status(cluster_t *cluster, nullable value); +attribute_t *create_operational_status(cluster_t *cluster, uint8_t value); attribute_t *create_target_position_lift_percent_100ths(cluster_t *cluster, nullable value); attribute_t *create_target_position_tilt_percent_100ths(cluster_t *cluster, nullable value); -attribute_t *create_end_product_type(cluster_t *cluster, uint8_t value); +attribute_t *create_end_product_type(cluster_t *cluster, const uint8_t value); attribute_t *create_current_position_lift_percent_100ths(cluster_t *cluster, nullable value); attribute_t *create_current_position_tilt_percent_100ths(cluster_t *cluster, nullable value); attribute_t *create_installed_open_limit_lift(cluster_t *cluster, uint16_t value); attribute_t *create_installed_closed_limit_lift(cluster_t *cluster, uint16_t value); attribute_t *create_installed_open_limit_tilt(cluster_t *cluster, uint16_t value); attribute_t *create_installed_closed_limit_tilt(cluster_t *cluster, uint16_t value); -attribute_t *create_mode(cluster_t *cluster, uint16_t value); +attribute_t *create_mode(cluster_t *cluster, uint8_t value); attribute_t *create_safety_status(cluster_t *cluster, uint16_t value); } /* attribute */ } /* window_covering */ diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index 2b85876a70..a37dc77517 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -1355,7 +1355,7 @@ const function_generic_t function_list[] = { }; const int function_flags = CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION; -cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, WindowCovering::Id, flags); if (!cluster) { @@ -1394,6 +1394,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) command::create_down_or_close(cluster); command::create_stop_motion(cluster); + /* Features */ + if (features & feature::lift::get_id()) { + feature::lift::add(cluster, &(config->lift)); + } + return cluster; } } /* window_covering */ diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index d4d1260764..f159a95baf 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -320,31 +320,15 @@ namespace window_covering { typedef struct config { uint16_t cluster_revision; uint8_t type; - uint16_t physical_closed_limit_lift; - uint16_t physical_closed_limit_tilt; - nullable current_position_lift; - nullable current_position_tilt; - uint16_t number_of_actuations_lift; - uint16_t number_of_actuations_tilt; uint8_t config_status; - nullable current_position_lift_percentage; - nullable current_position_tilt_percentage; - nullable operational_status; - nullable target_position_lift_percent_100ths; - nullable target_position_tilt_percent_100ths; - uint8_t end_product_type; - nullable current_position_lift_percent_100ths; - nullable current_position_tilt_percent_100ths; - uint16_t installed_open_limit_lift; - uint16_t installed_closed_limit_lift; - uint16_t installed_open_limit_tilt; - uint16_t installed_closed_limit_tilt; - uint16_t mode; - uint16_t safety_status; - config() : cluster_revision(5), type(0), operational_status(0), end_product_type(0), mode(0) {} + uint8_t operational_status; + const uint8_t end_product_type; + uint8_t mode; + feature::lift::config_t lift; + config() : cluster_revision(5), type(0), config_status(0), operational_status(0), end_product_type(0), mode(0) {} } config_t; -cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features); } /* window_covering */ namespace switch_cluster { diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index 4044c2b633..000761727b 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -1304,7 +1304,7 @@ esp_err_t store_val_in_nvs(attribute_t *attribute) if (err != ESP_OK) { return err; } - ESP_LOGD(TAG, "strore attribute in nvs: endpoint_id-0x%x, cluster_id-0x%x, attribute_id-0x%x", + ESP_LOGD(TAG, "Store attribute in nvs: endpoint_id-0x%x, cluster_id-0x%x, attribute_id-0x%x", endpoint_id, cluster_id, attribute_id); if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING || current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING || diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index f3de928562..6e7f788e99 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -637,7 +637,7 @@ endpoint_t *add(endpoint_t *endpoint, config_t *config) descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - window_covering::create(endpoint, &(config->window_covering), CLUSTER_FLAG_SERVER); + window_covering::create(endpoint, &(config->window_covering), CLUSTER_FLAG_SERVER, ESP_MATTER_NONE_FEATURE_ID); return endpoint; } diff --git a/components/esp_matter/esp_matter_feature.cpp b/components/esp_matter/esp_matter_feature.cpp index b43c27e46c..e15c87b9c1 100644 --- a/components/esp_matter/esp_matter_feature.cpp +++ b/components/esp_matter/esp_matter_feature.cpp @@ -381,6 +381,12 @@ esp_err_t add(cluster_t *cluster, config_t *config) attribute::create_number_of_actuations_lift(cluster, config->number_of_actuations_lift); + uint8_t set_second_bit = 1 << 2; + esp_matter::attribute_t *attribute = esp_matter::attribute::get(cluster, WindowCovering::Attributes::ConfigStatus::Id); + esp_matter_attr_val_t val = esp_matter_invalid(NULL); + esp_matter::attribute::get_val(attribute, &val); + val.val.u8 = val.val.u8 | set_second_bit; + esp_matter::attribute::set_val(attribute, &val); return ESP_OK; } @@ -430,6 +436,14 @@ esp_err_t add(cluster_t *cluster, config_t *config) attribute::create_current_position_lift_percent_100ths(cluster, config->current_position_lift_percent_100ths); command::create_go_to_lift_percentage(cluster); + + // We should update config_status attribute as position_aware_lift feature is added + uint8_t set_third_bit = 1 << 3; + attribute_t *attribute = esp_matter::attribute::get(cluster, WindowCovering::Attributes::ConfigStatus::Id); + esp_matter_attr_val_t val = esp_matter_invalid(NULL); + esp_matter::attribute::get_val(attribute, &val); + val.val.u8 = val.val.u8 | set_third_bit; + esp_matter::attribute::set_val(attribute, &val); } else { ESP_LOGE(TAG, "Cluster shall support Lift feature"); return ESP_ERR_NOT_SUPPORTED; @@ -524,6 +538,14 @@ esp_err_t add(cluster_t *cluster, config_t *config) attribute::create_current_position_tilt_percent_100ths(cluster, config->current_position_tilt_percent_100ths); command::create_go_to_tilt_percentage(cluster); + + // We should update config_status attribute as position_aware_tilt feature is added + uint8_t set_fourth_bit = 1 << 4; + attribute_t *attribute = esp_matter::attribute::get(cluster, WindowCovering::Attributes::ConfigStatus::Id); + esp_matter_attr_val_t val = esp_matter_invalid(NULL); + esp_matter::attribute::get_val(attribute, &val); + val.val.u8 = val.val.u8 | set_fourth_bit; + esp_matter::attribute::set_val(attribute, &val); } else { ESP_LOGE(TAG, "Cluster shall support Tilt feature"); return ESP_ERR_NOT_SUPPORTED; diff --git a/components/esp_matter/esp_matter_feature.h b/components/esp_matter/esp_matter_feature.h index c0d0564f69..829d208d93 100644 --- a/components/esp_matter/esp_matter_feature.h +++ b/components/esp_matter/esp_matter_feature.h @@ -195,9 +195,9 @@ esp_err_t add(cluster_t *cluster, config_t *config); namespace position_aware_lift { typedef struct config { - uint16_t current_position_lift_percentage; - uint16_t target_position_lift_percent_100ths; - uint16_t current_position_lift_percent_100ths; + nullable current_position_lift_percentage; + nullable target_position_lift_percent_100ths; + nullable current_position_lift_percent_100ths; config() : current_position_lift_percentage(), target_position_lift_percent_100ths(), current_position_lift_percent_100ths() {} } config_t; @@ -210,14 +210,14 @@ namespace absolute_position { typedef struct config { uint16_t physical_closed_limit_lift; - uint16_t current_position_lift; + nullable current_position_lift; uint16_t installed_open_limit_lift; uint16_t installed_closed_limit_lift; uint16_t physical_closed_limit_tilt; - uint16_t current_position_tilt; + nullable current_position_tilt; uint16_t installed_open_limit_tilt; uint16_t installed_closed_limit_tilt; - config() : physical_closed_limit_lift(0), current_position_lift(0), installed_open_limit_lift(0), installed_closed_limit_lift(65534), physical_closed_limit_tilt(0), current_position_tilt(0), installed_open_limit_tilt(0), installed_closed_limit_tilt(65534) {} + config() : physical_closed_limit_lift(0), current_position_lift(), installed_open_limit_lift(0), installed_closed_limit_lift(65534), physical_closed_limit_tilt(0), current_position_tilt(), installed_open_limit_tilt(0), installed_closed_limit_tilt(65534) {} } config_t; uint32_t get_id(); @@ -228,9 +228,9 @@ esp_err_t add(cluster_t *cluster, config_t *config); namespace position_aware_tilt { typedef struct config { - uint16_t current_position_tilt_percentage; - uint16_t target_position_tilt_percent_100ths; - uint16_t current_position_tilt_percent_100ths; + nullable current_position_tilt_percentage; + nullable target_position_tilt_percent_100ths; + nullable current_position_tilt_percent_100ths; config() : current_position_tilt_percentage(), target_position_tilt_percent_100ths(), current_position_tilt_percent_100ths() {} } config_t;