Skip to content

Commit

Permalink
Removed un-used code of window covering cluster and sync with spec
Browse files Browse the repository at this point in the history
Addressed review comments
  • Loading branch information
jadhavrohit924 committed Mar 15, 2023
1 parent d886f9c commit 3484600
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 43 deletions.
12 changes: 6 additions & 6 deletions components/esp_matter/esp_matter_attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> 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<uint16_t> value)
Expand All @@ -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));
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions components/esp_matter/esp_matter_attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> value);
attribute_t *create_current_position_tilt_percentage(cluster_t *cluster, nullable<uint8_t> value);
attribute_t *create_operational_status(cluster_t *cluster, nullable<uint8_t> value);
attribute_t *create_operational_status(cluster_t *cluster, uint8_t value);
attribute_t *create_target_position_lift_percent_100ths(cluster_t *cluster, nullable<uint16_t> value);
attribute_t *create_target_position_tilt_percent_100ths(cluster_t *cluster, nullable<uint16_t> 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<uint16_t> value);
attribute_t *create_current_position_tilt_percent_100ths(cluster_t *cluster, nullable<uint16_t> 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 */
Expand Down
7 changes: 6 additions & 1 deletion components/esp_matter/esp_matter_cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 */
Expand Down
28 changes: 6 additions & 22 deletions components/esp_matter/esp_matter_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t> current_position_lift;
nullable<uint16_t> current_position_tilt;
uint16_t number_of_actuations_lift;
uint16_t number_of_actuations_tilt;
uint8_t config_status;
nullable<uint8_t> current_position_lift_percentage;
nullable<uint8_t> current_position_tilt_percentage;
nullable<uint8_t> operational_status;
nullable<uint16_t> target_position_lift_percent_100ths;
nullable<uint16_t> target_position_tilt_percent_100ths;
uint8_t end_product_type;
nullable<uint16_t> current_position_lift_percent_100ths;
nullable<uint16_t> 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 {
Expand Down
2 changes: 1 addition & 1 deletion components/esp_matter/esp_matter_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
2 changes: 1 addition & 1 deletion components/esp_matter/esp_matter_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 22 additions & 0 deletions components/esp_matter/esp_matter_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions components/esp_matter/esp_matter_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> current_position_lift_percentage;
nullable<uint16_t> target_position_lift_percent_100ths;
nullable<uint16_t> current_position_lift_percent_100ths;
config() : current_position_lift_percentage(), target_position_lift_percent_100ths(), current_position_lift_percent_100ths() {}
} config_t;

Expand All @@ -210,14 +210,14 @@ namespace absolute_position {

typedef struct config {
uint16_t physical_closed_limit_lift;
uint16_t current_position_lift;
nullable<uint16_t> 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<uint16_t> 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();
Expand All @@ -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<uint8_t> current_position_tilt_percentage;
nullable<uint16_t> target_position_tilt_percent_100ths;
nullable<uint16_t> current_position_tilt_percent_100ths;
config() : current_position_tilt_percentage(), target_position_tilt_percent_100ths(), current_position_tilt_percent_100ths() {}
} config_t;

Expand Down

0 comments on commit 3484600

Please sign in to comment.