components/esp-matter: fix the inconsistency between feature flag and

added features

After restructuring we were only adding features that are marked with
O.a or O.a+ conformance. But, it leads to the inconsistency where user
speicied features will not be added.

For clusters which has O.a or O.a+ feature conformance, linking all the
supported features in cluster create to address the incosistency.

Also, moved the feature create in the server part.
This commit is contained in:
Shubham Patil
2025-08-22 10:40:12 +05:30
parent 1f417192d9
commit a40259cd96
3 changed files with 487 additions and 402 deletions
File diff suppressed because it is too large Load Diff
@@ -225,6 +225,8 @@ typedef struct config {
struct {
feature::wired::config_t wired;
feature::battery::config_t battery;
feature::rechargeable::config_t rechargeable;
feature::replaceable::config_t replaceable;
} features;
uint32_t feature_flags;
config() : status(0), order(0), description{0}, feature_flags(0) {}
@@ -329,6 +331,10 @@ typedef struct config {
feature::heating::config_t heating;
feature::cooling::config_t cooling;
feature::auto_mode::config_t auto_mode;
feature::occupancy::config_t occupancy;
feature::setback::config_t setback;
feature::local_temperature_not_exposed::config_t local_temperature_not_exposed;
feature::matter_schedule_configuration::config_t matter_schedule_configuration;
} features;
uint32_t feature_flags;
config() : local_temperature(), control_sequence_of_operation(4), system_mode(1), delegate(nullptr), feature_flags(0) {}
@@ -377,6 +383,8 @@ typedef struct config {
struct {
feature::numeric_measurement::config_t numeric_measurement;
feature::level_indication::config_t level_indication;
feature::peak_measurement::config_t peak_measurement;
feature::average_measurement::config_t average_measurement;
} features;
uint32_t feature_flags;
void *delegate;
@@ -529,6 +537,9 @@ typedef struct config {
struct {
feature::lift::config_t lift;
feature::tilt::config_t tilt;
feature::position_aware_lift::config_t position_aware_lift;
feature::absolute_position::config_t absolute_position;
feature::position_aware_tilt::config_t position_aware_tilt;
} features;
uint32_t feature_flags;
void *delegate;
@@ -542,6 +553,9 @@ namespace switch_cluster {
typedef struct config {
uint8_t number_of_positions;
uint8_t current_position;
struct {
feature::momentary_switch_multi_press::config_t momentary_switch_multi_press;
} features;
uint32_t feature_flags;
config() : number_of_positions(2), current_position(0), feature_flags(0) {}
} config_t;
@@ -701,6 +715,7 @@ typedef struct config {
struct {
feature::temperature_number::config_t temperature_number;
feature::temperature_level::config_t temperature_level;
feature::temperature_step::config_t temperature_step;
} features;
uint32_t feature_flags;
config() : feature_flags(0) {}
@@ -1233,8 +1233,10 @@ uint32_t get_id()
esp_err_t add(cluster_t *cluster)
{
VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Cluster cannot be NULL"));
update_feature_map(cluster, get_id());
bool has_level_indication = get_feature_map_value(cluster) & feature::level_indication::get_id();
VerifyOrReturnError(has_level_indication, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Level indication feature is not supported."));
update_feature_map(cluster, get_id());
return ESP_OK;
}
@@ -1251,8 +1253,10 @@ uint32_t get_id()
esp_err_t add(cluster_t *cluster)
{
VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Cluster cannot be NULL"));
update_feature_map(cluster, get_id());
bool has_level_indication = get_feature_map_value(cluster) & feature::level_indication::get_id();
VerifyOrReturnError(has_level_indication, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Level indication feature is not supported."));
update_feature_map(cluster, get_id());
return ESP_OK;
}
@@ -1268,6 +1272,10 @@ uint32_t get_id()
esp_err_t add(cluster_t *cluster, config_t *config)
{
VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Cluster cannot be NULL"));
bool has_numeric_measurement = get_feature_map_value(cluster) & feature::numeric_measurement::get_id();
VerifyOrReturnError(has_numeric_measurement, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Numeric measurement feature is not supported."));
update_feature_map(cluster, get_id());
attribute::create_peak_measured_value(cluster, config->peak_measured_value);
@@ -1288,6 +1296,9 @@ uint32_t get_id()
esp_err_t add(cluster_t *cluster, config_t *config)
{
VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Cluster cannot be NULL"));
bool has_numeric_measurement = get_feature_map_value(cluster) & feature::numeric_measurement::get_id();
VerifyOrReturnError(has_numeric_measurement, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Numeric measurement feature is not supported."));
update_feature_map(cluster, get_id());
attribute::create_average_measured_value(cluster, config->average_measured_value);