mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Added attributes/commands for features of window covering
This commit is contained in:
@@ -54,6 +54,15 @@ static esp_err_t update_feature_map(cluster_t *cluster, uint32_t value)
|
||||
return attribute::set_val(attribute, &val);
|
||||
}
|
||||
|
||||
static uint32_t get_feature_map_value(cluster_t *cluster)
|
||||
{
|
||||
attribute_t *attribute = attribute::get(cluster, Globals::Attributes::FeatureMap::Id);
|
||||
|
||||
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
||||
attribute::get_val(attribute, &val);
|
||||
return val.val.u32;
|
||||
}
|
||||
|
||||
namespace on_off {
|
||||
namespace feature {
|
||||
namespace lighting {
|
||||
@@ -332,7 +341,7 @@ uint32_t get_id()
|
||||
return (uint32_t)WindowCovering::Feature::kLift;
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster)
|
||||
esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
{
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Cluster cannot be NULL");
|
||||
@@ -340,6 +349,8 @@ esp_err_t add(cluster_t *cluster)
|
||||
}
|
||||
update_feature_map(cluster, get_id());
|
||||
|
||||
attribute::create_number_of_actuations_lift(cluster, config->number_of_actuations_lift);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -352,7 +363,7 @@ uint32_t get_id()
|
||||
return (uint32_t)WindowCovering::Feature::kTilt;
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster)
|
||||
esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
{
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Cluster cannot be NULL");
|
||||
@@ -360,6 +371,8 @@ esp_err_t add(cluster_t *cluster)
|
||||
}
|
||||
update_feature_map(cluster, get_id());
|
||||
|
||||
attribute::create_number_of_actuations_tilt(cluster, config->number_of_actuations_tilt);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -372,14 +385,25 @@ uint32_t get_id()
|
||||
return (uint32_t)WindowCovering::Feature::kPositionAwareLift;
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster)
|
||||
esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
{
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Cluster cannot be NULL");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
update_feature_map(cluster, get_id());
|
||||
uint32_t pa_lt_and_lift_feature_map = get_id() | feature::lift::get_id();
|
||||
if((get_feature_map_value(cluster) & pa_lt_and_lift_feature_map) == pa_lt_and_lift_feature_map)
|
||||
{
|
||||
attribute::create_current_position_lift_percentage(cluster, config->current_position_lift_percentage);
|
||||
attribute::create_target_position_lift_percent_100ths(cluster, config->target_position_lift_percent_100ths);
|
||||
attribute::create_current_position_lift_percent_100ths(cluster, config->current_position_lift_percent_100ths);
|
||||
|
||||
command::create_go_to_lift_percentage(cluster);
|
||||
}else{
|
||||
ESP_LOGE(TAG, "Cluster shall support Lift feature");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
} /* position_aware_lift */
|
||||
@@ -391,14 +415,50 @@ uint32_t get_id()
|
||||
return (uint32_t)WindowCovering::Feature::kAbsolutePosition;
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster)
|
||||
esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
{
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Cluster cannot be NULL");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
update_feature_map(cluster, get_id());
|
||||
uint32_t abs_and_pa_lf_feature_map = get_id() | feature::position_aware_lift::get_id();
|
||||
uint32_t abs_and_pa_tl_feature_map = get_id() | feature::position_aware_tilt::get_id();
|
||||
uint32_t abs_and_lift_feature_map = get_id() | feature::lift::get_id();
|
||||
uint32_t abs_and_tilt_feature_map = get_id() | feature::tilt::get_id();
|
||||
if((get_feature_map_value(cluster) & abs_and_pa_lf_feature_map) == abs_and_pa_lf_feature_map)
|
||||
{
|
||||
attribute::create_physical_closed_limit_lift(cluster, config->physical_closed_limit_lift);
|
||||
attribute::create_current_position_lift(cluster, config->current_position_lift);
|
||||
attribute::create_installed_open_limit_lift(cluster, config->installed_open_limit_lift);
|
||||
attribute::create_installed_closed_limit_lift(cluster, config->installed_open_limit_lift);
|
||||
|
||||
}else{
|
||||
ESP_LOGE(TAG, "Cluster shall support Position_Aware_Lift feature");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if((get_feature_map_value(cluster) & abs_and_pa_tl_feature_map) == abs_and_pa_tl_feature_map)
|
||||
{
|
||||
attribute::create_physical_closed_limit_tilt(cluster, config->physical_closed_limit_tilt);
|
||||
attribute::create_current_position_tilt(cluster, config->current_position_tilt);
|
||||
attribute::create_installed_open_limit_tilt(cluster, config->installed_open_limit_tilt);
|
||||
attribute::create_installed_closed_limit_tilt(cluster, config->installed_open_limit_tilt);
|
||||
|
||||
}else{
|
||||
ESP_LOGE(TAG, "Cluster shall support Position_Aware_Tilt feature");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if((get_feature_map_value(cluster) & abs_and_lift_feature_map) == abs_and_lift_feature_map)
|
||||
{
|
||||
command::create_go_to_lift_value(cluster);
|
||||
}
|
||||
|
||||
if((get_feature_map_value(cluster) & abs_and_tilt_feature_map) == abs_and_tilt_feature_map)
|
||||
{
|
||||
command::create_go_to_tilt_value(cluster);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -411,7 +471,7 @@ uint32_t get_id()
|
||||
return (uint32_t)WindowCovering::Feature::kPositionAwareTilt;
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster)
|
||||
esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
{
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Cluster cannot be NULL");
|
||||
@@ -419,6 +479,18 @@ esp_err_t add(cluster_t *cluster)
|
||||
}
|
||||
update_feature_map(cluster, get_id());
|
||||
|
||||
uint32_t pa_lt_and_tilt_feature_map = get_id() | feature::tilt::get_id();
|
||||
if((get_feature_map_value(cluster) & pa_lt_and_tilt_feature_map) == pa_lt_and_tilt_feature_map)
|
||||
{
|
||||
attribute::create_current_position_tilt_percentage(cluster, config->current_position_tilt_percentage);
|
||||
attribute::create_target_position_tilt_percent_100ths(cluster, config->target_position_tilt_percent_100ths);
|
||||
attribute::create_current_position_tilt_percent_100ths(cluster, config->current_position_tilt_percent_100ths);
|
||||
|
||||
command::create_go_to_tilt_percentage(cluster);
|
||||
}else{
|
||||
ESP_LOGE(TAG, "Cluster shall support Tilt feature");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -170,36 +170,72 @@ namespace window_covering {
|
||||
namespace feature {
|
||||
namespace lift {
|
||||
|
||||
typedef struct config {
|
||||
uint16_t number_of_actuations_lift;
|
||||
config() : number_of_actuations_lift(0) {}
|
||||
} config_t;
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* lift */
|
||||
|
||||
namespace tilt {
|
||||
|
||||
typedef struct config {
|
||||
uint16_t number_of_actuations_tilt;
|
||||
config() : number_of_actuations_tilt(0) {}
|
||||
} config_t;
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* tilt */
|
||||
|
||||
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;
|
||||
config() : current_position_lift_percentage(), target_position_lift_percent_100ths(), current_position_lift_percent_100ths() {}
|
||||
} config_t;
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* position_aware_lift */
|
||||
|
||||
namespace absolute_position {
|
||||
|
||||
typedef struct config {
|
||||
uint16_t physical_closed_limit_lift;
|
||||
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;
|
||||
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_t;
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* absolute_position */
|
||||
|
||||
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;
|
||||
config() : current_position_tilt_percentage(), target_position_tilt_percent_100ths(), current_position_tilt_percent_100ths() {}
|
||||
} config_t;
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* position_aware_tilt */
|
||||
} /* feature */
|
||||
|
||||
Reference in New Issue
Block a user