diff --git a/components/esp_matter/CMakeLists.txt b/components/esp_matter/CMakeLists.txt index ad79e53c2..ecb13287b 100644 --- a/components/esp_matter/CMakeLists.txt +++ b/components/esp_matter/CMakeLists.txt @@ -11,8 +11,7 @@ set(INCLUDE_DIRS_LIST "." "${MATTER_SDK_PATH}/src") # TODO: These files have compilation errors -set(EXCLUDE_SRCS_LIST "${MATTER_SDK_PATH}/src/app/clusters/closure-control-server/closure-control-server.cpp" - "${MATTER_SDK_PATH}/src/app/clusters/commodity-tariff-server/commodity-tariff-server.cpp" +set(EXCLUDE_SRCS_LIST "${MATTER_SDK_PATH}/src/app/clusters/commodity-tariff-server/commodity-tariff-server.cpp" "${MATTER_SDK_PATH}/src/app/clusters/commodity-tariff-server/CommodityTariffAttrsDataMgmt.cpp") set(PRIV_INCLUDE_DIRS_LIST ) diff --git a/components/esp_matter/data_model/esp_matter_endpoint.cpp b/components/esp_matter/data_model/esp_matter_endpoint.cpp index b86846915..5f4ea917b 100644 --- a/components/esp_matter/data_model/esp_matter_endpoint.cpp +++ b/components/esp_matter/data_model/esp_matter_endpoint.cpp @@ -2091,6 +2091,90 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) return ESP_OK; } } /* thermostat_controller */ + +namespace closure_controller { +uint32_t get_device_type_id() +{ + return ESP_MATTER_CLOSURE_CONTROLLER_DEVICE_TYPE_ID; +} + +uint8_t get_device_type_version() +{ + return ESP_MATTER_CLOSURE_CONTROLLER_DEVICE_TYPE_VERSION; +} +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) +{ + endpoint_t * endpoint = common::create(node, config, flags, priv_data, add); + VerifyOrReturnError(endpoint != nullptr, NULL); + + cluster_t *binding_cluster = binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); + VerifyOrReturnValue(binding_cluster != nullptr, NULL, ESP_LOGE(TAG, "Failed to create binding cluster")); + + return endpoint; +} + +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); + cluster::closure_control::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); + + return ESP_OK; +} +} /* closure_controller */ + +namespace closure { +uint32_t get_device_type_id() +{ + return ESP_MATTER_CLOSURE_DEVICE_TYPE_ID; +} + +uint8_t get_device_type_version() +{ + return ESP_MATTER_CLOSURE_DEVICE_TYPE_VERSION; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) +{ + return common::create(node, config, flags, priv_data, add); +} + +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); + cluster::identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + cluster::closure_control::create(endpoint, &(config->closure_control), CLUSTER_FLAG_SERVER); + + return ESP_OK; +} +} /* closure */ + +namespace closure_panel { +uint32_t get_device_type_id() +{ + return ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_ID; +} + +uint8_t get_device_type_version() +{ + return ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_VERSION; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) +{ + return common::create(node, config, flags, priv_data, add); +} + +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); + cluster::closure_dimension::create(endpoint, &(config->closure_dimension), CLUSTER_FLAG_SERVER); + + return ESP_OK; +} +} /* closure_panel */ } /* endpoint */ namespace node { diff --git a/components/esp_matter/data_model/esp_matter_endpoint.h b/components/esp_matter/data_model/esp_matter_endpoint.h index 3fb87b9ba..2653ccd31 100644 --- a/components/esp_matter/data_model/esp_matter_endpoint.h +++ b/components/esp_matter/data_model/esp_matter_endpoint.h @@ -153,6 +153,12 @@ #define ESP_MATTER_CAMERA_DEVICE_TYPE_ID 0x0142 #define ESP_MATTER_CAMERA_DEVICE_TYPE_VERSION 1 +#define ESP_MATTER_CLOSURE_CONTROLLER_DEVICE_TYPE_ID 0x023E +#define ESP_MATTER_CLOSURE_CONTROLLER_DEVICE_TYPE_VERSION 1 +#define ESP_MATTER_CLOSURE_DEVICE_TYPE_ID 0x0230 +#define ESP_MATTER_CLOSURE_DEVICE_TYPE_VERSION 1 +#define ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_ID 0x0231 +#define ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_VERSION 1 namespace esp_matter { @@ -1051,7 +1057,41 @@ 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); } /** thermostat_controller **/ +namespace closure_controller { +using config_t = app_client_config; +uint32_t get_device_type_id(); +uint8_t get_device_type_version(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); +esp_err_t add(endpoint_t *endpoint, config_t *config); +} /* closure_controller */ + +namespace closure { +typedef struct config : app_base_config { + cluster::closure_control::config_t closure_control; + + config() { + identify.identify_type = chip::to_underlying(chip::app::Clusters::Identify::IdentifyTypeEnum::kActuator); + } +} config_t; + +uint32_t get_device_type_id(); +uint8_t get_device_type_version(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); +esp_err_t add(endpoint_t *endpoint, config_t *config); +} /* closure */ + +namespace closure_panel { +typedef struct config { + cluster::descriptor::config_t descriptor; + cluster::closure_dimension::config_t closure_dimension; +} config_t; + +uint32_t get_device_type_id(); +uint8_t get_device_type_version(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); +esp_err_t add(endpoint_t *endpoint, config_t *config); +} /* closure_panel */ } /* endpoint */ namespace node { diff --git a/components/esp_matter/weak_functions.cpp b/components/esp_matter/weak_functions.cpp index ccba63a97..0d98d1509 100644 --- a/components/esp_matter/weak_functions.cpp +++ b/components/esp_matter/weak_functions.cpp @@ -13,6 +13,11 @@ // limitations under the License. #include +#include +#include +#include "esp_log.h" + +static const char *TAG = "weak_functions"; namespace chip { namespace app { @@ -29,3 +34,21 @@ __attribute__((weak)) const SupportedModesManager * getSupportedModesManager(voi } /* namespace Clusters */ } /* namespace ModeSelect */ + +// Provide weak defaults for attribute changed callbacks so apps +// Strong definitions in an app will override these. + +__attribute__((weak)) void MatterClosureControlClusterServerAttributeChangedCallback( + const chip::app::ConcreteAttributePath & attributePath) +{ + ESP_LOGI(TAG, "Attribute Changed Callback: Endpoint: %d, Cluster: %ld, Attribute: %ld", + attributePath.mEndpointId, attributePath.mClusterId, attributePath.mAttributeId); +} + +__attribute__((weak)) void MatterClosureDimensionClusterServerAttributeChangedCallback( + const chip::app::ConcreteAttributePath & attributePath) +{ + ESP_LOGI(TAG, "Attribute Changed Callback: Endpoint: %d, Cluster: %ld, Attribute: %ld", + attributePath.mEndpointId, attributePath.mClusterId, attributePath.mAttributeId); +} + diff --git a/examples/all_device_types_app/main/device_types.h b/examples/all_device_types_app/main/device_types.h index 30e041a4c..595509f59 100644 --- a/examples/all_device_types_app/main/device_types.h +++ b/examples/all_device_types_app/main/device_types.h @@ -60,6 +60,9 @@ enum device_type_enum { ESP_MATTER_BATTERY_STORAGE, ESP_MATTER_HEAT_PUMP, ESP_MATTER_THERMOSTAT_CONTROLLER, + ESP_MATTER_CLOSURE_CONTROLLER, + ESP_MATTER_CLOSURE, + ESP_MATTER_CLOSURE_PANEL, ESP_MATTER_DEVICE_TYPE_MAX }; @@ -126,5 +129,8 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = { {"battery_storage", ESP_MATTER_BATTERY_STORAGE}, {"heat_pump", ESP_MATTER_HEAT_PUMP}, {"thermostat_controller", ESP_MATTER_THERMOSTAT_CONTROLLER}, + {"closure_controller", ESP_MATTER_CLOSURE_CONTROLLER}, + {"closure", ESP_MATTER_CLOSURE}, + {"closure_panel", ESP_MATTER_CLOSURE_PANEL}, }; } /* namespace esp_matter */ 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 0e6b0ef7f..64138f0a6 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 @@ -587,6 +587,23 @@ int create(uint8_t device_type_index) endpoint = esp_matter::endpoint::thermostat_controller::create(node, &thermostat_controller_config, ENDPOINT_FLAG_NONE, NULL); break; } + case ESP_MATTER_CLOSURE_CONTROLLER: { + esp_matter::endpoint::closure_controller::config_t closure_controller_config; + endpoint = esp_matter::endpoint::closure_controller::create(node, &closure_controller_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_CLOSURE: { + esp_matter::endpoint::closure::config_t closure_config; + closure_config.closure_control.feature_flags = cluster::closure_control::feature::positioning::get_id(); + endpoint = esp_matter::endpoint::closure::create(node, &closure_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_CLOSURE_PANEL: { + esp_matter::endpoint::closure_panel::config_t closure_panel_config; + closure_panel_config.closure_dimension.feature_flags = cluster::closure_dimension::feature::positioning::get_id(); + endpoint = esp_matter::endpoint::closure_panel::create(node, &closure_panel_config, ENDPOINT_FLAG_NONE, NULL); + break; + } default: { ESP_LOGE(TAG, "Please input a valid device type"); break;