From 807abe17a4d61f32aba51154a71875ddd79f501d Mon Sep 17 00:00:00 2001 From: Rohit Date: Wed, 14 May 2025 17:17:18 +0530 Subject: [PATCH] components/esp-matter: Move feature creation from cluster to endpoint. --- RELEASE_NOTES.md | 5 +- components/esp_matter/esp_matter_cluster.cpp | 832 +++++------------- components/esp_matter/esp_matter_cluster.h | 217 +---- components/esp_matter/esp_matter_core.cpp | 2 +- components/esp_matter/esp_matter_core.h | 12 + components/esp_matter/esp_matter_endpoint.cpp | 173 ++-- components/esp_matter/esp_matter_endpoint.h | 24 +- components/esp_matter/esp_matter_feature.h | 21 - docs/en/developing.rst | 27 +- .../main/esp_matter_console_helpers.cpp | 22 +- .../esp-now_bridge_light/main/app_main.cpp | 10 +- examples/demo/badge/main/app_main.cpp | 3 +- examples/generic_switch/main/app_main.cpp | 14 +- examples/light/main/app_main.cpp | 10 +- examples/light_network_prov/main/app_main.cpp | 10 +- .../managed_component_light/main/app_main.cpp | 4 +- examples/refrigerator/main/app_main.cpp | 6 - .../thread_border_router/main/app_main.cpp | 3 +- 18 files changed, 437 insertions(+), 958 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d85fe3d14..e3207f856 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,4 @@ -# 13-May-2025 +# 10-June-2025 API Change. Removed the `features` parameter from the `cluster::create()` API to make it consistent across all clusters. @@ -6,6 +6,9 @@ The new API signature is: ``` cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); ``` +For clusters with `O.a/O.a+` features conformance, the `feature_flags` is available at cluster level. +For device types with `M` feature conformance of a cluster, the feature config is available at device type level. +For clusters with `O` feature conformance, feature should be added using `feature_name::add()` API in the application. # 3-Feb-2024 diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index f84b01197..40bafcbec 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include #include #include @@ -140,11 +141,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) global::attribute::create_cluster_revision(cluster, cluster_revision); } - /* Features */ - if (config && config->feature_flags & feature::taglist::get_id()) { - feature::taglist::add(cluster); - } - return cluster; } } /* descriptor */ @@ -207,16 +203,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) event::create_access_control_entry_changed(cluster); - /* Features */ - if (config) { - if (config->feature_flags & feature::extension::get_id()) { - feature::extension::add(cluster); - } - if (config->feature_flags & feature::managed_device::get_id()) { - feature::managed_device::add(cluster); - } - } - return cluster; } } /* access_control */ @@ -402,11 +388,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } - /* Features */ - if (config && config->feature_flags & feature::terms_and_conditions::get_id()) { - feature::terms_and_conditions::add(cluster, &(config->features.terms_and_conditions)); - } - return cluster; } } /* general_commissioning */ @@ -445,7 +426,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_supported_thread_features(cluster, 0); attribute::create_thread_version(cluster, 0); } - global::attribute::create_feature_map(cluster, 0); + global::attribute::create_feature_map(cluster, config->feature_map); /* Attributes not managed internally */ global::attribute::create_cluster_revision(cluster, cluster_revision); @@ -519,11 +500,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) global::attribute::create_cluster_revision(cluster, cluster_revision); } - /* Features */ - if (config && config->feature_flags & feature::basic::get_id()) { - feature::basic::add(cluster); - } - return cluster; } } /* administrator_commissioning */ @@ -615,16 +591,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) global::attribute::create_cluster_revision(cluster, cluster_revision); } - /* Features */ - if (config) { - if (config->feature_flags & feature::packet_counts::get_id()) { - feature::packet_counts::add(cluster); - } - if (config->feature_flags & feature::error_counts::get_id()) { - feature::error_counts::add(cluster); - } - } - return cluster; } } /* wifi_network_diagnostics */ @@ -693,16 +659,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) global::attribute::create_cluster_revision(cluster, cluster_revision); } - /* Features */ - if (config) { - if (config->feature_flags & feature::packet_counts::get_id()) { - feature::packet_counts::add(cluster, &(config->features.packet_counts)); - } - if (config->feature_flags & feature::error_counts::get_id()) { - feature::error_counts::add(cluster, &(config->features.error_counts)); - } - } - return cluster; } } /* ethernet_network_diagnostics */ @@ -740,20 +696,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) event::create_time_failure(cluster); - if(config) { - if(config->feature_flags & feature::time_zone::get_id()) { - feature::time_zone::add(cluster, &(config->features.time_zone)); - } - if(config->feature_flags & feature::ntp_client::get_id()) { - feature::ntp_client::add(cluster, &(config->features.ntp_client)); - } - if(config->feature_flags & feature::ntp_server::get_id()) { - feature::ntp_server::add(cluster, &(config->features.ntp_server)); - } - if(config->feature_flags & feature::time_sync_client::get_id()) { - feature::time_sync_client::add(cluster); - } - } return cluster; } } /* time_synchronization */ @@ -777,11 +719,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) global::attribute::create_cluster_revision(cluster, cluster_revision); } - /* Features */ - if (config && config->feature_flags & feature::temperature_unit::get_id()) { - feature::temperature_unit::add(cluster, &(config->features.temperature_unit)); - } - return cluster; } } /* unit_localization */ @@ -815,11 +752,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) event::create_reachable_changed(cluster); - /* Features */ - if (config && config->feature_flags & feature::bridged_icd_support::get_id()) { - feature::bridged_icd_support::add(cluster); - } - return cluster; } } /* bridged_device_basic_information */ @@ -857,18 +789,16 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (config->feature_flags & feature::wired::get_id()) { feature::wired::add(cluster, &(config->features.wired)); } - - if (config->feature_flags & feature::battery::get_id()) { + else if (config->feature_flags & feature::battery::get_id()) { feature::battery::add(cluster, &(config->features.battery)); } - - if (config->feature_flags & feature::rechargeable::get_id()) { - feature::rechargeable::add(cluster, &(config->features.rechargeable)); + else { + ESP_LOGE(TAG, "No feature found for power source cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } - if (config->feature_flags & feature::replaceable::get_id()) { - feature::replaceable::add(cluster, &(config->features.replaceable)); - } } return cluster; @@ -898,20 +828,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Attributes not managed internally */ global::attribute::create_cluster_revision(cluster, cluster_revision); } - -#if defined(CHIP_CONFIG_ENABLE_ICD_CIP) && CHIP_CONFIG_ENABLE_ICD_CIP - if(config) { - if (config->feature_flags & feature::long_idle_time_support::get_id()) { - feature::long_idle_time_support::add(cluster); - if (config->feature_flags & feature::user_active_mode_trigger::get_id()) { - feature::user_active_mode_trigger::add(cluster, &config->features.user_active_mode_trigger); - } - if (config->feature_flags & feature::check_in_protocol_support::get_id()) { - feature::check_in_protocol_support::add(cluster); - } - } - } -#endif // defined(CHIP_CONFIG_ENABLE_ICD_CIP) && CHIP_CONFIG_ENABLE_ICD_CIP #endif // CONFIG_ENABLE_ICD_SERVER return cluster; } @@ -1100,22 +1016,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) command::create_store_scene_response(cluster); command::create_get_scene_membership_response(cluster); - /* Features */ - if(config) { - if (config->feature_flags & feature::scene_names::get_id()) { - feature::scene_names::add(cluster); - } - if (config->feature_flags & feature::explicit_feature::get_id()) { - feature::explicit_feature::add(cluster); - } - if (config->feature_flags & feature::table_size::get_id()) { - feature::table_size::add(cluster); - } - if (config->feature_flags & feature::fabric_scenes::get_id()) { - feature::fabric_scenes::add(cluster); - } - } - return cluster; } } /* scenes_management */ @@ -1153,25 +1053,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Commands */ command::create_off(cluster); - /* Features */ - if (config) { - if (config->feature_flags & feature::off_only::get_id()) { - feature::off_only::add(cluster); - } - else { - if (config->feature_flags & feature::lighting::get_id()) { - feature::lighting::add(cluster, &(config->features.lighting)); - } - if (config->feature_flags & feature::dead_front_behavior::get_id()) { - feature::dead_front_behavior::add(cluster); - } - } - if (!(config->feature_flags & feature::off_only::get_id())) { - command::create_on(cluster); - command::create_toggle(cluster); - } - } - return cluster; } } /* on_off */ @@ -1218,19 +1099,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) command::create_step_with_on_off(cluster); command::create_stop_with_on_off(cluster); - /* Features */ - if (config) { - if (config->feature_flags & feature::on_off::get_id()) { - feature::on_off::add(cluster); - } - if (config->feature_flags & feature::lighting::get_id()) { - feature::lighting::add(cluster, &(config->features.lighting)); - } - if (config->feature_flags & feature::frequency::get_id()) { - feature::frequency::add(cluster, &(config->features.frequency)); - } - } - return cluster; } } /* level_control */ @@ -1277,30 +1145,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } - /* Commands */ - if(config) { - if (config->feature_flags & feature::hue_saturation::get_id() || config->feature_flags & feature::color_temperature::get_id() || config->feature_flags & feature::xy::get_id()) { - command::create_stop_move_step(cluster); - } - - /* Features */ - if (config->feature_flags & feature::hue_saturation::get_id()) { - feature::hue_saturation::add(cluster, &(config->features.hue_saturation)); - } - if (config->feature_flags & feature::color_temperature::get_id()) { - feature::color_temperature::add(cluster, &(config->features.color_temperature)); - } - if (config->feature_flags & feature::xy::get_id()) { - feature::xy::add(cluster, &(config->features.xy)); - } - if (config->feature_flags & feature::enhanced_hue::get_id()) { - feature::enhanced_hue::add(cluster, &(config->features.enhanced_hue)); - } - if (config->feature_flags & feature::color_loop::get_id()) { - feature::color_loop::add(cluster, &(config->features.color_loop)); - } - } - return cluster; } } /* color_control */ @@ -1346,28 +1190,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) create_default_binding_cluster(endpoint); } - /* Features */ - if(config) { - if (config->feature_flags & feature::multi_speed::get_id()) { - feature::multi_speed::add(cluster, &(config->features.multi_speed)); - } - if (config->feature_flags & feature::fan_auto::get_id()) { - feature::fan_auto::add(cluster); - } - if (config->feature_flags & feature::rocking::get_id()) { - feature::rocking::add(cluster, &(config->features.rocking)); - } - if (config->feature_flags & feature::wind::get_id()) { - feature::wind::add(cluster, &(config->features.wind)); - } - if (config->feature_flags & feature::step::get_id()) { - feature::step::add(cluster); - } - if (config->feature_flags & feature::airflow_direction::get_id()) { - feature::airflow_direction::add(cluster, &(config->features.airflow_direction)); - } - } - return cluster; } } /* fan_control */ @@ -1413,32 +1235,22 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Features */ if(config) { - if (!(config->feature_flags & (feature::heating::get_id() | feature::cooling::get_id()))) { - ESP_LOGE(TAG, "Cluster shall support at least one of heating or cooling features."); - } - if (config->feature_flags & feature::heating::get_id()) { - feature::heating::add(cluster, &(config->features.heating)); - } - if (config->feature_flags & feature::cooling::get_id()) { - feature::cooling::add(cluster, &(config->features.cooling)); - } - if (config->feature_flags & feature::setback::get_id()) { - feature::setback::add(cluster, &(config->features.setback)); - } - if (config->feature_flags & feature::occupancy::get_id()) { - feature::occupancy::add(cluster, &(config->features.occupancy)); - } if (config->feature_flags & feature::auto_mode::get_id()) { feature::auto_mode::add(cluster, &(config->features.auto_mode)); + feature::heating::add(cluster, &(config->features.heating)); + feature::cooling::add(cluster, &(config->features.cooling)); } - if (config->feature_flags & feature::local_temperature_not_exposed::get_id()) { - feature::local_temperature_not_exposed::add(cluster, &(config->features.local_temperature_not_exposed)); + else if(config->feature_flags & feature::heating::get_id()) { + feature::heating::add(cluster, &(config->features.heating)); } - if (config->feature_flags & feature::matter_schedule_configuration::get_id()) { - feature::matter_schedule_configuration::add(cluster, &(config->features.matter_schedule_configuration)); + else if(config->feature_flags & feature::cooling::get_id()) { + feature::cooling::add(cluster, &(config->features.cooling)); } - if (config->feature_flags & feature::presets::get_id()) { - feature::presets::add(cluster); + else { + ESP_LOGE(TAG, "Cluster shall support at least one of heating or cooling features."); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1506,21 +1318,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) create_default_binding_cluster(endpoint); } - /* Features */ - if(config) { - if(config->feature_flags & feature::fair::get_id()) { - feature::fair::add(cluster); - } - if(config->feature_flags & feature::moderate::get_id()) { - feature::moderate::add(cluster); - } - if(config->feature_flags & feature::very_poor::get_id()) { - feature::very_poor::add(cluster); - } - if(config->feature_flags & feature::extremely_poor::get_id()) { - feature::extremely_poor::add(cluster); - } - } return cluster; } } /* air_quality */ @@ -1554,17 +1351,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) create_default_binding_cluster(endpoint); } - if(config) { - if(config->feature_flags & feature::condition::get_id()) { - feature::condition::add(cluster, &(config->features.condition)); - } - if(config->feature_flags & feature::warning::get_id()) { - feature::warning::add(cluster); - } - if(config->feature_flags & feature::replacement_product_list::get_id()) { - feature::replacement_product_list::add(cluster); - } - } return cluster; } } /* hepa_filter_monitoring */ @@ -1598,17 +1384,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) create_default_binding_cluster(endpoint); } - if(config) { - if(config->feature_flags & feature::condition::get_id()) { - feature::condition::add(cluster, &(config->features.condition)); - } - if(config->feature_flags & feature::warning::get_id()) { - feature::warning::add(cluster); - } - if(config->feature_flags & feature::replacement_product_list::get_id()) { - feature::replacement_product_list::add(cluster); - } - } return cluster; } } /* activated_carbon_filter_monitoring */ @@ -1645,30 +1420,28 @@ static cluster_t *create(endpoint_t *endpoint, T *config, uint8_t flags, uint32_ } // concentration_measurement -namespace carbon_monoxide_concentration_measurement { +namespace carbon_monoxide_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, CarbonMonoxideConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for carbon monoxide concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1676,30 +1449,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* carbon_monoxide_concentration_measurement */ -namespace carbon_dioxide_concentration_measurement { +namespace carbon_dioxide_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, CarbonDioxideConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for carbon dioxide concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1707,30 +1478,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* carbon_dioxide_concentration_measurement */ -namespace nitrogen_dioxide_concentration_measurement { +namespace nitrogen_dioxide_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, NitrogenDioxideConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for nitrogen dioxide concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1738,30 +1507,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* nitrogen_dioxide_concentration_measurement */ -namespace ozone_concentration_measurement { +namespace ozone_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, OzoneConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for ozone concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1769,30 +1536,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* ozone_concentration_measurement */ -namespace formaldehyde_concentration_measurement { +namespace formaldehyde_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, FormaldehydeConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for formaldehyde concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1800,30 +1565,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* formaldehyde_concentration_measurement */ -namespace pm1_concentration_measurement { +namespace pm1_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, Pm1ConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for pm1 concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1831,30 +1594,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* pm1_concentration_measurement */ -namespace pm25_concentration_measurement { +namespace pm25_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, Pm25ConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for pm25 concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1862,30 +1623,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* pm25_concentration_measurement */ -namespace pm10_concentration_measurement { +namespace pm10_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, Pm10ConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for pm10 concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1893,30 +1652,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* pm10_concentration_measurement */ -namespace radon_concentration_measurement { +namespace radon_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, RadonConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for radon concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -1924,29 +1681,27 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* radon_concentration_measurement */ -namespace total_volatile_organic_compounds_concentration_measurement { +namespace total_volatile_organic_compounds_concentration_measurement { cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = concentration_measurement::create(endpoint, config, flags, TotalVolatileOrganicCompoundsConcentrationMeasurement::Id, cluster_revision); if(config) { - if(config->feature_flags & feature::numeric_measurement::get_id()) { + if(config->feature_flags & feature::numeric_measurement::get_id() && config->feature_flags & feature::level_indication::get_id()) { feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); - } - if(config->feature_flags & feature::level_indication::get_id()) { feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::medium_level::get_id()) { - feature::medium_level::add(cluster); + else if(config->feature_flags & feature::numeric_measurement::get_id()) { + feature::numeric_measurement::add(cluster, &(config->features.numeric_measurement)); } - if(config->feature_flags & feature::critical_level::get_id()) { - feature::critical_level::add(cluster); + else if(config->feature_flags & feature::level_indication::get_id()) { + feature::level_indication::add(cluster, &(config->features.level_indication)); } - if(config->feature_flags & feature::peak_measurement::get_id()) { - feature::peak_measurement::add(cluster, &(config->features.peak_measurement)); - } - if(config->feature_flags & feature::average_measurement::get_id()) { - feature::average_measurement::add(cluster, &(config->features.average_measurement)); + else { + ESP_LOGE(TAG, "No feature found for total volatile organic compounds concentration measurement cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -2061,12 +1816,22 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } if(config) { - if (config->feature_flags & feature::spin::get_id()) { + if(config->feature_flags & feature::spin::get_id() && config->feature_flags & feature::rinse::get_id()) { + feature::spin::add(cluster, &(config->features.spin)); + feature::rinse::add(cluster, &(config->features.rinse)); + } + else if (config->feature_flags & feature::spin::get_id()) { feature::spin::add(cluster, &(config->features.spin)); } - if (config->feature_flags & feature::rinse::get_id()) { + else if (config->feature_flags & feature::rinse::get_id()) { feature::rinse::add(cluster, &(config->features.rinse)); } + else { + ESP_LOGE(TAG, "No feature found for laundry washer controls cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; + } } return cluster; } @@ -2216,12 +1981,22 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Features */ if(config) { - if(config->feature_flags & feature::smoke_alarm::get_id()) { + if(config->feature_flags & feature::smoke_alarm::get_id() && config->feature_flags & feature::co_alarm::get_id()) { + feature::smoke_alarm::add(cluster); + feature::co_alarm::add(cluster); + } + else if(config->feature_flags & feature::smoke_alarm::get_id()) { feature::smoke_alarm::add(cluster); } - if(config->feature_flags & feature::co_alarm::get_id()) { + else if(config->feature_flags & feature::co_alarm::get_id()) { feature::co_alarm::add(cluster); } + else { + ESP_LOGE(TAG, "No feature found for smoke co alarm cluster. At least one feature (smoke_alarm or co_alarm) must be set."); + cluster::destroy(cluster); + assert(false); + return NULL; + } } return cluster; @@ -2280,48 +2055,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) command::create_lock_door(cluster); command::create_unlock_door(cluster); - /* Features */ - if(config) { - if(config->feature_flags & feature::pin_credential::get_id()) { - feature::pin_credential::add(cluster, &(config->features.pin_credential)); - } - if(config->feature_flags & feature::rfid_credential::get_id()) { - feature::rfid_credential::add(cluster, &(config->features.rfid_credential)); - } - if(config->feature_flags & feature::finger_credentials::get_id()) { - feature::finger_credentials::add(cluster); - } - if(config->feature_flags & feature::weekday_access_schedules::get_id()) { - feature::weekday_access_schedules::add(cluster); - } - if(config->feature_flags & feature::door_position_sensor::get_id()) { - feature::door_position_sensor::add(cluster); - } - if(config->feature_flags & feature::face_credentials::get_id()) { - feature::face_credentials::add(cluster); - } - if(config->feature_flags & feature::credential_over_the_air_access::get_id()) { - feature::credential_over_the_air_access::add(cluster, &(config->features.credential_over_the_air_access)); - } - if(config->feature_flags & feature::user::get_id()) { - feature::user::add(cluster, &(config->features.user)); - } - if(config->feature_flags & feature::year_day_access_schedules::get_id()) { - feature::year_day_access_schedules::add(cluster); - } - if(config->feature_flags & feature::holiday_schedules::get_id()) { - feature::holiday_schedules::add(cluster); - } - if(config->feature_flags & feature::unbolting::get_id()) { - feature::unbolting::add(cluster); - } - if(config->feature_flags & feature::aliro_provisioning::get_id()) { - feature::aliro_provisioning::add(cluster); - } - if(config->feature_flags & feature::aliro_bleuwb::get_id()) { - feature::aliro_bleuwb::add(cluster); - } - } return cluster; } } /* door_lock */ @@ -2374,20 +2107,21 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Features */ if(config) { - if (config->feature_flags & feature::lift::get_id()) { + if(config->feature_flags & feature::lift::get_id() && config->feature_flags & feature::tilt::get_id()) { feature::lift::add(cluster, &(config->features.lift)); - } - if (config->feature_flags & feature::tilt::get_id()) { feature::tilt::add(cluster, &(config->features.tilt)); } - if (config->feature_flags & feature::position_aware_lift::get_id()) { - feature::position_aware_lift::add(cluster, &(config->features.position_aware_lift)); + else if (config->feature_flags & feature::lift::get_id()) { + feature::lift::add(cluster, &(config->features.lift)); } - if (config->feature_flags & feature::absolute_position::get_id()) { - feature::absolute_position::add(cluster, &(config->features.absolute_position)); + else if (config->feature_flags & feature::tilt::get_id()) { + feature::tilt::add(cluster, &(config->features.tilt)); } - if (config->feature_flags & feature::position_aware_tilt::get_id()) { - feature::position_aware_tilt::add(cluster, &(config->features.position_aware_tilt)); + else { + ESP_LOGE(TAG, "No feature found for window covering cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -2429,20 +2163,14 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (config->feature_flags & feature::latching_switch::get_id()) { feature::latching_switch::add(cluster); } - if (config->feature_flags & feature::momentary_switch::get_id()) { + else if (config->feature_flags & feature::momentary_switch::get_id()) { feature::momentary_switch::add(cluster); } - if (config->feature_flags & feature::momentary_switch_release::get_id()) { - feature::momentary_switch_release::add(cluster); - } - if (config->feature_flags & feature::momentary_switch_long_press::get_id()) { - feature::momentary_switch_long_press::add(cluster); - } - if (config->feature_flags & feature::momentary_switch_multi_press::get_id()) { - feature::momentary_switch_multi_press::add(cluster, &(config->features.momentary_switch_multi_press)); - } - if (config->feature_flags & feature::action_switch::get_id()) { - feature::action_switch::add(cluster); + else { + ESP_LOGE(TAG, "No feature found for switch cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } return cluster; @@ -2601,6 +2329,9 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } else { ESP_LOGE(TAG, "Config is NULL or mandatory feature_flags are missing."); + cluster::destroy(cluster); + assert(false); + return NULL; } return cluster; } @@ -2669,21 +2400,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) create_default_binding_cluster(endpoint); } - /* Features */ - if(config) { - if (config->feature_flags & feature::visual::get_id()) { - feature::visual::add(cluster, &(config->features.visual)); - } - if (config->feature_flags & feature::audible::get_id()) { - feature::audible::add(cluster, &(config->features.audible)); - } - if (config->feature_flags & feature::alarm_suppress::get_id()) { - feature::alarm_suppress::add(cluster, &(config->features.alarm_suppress)); - } - if (config->feature_flags & feature::sensitivity_level::get_id()) { - feature::sensitivity_level::add(cluster, &(config->features.sensitivity_level)); - } - } return cluster; } } /* boolean_state_configuration */ @@ -2754,11 +2470,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } - /* Features */ - if (config && config->feature_flags & feature::calendar_format::get_id()) { - feature::calendar_format::add(cluster, &(config->features.calendar_format)); - } - return cluster; } } /* time_format_localization */ @@ -2940,14 +2651,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (config->feature_flags & feature::constant_temperature::get_id()) { feature::constant_temperature::add(cluster, &config->features.constant_temperature); } - if (config->feature_flags & feature::automatic::get_id()) { - feature::automatic::add(cluster); - } - if (config->feature_flags & feature::local_operation::get_id()) { - feature::local_operation::add(cluster); - } } else { - ESP_LOGE(TAG, "Config is NULL or mandatory feature_flags are missing."); + ESP_LOGE(TAG, "Config is NULL or mandatory features are missing."); + cluster::destroy(cluster); + assert(false); + return NULL; } return cluster; } @@ -2993,10 +2701,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Commands */ command::create_change_to_mode(cluster); - /* Features */ - if (config && config->feature_flags & feature::on_off::get_id()) { - feature::on_off::add(cluster, &(config->features.on_off)); - } return cluster; } } /* mode_select */ @@ -3053,10 +2757,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Attributes not managed internally */ global::attribute::create_cluster_revision(cluster, cluster_revision); } - /* Features */ - if (config && config->feature_flags & feature::watermarks::get_id()) { - feature::watermarks::add(cluster); - } return cluster; } @@ -3091,11 +2791,14 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (config->feature_flags & feature::temperature_number::get_id()) { feature::temperature_number::add(cluster, &(config->features.temperature_number)); } - if (config->feature_flags & feature::temperature_level::get_id()) { + else if (config->feature_flags & feature::temperature_level::get_id()) { feature::temperature_level::add(cluster, &(config->features.temperature_level)); } - if (config->feature_flags & feature::temperature_step::get_id()) { - feature::temperature_step::add(cluster, &(config->features.temperature_step)); + else { + ESP_LOGE(TAG, "No feature found for temperature control cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; } } @@ -3317,9 +3020,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (config->feature_flags & feature::power_in_watts::get_id()) { feature::power_in_watts::add(cluster); } - if (config->feature_flags & feature::power_number_limits::get_id()) { - feature::power_number_limits::add(cluster); - } } return cluster; @@ -3391,19 +3091,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) command::create_send_key(cluster); command::create_send_key_response(cluster); - /* Features */ - if(config) { - if(config->feature_flags & feature::navigation_key_codes::get_id()) { - feature::navigation_key_codes::add(cluster); - } - if(config->feature_flags & feature::location_keys::get_id()) { - feature::location_keys::add(cluster); - } - if(config->feature_flags & feature::number_keys::get_id()) { - feature::number_keys::add(cluster); - } - } - return cluster; } } /* keypad_input */ @@ -3439,12 +3126,15 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) else if (config->feature_flags & feature::tree_topology::get_id()) { feature::tree_topology::add(cluster); } - else if (config->feature_flags & feature::set_topology::get_id()) { - feature::set_topology::add(cluster); - if (config->feature_flags & feature::dynamic_power_flow::get_id()) { - feature::dynamic_power_flow::add(cluster); - } - } + else if (config->feature_flags & feature::set_topology::get_id()) { + feature::set_topology::add(cluster); + } + else { + ESP_LOGE(TAG, "No feature found for power topology cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; + } } return cluster; @@ -3480,27 +3170,20 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Features */ if(config) { - if((config->feature_flags & feature::direct_current::get_id()) || (config->feature_flags & feature::alternating_current::get_id())) { - if (config->feature_flags & feature::direct_current::get_id()) { - feature::direct_current::add(cluster); - } - if (config->feature_flags & feature::alternating_current::get_id()) { - feature::alternating_current::add(cluster); - - if (config->feature_flags & feature::polyphase_power::get_id()) { - feature::polyphase_power::add(cluster); - } - - if (config->feature_flags & feature::harmonics::get_id()) { - feature::harmonics::add(cluster); - } - - if (config->feature_flags & feature::power_quality::get_id()) { - feature::power_quality::add(cluster); - } - } - } else { + if((config->feature_flags & feature::direct_current::get_id()) && (config->feature_flags & feature::alternating_current::get_id())) { + feature::direct_current::add(cluster); + feature::alternating_current::add(cluster); + } + else if(config->feature_flags & feature::direct_current::get_id()) { + feature::direct_current::add(cluster); + } + else if(config->feature_flags & feature::alternating_current::get_id()) { + feature::alternating_current::add(cluster); + } + else { ESP_LOGE(TAG, "At least one of the feature from Direct Current, Alternating Current shall be supported."); + cluster::destroy(cluster); + assert(false); return NULL; } } @@ -3540,6 +3223,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } else { ESP_LOGE(TAG, "At least one of the feature from Imported Energy, Exported Energy shall be supported."); + cluster::destroy(cluster); + assert(false); return NULL; } @@ -3552,6 +3237,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } else { ESP_LOGE(TAG, "At least one of the feature from Cumulative Energy, Periodic Energy shall be supported."); + cluster::destroy(cluster); + assert(false); return NULL; } } @@ -3629,25 +3316,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Attributes not managed internally */ global::attribute::create_cluster_revision(cluster, cluster_revision); } - - /* Features */ - if(config) { - if (config->feature_flags & feature::charging_preferences::get_id()) { - feature::charging_preferences::add(cluster); - } - if (config->feature_flags & feature::soc_reporting::get_id()) { - feature::soc_reporting::add(cluster); - } - if (config->feature_flags & feature::plug_and_charge::get_id()) { - feature::plug_and_charge::add(cluster); - } - if (config->feature_flags & feature::rfid::get_id()) { - feature::rfid::add(cluster); - } - if (config->feature_flags & feature::v2x::get_id()) { - feature::v2x::add(cluster); - } - } + feature::charging_preferences::add(cluster); /* Commands */ command::create_disable(cluster); @@ -3698,16 +3367,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) command::create_open(cluster); command::create_close(cluster); - /* Features */ - if(config) { - if (config->feature_flags & feature::time_sync::get_id()) { - feature::time_sync::add(cluster, &(config->features.time_sync)); - } - if (config->feature_flags & feature::level::get_id()) { - feature::level::add(cluster, &(config->features.level)); - } - } - return cluster; } } /* valve_configuration_and_control */ @@ -3746,39 +3405,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) create_default_binding_cluster(endpoint); } - /* Features */ - if(config) { - if (config->feature_flags & feature::power_adjustment::get_id()) { - feature::power_adjustment::add(cluster); - } - if (config->feature_flags & feature::power_forecast_reporting::get_id()) { - if ((!(config->feature_flags & feature::power_adjustment::get_id()) || - (config->feature_flags & feature::start_time_adjustment::get_id()) || - (config->feature_flags & feature::pausable::get_id()) || - (config->feature_flags & feature::forecast_adjustment::get_id()) || - (config->feature_flags & feature::constraint_based_adjustment::get_id()))) { - - feature::power_forecast_reporting::add(cluster); - } - } - else if (config->feature_flags & feature::state_forecast_reporting::get_id()) { - if (!(config->feature_flags & feature::power_adjustment::get_id())) { - feature::state_forecast_reporting::add(cluster); - } - } - if (config->feature_flags & feature::pausable::get_id()) { - feature::pausable::add(cluster); - } - if (config->feature_flags & feature::start_time_adjustment::get_id()) { - feature::start_time_adjustment::add(cluster); - } - if (config->feature_flags & feature::forecast_adjustment::get_id()) { - feature::forecast_adjustment::add(cluster); - } - if (config->feature_flags & feature::constraint_based_adjustment::get_id()) { - feature::constraint_based_adjustment::add(cluster); - } - } return cluster; } } /* device_energy_management */ @@ -3894,10 +3520,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) command::create_dataset_response(cluster); command::create_set_active_dataset_request(cluster); - if (config && config->feature_flags & feature::pan_change::get_id()) { - feature::pan_change::add(cluster); - } - return cluster; } @@ -4002,18 +3624,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) global::attribute::create_cluster_revision(cluster, cluster_revision); } - if(config) { - if (config->feature_flags & feature::select_while_running::get_id()) { - feature::select_while_running::add(cluster); - } - if (config->feature_flags & feature::progress_reporting::get_id()) { - feature::progress_reporting::add(cluster); - } - if (config->feature_flags & feature::maps::get_id()) { - feature::maps::add(cluster); - } - } - /* Commands */ command::create_select_areas(cluster); command::create_select_areas_response(cluster); @@ -4051,16 +3661,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_heat_demand(cluster, config->heat_demand); attribute::create_boost_state(cluster, config->boost_state); } - - if(config) { - if (config->feature_flags & feature::energy_management::get_id()) { - feature::energy_management::add(cluster, &(config->features.energy_management)); - } - if (config->feature_flags & feature::tank_percent::get_id()) { - feature::tank_percent::add(cluster, &(config->features.tank_percent)); - } - } - /* Commands */ command::create_boost(cluster); command::create_cancel_boost(cluster); @@ -4145,12 +3745,22 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) /* Features */ if(config) { - if (config->feature_flags & feature::energy_balance::get_id()) { + if(config->feature_flags & feature::energy_balance::get_id() && config->feature_flags & feature::low_power_mode_sensitivity::get_id()) { + feature::energy_balance::add(cluster, &(config->features.energy_balance)); + feature::low_power_mode_sensitivity::add(cluster, &(config->features.low_power_mode_sensitivity)); + } + else if (config->feature_flags & feature::energy_balance::get_id()) { feature::energy_balance::add(cluster, &(config->features.energy_balance)); } - if (config->feature_flags & feature::low_power_mode_sensitivity::get_id()) { + else if (config->feature_flags & feature::low_power_mode_sensitivity::get_id()) { feature::low_power_mode_sensitivity::add(cluster, &(config->features.low_power_mode_sensitivity)); } + else { + ESP_LOGE(TAG, "No feature found for energy preference cluster"); + cluster::destroy(cluster); + assert(false); + return NULL; + } } return cluster; diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index 62f38cc45..ffafdb146 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -71,10 +71,7 @@ typedef struct config { } /* common */ namespace descriptor { -typedef struct config { - uint32_t feature_flags; - config() : feature_flags(0) {} -} config_t; +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* descriptor */ @@ -84,10 +81,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* actions */ namespace access_control { -typedef struct config { - uint32_t feature_flags; - config() : feature_flags(0) {} -} config_t; +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* access_control */ @@ -124,11 +118,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace general_commissioning { typedef struct config { uint64_t breadcrumb; - struct { - feature::terms_and_conditions::config_t terms_and_conditions; - } features; - uint32_t feature_flags; - config() : breadcrumb(0), feature_flags(0) {} + config() : breadcrumb(0) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -160,21 +150,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* general_diagnostics */ namespace software_diagnostics { -typedef struct config { - uint32_t feature_flags; - struct { - feature::watermarks::config_t watermarks; - } features; - config() : feature_flags(0) {} -} config_t; +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* software_diagnostics */ namespace administrator_commissioning { -typedef struct config { - uint32_t feature_flags; - config() : feature_flags(0) {} -} config_t; +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* administrator_commissioning */ @@ -189,10 +170,7 @@ cluster_t *create(endpoint_t *endpoint, uint8_t flags); } /* group_key_management */ namespace wifi_network_diagnostics { -typedef struct config { - uint32_t feature_flags; - config() : feature_flags(0) {} -} config_t; +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* wifi_network_diagnostics */ @@ -202,49 +180,28 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* thread_network_diagnostics */ namespace ethernet_network_diagnostics { -typedef struct config { - struct { - feature::packet_counts::config_t packet_counts; - feature::error_counts::config_t error_counts; - } features; - uint32_t feature_flags; - config() : feature_flags(0) {} -} config_t; +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* ethernet_network_diagnostics */ namespace time_synchronization { typedef struct config { - struct { - feature::time_zone::config_t time_zone; - feature::ntp_client::config_t ntp_client; - feature::ntp_server::config_t ntp_server; - } features; - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* time_synchronization */ namespace unit_localization { -typedef struct config { - struct { - feature::temperature_unit::config_t temperature_unit; - } features; - uint32_t feature_flags; - config() : feature_flags(0) {} -} config_t; - +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* unit_localization */ namespace bridged_device_basic_information { typedef struct config { bool reachable; - uint32_t feature_flags; - config() : reachable(true), feature_flags(0) {} + config() : reachable(true) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -258,8 +215,6 @@ 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) {} @@ -268,13 +223,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* power_source */ namespace icd_management { -typedef struct config { - struct { - feature::user_active_mode_trigger::config_t user_active_mode_trigger; - } features; - uint32_t feature_flags; - config() : feature_flags(0) {} -} config_t; +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* icd_management */ @@ -307,8 +256,7 @@ uint8_t get_server_cluster_count(); namespace scenes_management { typedef struct config { uint16_t scene_table_size; - uint32_t feature_flags; - config() : scene_table_size(16), feature_flags(0) {} + config() : scene_table_size(16) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -317,11 +265,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace on_off { typedef struct config { bool on_off; - struct { - feature::lighting::config_t lighting; - } features; - uint32_t feature_flags; - config() : on_off(false), feature_flags(0) {} + config() : on_off(false) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -332,12 +276,7 @@ typedef struct config { nullable current_level; nullable on_level; uint8_t options; - struct { - feature::lighting::config_t lighting; - feature::frequency::config_t frequency; - } features; - uint32_t feature_flags; - config() : current_level(), on_level(), options(0), feature_flags(0) {} + config() : current_level(), on_level(), options(0) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -350,16 +289,8 @@ typedef struct config { uint8_t enhanced_color_mode; uint16_t color_capabilities; nullable number_of_primaries; - struct { - feature::hue_saturation::config_t hue_saturation; - feature::color_temperature::config_t color_temperature; - feature::xy::config_t xy; - feature::enhanced_hue::config_t enhanced_hue; - feature::color_loop::config_t color_loop; - } features; - uint32_t feature_flags; config() : color_mode(1), color_control_options(0), enhanced_color_mode(1), - color_capabilities(0), number_of_primaries(0), feature_flags(0) {} + color_capabilities(0), number_of_primaries(0) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -371,15 +302,8 @@ typedef struct config { uint8_t fan_mode_sequence; nullable percent_setting; uint8_t percent_current; - struct { - feature::multi_speed::config_t multi_speed; - feature::rocking::config_t rocking; - feature::wind::config_t wind; - feature::airflow_direction::config_t airflow_direction; - } features; - uint32_t feature_flags; void *delegate; - config() : fan_mode(0), fan_mode_sequence(2), percent_setting(0), percent_current(0), feature_flags(0), delegate(nullptr) {} + config() : fan_mode(0), fan_mode_sequence(2), percent_setting(0), percent_current(0), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -393,11 +317,7 @@ typedef struct config { struct { feature::heating::config_t heating; feature::cooling::config_t cooling; - feature::occupancy::config_t occupancy; - feature::setback::config_t setback; feature::auto_mode::config_t auto_mode; - 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), feature_flags(0) {} @@ -417,22 +337,15 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* thermostat_user_interface_configuration */ namespace air_quality { -typedef struct config { - uint32_t feature_flags; - config() : feature_flags(0) {} -} config_t; +using config_t = common::config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); } /* air_quality */ namespace hepa_filter_monitoring { typedef struct config { - struct { - feature::condition::config_t condition; - } features; - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -440,12 +353,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace activated_carbon_filter_monitoring { typedef struct config { - struct { - feature::condition::config_t condition; - } features; - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -457,8 +366,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -473,8 +380,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -489,8 +394,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -505,8 +408,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -521,8 +422,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -537,8 +436,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -553,8 +450,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -569,8 +464,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -585,8 +478,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -601,8 +492,6 @@ 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; config() : measurement_medium(0), feature_flags(0) {} @@ -689,15 +578,8 @@ typedef struct config { bool actuator_enabled; uint8_t operating_mode; uint16_t supported_operating_modes; - struct { - feature::pin_credential::config_t pin_credential; - feature::rfid_credential::config_t rfid_credential; - feature::credential_over_the_air_access::config_t credential_over_the_air_access; - feature::user::config_t user; - } features; - uint32_t feature_flags; void *delegate; - config() : lock_state(0), lock_type(0), actuator_enabled(0), operating_mode(0), supported_operating_modes(0xFFF6), feature_flags(0), delegate(nullptr) {} + config() : lock_state(0), lock_type(0), actuator_enabled(0), operating_mode(0), supported_operating_modes(0xFFF6), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -713,9 +595,6 @@ 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; @@ -729,9 +608,6 @@ 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; @@ -785,15 +661,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace boolean_state_configuration { typedef struct config { - struct { - feature::visual::config_t visual; - feature::audible::config_t audible; - feature::alarm_suppress::config_t alarm_suppress; - feature::sensitivity_level::config_t sensitivity_level; - } features; - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -811,11 +680,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace time_format_localization { typedef struct config { uint8_t hour_format; - struct { - feature::calendar_format::config_t calendar_format; - } features; - uint32_t feature_flags; - config() : hour_format(0), feature_flags(0) {} + config() : hour_format(0) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -890,12 +755,8 @@ typedef struct config { char mode_select_description[k_max_mode_select_description_length + 1]; const nullable standard_namespace; uint8_t current_mode; - struct { - feature::on_off::config_t on_off; - } features; - uint32_t feature_flags; void *delegate; - config() : mode_select_description{0}, standard_namespace(), current_mode(0), feature_flags(0), delegate(nullptr) {} + config() : mode_select_description{0}, standard_namespace(), current_mode(0), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -906,7 +767,6 @@ 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) {} @@ -983,9 +843,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace keypad_input { typedef struct config { - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -995,7 +854,7 @@ namespace power_topology { typedef struct config { uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : feature_flags(0), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -1033,9 +892,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace energy_evse { typedef struct config { - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -1047,13 +905,8 @@ typedef struct config { nullable default_open_duration; nullable current_state; nullable target_state; - struct { - feature::time_sync::config_t time_sync; - feature::level::config_t level; - } features; - uint32_t feature_flags; void *delegate; - config() : open_duration(), default_open_duration(), current_state(), target_state(), feature_flags(0), delegate(nullptr) {} + config() : open_duration(), default_open_duration(), current_state(), target_state(), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -1061,9 +914,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace device_energy_management { typedef struct config { - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -1090,9 +942,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace thread_border_router_management { typedef struct config { - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -1110,9 +961,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace service_area { typedef struct config { - uint32_t feature_flags; void *delegate; - config() : feature_flags(0), delegate(nullptr) {} + config() : delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -1123,13 +973,8 @@ typedef struct config { uint8_t heater_types; uint8_t heat_demand; uint8_t boost_state; - struct { - feature::energy_management::config_t energy_management; - feature::tank_percent::config_t tank_percent; - } features; - uint32_t feature_flags; void *delegate; - config() : heater_types(0), heat_demand(0), boost_state(0), feature_flags(0), delegate(nullptr) {} + config() : heater_types(0), heat_demand(0), boost_state(0), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index 34f7a793b..3ef0db14f 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -1572,7 +1572,7 @@ cluster_t *create(endpoint_t *endpoint, uint32_t cluster_id, uint8_t flags) return (cluster_t *)cluster; } -static esp_err_t destroy(cluster_t *cluster) +esp_err_t destroy(cluster_t *cluster) { VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Cluster cannot be NULL")); _cluster_t *current_cluster = (_cluster_t *)cluster; diff --git a/components/esp_matter/esp_matter_core.h b/components/esp_matter/esp_matter_core.h index 116904be5..b22ca69fd 100644 --- a/components/esp_matter/esp_matter_core.h +++ b/components/esp_matter/esp_matter_core.h @@ -429,6 +429,18 @@ typedef void (*function_generic_t)(); */ cluster_t *create(endpoint_t *endpoint, uint32_t cluster_id, uint8_t flags); +/** Destroy cluster + * + * This will destroy the cluster which has been created and added to the endpoint. It also destroys the associated + * attributes, commands and events. + * + * @param[in] cluster Cluster handle. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t destroy(cluster_t *cluster); + /** Get cluster * * Get the cluster present on the endpoint. diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index e1c035f71..456137e23 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -74,21 +74,18 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) administrator_commissioning::create(endpoint, &(config->administrator_commissioning), CLUSTER_FLAG_SERVER); operational_credentials::create(endpoint, &(config->operational_credentials), CLUSTER_FLAG_SERVER); group_key_management::create(endpoint, CLUSTER_FLAG_SERVER); - #if CHIP_CONFIG_ENABLE_ICD_SERVER if (icd::get_icd_server_enabled()) { - config->icd_management.feature_flags |= + cluster_t *icd_management_cluster = icd_management::create(endpoint, &(config->icd_management), CLUSTER_FLAG_SERVER); #if CHIP_CONFIG_ENABLE_ICD_LIT - icd_management::feature::long_idle_time_support::get_id() | + icd_management::feature::long_idle_time_support::add(icd_management_cluster); #if CHIP_CONFIG_ENABLE_ICD_CIP - icd_management::feature::check_in_protocol_support::get_id() | + icd_management::feature::check_in_protocol_support::add(icd_management_cluster); #endif // CHIP_CONFIG_ENABLE_ICD_CIP #if CHIP_CONFIG_ENABLE_ICD_UAT - icd_management::feature::user_active_mode_trigger::get_id() | + icd_management::feature::user_active_mode_trigger::add(icd_management_cluster); #endif // CHIP_CONFIG_ENABLE_ICD_UAT #endif // CHIP_CONFIG_ENABLE_ICD_LIT - 0; - icd_management::create(endpoint, &(config->icd_management), CLUSTER_FLAG_SERVER); } #endif // CHIP_CONFIG_ENABLE_ICD_SERVER return ESP_OK; @@ -223,8 +220,10 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); identify::command::create_trigger_effect(identify_cluster); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::lighting::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::lighting::add(on_off_cluster, &(config->on_off_lighting)); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); return ESP_OK; } @@ -255,11 +254,13 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); identify::command::create_trigger_effect(identify_cluster); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::lighting::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); - // Set the mandatory feature flags in the config structure - config->level_control.feature_flags |= level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id(); - level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::lighting::add(on_off_cluster, &(config->on_off_lighting)); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); + cluster_t *level_control_cluster = level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); + level_control::feature::on_off::add(level_control_cluster); + level_control::feature::lighting::add(level_control_cluster, &(config->level_control_lighting)); return ESP_OK; } @@ -289,14 +290,16 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); identify::command::create_trigger_effect(identify_cluster); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::lighting::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); - // Set the mandatory feature flags in the config structure - config->level_control.feature_flags |= level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id(); - level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); - // Set the mandatory feature flags in the config structure - config->color_control.feature_flags |= color_control::feature::color_temperature::get_id(); - color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::lighting::add(on_off_cluster, &(config->on_off_lighting)); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); + cluster_t *level_control_cluster = level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); + level_control::feature::on_off::add(level_control_cluster); + level_control::feature::lighting::add(level_control_cluster, &(config->level_control_lighting)); + cluster_t *color_control_cluster = color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER); + color_control::feature::color_temperature::add(color_control_cluster, &(config->color_control_color_temperature)); + color_control::attribute::create_remaining_time(color_control_cluster, config->color_control_remaining_time); return ESP_OK; } @@ -326,14 +329,17 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); identify::command::create_trigger_effect(identify_cluster); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::lighting::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); - // Set the mandatory feature flags in the config structure - config->level_control.feature_flags |= level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id(); - level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); - // Set the mandatory feature flags in the config structure - config->color_control.feature_flags |= color_control::feature::color_temperature::get_id() | color_control::feature::xy::get_id(); - color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::lighting::add(on_off_cluster, &(config->on_off_lighting)); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); + cluster_t *level_control_cluster = level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); + level_control::feature::on_off::add(level_control_cluster); + level_control::feature::lighting::add(level_control_cluster, &(config->level_control_lighting)); + cluster_t *color_control_cluster = color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER); + color_control::feature::color_temperature::add(color_control_cluster, &(config->color_control_color_temperature)); + color_control::feature::xy::add(color_control_cluster, &(config->color_control_xy)); + color_control::attribute::create_remaining_time(color_control_cluster, config->color_control_remaining_time); return ESP_OK; } } /* extended_color_light */ @@ -496,8 +502,10 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); identify::command::create_trigger_effect(identify_cluster); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::lighting::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::lighting::add(on_off_cluster, &(config->on_off_lighting)); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); return ESP_OK; } @@ -527,10 +535,13 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); identify::command::create_trigger_effect(identify_cluster); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::lighting::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); - config->level_control.feature_flags |= level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id(); - level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::lighting::add(on_off_cluster, &(config->on_off_lighting)); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); + cluster_t *level_control_cluster = level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); + level_control::feature::on_off::add(level_control_cluster); + level_control::feature::lighting::add(level_control_cluster, &(config->level_control_lighting)); return ESP_OK; } @@ -588,7 +599,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->thermostat.feature_flags |= cluster::thermostat::feature::heating::get_id(); cluster::thermostat::create(endpoint, &(config->thermostat), CLUSTER_FLAG_SERVER); return ESP_OK; @@ -733,7 +743,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); VerifyOrReturnError(err == ESP_OK, err); - operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER); + cluster_t *operational_state_cluster = operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER); + operational_state::event::create_operation_completion(operational_state_cluster); return ESP_OK; } @@ -760,7 +771,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); VerifyOrReturnError(err == ESP_OK, err); - operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER); + cluster_t *operational_state_cluster = operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER); + operational_state::event::create_operation_completion(operational_state_cluster); return ESP_OK; } @@ -787,7 +799,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); VerifyOrReturnError(err == ESP_OK, err); - operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER); + cluster_t *operational_state_cluster = operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER); + operational_state::event::create_operation_completion(operational_state_cluster); return ESP_OK; } @@ -1115,7 +1128,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) } } /* flow_sensor */ -namespace pump{ +namespace pump { uint32_t get_device_type_id() { @@ -1138,14 +1151,16 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) VerifyOrReturnError(err == ESP_OK, err); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); pump_configuration_and_control::create(endpoint, &(config->pump_configuration_and_control), CLUSTER_FLAG_SERVER); return ESP_OK; } } /** pump **/ -namespace pump_controller{ +namespace pump_controller { uint32_t get_device_type_id() { @@ -1168,8 +1183,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) VerifyOrReturnError(err == ESP_OK, err); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_CLIENT); - pump_configuration_and_control::create(endpoint, &(config->pump_configuration_and_control), CLUSTER_FLAG_CLIENT); + on_off::create(endpoint, nullptr, CLUSTER_FLAG_CLIENT); + pump_configuration_and_control::create(endpoint, nullptr, CLUSTER_FLAG_CLIENT); binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); return ESP_OK; @@ -1206,7 +1221,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) } } /** mode_select_device **/ -namespace room_air_conditioner{ +namespace room_air_conditioner { uint32_t get_device_type_id() { @@ -1230,8 +1245,10 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) VerifyOrReturnError(err == ESP_OK, err); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::dead_front_behavior::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::dead_front_behavior::add(on_off_cluster); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); config->thermostat.feature_flags |= cluster::thermostat::feature::cooling::get_id(); cluster::thermostat::create(endpoint, &(config->thermostat), CLUSTER_FLAG_SERVER); @@ -1261,7 +1278,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); VerifyOrReturnError(err == ESP_OK, err); - config->temperature_control.feature_flags |= temperature_control::feature::temperature_number::get_id(); temperature_control::create(endpoint, &(config->temperature_control), CLUSTER_FLAG_SERVER); return ESP_OK; @@ -1321,7 +1337,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) } /** oven **/ -namespace robotic_vacuum_cleaner{ +namespace robotic_vacuum_cleaner { uint32_t get_device_type_id() { @@ -1345,7 +1361,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); rvc_run_mode::create(endpoint, &(config->rvc_run_mode), CLUSTER_FLAG_SERVER); - rvc_operational_state::create(endpoint, &(config->rvc_operational_state), CLUSTER_FLAG_SERVER); + cluster_t *rvc_operational_state_cluster = rvc_operational_state::create(endpoint, &(config->rvc_operational_state), CLUSTER_FLAG_SERVER); + operational_state::event::create_operation_completion(rvc_operational_state_cluster); return ESP_OK; } @@ -1373,7 +1390,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) VerifyOrReturnError(err == ESP_OK, err); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - boolean_state::create(endpoint, &(config->boolean_state), CLUSTER_FLAG_SERVER); + cluster_t *cluster = boolean_state::create(endpoint, &(config->boolean_state), CLUSTER_FLAG_SERVER); + boolean_state::event::create_state_change(cluster); return ESP_OK; } @@ -1401,7 +1419,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) VerifyOrReturnError(err == ESP_OK, err); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - boolean_state::create(endpoint, &(config->boolean_state), CLUSTER_FLAG_SERVER); + cluster_t *cluster = boolean_state::create(endpoint, &(config->boolean_state), CLUSTER_FLAG_SERVER); + boolean_state::event::create_state_change(cluster); return ESP_OK; } @@ -1430,7 +1449,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); cluster_t *cluster = boolean_state::create(endpoint, &(config->boolean_state), CLUSTER_FLAG_SERVER); - boolean_state::event::create_state_change(cluster); return ESP_OK; } @@ -1457,12 +1475,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); VerifyOrReturnError(err == ESP_OK, err); - // Set the mandatory feature flags in the config structures - config->power_topology.feature_flags |= power_topology::feature::set_topology::get_id(); power_topology::create(endpoint, &(config->power_topology), CLUSTER_FLAG_SERVER); - config->electrical_power_measurement.feature_flags |= electrical_power_measurement::feature::direct_current::get_id() - | electrical_power_measurement::feature::alternating_current::get_id(); electrical_power_measurement::create(endpoint, &(config->electrical_power_measurement), CLUSTER_FLAG_SERVER); return ESP_OK; @@ -1490,6 +1504,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); VerifyOrReturnError(err == ESP_OK, err); + config->temperature_control.feature_flags = cluster::temperature_control::feature::temperature_level::get_id(); temperature_control::create(endpoint, &(config->temperature_control), CLUSTER_FLAG_SERVER); return ESP_OK; @@ -1517,8 +1532,8 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); VerifyOrReturnError(err == ESP_OK, err); - config->on_off.feature_flags |= on_off::feature::off_only::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + cluster_t *cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::off_only::add(cluster); return ESP_OK; } @@ -1576,6 +1591,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *cluster = operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER); operational_state::attribute::create_countdown_time(cluster, 0); + operational_state::event::create_operation_completion(cluster); microwave_oven_mode::create(endpoint, &(config->microwave_oven_mode), CLUSTER_FLAG_SERVER); microwave_oven_control::create(endpoint, &(config->microwave_oven_control), CLUSTER_FLAG_SERVER); @@ -1691,7 +1707,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) VerifyOrReturnError(err == ESP_OK, err); thread_network_diagnostics::create(endpoint, &(config->thread_network_diagnostics), CLUSTER_FLAG_SERVER); - config->thread_border_router_management.feature_flags |= thread_border_router_management::feature::pan_change::get_id(); thread_border_router_management::create(endpoint, &(config->thread_border_router_management), CLUSTER_FLAG_SERVER); return ESP_OK; } @@ -1749,8 +1764,10 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); identify::command::create_trigger_effect(identify_cluster); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::lighting::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::lighting::add(on_off_cluster, &(config->on_off_lighting)); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); return ESP_OK; } @@ -1781,11 +1798,13 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); identify::command::create_trigger_effect(identify_cluster); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - config->on_off.feature_flags |= on_off::feature::lighting::get_id(); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); - // Set the mandatory feature flags in the config structure - config->level_control.feature_flags |= level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id(); - level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); + cluster_t *on_off_cluster = on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER); + on_off::feature::lighting::add(on_off_cluster, &(config->on_off_lighting)); + on_off::command::create_on(on_off_cluster); + on_off::command::create_toggle(on_off_cluster); + cluster_t *level_control_cluster = level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER); + level_control::feature::lighting::add(level_control_cluster, &(config->level_control_lighting)); + level_control::feature::on_off::add(level_control_cluster); return ESP_OK; } @@ -1812,7 +1831,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); VerifyOrReturnError(err == ESP_OK, err); - config->thermostat.feature_flags |= cluster::thermostat::feature::heating::get_id(); cluster::thermostat::create(endpoint, &(config->thermostat), CLUSTER_FLAG_SERVER); water_heater_management::create(endpoint, &(config->water_heater_management), CLUSTER_FLAG_SERVER); water_heater_mode::create(endpoint, &(config->water_heater_mode), CLUSTER_FLAG_SERVER); @@ -1845,13 +1863,10 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *descriptor_cluster = cluster::get(endpoint, Descriptor::Id); descriptor::feature::taglist::add(descriptor_cluster); + config->power_source_device.power_source.feature_flags = power_source::feature::wired::get_id(); power_source_device::add(endpoint, &config->power_source_device); - cluster_t *power_source_cluster = cluster::get(endpoint, PowerSource::Id); - power_source::feature::wired::add(power_source_cluster, &config->power_source_device.power_source.features.wired); electrical_sensor::add(endpoint, &config->electrical_sensor); - // Set the mandatory feature flags in the config structure - config->electrical_energy_measurement.feature_flags |= electrical_energy_measurement::feature::exported_energy::get_id() | electrical_energy_measurement::feature::cumulative_energy::get_id(); electrical_energy_measurement::create(endpoint, &(config->electrical_energy_measurement), CLUSTER_FLAG_SERVER); cluster_t *elec_power_measurement_cluster = cluster::get(endpoint, ElectricalPowerMeasurement::Id); @@ -1888,11 +1903,10 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *descriptor_cluster = cluster::get(endpoint, Descriptor::Id); descriptor::feature::taglist::add(descriptor_cluster); + config->power_source_device.power_source.feature_flags = power_source::feature::battery::get_id() | power_source::feature::wired::get_id(); power_source_device::add(endpoint, &config->power_source_device); cluster_t *power_source_cluster = cluster::get(endpoint, PowerSource::Id); - power_source::feature::wired::add(power_source_cluster, &config->power_source_device.power_source.features.wired); - power_source::feature::battery::add(power_source_cluster, &config->power_source_device.power_source.features.battery); power_source::attribute::create_bat_voltage(power_source_cluster, config->bat_voltage, 0x00, 0xFFFF); power_source::attribute::create_bat_percent_remaining(power_source_cluster, config->bat_percent_remaining, 0, 200); @@ -1904,8 +1918,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) power_source::attribute::create_active_bat_charge_faults(power_source_cluster, NULL, 0, 0); electrical_sensor::add(endpoint, &config->electrical_sensor); - // Set the mandatory feature flags in the config structure - config->electrical_energy_measurement.feature_flags |= electrical_energy_measurement::feature::exported_energy::get_id() | electrical_energy_measurement::feature::cumulative_energy::get_id(); electrical_energy_measurement::create(endpoint, &(config->electrical_energy_measurement), CLUSTER_FLAG_SERVER); cluster_t *elec_power_measurement_cluster = cluster::get(endpoint, ElectricalPowerMeasurement::Id); @@ -1945,11 +1957,10 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) cluster_t *descriptor_cluster = cluster::get(endpoint, Descriptor::Id); descriptor::feature::taglist::add(descriptor_cluster); + config->power_source_device.power_source.feature_flags = power_source::feature::wired::get_id(); power_source_device::add(endpoint, &config->power_source_device); - - cluster_t *power_source_cluster = cluster::get(endpoint, PowerSource::Id); - power_source::feature::wired::add(power_source_cluster, &config->power_source_device.power_source.features.wired); + config->electrical_sensor.electrical_power_measurement.feature_flags = electrical_power_measurement::feature::alternating_current::get_id(); electrical_sensor::add(endpoint, &config->electrical_sensor); cluster_t *elec_power_measurement_cluster = cluster::get(endpoint, ElectricalPowerMeasurement::Id); @@ -1957,8 +1968,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) electrical_power_measurement::attribute::create_voltage(elec_power_measurement_cluster, config->voltage); electrical_power_measurement::attribute::create_active_current(elec_power_measurement_cluster, config->active_current); - // Set the mandatory feature flags in the config structure - config->electrical_energy_measurement.feature_flags |= electrical_energy_measurement::feature::exported_energy::get_id() | electrical_energy_measurement::feature::cumulative_energy::get_id(); electrical_energy_measurement::create(endpoint, &(config->electrical_energy_measurement), CLUSTER_FLAG_SERVER); device_energy_management::add(endpoint, &config->device_energy_management); diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index aff6b1d3b..d868a46ab 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -14,6 +14,7 @@ #pragma once +#include #include #include #include @@ -175,6 +176,7 @@ typedef struct : app_base_config { typedef struct : app_with_group_config { cluster::on_off::config_t on_off; + cluster::on_off::feature::lighting::config_t on_off_lighting; } on_off_config; typedef struct : app_with_group_config { @@ -264,6 +266,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config); namespace dimmable_light { typedef struct config : on_off_light::config_t { cluster::level_control::config_t level_control; + cluster::level_control::feature::lighting::config_t level_control_lighting; } config_t; uint32_t get_device_type_id(); @@ -275,6 +278,9 @@ esp_err_t add(endpoint_t *endpoint, config_t *config); namespace color_temperature_light { typedef struct config : dimmable_light::config_t { cluster::color_control::config_t color_control; + cluster::color_control::feature::color_temperature::config_t color_control_color_temperature; + uint16_t color_control_remaining_time; + config() : color_control_remaining_time(0) {} } config_t; uint32_t get_device_type_id(); @@ -286,6 +292,10 @@ esp_err_t add(endpoint_t *endpoint, config_t *config); namespace extended_color_light { typedef struct config : dimmable_light::config_t { cluster::color_control::config_t color_control; + cluster::color_control::feature::color_temperature::config_t color_control_color_temperature; + cluster::color_control::feature::xy::config_t color_control_xy; + uint16_t color_control_remaining_time; + config() : color_control_remaining_time(0) {} } config_t; uint32_t get_device_type_id(); @@ -367,6 +377,7 @@ esp_err_t add(endpoint_t *endpoint, config_t *config); namespace dimmable_plugin_unit { typedef struct config : on_off_plugin_unit::config_t { cluster::level_control::config_t level_control; + cluster::level_control::feature::lighting::config_t level_control_lighting; } config_t; uint32_t get_device_type_id(); @@ -633,7 +644,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat esp_err_t add(endpoint_t *endpoint, config_t *config); } /* flow_sensor */ -namespace pump{ +namespace pump { typedef struct config : app_base_config { cluster::on_off::config_t on_off; cluster::pump_configuration_and_control::config_t pump_configuration_and_control; @@ -657,8 +668,6 @@ typedef struct config : app_client_config { config() { identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator); } - cluster::on_off::config_t on_off; - cluster::pump_configuration_and_control::config_t pump_configuration_and_control; } config_t; uint32_t get_device_type_id(); @@ -679,7 +688,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat esp_err_t add(endpoint_t *endpoint, config_t *config); } /** mode_select_device **/ -namespace room_air_conditioner{ +namespace room_air_conditioner { typedef struct config : app_base_config { config() { identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); @@ -694,7 +703,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat esp_err_t add(endpoint_t *endpoint, config_t *config); } /** room air conditioner **/ -namespace temperature_controlled_cabinet{ +namespace temperature_controlled_cabinet { typedef struct config { cluster::descriptor::config_t descriptor; cluster::temperature_control::config_t temperature_control; @@ -706,7 +715,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat esp_err_t add(endpoint_t *endpoint, config_t *config); } /** temperature_controlled_cabinet **/ -namespace refrigerator{ +namespace refrigerator { typedef struct config { cluster::descriptor::config_t descriptor; } config_t; @@ -728,7 +737,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat esp_err_t add(endpoint_t *endpoint, config_t *config); } /** oven **/ -namespace robotic_vacuum_cleaner{ +namespace robotic_vacuum_cleaner { typedef struct config : app_base_config { config() { identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); @@ -913,7 +922,6 @@ esp_err_t add(endpoint_t *endpoint, config_t *config); } /* secondary_network_interface */ namespace mounted_on_off_control { - typedef struct config : on_off_config { config() { identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); diff --git a/components/esp_matter/esp_matter_feature.h b/components/esp_matter/esp_matter_feature.h index a2bd6fc6a..11d71ca9b 100644 --- a/components/esp_matter/esp_matter_feature.h +++ b/components/esp_matter/esp_matter_feature.h @@ -173,27 +173,6 @@ esp_err_t add(cluster_t *cluster); } /* scene_names */ -namespace explicit_feature { - -uint32_t get_id(); -esp_err_t add(cluster_t *cluster); - -} /* explicit_feature */ - -namespace table_size { - -uint32_t get_id(); -esp_err_t add(cluster_t *cluster); - -} /* table_size */ - -namespace fabric_scenes { - -uint32_t get_id(); -esp_err_t add(cluster_t *cluster); - -} /* fabric_scenes*/ - } /* feature */ } /* scenes_management */ diff --git a/docs/en/developing.rst b/docs/en/developing.rst index 1a54f0aeb..8ee94dfe9 100644 --- a/docs/en/developing.rst +++ b/docs/en/developing.rst @@ -796,8 +796,7 @@ Additional clusters can also be added to an endpoint. Examples: :: on_off::config_t on_off_config; - on_off_config.feature_flags = on_off::feature::lighting::get_id(); - cluster_t *cluster = on_off::create(endpoint, &on_off_config, CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + cluster_t *cluster = on_off::create(endpoint, &on_off_config, CLUSTER_FLAG_SERVER); - temperature_measurement: @@ -811,6 +810,7 @@ Additional clusters can also be added to an endpoint. Examples: :: window_covering::config_t window_covering_config(static_cast(chip::app::Clusters::WindowCovering::EndProductType::kTiltOnlyInteriorBlind)); + window_covering_config.feature_flags = window_covering::feature::lift::get_id(); cluster_t *cluster = window_covering::create(endpoint, &window_covering_config, CLUSTER_FLAG_SERVER); The ``window_covering`` ``config_t`` structure includes a constructor that allows specifying @@ -822,6 +822,7 @@ Additional clusters can also be added to an endpoint. Examples: :: pump_configuration_and_control::config_t pump_configuration_and_control_config(1, 10, 20); + pump_configuration_and_control_config..feature_flags = pump_configuration_and_control::feature::constant_pressure::get_id(); cluster_t *cluster = pump_configuration_and_control::create(endpoint, &pump_configuration_and_control_config, CLUSTER_FLAG_SERVER); The ``pump_configuration_and_control`` ``config_t`` structure includes a constructor that allows specifying @@ -862,6 +863,28 @@ Examples: 2.5.2.4 Features ^^^^^^^^^^^^^^^^^^ +Mandatory features for a device type or endpoint can be configured at endpoint level. + +- feature: lighting: On/Off cluster: + + :: + + extended_color_light::config_t light_config; + light_config.on_off_lighting.start_up_on_off = nullptr; + endpoint_t *endpoint = extended_color_light::create(node, &light_config, ENDPOINT_FLAG_NONE, nullptr); + +Few of some mandatory feature for a cluster (i.e. cluster having O.a/O.a+ feature conformance) can be configured at cluster level. +For example: Thermostat cluster has O.a+ conformance for Heating and Cooling features, that means at least one of them should be present on the thermostat cluster while creating it. + +- feature: heating: Thermostat cluster: + + :: + + thermostat::config_t thermostat_config; + thermostat_config.features.heating.occupied_heating_setpoint = 2200; + thermostat_config.feature_flags = thermostat::feature::heating::get_id(); + cluster::thermostat::create(endpoint, &(config->thermostat_config), CLUSTER_FLAG_SERVER); + Optional features which are applicable to a cluster can also be added. - feature: taglist: Descriptor cluster: diff --git a/examples/all_device_types_app/main/esp_matter_console_helpers.cpp b/examples/all_device_types_app/main/esp_matter_console_helpers.cpp index 6102caab2..05723e268 100644 --- a/examples/all_device_types_app/main/esp_matter_console_helpers.cpp +++ b/examples/all_device_types_app/main/esp_matter_console_helpers.cpp @@ -210,6 +210,7 @@ int create(uint8_t device_type_index) } case ESP_MATTER_GENERIC_SWITCH: { esp_matter::endpoint::generic_switch::config_t generic_switch_config; + generic_switch_config.switch_cluster.feature_flags = cluster::switch_cluster::feature::latching_switch::get_id(); endpoint = esp_matter::endpoint::generic_switch::create(node, &generic_switch_config, ENDPOINT_FLAG_NONE, NULL); break; } @@ -257,6 +258,7 @@ int create(uint8_t device_type_index) } case ESP_MATTER_THERMOSTAT: { esp_matter::endpoint::thermostat::config_t thermostat_config; + thermostat_config.thermostat.feature_flags = cluster::thermostat::feature::auto_mode::get_id(); endpoint = esp_matter::endpoint::thermostat::create(node, &thermostat_config, ENDPOINT_FLAG_NONE, NULL); break; } @@ -282,9 +284,9 @@ int create(uint8_t device_type_index) } case ESP_MATTER_WINDOW_COVERING_DEVICE: { esp_matter::endpoint::window_covering_device::config_t window_covering_device_config; + window_covering_device_config.window_covering.feature_flags = cluster::window_covering::feature::lift::get_id(); endpoint = esp_matter::endpoint::window_covering_device::create(node, &window_covering_device_config, ENDPOINT_FLAG_NONE, NULL); cluster_t *cluster = cluster::get(endpoint, chip::app::Clusters::WindowCovering::Id); - cluster::window_covering::feature::lift::config_t lift; cluster::window_covering::feature::position_aware_lift::config_t position_aware_lift; cluster::window_covering::feature::absolute_position::config_t absolute_position; @@ -294,7 +296,6 @@ int create(uint8_t device_type_index) position_aware_lift.target_position_lift_percent_100ths = percentage_100ths; position_aware_lift.current_position_lift_percent_100ths = percentage_100ths; - cluster::window_covering::feature::lift::add(cluster, &lift); cluster::window_covering::feature::position_aware_lift::add(cluster, &position_aware_lift); cluster::window_covering::feature::absolute_position::add(cluster, &absolute_position); break; @@ -348,11 +349,13 @@ int create(uint8_t device_type_index) } case ESP_MATTER_RAC: { esp_matter::endpoint::room_air_conditioner::config_t room_air_conditioner_config; + room_air_conditioner_config.thermostat.feature_flags = cluster::thermostat::feature::cooling::get_id(); endpoint = esp_matter::endpoint::room_air_conditioner::create(node, &room_air_conditioner_config, ENDPOINT_FLAG_NONE, NULL); break; } case ESP_MATTER_TEMP_CTRL_CABINET: { esp_matter::endpoint::temperature_controlled_cabinet::config_t temperature_controlled_cabinet_config; + temperature_controlled_cabinet_config.temperature_control.feature_flags = cluster::temperature_control::feature::temperature_number::get_id(); endpoint = esp_matter::endpoint::temperature_controlled_cabinet::create(node, &temperature_controlled_cabinet_config, ENDPOINT_FLAG_NONE, NULL); break; } @@ -361,6 +364,7 @@ int create(uint8_t device_type_index) endpoint = esp_matter::endpoint::refrigerator::create(node, &refrigerator_config, ENDPOINT_FLAG_NONE, NULL); esp_matter::endpoint::temperature_controlled_cabinet::config_t temperature_controlled_cabinet_config; + temperature_controlled_cabinet_config.temperature_control.feature_flags = cluster::temperature_control::feature::temperature_number::get_id(); esp_matter::endpoint_t *tcc_endpoint = esp_matter::endpoint::temperature_controlled_cabinet::create(node, &temperature_controlled_cabinet_config, ENDPOINT_FLAG_NONE, NULL); if (!tcc_endpoint) { @@ -368,9 +372,6 @@ int create(uint8_t device_type_index) return 1; } - esp_matter::cluster_t *cluster = esp_matter::cluster::get(tcc_endpoint, chip::app::Clusters::TemperatureControl::Id); - cluster::temperature_control::feature::temperature_number::config_t temperature_number_config; - cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config); break; } case ESP_MATTER_OVEN: { @@ -378,16 +379,13 @@ int create(uint8_t device_type_index) endpoint = esp_matter::endpoint::oven::create(node, &oven_config, ENDPOINT_FLAG_NONE, NULL); esp_matter::endpoint::temperature_controlled_cabinet::config_t temperature_controlled_cabinet_config; + temperature_controlled_cabinet_config.temperature_control.feature_flags = cluster::temperature_control::feature::temperature_number::get_id(); esp_matter::endpoint_t *tcc_endpoint = esp_matter::endpoint::temperature_controlled_cabinet::create(node, &temperature_controlled_cabinet_config, ENDPOINT_FLAG_NONE, NULL); if (!tcc_endpoint) { ESP_LOGE(TAG, "Matter create endpoint failed"); return 1; } - - esp_matter::cluster_t *cluster = esp_matter::cluster::get(tcc_endpoint, chip::app::Clusters::TemperatureControl::Id); - cluster::temperature_control::feature::temperature_number::config_t temperature_number_config; - cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config); break; } case ESP_MATTER_AIR_PURIFIER: { @@ -417,9 +415,11 @@ int create(uint8_t device_type_index) } case ESP_MATTER_SMOKE_CO_ALARM: { esp_matter::endpoint::smoke_co_alarm::config_t smoke_co_alarm_config; + smoke_co_alarm_config.smoke_co_alarm.feature_flags = cluster::smoke_co_alarm::feature::smoke_alarm::get_id(); endpoint = esp_matter::endpoint::smoke_co_alarm::create(node, &smoke_co_alarm_config, ENDPOINT_FLAG_NONE, NULL); esp_matter::endpoint::power_source_device::config_t power_source_config; + power_source_config.power_source.feature_flags = cluster::power_source::feature::wired::get_id(); esp_matter::endpoint_t *ps_endpoint = esp_matter::endpoint::power_source_device::create(node, &power_source_config, ENDPOINT_FLAG_NONE, NULL); if (!ps_endpoint) { @@ -440,6 +440,7 @@ int create(uint8_t device_type_index) } case ESP_MATTER_POWER_SOURCE: { esp_matter::endpoint::power_source_device::config_t power_source_device_config; + power_source_device_config.power_source.feature_flags = esp_matter::cluster::power_source::feature::wired::get_id(); endpoint = esp_matter::endpoint::power_source_device::create(node, &power_source_device_config, ENDPOINT_FLAG_NONE, NULL); break; } @@ -450,6 +451,8 @@ int create(uint8_t device_type_index) } case ESP_MATTER_ELECTRICAL_SENSOR: { esp_matter::endpoint::electrical_sensor::config_t electrical_sensor_config; + electrical_sensor_config.power_topology.feature_flags = esp_matter::cluster::power_topology::feature::node_topology::get_id(); + electrical_sensor_config.electrical_power_measurement.feature_flags = esp_matter::cluster::electrical_power_measurement::feature::direct_current::get_id(); endpoint = esp_matter::endpoint::electrical_sensor::create(node, &electrical_sensor_config, ENDPOINT_FLAG_NONE, NULL); break; } @@ -533,6 +536,7 @@ int create(uint8_t device_type_index) } case ESP_MATTER_WATER_HEATER: { esp_matter::endpoint::water_heater::config_t water_heater_config; + water_heater_config.thermostat.feature_flags = cluster::thermostat::feature::heating::get_id(); endpoint = esp_matter::endpoint::water_heater::create(node, &water_heater_config, ENDPOINT_FLAG_NONE, NULL); break; } diff --git a/examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp b/examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp index 6d844124b..5ef0e6faf 100644 --- a/examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp +++ b/examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp @@ -150,16 +150,12 @@ extern "C" void app_main() color_temperature_light::config_t light_config; light_config.on_off.on_off = DEFAULT_POWER; - light_config.on_off.features.lighting.start_up_on_off = nullptr; + light_config.on_off_lighting.start_up_on_off = nullptr; light_config.level_control.current_level = DEFAULT_BRIGHTNESS; - light_config.level_control.features.lighting.start_up_current_level = DEFAULT_BRIGHTNESS; + light_config.level_control_lighting.start_up_current_level = DEFAULT_BRIGHTNESS; light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; - light_config.color_control.features.color_temperature.startup_color_temperature_mireds = nullptr; - - light_config.on_off.feature_flags = cluster::on_off::feature::lighting::get_id(); - light_config.level_control.feature_flags = cluster::level_control::feature::lighting::get_id(); - light_config.color_control.feature_flags = cluster::color_control::feature::color_temperature::get_id(); + light_config.color_control_color_temperature.startup_color_temperature_mireds = nullptr; // endpoint handles can be used to add/modify clusters. endpoint_t *endpoint = color_temperature_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle); diff --git a/examples/demo/badge/main/app_main.cpp b/examples/demo/badge/main/app_main.cpp index 340c60037..a37ad55ae 100644 --- a/examples/demo/badge/main/app_main.cpp +++ b/examples/demo/badge/main/app_main.cpp @@ -307,8 +307,7 @@ extern "C" void app_main() on_off_light::config_t light_config; light_config.on_off.on_off = DEFAULT_POWER; - light_config.on_off.features.lighting.start_up_on_off = nullptr; - light_config.on_off.feature_flags = cluster::on_off::feature::lighting::get_id(); + light_config.on_off_lighting.start_up_on_off = nullptr; endpoint_t *endpoint = on_off_light::create(node, &light_config, ENDPOINT_FLAG_NONE, NULL); ABORT_APP_ON_FAILURE(endpoint != nullptr, ESP_LOGE(TAG, "Failed to create on off light endpoint")); diff --git a/examples/generic_switch/main/app_main.cpp b/examples/generic_switch/main/app_main.cpp index 10aa78de7..7f4df773c 100644 --- a/examples/generic_switch/main/app_main.cpp +++ b/examples/generic_switch/main/app_main.cpp @@ -134,6 +134,15 @@ static esp_err_t create_button(struct gpio_button* button, node_t* node) /* Create a new endpoint. */ generic_switch::config_t switch_config; + switch_config.switch_cluster.feature_flags = +#if CONFIG_GENERIC_SWITCH_TYPE_LATCHING + cluster::switch_cluster::feature::latching_switch::get_id(); +#endif + +#if CONFIG_GENERIC_SWITCH_TYPE_MOMENTARY + cluster::switch_cluster::feature::momentary_switch::get_id(); +#endif + endpoint_t *endpoint = generic_switch::create(node, &switch_config, ENDPOINT_FLAG_NONE, button_handle); cluster_t* descriptor = cluster::get(endpoint,Descriptor::Id); @@ -173,12 +182,7 @@ static esp_err_t create_button(struct gpio_button* button, node_t* node) /* Add additional features to the node */ cluster_t *cluster = cluster::get(endpoint, Switch::Id); -#if CONFIG_GENERIC_SWITCH_TYPE_LATCHING - cluster::switch_cluster::feature::latching_switch::add(cluster); -#endif - #if CONFIG_GENERIC_SWITCH_TYPE_MOMENTARY - cluster::switch_cluster::feature::momentary_switch::add(cluster); cluster::switch_cluster::feature::action_switch::add(cluster); cluster::switch_cluster::feature::momentary_switch_multi_press::config_t msm; msm.multi_press_max = 5; diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index caaf6a5fb..6b10c42f3 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -191,17 +191,13 @@ extern "C" void app_main() extended_color_light::config_t light_config; light_config.on_off.on_off = DEFAULT_POWER; - light_config.on_off.features.lighting.start_up_on_off = nullptr; + light_config.on_off_lighting.start_up_on_off = nullptr; light_config.level_control.current_level = DEFAULT_BRIGHTNESS; light_config.level_control.on_level = DEFAULT_BRIGHTNESS; - light_config.level_control.features.lighting.start_up_current_level = DEFAULT_BRIGHTNESS; + light_config.level_control_lighting.start_up_current_level = DEFAULT_BRIGHTNESS; light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; - light_config.color_control.features.color_temperature.startup_color_temperature_mireds = nullptr; - - light_config.on_off.feature_flags = cluster::on_off::feature::lighting::get_id(); - light_config.level_control.feature_flags = cluster::level_control::feature::lighting::get_id(); - light_config.color_control.feature_flags = cluster::color_control::feature::color_temperature::get_id() | cluster::color_control::feature::xy::get_id(); + light_config.color_control_color_temperature.startup_color_temperature_mireds = nullptr; // endpoint handles can be used to add/modify clusters. endpoint_t *endpoint = extended_color_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle); diff --git a/examples/light_network_prov/main/app_main.cpp b/examples/light_network_prov/main/app_main.cpp index e290976a5..fc222d3d4 100644 --- a/examples/light_network_prov/main/app_main.cpp +++ b/examples/light_network_prov/main/app_main.cpp @@ -235,17 +235,13 @@ extern "C" void app_main() extended_color_light::config_t light_config; light_config.on_off.on_off = DEFAULT_POWER; - light_config.on_off.features.lighting.start_up_on_off = nullptr; + light_config.on_off_lighting.start_up_on_off = nullptr; light_config.level_control.current_level = DEFAULT_BRIGHTNESS; light_config.level_control.on_level = DEFAULT_BRIGHTNESS; - light_config.level_control.features.lighting.start_up_current_level = DEFAULT_BRIGHTNESS; + light_config.level_control_lighting.start_up_current_level = DEFAULT_BRIGHTNESS; light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; - light_config.color_control.features.color_temperature.startup_color_temperature_mireds = nullptr; - - light_config.on_off.feature_flags = cluster::on_off::feature::lighting::get_id(); - light_config.level_control.feature_flags = cluster::level_control::feature::lighting::get_id(); - light_config.color_control.feature_flags = cluster::color_control::feature::color_temperature::get_id(); + light_config.color_control_color_temperature.startup_color_temperature_mireds = nullptr; // endpoint handles can be used to add/modify clusters. endpoint_t *endpoint = extended_color_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle); diff --git a/examples/managed_component_light/main/app_main.cpp b/examples/managed_component_light/main/app_main.cpp index f119b14fa..4dc60a3a4 100644 --- a/examples/managed_component_light/main/app_main.cpp +++ b/examples/managed_component_light/main/app_main.cpp @@ -164,10 +164,10 @@ extern "C" void app_main() extended_color_light::config_t light_config; light_config.on_off.on_off = DEFAULT_POWER; - light_config.on_off.lighting.start_up_on_off = nullptr; + //light_config.on_off_lighting.start_up_on_off = nullptr; light_config.level_control.current_level = DEFAULT_BRIGHTNESS; light_config.level_control.on_level = DEFAULT_BRIGHTNESS; - light_config.level_control.lighting.start_up_current_level = DEFAULT_BRIGHTNESS; + //light_config.level_control_lighting.start_up_current_level = DEFAULT_BRIGHTNESS; light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature; light_config.color_control.color_temperature.startup_color_temperature_mireds = nullptr; diff --git a/examples/refrigerator/main/app_main.cpp b/examples/refrigerator/main/app_main.cpp index 3d8c7e8c7..84ada01af 100644 --- a/examples/refrigerator/main/app_main.cpp +++ b/examples/refrigerator/main/app_main.cpp @@ -114,12 +114,6 @@ extern "C" void app_main() endpoint_t *endpoint1 = temperature_controlled_cabinet::create(node, &temperature_controlled_cabinet_config, ENDPOINT_FLAG_NONE, NULL); ABORT_APP_ON_FAILURE(endpoint1 != nullptr, ESP_LOGE(TAG, "Failed to create temperature controlled cabinet endpoint")); - esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpoint1, chip::app::Clusters::TemperatureControl::Id); - - // Atlest one of temperature_number and temperature_level feature is mandatory. - cluster::temperature_control::feature::temperature_number::config_t temperature_number_config; - cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config); - refrigerator_endpoint_id = endpoint::get_id(endpoint); ESP_LOGI(TAG, "Refrigerator created with endpoint_id %d", refrigerator_endpoint_id); diff --git a/examples/thread_border_router/main/app_main.cpp b/examples/thread_border_router/main/app_main.cpp index 72d3dda39..e2d119b0b 100644 --- a/examples/thread_border_router/main/app_main.cpp +++ b/examples/thread_border_router/main/app_main.cpp @@ -82,12 +82,13 @@ extern "C" void app_main() } thread_border_router::config_t tbr_config; tbr_config.thread_border_router_management.delegate = delegate; - tbr_config.thread_border_router_management.feature_flags = cluster::thread_border_router_management::feature::pan_change::get_id(); endpoint_t *tbr_endpoint = thread_border_router::create(node, &tbr_config, ENDPOINT_FLAG_NONE, NULL); if (!node || !tbr_endpoint) { ESP_LOGE(TAG, "Failed to create data model"); return; } + cluster_t *tbr_cluster = cluster::get(tbr_endpoint, ThreadBorderRouterManagement::Id); + cluster::thread_border_router_management::feature::pan_change::add(tbr_cluster); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD #if defined(CONFIG_OPENTHREAD_BORDER_ROUTER) && defined(CONFIG_AUTO_UPDATE_RCP) esp_vfs_spiffs_conf_t rcp_fw_conf = {