diff --git a/components/esp_matter/esp_matter.h b/components/esp_matter/esp_matter.h index 6bd44acb1..68fbfd3a9 100644 --- a/components/esp_matter/esp_matter.h +++ b/components/esp_matter/esp_matter.h @@ -21,9 +21,9 @@ application. #include #include +#include #include #include -#include #include #include #include @@ -48,7 +48,8 @@ typedef enum esp_matter_cluster_flags { ESP_MATTER_CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION = CLUSTER_MASK_ATTRIBUTE_CHANGED_FUNCTION, /* 0x02 */ ESP_MATTER_CLUSTER_FLAG_DEFAULT_RESPONSE_FUNCTION = CLUSTER_MASK_DEFAULT_RESPONSE_FUNCTION, /* 0x04 */ ESP_MATTER_CLUSTER_FLAG_MESSAGE_SENT_FUNCTION = CLUSTER_MASK_MESSAGE_SENT_FUNCTION, /* 0x08 */ - ESP_MATTER_CLUSTER_FLAG_MANUFACTURER_SPECIFIC_ATTRIBUTE_CHANGED_FUNCTION = CLUSTER_MASK_MANUFACTURER_SPECIFIC_ATTRIBUTE_CHANGED_FUNCTION, /* 0x10 */ + ESP_MATTER_CLUSTER_FLAG_MANUFACTURER_SPECIFIC_ATTRIBUTE_CHANGED_FUNCTION = + CLUSTER_MASK_MANUFACTURER_SPECIFIC_ATTRIBUTE_CHANGED_FUNCTION, /* 0x10 */ ESP_MATTER_CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION = CLUSTER_MASK_PRE_ATTRIBUTE_CHANGED_FUNCTION, /* 0x20 */ ESP_MATTER_CLUSTER_FLAG_SERVER = CLUSTER_MASK_SERVER, /* 0x40 */ ESP_MATTER_CLUSTER_FLAG_CLIENT = CLUSTER_MASK_CLIENT, /* 0x80 */ diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index c4b863bd8..c7047e313 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -16,675 +16,786 @@ static const char *TAG = "esp_matter_attribute"; -esp_matter_attribute_t *esp_matter_attribute_create_cluster_revision(esp_matter_cluster_t *cluster, uint16_t value) +namespace esp_matter { +namespace cluster { + +namespace global { +namespace attribute { + +attribute_t *create_cluster_revision(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_feature_map(esp_matter_cluster_t *cluster, uint32_t value) +attribute_t *create_feature_map(cluster_t *cluster, uint32_t value) { - return esp_matter_attribute_create(cluster, ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bitmap32(value)); + return esp_matter::attribute::create(cluster, ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bitmap32(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_device_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +} /* attribute */ +} /* global */ + +namespace descriptor { +namespace attribute { + +attribute_t *create_device_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_DEVICE_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_DEVICE_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_server_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +attribute_t *create_server_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_SERVER_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_SERVER_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_client_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +attribute_t *create_client_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_CLIENT_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_CLIENT_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_parts_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +attribute_t *create_parts_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_PARTS_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_PARTS_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_acl(esp_matter_cluster_t *cluster, uint8_t *value, uint16_t length, - uint16_t count) +} /* attribute */ +} /* descriptor */ + +namespace access_control { +namespace attribute { + +attribute_t *create_acl(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_ACL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_ACL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_extension(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +attribute_t *create_extension(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_EXTENSION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_EXTENSION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_data_model_revision(esp_matter_cluster_t *cluster, uint16_t value) +} /* attribute */ +} /* access_control */ + +namespace basic { +namespace attribute { + +attribute_t *create_data_model_revision(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_DATA_MODEL_REVISION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_DATA_MODEL_REVISION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_vendor_name(esp_matter_cluster_t *cluster, char *value, - uint16_t length) +attribute_t *create_vendor_name(cluster_t *cluster, char *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_VENDOR_NAME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_char_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_VENDOR_NAME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_char_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_vendor_id(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_vendor_id(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_VENDOR_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_VENDOR_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_product_name(esp_matter_cluster_t *cluster, char *value, - uint16_t length) +attribute_t *create_product_name(cluster_t *cluster, char *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_PRODUCT_NAME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_char_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_PRODUCT_NAME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_char_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_product_id(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_product_id(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_PRODUCT_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_PRODUCT_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_node_label(esp_matter_cluster_t *cluster, char *value, - uint16_t length) +attribute_t *create_node_label(cluster_t *cluster, char *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_NODE_LABEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_char_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_NODE_LABEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_char_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_location(esp_matter_cluster_t *cluster, char *value, - uint16_t length) +attribute_t *create_location(cluster_t *cluster, char *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_LOCATION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_char_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_LOCATION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_char_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_hardware_version(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_hardware_version(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_HARDWARE_VERSION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_HARDWARE_VERSION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_hardware_version_string(esp_matter_cluster_t *cluster, char *value, - uint16_t length) +attribute_t *create_hardware_version_string(cluster_t *cluster, char *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_software_version(esp_matter_cluster_t *cluster, uint32_t value) +attribute_t *create_software_version(cluster_t *cluster, uint32_t value) { - return esp_matter_attribute_create(cluster, ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint32(value)); + return esp_matter::attribute::create(cluster, ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint32(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_software_version_string(esp_matter_cluster_t *cluster, char *value, - uint16_t length) +attribute_t *create_software_version_string(cluster_t *cluster, char *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_binding(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +} /* attribute */ +} /* basic */ + +namespace binding { +namespace attribute { + +attribute_t *create_binding(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_BINDING_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_BINDING_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_default_ota_providers(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length) +} /* attribute */ +} /* binding */ + +namespace ota_requestor { +namespace attribute { + +attribute_t *create_default_ota_providers(cluster_t *cluster, uint8_t *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_DEFAULT_OTA_PROVIDERS_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_octet_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_DEFAULT_OTA_PROVIDERS_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_octet_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_update_possible(esp_matter_cluster_t *cluster, bool value) +attribute_t *create_update_possible(cluster_t *cluster, bool value) { - return esp_matter_attribute_create(cluster, ZCL_UPDATE_POSSIBLE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bool(value)); + return esp_matter::attribute::create(cluster, ZCL_UPDATE_POSSIBLE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bool(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_update_state(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_update_state(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_UPDATE_STATE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_UPDATE_STATE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_update_state_progress(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_update_state_progress(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_UPDATE_STATE_PROGRESS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_UPDATE_STATE_PROGRESS_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_breadcrumb(esp_matter_cluster_t *cluster, uint64_t value) +} /* attribute */ +} /* ota_requestor */ + +namespace general_commissioning { +namespace attribute { + +attribute_t *create_breadcrumb(cluster_t *cluster, uint64_t value) { - return esp_matter_attribute_create(cluster, ZCL_BREADCRUMB_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_uint64(value)); + return esp_matter::attribute::create(cluster, ZCL_BREADCRUMB_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_uint64(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_basic_commissioning_info(esp_matter_cluster_t *cluster, - uint8_t *value, uint16_t length, - uint16_t count) +attribute_t *create_basic_commissioning_info(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_BASICCOMMISSIONINGINFO_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_BASICCOMMISSIONINGINFO_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_regulatory_config(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_regulatory_config(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_REGULATORYCONFIG_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_REGULATORYCONFIG_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_location_capability(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_location_capability(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_LOCATIONCAPABILITY_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_LOCATIONCAPABILITY_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_max_networks(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* general_commissioning */ + +namespace network_commissioning { +namespace attribute { + +attribute_t *create_max_networks(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_MAX_NETWORKS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_MAX_NETWORKS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_networks(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +attribute_t *create_networks(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_NETWORKS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_NETWORKS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_scan_max_time_seconds(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_scan_max_time_seconds(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_SCAN_MAX_TIME_SECONDS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_SCAN_MAX_TIME_SECONDS_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_connect_max_time_seconds(esp_matter_cluster_t *cluster, - uint8_t value) +attribute_t *create_connect_max_time_seconds(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_CONNECT_MAX_TIME_SECONDS_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_CONNECT_MAX_TIME_SECONDS_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_interface_enabled(esp_matter_cluster_t *cluster, bool value) +attribute_t *create_interface_enabled(cluster_t *cluster, bool value) { - return esp_matter_attribute_create(cluster, ZCL_INTERFACE_ENABLED_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_bool(value)); + return esp_matter::attribute::create(cluster, ZCL_INTERFACE_ENABLED_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_bool(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_last_networking_status(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_last_networking_status(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_LAST_NETWORKING_STATUS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_LAST_NETWORKING_STATUS_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_last_network_id(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length) +attribute_t *create_last_network_id(cluster_t *cluster, uint8_t *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_LAST_NETWORK_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_octet_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_LAST_NETWORK_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_octet_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_last_connect_error_value(esp_matter_cluster_t *cluster, - uint32_t value) +attribute_t *create_last_connect_error_value(cluster_t *cluster, uint32_t value) { - return esp_matter_attribute_create(cluster, ZCL_LAST_CONNECT_ERROR_VALUE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value)); + return esp_matter::attribute::create(cluster, ZCL_LAST_CONNECT_ERROR_VALUE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_network_interfaces(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +} /* attribute */ +} /* network_commissioning */ + +namespace general_diagnostics { +namespace attribute { + +attribute_t *create_network_interfaces(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_NETWORK_INTERFACES_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_NETWORK_INTERFACES_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_reboot_count(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_reboot_count(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_REBOOT_COUNT_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_REBOOT_COUNT_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_window_status(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* general_diagnostics */ + +namespace administrator_commissioning { +namespace attribute { + +attribute_t *create_window_status(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_WINDOW_STATUS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_WINDOW_STATUS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_admin_fabric_index(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_admin_fabric_index(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_ADMIN_FABRIC_INDEX_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_ADMIN_FABRIC_INDEX_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_admin_vendor_id(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_admin_vendor_id(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_ADMIN_VENDOR_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_ADMIN_VENDOR_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_nocs(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +} /* attribute */ +} /* administrator_commissioning */ + +namespace operational_credentials { +namespace attribute { + +attribute_t *create_nocs(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_NOCS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_NOCS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_fabrics(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +attribute_t *create_fabrics(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_FABRICS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_FABRICS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_supported_fabrics(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_supported_fabrics(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_SUPPORTED_FABRICS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_SUPPORTED_FABRICS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_commissioned_fabrics(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_commissioned_fabrics(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_COMMISSIONED_FABRICS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_COMMISSIONED_FABRICS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_trusted_root_certificates(esp_matter_cluster_t *cluster, - uint8_t *value, uint16_t length, - uint16_t count) +attribute_t *create_trusted_root_certificates(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_TRUSTED_ROOTS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_TRUSTED_ROOTS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_current_fabric_index(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_current_fabric_index(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_CURRENT_FABRIC_INDEX_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_CURRENT_FABRIC_INDEX_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_group_key_map(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +} /* attribute */ +} /* operational_credentials */ + +namespace group_key_management { +namespace attribute { + +attribute_t *create_group_key_map(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_GROUP_KEY_MAP_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_GROUP_KEY_MAP_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_group_table(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +attribute_t *create_group_table(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_GROUP_TABLE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_GROUP_TABLE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_max_groups_per_fabric(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_max_groups_per_fabric(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_MAX_GROUPS_PER_FABRIC_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_MAX_GROUPS_PER_FABRIC_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_max_group_keys_per_fabric(esp_matter_cluster_t *cluster, - uint16_t value) +attribute_t *create_max_group_keys_per_fabric(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_MAX_GROUP_KEYS_PER_FABRIC_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_MAX_GROUP_KEYS_PER_FABRIC_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_identify_time(esp_matter_cluster_t *cluster, uint16_t value, - uint16_t min, uint16_t max) +} /* attribute */ +} /* group_key_management */ + +namespace identify { +namespace attribute { + +attribute_t *create_identify_time(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max) { - esp_matter_attribute_t *attribute = esp_matter_attribute_create(cluster, ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_uint16(value)); + attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_uint16(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter_attribute_add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max)); return attribute; } -esp_matter_attribute_t *esp_matter_attribute_create_identify_type(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_identify_type(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_IDENTIFY_TYPE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_IDENTIFY_TYPE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_group_name_support(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* identify */ + +namespace groups { +namespace attribute { + +attribute_t *create_group_name_support(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_GROUP_NAME_SUPPORT_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bitmap8(value)); + return esp_matter::attribute::create(cluster, ZCL_GROUP_NAME_SUPPORT_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bitmap8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_scene_count(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* groups */ + +namespace scenes { +namespace attribute { + +attribute_t *create_scene_count(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_SCENE_COUNT_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_SCENE_COUNT_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_current_scene(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_current_scene(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_CURRENT_SCENE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_CURRENT_SCENE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_current_group(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_current_group(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_CURRENT_GROUP_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_CURRENT_GROUP_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_scene_valid(esp_matter_cluster_t *cluster, bool value) +attribute_t *create_scene_valid(cluster_t *cluster, bool value) { - return esp_matter_attribute_create(cluster, ZCL_SCENE_VALID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bool(value)); + return esp_matter::attribute::create(cluster, ZCL_SCENE_VALID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bool(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_scene_name_support(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_scene_name_support(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_SCENE_NAME_SUPPORT_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bitmap8(value)); + return esp_matter::attribute::create(cluster, ZCL_SCENE_NAME_SUPPORT_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bitmap8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_on_off(esp_matter_cluster_t *cluster, bool value) +} /* attribute */ +} /* scenes */ + +namespace on_off { +namespace attribute { + +attribute_t *create_on_off(cluster_t *cluster, bool value) { - return esp_matter_attribute_create(cluster, ZCL_ON_OFF_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bool(value)); + return esp_matter::attribute::create(cluster, ZCL_ON_OFF_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bool(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_global_scene_control(esp_matter_cluster_t *cluster, bool value) +attribute_t *create_global_scene_control(cluster_t *cluster, bool value) { - return esp_matter_attribute_create(cluster, ZCL_GLOBAL_SCENE_CONTROL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bool(value)); + return esp_matter::attribute::create(cluster, ZCL_GLOBAL_SCENE_CONTROL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bool(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_on_time(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_on_time(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_ON_TIME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_ON_TIME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_off_wait_time(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_off_wait_time(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_OFF_WAIT_TIME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_OFF_WAIT_TIME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_start_up_on_off(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_start_up_on_off(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_START_UP_ON_OFF_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_START_UP_ON_OFF_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_current_level(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* on_off */ + +namespace level_control { +namespace attribute { + +attribute_t *create_current_level(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_on_level(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_on_level(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_ON_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_ON_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_options(esp_matter_cluster_t *cluster, uint8_t value, uint8_t min, - uint8_t max) +attribute_t *create_options(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { - esp_matter_attribute_t *attribute = esp_matter_attribute_create(cluster, ZCL_OPTIONS_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_bitmap8(value)); + attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_OPTIONS_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_bitmap8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter_attribute_add_bounds(attribute, esp_matter_bitmap8(min), esp_matter_bitmap8(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_bitmap8(min), esp_matter_bitmap8(max)); return attribute; } -esp_matter_attribute_t *esp_matter_attribute_create_remaining_time(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_remaining_time(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_REMAINING_TIME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_REMAINING_TIME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_min_level(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_min_level(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_MIN_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_MINIMUM_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_max_level(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_max_level(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_MAX_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_MAXIMUM_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_start_up_current_level(esp_matter_cluster_t *cluster, - uint8_t value) +attribute_t *create_start_up_current_level(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_START_UP_CURRENT_LEVEL_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_START_UP_CURRENT_LEVEL_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_current_hue(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* level_control */ + +namespace color_control { +namespace attribute { + +attribute_t *create_current_hue(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_current_saturation(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_current_saturation(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_color_mode(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_color_mode(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_COLOR_CONTROL_COLOR_MODE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_COLOR_CONTROL_COLOR_MODE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_color_control_options(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_color_control_options(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_COLOR_CONTROL_OPTIONS_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_bitmap8(value)); + return esp_matter::attribute::create(cluster, ZCL_COLOR_CONTROL_OPTIONS_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_bitmap8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_enhanced_color_mode(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_enhanced_color_mode(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_COLOR_CONTROL_ENHANCED_COLOR_MODE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_COLOR_CONTROL_ENHANCED_COLOR_MODE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_color_capabilities(esp_matter_cluster_t *cluster, uint16_t value) +attribute_t *create_color_capabilities(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_COLOR_CONTROL_COLOR_CAPABILITIES_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_bitmap16(value)); + return esp_matter::attribute::create(cluster, ZCL_COLOR_CONTROL_COLOR_CAPABILITIES_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_bitmap16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_fan_mode(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* color_control */ + +namespace fan_control { +namespace attribute { + +attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_fan_mode_sequence(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_fan_mode_sequence(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_local_temperature(esp_matter_cluster_t *cluster, uint16_t value) +} /* attribute */ +} /* fan_control */ + +namespace thermostat { +namespace attribute { + +attribute_t *create_local_temperature(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_occupied_cooling_setpoint(esp_matter_cluster_t *cluster, - uint16_t value) +attribute_t *create_occupied_cooling_setpoint(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_OCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_OCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_occupied_heating_setpoint(esp_matter_cluster_t *cluster, - uint16_t value) +attribute_t *create_occupied_heating_setpoint(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value)); + return esp_matter::attribute::create(cluster, ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_control_sequence_of_operation(esp_matter_cluster_t *cluster, - uint8_t value, uint8_t min, - uint8_t max) +attribute_t *create_control_sequence_of_operation(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { - esp_matter_attribute_t *attribute = esp_matter_attribute_create(cluster, - ZCL_CONTROL_SEQUENCE_OF_OPERATION_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_enum8(value)); + attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_CONTROL_SEQUENCE_OF_OPERATION_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_enum8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter_attribute_add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); return attribute; } -esp_matter_attribute_t *esp_matter_attribute_create_system_mode(esp_matter_cluster_t *cluster, uint8_t value, - uint8_t min, uint8_t max) +attribute_t *create_system_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { - esp_matter_attribute_t *attribute = esp_matter_attribute_create(cluster, ZCL_SYSTEM_MODE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_enum8(value)); + attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_SYSTEM_MODE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_enum8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter_attribute_add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); return attribute; } -esp_matter_attribute_t *esp_matter_attribute_create_lock_state(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* thermostat */ + +namespace door_lock { +namespace attribute { + +attribute_t *create_lock_state(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_LOCK_STATE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_LOCK_STATE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_lock_type(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_lock_type(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_LOCK_TYPE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_enum8(value)); + return esp_matter::attribute::create(cluster, ZCL_LOCK_TYPE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_enum8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_actuator_enabled(esp_matter_cluster_t *cluster, bool value) +attribute_t *create_actuator_enabled(cluster_t *cluster, bool value) { - return esp_matter_attribute_create(cluster, ZCL_ACTUATOR_ENABLED_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bool(value)); + return esp_matter::attribute::create(cluster, ZCL_ACTUATOR_ENABLED_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bool(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_auto_relock_time(esp_matter_cluster_t *cluster, uint32_t value) +attribute_t *create_auto_relock_time(cluster_t *cluster, uint32_t value) { - return esp_matter_attribute_create(cluster, ZCL_AUTO_RELOCK_TIME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_bitmap32(value)); + return esp_matter::attribute::create(cluster, ZCL_AUTO_RELOCK_TIME_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_bitmap32(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_operating_mode(esp_matter_cluster_t *cluster, uint8_t value, - uint8_t min, uint8_t max) +attribute_t *create_operating_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { - esp_matter_attribute_t *attribute = esp_matter_attribute_create(cluster, ZCL_OPERATING_MODE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_enum8(value)); + attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_OPERATING_MODE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter_attribute_add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max)); return attribute; } -esp_matter_attribute_t *esp_matter_attribute_create_supported_operating_modes(esp_matter_cluster_t *cluster, - uint16_t value) +attribute_t *create_supported_operating_modes(cluster_t *cluster, uint16_t value) { - return esp_matter_attribute_create(cluster, ZCL_SUPPORTED_OPERATING_MODES_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_bitmap16(value)); + return esp_matter::attribute::create(cluster, ZCL_SUPPORTED_OPERATING_MODES_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_bitmap16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_bridged_device_basic_node_label(esp_matter_cluster_t *cluster, - char *value, uint16_t length) +} /* attribute */ +} /* door_lock */ + +namespace bridged_device_basic { +namespace attribute { + +attribute_t *create_bridged_device_basic_node_label(cluster_t *cluster, char *value, uint16_t length) { - return esp_matter_attribute_create(cluster, ZCL_NODE_LABEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_char_str(value, length)); + return esp_matter::attribute::create(cluster, ZCL_NODE_LABEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_char_str(value, length)); } -esp_matter_attribute_t *esp_matter_attribute_create_reachable(esp_matter_cluster_t *cluster, bool value) +attribute_t *create_reachable(cluster_t *cluster, bool value) { - return esp_matter_attribute_create(cluster, ZCL_REACHABLE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bool(value)); + return esp_matter::attribute::create(cluster, ZCL_REACHABLE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bool(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_label_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count) +} /* attribute */ +} /* bridged_device_basic */ + +namespace fixed_label { +namespace attribute { + +attribute_t *create_label_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) { - return esp_matter_attribute_create(cluster, ZCL_LABEL_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, - esp_matter_array(value, length, count)); + return esp_matter::attribute::create(cluster, ZCL_LABEL_LIST_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + esp_matter_array(value, length, count)); } -esp_matter_attribute_t *esp_matter_attribute_create_number_of_positions(esp_matter_cluster_t *cluster, uint8_t value) +} /* attribute */ +} /* fixed_label */ + +namespace switch_cluster { +namespace attribute { + +attribute_t *create_number_of_positions(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_NUMBER_OF_POSITIONS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_NUMBER_OF_POSITIONS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_current_position(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_current_position(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_CURRENT_POSITION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_CURRENT_POSITION_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_multi_press_max(esp_matter_cluster_t *cluster, uint8_t value) +attribute_t *create_multi_press_max(cluster_t *cluster, uint8_t value) { - return esp_matter_attribute_create(cluster, ZCL_MULTI_PRESS_MAX_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint8(value)); + return esp_matter::attribute::create(cluster, ZCL_MULTI_PRESS_MAX_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint8(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_temperature_measured_value(esp_matter_cluster_t *cluster, - int16_t value) +} /* attribute */ +} /* switch_cluster */ + +namespace temperature_measurement { +namespace attribute { + +attribute_t *create_temperature_measured_value(cluster_t *cluster, int16_t value) { - return esp_matter_attribute_create(cluster, ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_int16(value)); + return esp_matter::attribute::create(cluster, ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_int16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_temperature_min_measured_value(esp_matter_cluster_t *cluster, - int16_t value) +attribute_t *create_temperature_min_measured_value(cluster_t *cluster, int16_t value) { - return esp_matter_attribute_create(cluster, ZCL_TEMP_MIN_MEASURED_VALUE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_int16(value)); + return esp_matter::attribute::create(cluster, ZCL_TEMP_MIN_MEASURED_VALUE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_int16(value)); } -esp_matter_attribute_t *esp_matter_attribute_create_temperature_max_measured_value(esp_matter_cluster_t *cluster, - int16_t value) +attribute_t *create_temperature_max_measured_value(cluster_t *cluster, int16_t value) { - return esp_matter_attribute_create(cluster, ZCL_TEMP_MAX_MEASURED_VALUE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_int16(value)); + return esp_matter::attribute::create(cluster, ZCL_TEMP_MAX_MEASURED_VALUE_ATTRIBUTE_ID, + ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_int16(value)); } + +} /* attribute */ +} /* temperature_measurement */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index cd9583afe..d19e80afe 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -17,196 +17,232 @@ #include #include -/** cluster: global */ -esp_matter_attribute_t *esp_matter_attribute_create_cluster_revision(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_feature_map(esp_matter_cluster_t *cluster, uint32_t value); +namespace esp_matter { +namespace cluster { -/** cluster: descriptor */ -esp_matter_attribute_t *esp_matter_attribute_create_device_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_server_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_client_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_parts_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); +namespace global { +namespace attribute { +attribute_t *create_cluster_revision(cluster_t *cluster, uint16_t value); +attribute_t *create_feature_map(cluster_t *cluster, uint32_t value); +} /* attribute */ +} /* global */ -/** cluster: access control */ -esp_matter_attribute_t *esp_matter_attribute_create_acl(esp_matter_cluster_t *cluster, uint8_t *value, uint16_t length, - uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_extension(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); +namespace descriptor { +namespace attribute { +attribute_t *create_device_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_server_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_client_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_parts_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +} /* attribute */ +} /* descriptor */ -/** cluster: basic */ -esp_matter_attribute_t *esp_matter_attribute_create_data_model_revision(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_vendor_name(esp_matter_cluster_t *cluster, char *value, - uint16_t length); -esp_matter_attribute_t *esp_matter_attribute_create_vendor_id(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_product_name(esp_matter_cluster_t *cluster, char *value, - uint16_t length); -esp_matter_attribute_t *esp_matter_attribute_create_product_id(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_node_label(esp_matter_cluster_t *cluster, char *value, - uint16_t length); -esp_matter_attribute_t *esp_matter_attribute_create_location(esp_matter_cluster_t *cluster, char *value, - uint16_t length); -esp_matter_attribute_t *esp_matter_attribute_create_hardware_version(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_hardware_version_string(esp_matter_cluster_t *cluster, char *value, - uint16_t length); -esp_matter_attribute_t *esp_matter_attribute_create_software_version(esp_matter_cluster_t *cluster, uint32_t value); -esp_matter_attribute_t *esp_matter_attribute_create_software_version_string(esp_matter_cluster_t *cluster, char *value, - uint16_t length); +namespace access_control { +namespace attribute { +attribute_t *create_acl(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_extension(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +} /* attribute */ +} /* access_control */ -/** cluster: binding */ -esp_matter_attribute_t *esp_matter_attribute_create_binding(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); +namespace basic { +namespace attribute { +attribute_t *create_data_model_revision(cluster_t *cluster, uint16_t value); +attribute_t *create_vendor_name(cluster_t *cluster, char *value, uint16_t length); +attribute_t *create_vendor_id(cluster_t *cluster, uint16_t value); +attribute_t *create_product_name(cluster_t *cluster, char *value, uint16_t length); +attribute_t *create_product_id(cluster_t *cluster, uint16_t value); +attribute_t *create_node_label(cluster_t *cluster, char *value, uint16_t length); +attribute_t *create_location(cluster_t *cluster, char *value, uint16_t length); +attribute_t *create_hardware_version(cluster_t *cluster, uint16_t value); +attribute_t *create_hardware_version_string(cluster_t *cluster, char *value, uint16_t length); +attribute_t *create_software_version(cluster_t *cluster, uint32_t value); +attribute_t *create_software_version_string(cluster_t *cluster, char *value, uint16_t length); +} /* attribute */ +} /* basic */ -/** cluster: ota requestor */ -esp_matter_attribute_t *esp_matter_attribute_create_default_ota_providers(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length); -esp_matter_attribute_t *esp_matter_attribute_create_update_possible(esp_matter_cluster_t *cluster, bool value); -esp_matter_attribute_t *esp_matter_attribute_create_update_state(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_update_state_progress(esp_matter_cluster_t *cluster, uint8_t value); +namespace binding { +namespace attribute { +attribute_t *create_binding(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +} /* attribute */ +} /* binding */ -/** cluster: general commissioning */ -esp_matter_attribute_t *esp_matter_attribute_create_breadcrumb(esp_matter_cluster_t *cluster, uint64_t value); -esp_matter_attribute_t *esp_matter_attribute_create_basic_commissioning_info(esp_matter_cluster_t *cluster, - uint8_t *value, uint16_t length, - uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_regulatory_config(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_location_capability(esp_matter_cluster_t *cluster, uint8_t value); +namespace ota_requestor { +namespace attribute { +attribute_t *create_default_ota_providers(cluster_t *cluster, uint8_t *value, uint16_t length); +attribute_t *create_update_possible(cluster_t *cluster, bool value); +attribute_t *create_update_state(cluster_t *cluster, uint8_t value); +attribute_t *create_update_state_progress(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* ota_requestor */ -/** cluster: network commissioning */ -esp_matter_attribute_t *esp_matter_attribute_create_max_networks(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_networks(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_scan_max_time_seconds(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_connect_max_time_seconds(esp_matter_cluster_t *cluster, - uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_interface_enabled(esp_matter_cluster_t *cluster, bool value); -esp_matter_attribute_t *esp_matter_attribute_create_last_networking_status(esp_matter_cluster_t *cluster, - uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_last_network_id(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length); -esp_matter_attribute_t *esp_matter_attribute_create_last_connect_error_value(esp_matter_cluster_t *cluster, - uint32_t value); +namespace general_commissioning { +namespace attribute { +attribute_t *create_breadcrumb(cluster_t *cluster, uint64_t value); +attribute_t *create_basic_commissioning_info(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_regulatory_config(cluster_t *cluster, uint8_t value); +attribute_t *create_location_capability(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* general_commissioning */ -/** cluster: general diagnostics */ -esp_matter_attribute_t *esp_matter_attribute_create_network_interfaces(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_reboot_count(esp_matter_cluster_t *cluster, uint16_t value); +namespace network_commissioning { +namespace attribute { +attribute_t *create_max_networks(cluster_t *cluster, uint8_t value); +attribute_t *create_networks(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_scan_max_time_seconds(cluster_t *cluster, uint8_t value); +attribute_t *create_connect_max_time_seconds(cluster_t *cluster, uint8_t value); +attribute_t *create_interface_enabled(cluster_t *cluster, bool value); +attribute_t *create_last_networking_status(cluster_t *cluster, uint8_t value); +attribute_t *create_last_network_id(cluster_t *cluster, uint8_t *value, uint16_t length); +attribute_t *create_last_connect_error_value(cluster_t *cluster, uint32_t value); +} /* attribute */ +} /* network_commissioning */ -/** cluster: administrator commissioning */ -esp_matter_attribute_t *esp_matter_attribute_create_window_status(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_admin_fabric_index(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_admin_vendor_id(esp_matter_cluster_t *cluster, uint16_t value); +namespace general_diagnostics { +namespace attribute { +attribute_t *create_network_interfaces(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_reboot_count(cluster_t *cluster, uint16_t value); +} /* attribute */ +} /* general_diagnostics */ -/** cluster: operational credentials */ -esp_matter_attribute_t *esp_matter_attribute_create_nocs(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_fabrics(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_supported_fabrics(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_commissioned_fabrics(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_trusted_root_certificates(esp_matter_cluster_t *cluster, - uint8_t *value, uint16_t length, - uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_current_fabric_index(esp_matter_cluster_t *cluster, uint8_t value); +namespace administrator_commissioning { +namespace attribute { +attribute_t *create_window_status(cluster_t *cluster, uint8_t value); +attribute_t *create_admin_fabric_index(cluster_t *cluster, uint16_t value); +attribute_t *create_admin_vendor_id(cluster_t *cluster, uint16_t value); +} /* attribute */ +} /* administrator_commissioning */ -/** cluster: group key management */ -esp_matter_attribute_t *esp_matter_attribute_create_group_key_map(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_group_table(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); -esp_matter_attribute_t *esp_matter_attribute_create_max_groups_per_fabric(esp_matter_cluster_t *cluster, - uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_max_group_keys_per_fabric(esp_matter_cluster_t *cluster, - uint16_t value); +namespace operational_credentials { +namespace attribute { +attribute_t *create_nocs(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_fabrics(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_supported_fabrics(cluster_t *cluster, uint8_t value); +attribute_t *create_commissioned_fabrics(cluster_t *cluster, uint8_t value); +attribute_t *create_trusted_root_certificates(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_current_fabric_index(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* operational_credentials */ -/** cluster: identify */ -esp_matter_attribute_t *esp_matter_attribute_create_identify_time(esp_matter_cluster_t *cluster, uint16_t value, - uint16_t min, uint16_t max); -esp_matter_attribute_t *esp_matter_attribute_create_identify_type(esp_matter_cluster_t *cluster, uint8_t value); +namespace group_key_management { +namespace attribute { +attribute_t *create_group_key_map(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_group_table(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_max_groups_per_fabric(cluster_t *cluster, uint16_t value); +attribute_t *create_max_group_keys_per_fabric(cluster_t *cluster, uint16_t value); +} /* attribute */ +} /* group_key_management */ -/** cluster: groups */ -esp_matter_attribute_t *esp_matter_attribute_create_group_name_support(esp_matter_cluster_t *cluster, uint8_t value); +namespace identify { +namespace attribute { +attribute_t *create_identify_time(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max); +attribute_t *create_identify_type(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* identify */ -/** cluster: scenes */ -esp_matter_attribute_t *esp_matter_attribute_create_scene_count(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_current_scene(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_current_group(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_scene_valid(esp_matter_cluster_t *cluster, bool value); -esp_matter_attribute_t *esp_matter_attribute_create_scene_name_support(esp_matter_cluster_t *cluster, uint8_t value); +namespace groups { +namespace attribute { +attribute_t *create_group_name_support(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* groups */ -/** cluster: on off */ -esp_matter_attribute_t *esp_matter_attribute_create_on_off(esp_matter_cluster_t *cluster, bool value); -esp_matter_attribute_t *esp_matter_attribute_create_global_scene_control(esp_matter_cluster_t *cluster, bool value); -esp_matter_attribute_t *esp_matter_attribute_create_on_time(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_off_wait_time(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_start_up_on_off(esp_matter_cluster_t *cluster, uint8_t value); +namespace scenes { +namespace attribute { +attribute_t *create_scene_count(cluster_t *cluster, uint8_t value); +attribute_t *create_current_scene(cluster_t *cluster, uint8_t value); +attribute_t *create_current_group(cluster_t *cluster, uint16_t value); +attribute_t *create_scene_valid(cluster_t *cluster, bool value); +attribute_t *create_scene_name_support(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* scenes */ -/** cluster: level control */ -esp_matter_attribute_t *esp_matter_attribute_create_current_level(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_on_level(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_options(esp_matter_cluster_t *cluster, uint8_t value, uint8_t min, - uint8_t max); -esp_matter_attribute_t *esp_matter_attribute_create_remaining_time(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_min_level(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_max_level(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_start_up_current_level(esp_matter_cluster_t *cluster, - uint8_t value); +namespace on_off { +namespace attribute { +attribute_t *create_on_off(cluster_t *cluster, bool value); +attribute_t *create_global_scene_control(cluster_t *cluster, bool value); +attribute_t *create_on_time(cluster_t *cluster, uint16_t value); +attribute_t *create_off_wait_time(cluster_t *cluster, uint16_t value); +attribute_t *create_start_up_on_off(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* on_off */ -/** cluster: color control */ -esp_matter_attribute_t *esp_matter_attribute_create_current_hue(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_current_saturation(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_color_mode(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_color_control_options(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_enhanced_color_mode(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_color_capabilities(esp_matter_cluster_t *cluster, uint16_t value); +namespace level_control { +namespace attribute { +attribute_t *create_current_level(cluster_t *cluster, uint8_t value); +attribute_t *create_on_level(cluster_t *cluster, uint8_t value); +attribute_t *create_options(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max); +attribute_t *create_remaining_time(cluster_t *cluster, uint16_t value); +attribute_t *create_min_level(cluster_t *cluster, uint8_t value); +attribute_t *create_max_level(cluster_t *cluster, uint8_t value); +attribute_t *create_start_up_current_level(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* level_control */ -/** cluster: fan control */ -esp_matter_attribute_t *esp_matter_attribute_create_fan_mode(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_fan_mode_sequence(esp_matter_cluster_t *cluster, uint8_t value); +namespace color_control { +namespace attribute { +attribute_t *create_current_hue(cluster_t *cluster, uint8_t value); +attribute_t *create_current_saturation(cluster_t *cluster, uint8_t value); +attribute_t *create_color_mode(cluster_t *cluster, uint8_t value); +attribute_t *create_color_control_options(cluster_t *cluster, uint8_t value); +attribute_t *create_enhanced_color_mode(cluster_t *cluster, uint8_t value); +attribute_t *create_color_capabilities(cluster_t *cluster, uint16_t value); +} /* attribute */ +} /* color_control */ -/** cluster: thermostat */ -esp_matter_attribute_t *esp_matter_attribute_create_local_temperature(esp_matter_cluster_t *cluster, uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_occupied_cooling_setpoint(esp_matter_cluster_t *cluster, - uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_occupied_heating_setpoint(esp_matter_cluster_t *cluster, - uint16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_control_sequence_of_operation(esp_matter_cluster_t *cluster, - uint8_t value, uint8_t min, - uint8_t max); -esp_matter_attribute_t *esp_matter_attribute_create_system_mode(esp_matter_cluster_t *cluster, uint8_t value, - uint8_t min, uint8_t max); +namespace fan_control { +namespace attribute { +attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value); +attribute_t *create_fan_mode_sequence(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* fan_control */ -/** cluster: door lock */ -esp_matter_attribute_t *esp_matter_attribute_create_lock_state(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_lock_type(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_actuator_enabled(esp_matter_cluster_t *cluster, bool value); -esp_matter_attribute_t *esp_matter_attribute_create_auto_relock_time(esp_matter_cluster_t *cluster, uint32_t value); -esp_matter_attribute_t *esp_matter_attribute_create_operating_mode(esp_matter_cluster_t *cluster, uint8_t value, - uint8_t min, uint8_t max); -esp_matter_attribute_t *esp_matter_attribute_create_supported_operating_modes(esp_matter_cluster_t *cluster, - uint16_t value); +namespace thermostat { +namespace attribute { +attribute_t *create_local_temperature(cluster_t *cluster, uint16_t value); +attribute_t *create_occupied_cooling_setpoint(cluster_t *cluster, uint16_t value); +attribute_t *create_occupied_heating_setpoint(cluster_t *cluster, uint16_t value); +attribute_t *create_control_sequence_of_operation(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max); +attribute_t *create_system_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max); +} /* attribute */ +} /* thermostat */ -/** cluster: bridged device basic */ -esp_matter_attribute_t *esp_matter_attribute_create_bridged_device_basic_node_label(esp_matter_cluster_t *cluster, - char *value, uint16_t length); -esp_matter_attribute_t *esp_matter_attribute_create_reachable(esp_matter_cluster_t *cluster, bool value); +namespace door_lock { +namespace attribute { +attribute_t *create_lock_state(cluster_t *cluster, uint8_t value); +attribute_t *create_lock_type(cluster_t *cluster, uint8_t value); +attribute_t *create_actuator_enabled(cluster_t *cluster, bool value); +attribute_t *create_auto_relock_time(cluster_t *cluster, uint32_t value); +attribute_t *create_operating_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max); +attribute_t *create_supported_operating_modes(cluster_t *cluster, uint16_t value); +} /* attribute */ +} /* door_lock */ -/** cluster: fixed label */ -esp_matter_attribute_t *esp_matter_attribute_create_label_list(esp_matter_cluster_t *cluster, uint8_t *value, - uint16_t length, uint16_t count); +namespace bridged_device_basic { +namespace attribute { +attribute_t *create_bridged_device_basic_node_label(cluster_t *cluster, char *value, uint16_t length); +attribute_t *create_reachable(cluster_t *cluster, bool value); +} /* attribute */ +} /* bridged_device_basic */ -/** cluster: switch */ -esp_matter_attribute_t *esp_matter_attribute_create_number_of_positions(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_current_position(esp_matter_cluster_t *cluster, uint8_t value); -esp_matter_attribute_t *esp_matter_attribute_create_multi_press_max(esp_matter_cluster_t *cluster, uint8_t value); +namespace fixed_label { +namespace attribute { +attribute_t *create_label_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +} /* attribute */ +} /* fixed_label */ -/** cluster: temperature measurement */ -esp_matter_attribute_t *esp_matter_attribute_create_temperature_measured_value(esp_matter_cluster_t *cluster, - int16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_temperature_min_measured_value(esp_matter_cluster_t *cluster, - int16_t value); -esp_matter_attribute_t *esp_matter_attribute_create_temperature_max_measured_value(esp_matter_cluster_t *cluster, - int16_t value); +namespace switch_cluster { +namespace attribute { +attribute_t *create_number_of_positions(cluster_t *cluster, uint8_t value); +attribute_t *create_current_position(cluster_t *cluster, uint8_t value); +attribute_t *create_multi_press_max(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* switch_cluster */ + +namespace temperature_measurement { +namespace attribute { +attribute_t *create_temperature_measured_value(cluster_t *cluster, int16_t value); +attribute_t *create_temperature_min_measured_value(cluster_t *cluster, int16_t value); +attribute_t *create_temperature_max_measured_value(cluster_t *cluster, int16_t value); +} /* attribute */ +} /* temperature_measurement */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_attribute_utils.cpp b/components/esp_matter/esp_matter_attribute_utils.cpp index b2a7be504..7f1c81170 100644 --- a/components/esp_matter/esp_matter_attribute_utils.cpp +++ b/components/esp_matter/esp_matter_attribute_utils.cpp @@ -27,165 +27,10 @@ using chip::ClusterId; using chip::EndpointId; using chip::Protocols::InteractionModel::Status; +using namespace esp_matter; + static const char *TAG = "esp_matter_attribute"; -static esp_matter_attribute_callback_t attribute_callback = NULL; -static void *attribute_callback_priv_data = NULL; - -static esp_matter_val_type_t get_val_type_from_attribute_type(int attribute_type); - -static esp_err_t esp_matter_attribute_console_handler(int argc, char **argv) -{ - if (argc == 5 && strncmp(argv[0], "set", sizeof("set")) == 0) { - int endpoint_id = strtol((const char *)&argv[1][2], NULL, 16); - int cluster_id = strtol((const char *)&argv[2][2], NULL, 16); - int attribute_id = strtol((const char *)&argv[3][2], NULL, 16); - - /* Get type from matter_attribute */ - const EmberAfAttributeMetadata *matter_attribute = emberAfLocateAttributeMetadata(endpoint_id, cluster_id, - attribute_id, ESP_MATTER_CLUSTER_FLAG_SERVER); - if (!matter_attribute) { - ESP_LOGE(TAG, "Matter attribute not found"); - return ESP_ERR_INVALID_ARG; - } - - /* Use the type to create the val and then update te attribute */ - esp_matter_val_type_t type = get_val_type_from_attribute_type(matter_attribute->attributeType); - esp_matter_attr_val_t val = esp_matter_invalid(NULL); - if (type == ESP_MATTER_VAL_TYPE_BOOLEAN) { - bool value = atoi(argv[4]); - val = esp_matter_bool(value); - } else if (type == ESP_MATTER_VAL_TYPE_INT8) { - int8_t value = atoi(argv[4]); - val = esp_matter_int8(value); - } else if (type == ESP_MATTER_VAL_TYPE_UINT8) { - uint8_t value = atoi(argv[4]); - val = esp_matter_uint8(value); - } else if (type == ESP_MATTER_VAL_TYPE_INT16) { - int16_t value = atoi(argv[4]); - val = esp_matter_int16(value); - } else if (type == ESP_MATTER_VAL_TYPE_UINT16) { - uint16_t value = atoi(argv[4]); - val = esp_matter_uint16(value); - } else if (type == ESP_MATTER_VAL_TYPE_UINT32) { - uint32_t value = atoi(argv[4]); - val = esp_matter_uint32(value); - } else if (type == ESP_MATTER_VAL_TYPE_UINT64) { - uint64_t value = atoi(argv[4]); - val = esp_matter_uint64(value); - } else if (type == ESP_MATTER_VAL_TYPE_CHAR_STRING) { - char *value = argv[4]; - val = esp_matter_char_str(value, strlen(value)); - } else if (type == ESP_MATTER_VAL_TYPE_BITMAP8) { - uint8_t value = atoi(argv[4]); - val = esp_matter_bitmap8(value); - } else if (type == ESP_MATTER_VAL_TYPE_BITMAP16) { - uint16_t value = atoi(argv[4]); - val = esp_matter_bitmap16(value); - } else if (type == ESP_MATTER_VAL_TYPE_BITMAP32) { - uint32_t value = atoi(argv[4]); - val = esp_matter_bitmap32(value); - } else { - ESP_LOGE(TAG, "Type not handled: %d", type); - return ESP_ERR_INVALID_ARG; - } - esp_matter_attribute_update(endpoint_id, cluster_id, attribute_id, &val); - } else if (argc == 4 && strncmp(argv[0], "get", sizeof("get")) == 0) { - int endpoint_id = strtol((const char *)&argv[1][2], NULL, 16); - int cluster_id = strtol((const char *)&argv[2][2], NULL, 16); - int attribute_id = strtol((const char *)&argv[3][2], NULL, 16); - - /* Get type from matter_attribute */ - const EmberAfAttributeMetadata *matter_attribute = emberAfLocateAttributeMetadata(endpoint_id, cluster_id, - attribute_id, ESP_MATTER_CLUSTER_FLAG_SERVER); - if (!matter_attribute) { - ESP_LOGE(TAG, "Matter attribute not found"); - return ESP_ERR_INVALID_ARG; - } - - /* Use the type to read the raw value and then print */ - esp_matter_val_type_t type = get_val_type_from_attribute_type(matter_attribute->attributeType); - esp_matter_attr_val_t val = esp_matter_invalid(NULL); - if (type == ESP_MATTER_VAL_TYPE_BOOLEAN) { - bool value = false; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_bool(value); - } else if (type == ESP_MATTER_VAL_TYPE_INT8) { - int8_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_int8(value); - } else if (type == ESP_MATTER_VAL_TYPE_UINT8) { - uint8_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_uint8(value); - } else if (type == ESP_MATTER_VAL_TYPE_INT16) { - int16_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_int16(value); - } else if (type == ESP_MATTER_VAL_TYPE_UINT16) { - uint16_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_uint16(value); - } else if (type == ESP_MATTER_VAL_TYPE_UINT32) { - uint32_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_uint32(value); - } else if (type == ESP_MATTER_VAL_TYPE_UINT64) { - uint64_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_uint64(value); - } else if (type == ESP_MATTER_VAL_TYPE_CHAR_STRING) { - /* Get raw value */ - char value[256] = {0}; /* It can go upto 256 since only 1 byte (first) is used for size */ - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - /* Get val from raw value */ - val = esp_matter_char_str(NULL, 0); - int data_size_len = val.val.a.t - val.val.a.s; - int data_count = 0; - memcpy(&data_count, &value[0], data_size_len); - val = esp_matter_char_str((char *)(value + data_size_len), data_count); - } else if (type == ESP_MATTER_VAL_TYPE_BITMAP8) { - uint8_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_bitmap8(value); - } else if (type == ESP_MATTER_VAL_TYPE_BITMAP16) { - uint16_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_bitmap16(value); - } else if (type == ESP_MATTER_VAL_TYPE_BITMAP32) { - uint32_t value = 0; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); - val = esp_matter_bitmap32(value); - } else { - ESP_LOGE(TAG, "Type not handled: %d", type); - return ESP_ERR_INVALID_ARG; - } - esp_matter_attribute_val_print(endpoint_id, cluster_id, attribute_id, &val); - } else { - ESP_LOGE(TAG, "Incorrect arguments"); - return ESP_ERR_INVALID_ARG; - } - return ESP_OK; -} - -static void esp_matter_attribute_register_commands() -{ - static bool init_done = false; - if (init_done) { - return; - } - esp_matter_console_command_t command = { - .name = "attribute", - .description = "This can be used to simulate on-device control. " - "Usage: matter esp attribute [value]. " - "Example1: matter esp attribute set 0x0001 0x0006 0x0000 1. " - "Example2: matter esp attribute get 0x0001 0x0006 0x0000.", - .handler = esp_matter_attribute_console_handler, - }; - esp_matter_console_add_command(&command); - init_done = true; -} - esp_matter_attr_val_t esp_matter_invalid(void *val) { esp_matter_attr_val_t attr_val = { @@ -342,7 +187,7 @@ esp_matter_attr_val_t esp_matter_bitmap32(uint32_t val) esp_matter_attr_val_t esp_matter_char_str(char *val, uint16_t data_size) { - uint16_t data_size_len = 1; /* Number of bytes used to store the length */ + uint16_t data_size_len = 1; /* Number of bytes used to store the length */ esp_matter_attr_val_t attr_val = { .type = ESP_MATTER_VAL_TYPE_CHAR_STRING, .val = { @@ -359,7 +204,7 @@ esp_matter_attr_val_t esp_matter_char_str(char *val, uint16_t data_size) esp_matter_attr_val_t esp_matter_octet_str(uint8_t *val, uint16_t data_size) { - uint16_t data_size_len = 1; /* Number of bytes used to store the length */ + uint16_t data_size_len = 1; /* Number of bytes used to store the length */ esp_matter_attr_val_t attr_val = { .type = ESP_MATTER_VAL_TYPE_OCTET_STRING, .val = { @@ -376,7 +221,7 @@ esp_matter_attr_val_t esp_matter_octet_str(uint8_t *val, uint16_t data_size) esp_matter_attr_val_t esp_matter_array(uint8_t *val, uint16_t data_size, uint16_t count) { - uint16_t data_size_len = 2; /* Number of bytes used to store the length */ + uint16_t data_size_len = 2; /* Number of bytes used to store the length */ esp_matter_attr_val_t attr_val = { .type = ESP_MATTER_VAL_TYPE_ARRAY, .val = { @@ -391,9 +236,187 @@ esp_matter_attr_val_t esp_matter_array(uint8_t *val, uint16_t data_size, uint16_ return attr_val; } +namespace esp_matter { +namespace attribute { + +static esp_matter_val_type_t get_val_type_from_attribute_type(int attribute_type); +static callback_t attribute_callback = NULL; +static void *attribute_callback_priv_data = NULL; + +static esp_err_t console_handler(int argc, char **argv) +{ + if (argc == 5 && strncmp(argv[0], "set", sizeof("set")) == 0) { + int endpoint_id = strtol((const char *)&argv[1][2], NULL, 16); + int cluster_id = strtol((const char *)&argv[2][2], NULL, 16); + int attribute_id = strtol((const char *)&argv[3][2], NULL, 16); + + /* Get type from matter_attribute */ + const EmberAfAttributeMetadata *matter_attribute = emberAfLocateAttributeMetadata(endpoint_id, cluster_id, + attribute_id, ESP_MATTER_CLUSTER_FLAG_SERVER); + if (!matter_attribute) { + ESP_LOGE(TAG, "Matter attribute not found"); + return ESP_ERR_INVALID_ARG; + } + + /* Use the type to create the val and then update te attribute */ + esp_matter_val_type_t type = get_val_type_from_attribute_type(matter_attribute->attributeType); + esp_matter_attr_val_t val = esp_matter_invalid(NULL); + if (type == ESP_MATTER_VAL_TYPE_BOOLEAN) { + bool value = atoi(argv[4]); + val = esp_matter_bool(value); + } else if (type == ESP_MATTER_VAL_TYPE_INT8) { + int8_t value = atoi(argv[4]); + val = esp_matter_int8(value); + } else if (type == ESP_MATTER_VAL_TYPE_UINT8) { + uint8_t value = atoi(argv[4]); + val = esp_matter_uint8(value); + } else if (type == ESP_MATTER_VAL_TYPE_INT16) { + int16_t value = atoi(argv[4]); + val = esp_matter_int16(value); + } else if (type == ESP_MATTER_VAL_TYPE_UINT16) { + uint16_t value = atoi(argv[4]); + val = esp_matter_uint16(value); + } else if (type == ESP_MATTER_VAL_TYPE_UINT32) { + uint32_t value = atoi(argv[4]); + val = esp_matter_uint32(value); + } else if (type == ESP_MATTER_VAL_TYPE_UINT64) { + uint64_t value = atoi(argv[4]); + val = esp_matter_uint64(value); + } else if (type == ESP_MATTER_VAL_TYPE_CHAR_STRING) { + char *value = argv[4]; + val = esp_matter_char_str(value, strlen(value)); + } else if (type == ESP_MATTER_VAL_TYPE_BITMAP8) { + uint8_t value = atoi(argv[4]); + val = esp_matter_bitmap8(value); + } else if (type == ESP_MATTER_VAL_TYPE_BITMAP16) { + uint16_t value = atoi(argv[4]); + val = esp_matter_bitmap16(value); + } else if (type == ESP_MATTER_VAL_TYPE_BITMAP32) { + uint32_t value = atoi(argv[4]); + val = esp_matter_bitmap32(value); + } else { + ESP_LOGE(TAG, "Type not handled: %d", type); + return ESP_ERR_INVALID_ARG; + } + update(endpoint_id, cluster_id, attribute_id, &val); + } else if (argc == 4 && strncmp(argv[0], "get", sizeof("get")) == 0) { + int endpoint_id = strtol((const char *)&argv[1][2], NULL, 16); + int cluster_id = strtol((const char *)&argv[2][2], NULL, 16); + int attribute_id = strtol((const char *)&argv[3][2], NULL, 16); + + /* Get type from matter_attribute */ + const EmberAfAttributeMetadata *matter_attribute = emberAfLocateAttributeMetadata(endpoint_id, cluster_id, + attribute_id, ESP_MATTER_CLUSTER_FLAG_SERVER); + if (!matter_attribute) { + ESP_LOGE(TAG, "Matter attribute not found"); + return ESP_ERR_INVALID_ARG; + } + + /* Use the type to read the raw value and then print */ + esp_matter_val_type_t type = get_val_type_from_attribute_type(matter_attribute->attributeType); + esp_matter_attr_val_t val = esp_matter_invalid(NULL); + if (type == ESP_MATTER_VAL_TYPE_BOOLEAN) { + bool value = false; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_bool(value); + } else if (type == ESP_MATTER_VAL_TYPE_INT8) { + int8_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_int8(value); + } else if (type == ESP_MATTER_VAL_TYPE_UINT8) { + uint8_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_uint8(value); + } else if (type == ESP_MATTER_VAL_TYPE_INT16) { + int16_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_int16(value); + } else if (type == ESP_MATTER_VAL_TYPE_UINT16) { + uint16_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_uint16(value); + } else if (type == ESP_MATTER_VAL_TYPE_UINT32) { + uint32_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_uint32(value); + } else if (type == ESP_MATTER_VAL_TYPE_UINT64) { + uint64_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_uint64(value); + } else if (type == ESP_MATTER_VAL_TYPE_CHAR_STRING) { + /* Get raw value */ + char value[256] = {0}; /* It can go upto 256 since only 1 byte (first) is used for size */ + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + /* Get val from raw value */ + val = esp_matter_char_str(NULL, 0); + int data_size_len = val.val.a.t - val.val.a.s; + int data_count = 0; + memcpy(&data_count, &value[0], data_size_len); + val = esp_matter_char_str((char *)(value + data_size_len), data_count); + } else if (type == ESP_MATTER_VAL_TYPE_BITMAP8) { + uint8_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_bitmap8(value); + } else if (type == ESP_MATTER_VAL_TYPE_BITMAP16) { + uint16_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_bitmap16(value); + } else if (type == ESP_MATTER_VAL_TYPE_BITMAP32) { + uint32_t value = 0; + get_val_raw(endpoint_id, cluster_id, attribute_id, (uint8_t *)&value, sizeof(value)); + val = esp_matter_bitmap32(value); + } else { + ESP_LOGE(TAG, "Type not handled: %d", type); + return ESP_ERR_INVALID_ARG; + } + val_print(endpoint_id, cluster_id, attribute_id, &val); + } else { + ESP_LOGE(TAG, "Incorrect arguments"); + return ESP_ERR_INVALID_ARG; + } + return ESP_OK; +} + +static void register_commands() +{ + static bool init_done = false; + if (init_done) { + return; + } + esp_matter_console_command_t command = { + .name = "attribute", + .description = "This can be used to simulate on-device control. " + "Usage: matter esp attribute [value]. " + "Example1: matter esp attribute set 0x0001 0x0006 0x0000 1. " + "Example2: matter esp attribute get 0x0001 0x0006 0x0000.", + .handler = console_handler, + }; + esp_matter_console_add_command(&command); + init_done = true; +} + +esp_err_t set_callback(callback_t callback, void *priv_data) +{ + attribute_callback = callback; + attribute_callback_priv_data = priv_data; + + /* Other initialisations */ + register_commands(); + return ESP_OK; +} + +esp_err_t send_callback(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id, + esp_matter_attr_val_t *val) +{ + if (attribute_callback) { + attribute_callback(type, endpoint_id, cluster_id, attribute_id, val, attribute_callback_priv_data); + } + return ESP_OK; +} + static esp_matter_val_type_t get_val_type_from_attribute_type(int attribute_type) { - switch(attribute_type) { + switch (attribute_type) { case ZCL_BOOLEAN_ATTRIBUTE_TYPE: return ESP_MATTER_VAL_TYPE_BOOLEAN; break; @@ -675,16 +698,14 @@ static esp_err_t get_attr_val_from_data(esp_matter_attr_val_t *val, EmberAfAttri uint16_t attribute_size, uint8_t *value) { switch (attribute_type) { - case ZCL_BOOLEAN_ATTRIBUTE_TYPE: - { + case ZCL_BOOLEAN_ATTRIBUTE_TYPE: { bool attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(bool)); *val = esp_matter_bool(attribute_value); break; } - case ZCL_ARRAY_ATTRIBUTE_TYPE: - { + case ZCL_ARRAY_ATTRIBUTE_TYPE: { *val = esp_matter_array(NULL, 0, 0); int data_size_len = val->val.a.t - val->val.a.s; int data_count = 0; @@ -693,8 +714,7 @@ static esp_err_t get_attr_val_from_data(esp_matter_attr_val_t *val, EmberAfAttri break; } - case ZCL_CHAR_STRING_ATTRIBUTE_TYPE: - { + case ZCL_CHAR_STRING_ATTRIBUTE_TYPE: { *val = esp_matter_char_str(NULL, 0); int data_size_len = val->val.a.t - val->val.a.s; int data_count = 0; @@ -703,8 +723,7 @@ static esp_err_t get_attr_val_from_data(esp_matter_attr_val_t *val, EmberAfAttri break; } - case ZCL_OCTET_STRING_ATTRIBUTE_TYPE: - { + case ZCL_OCTET_STRING_ATTRIBUTE_TYPE: { *val = esp_matter_octet_str(NULL, 0); int data_size_len = val->val.a.t - val->val.a.s; int data_count = 0; @@ -713,72 +732,63 @@ static esp_err_t get_attr_val_from_data(esp_matter_attr_val_t *val, EmberAfAttri break; } - case ZCL_INT8S_ATTRIBUTE_TYPE: - { + case ZCL_INT8S_ATTRIBUTE_TYPE: { int8_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(int8_t)); *val = esp_matter_int8(attribute_value); break; } - case ZCL_INT8U_ATTRIBUTE_TYPE: - { + case ZCL_INT8U_ATTRIBUTE_TYPE: { uint8_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(uint8_t)); *val = esp_matter_uint8(attribute_value); break; } - case ZCL_INT16S_ATTRIBUTE_TYPE: - { + case ZCL_INT16S_ATTRIBUTE_TYPE: { int16_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(int16_t)); *val = esp_matter_int16(attribute_value); break; } - case ZCL_INT16U_ATTRIBUTE_TYPE: - { + case ZCL_INT16U_ATTRIBUTE_TYPE: { uint16_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(uint16_t)); *val = esp_matter_uint16(attribute_value); break; } - case ZCL_INT32U_ATTRIBUTE_TYPE: - { + case ZCL_INT32U_ATTRIBUTE_TYPE: { uint32_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(uint32_t)); *val = esp_matter_uint32(attribute_value); break; } - case ZCL_INT64U_ATTRIBUTE_TYPE: - { + case ZCL_INT64U_ATTRIBUTE_TYPE: { uint64_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(uint64_t)); *val = esp_matter_uint64(attribute_value); break; } - case ZCL_ENUM8_ATTRIBUTE_TYPE: - { + case ZCL_ENUM8_ATTRIBUTE_TYPE: { uint8_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(uint8_t)); *val = esp_matter_enum8(attribute_value); break; } - case ZCL_BITMAP8_ATTRIBUTE_TYPE: - { + case ZCL_BITMAP8_ATTRIBUTE_TYPE: { uint8_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(uint8_t)); *val = esp_matter_bitmap8(attribute_value); break; } - case ZCL_BITMAP16_ATTRIBUTE_TYPE: - { + case ZCL_BITMAP16_ATTRIBUTE_TYPE: { uint16_t attribute_value = 0; memcpy((uint8_t *)&attribute_value, value, sizeof(uint16_t)); *val = esp_matter_bitmap16(attribute_value); @@ -793,7 +803,7 @@ static esp_err_t get_attr_val_from_data(esp_matter_attr_val_t *val, EmberAfAttri return ESP_OK; } -void esp_matter_attribute_val_print(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val) +void val_print(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val) { if (val->type == ESP_MATTER_VAL_TYPE_BOOLEAN) { ESP_LOGI(TAG, "********** Endpoint 0x%04X's Cluster 0x%04X's Attribute 0x%04X is %d **********", endpoint_id, @@ -828,22 +838,11 @@ void esp_matter_attribute_val_print(int endpoint_id, int cluster_id, int attribu } } -esp_err_t esp_matter_attribute_callback_set(esp_matter_attribute_callback_t callback, void *priv_data) -{ - attribute_callback = callback; - attribute_callback_priv_data = priv_data; - - /* Other initialisations */ - esp_matter_attribute_register_commands(); - return ESP_OK; -} - -esp_err_t esp_matter_attribute_get_val_raw(int endpoint_id, int cluster_id, int attribute_id, uint8_t *value, - uint16_t attribute_size) +esp_err_t get_val_raw(int endpoint_id, int cluster_id, int attribute_id, uint8_t *value, uint16_t attribute_size) { /* Take lock if not already taken */ - esp_matter_lock_status_t lock_status = esp_matter_chip_stack_lock(portMAX_DELAY); - if (lock_status == ESP_MATTER_LOCK_FAILED) { + lock::status_t lock_status = lock::chip_stack_lock(portMAX_DELAY); + if (lock_status == lock::FAILED) { ESP_LOGE(TAG, "Could not get task context"); return ESP_FAIL; } @@ -851,22 +850,22 @@ esp_err_t esp_matter_attribute_get_val_raw(int endpoint_id, int cluster_id, int EmberAfStatus status = emberAfReadServerAttribute(endpoint_id, cluster_id, attribute_id, value, attribute_size); if (status != EMBER_ZCL_STATUS_SUCCESS) { ESP_LOGE(TAG, "Error getting raw value from matter: 0x%x", status); - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } return ESP_FAIL; } - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } return ESP_OK; } -esp_err_t esp_matter_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val) +esp_err_t update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val) { /* Take lock if not already taken */ - esp_matter_lock_status_t lock_status = esp_matter_chip_stack_lock(portMAX_DELAY); - if (lock_status == ESP_MATTER_LOCK_FAILED) { + lock::status_t lock_status = lock::chip_stack_lock(portMAX_DELAY); + if (lock_status == lock::FAILED) { ESP_LOGE(TAG, "Could not get task context"); return ESP_FAIL; } @@ -880,8 +879,8 @@ esp_err_t esp_matter_attribute_update(int endpoint_id, int cluster_id, int attri uint8_t *value = (uint8_t *)calloc(1, attribute_size); if (!value) { ESP_LOGE(TAG, "Could not allocate value buffer"); - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } return ESP_ERR_NO_MEM; } @@ -894,19 +893,22 @@ esp_err_t esp_matter_attribute_update(int endpoint_id, int cluster_id, int attri if (status != EMBER_ZCL_STATUS_SUCCESS) { ESP_LOGE(TAG, "Error updating attribute to matter: 0x%X", status); free(value); - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } return ESP_FAIL; } } free(value); - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } return ESP_OK; } +} /* attribute */ +} /* esp_matter */ + Status MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath &path, uint8_t mask, uint8_t type, uint16_t size, uint8_t *value) { @@ -914,18 +916,15 @@ Status MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath & int cluster_id = path.mClusterId; int attribute_id = path.mAttributeId; esp_matter_attr_val_t val = esp_matter_invalid(NULL); - get_attr_val_from_data(&val, type, size, value); + attribute::get_attr_val_from_data(&val, type, size, value); /* Print */ - esp_matter_attribute_val_print(endpoint_id, cluster_id, attribute_id, &val); + attribute::val_print(endpoint_id, cluster_id, attribute_id, &val); /* Callback to application */ - if (attribute_callback) { - esp_err_t err = attribute_callback(ESP_MATTER_CALLBACK_TYPE_PRE_ATTRIBUTE, endpoint_id, cluster_id, - attribute_id, &val, attribute_callback_priv_data); - if (err != ESP_OK) { - return Status::Failure; - } + esp_err_t err = send_callback(attribute::PRE_ATTRIBUTE, endpoint_id, cluster_id, attribute_id, &val); + if (err != ESP_OK) { + return Status::Failure; } return Status::Success; } @@ -937,13 +936,10 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &p int cluster_id = path.mClusterId; int attribute_id = path.mAttributeId; esp_matter_attr_val_t val = esp_matter_invalid(NULL); - get_attr_val_from_data(&val, type, size, value); + attribute::get_attr_val_from_data(&val, type, size, value); /* Callback to application */ - if (attribute_callback) { - attribute_callback(ESP_MATTER_CALLBACK_TYPE_POST_ATTRIBUTE, endpoint_id, cluster_id, attribute_id, &val, - attribute_callback_priv_data); - } + send_callback(attribute::POST_ATTRIBUTE, endpoint_id, cluster_id, attribute_id, &val); } EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint_id, ClusterId cluster_id, @@ -952,30 +948,30 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint_id, Clust { /* Get value */ int attribute_id = matter_attribute->attributeId; - esp_matter_node_t *node = esp_matter_node_get(); + node_t *node = node::get(); if (!node) { return EMBER_ZCL_STATUS_FAILURE; } - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get(node, endpoint_id); - esp_matter_cluster_t *cluster = esp_matter_cluster_get(endpoint, cluster_id); - esp_matter_attribute_t *attribute = esp_matter_attribute_get(cluster, attribute_id); + endpoint_t *endpoint = endpoint::get(node, endpoint_id); + cluster_t *cluster = cluster::get(endpoint, cluster_id); + attribute_t *attribute = attribute::get(cluster, attribute_id); esp_matter_attr_val_t val = esp_matter_invalid(NULL); - esp_matter_attribute_get_val(attribute, &val); + attribute::get_val(attribute, &val); /* Print */ - esp_matter_attribute_val_print(endpoint_id, cluster_id, attribute_id, &val); + attribute::val_print(endpoint_id, cluster_id, attribute_id, &val); /* Get size */ uint16_t attribute_size = 0; - get_data_from_attr_val(&val, NULL, &attribute_size, NULL); + attribute::get_data_from_attr_val(&val, NULL, &attribute_size, NULL); if (attribute_size > max_read_length) { ESP_LOGE(TAG, "Insufficient space for reading attribute: required: %d, max: %d", attribute_size, - max_read_length); + max_read_length); return EMBER_ZCL_STATUS_INSUFFICIENT_SPACE; } /* Assign value */ - get_data_from_attr_val(&val, NULL, &attribute_size, buffer); + attribute::get_data_from_attr_val(&val, NULL, &attribute_size, buffer); return EMBER_ZCL_STATUS_SUCCESS; } @@ -984,21 +980,21 @@ EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint_id, Clus { /* Get value */ int attribute_id = matter_attribute->attributeId; - esp_matter_node_t *node = esp_matter_node_get(); + node_t *node = node::get(); if (!node) { return EMBER_ZCL_STATUS_FAILURE; } - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get(node, endpoint_id); - esp_matter_cluster_t *cluster = esp_matter_cluster_get(endpoint, cluster_id); - esp_matter_attribute_t *attribute = esp_matter_attribute_get(cluster, attribute_id); + endpoint_t *endpoint = endpoint::get(node, endpoint_id); + cluster_t *cluster = cluster::get(endpoint, cluster_id); + attribute_t *attribute = attribute::get(cluster, attribute_id); /* Get val */ /* This creates a new variable val, and stores the new attribute value in the new variable. - The value in esp-matter data model is updated only when esp_matter_attribute_set_val() is called */ + The value in esp-matter data model is updated only when attribute::set_val() is called */ esp_matter_attr_val_t val = esp_matter_invalid(NULL); - get_attr_val_from_data(&val, matter_attribute->attributeType, matter_attribute->size, buffer); + attribute::get_attr_val_from_data(&val, matter_attribute->attributeType, matter_attribute->size, buffer); /* Update val */ - esp_matter_attribute_set_val(attribute, &val); + attribute::set_val(attribute, &val); return EMBER_ZCL_STATUS_SUCCESS; } diff --git a/components/esp_matter/esp_matter_attribute_utils.h b/components/esp_matter/esp_matter_attribute_utils.h index ac438d898..a571527d7 100644 --- a/components/esp_matter/esp_matter_attribute_utils.h +++ b/components/esp_matter/esp_matter_attribute_utils.h @@ -162,14 +162,20 @@ esp_matter_attr_val_t esp_matter_octet_str(uint8_t *val, uint16_t data_size); /** Array */ esp_matter_attr_val_t esp_matter_array(uint8_t *val, uint16_t data_size, uint16_t count); +namespace esp_matter { +namespace attribute { + /** Attribute update * * This API updates the attribute value */ -esp_err_t esp_matter_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); +esp_err_t update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); /** Attribute value print * * This API prints the attribute value according to the type */ -void esp_matter_attribute_val_print(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); +void val_print(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); + +} /* attribute */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_client.cpp b/components/esp_matter/esp_matter_client.cpp index b0efb4b4b..9f5606212 100644 --- a/components/esp_matter/esp_matter_client.cpp +++ b/components/esp_matter/esp_matter_client.cpp @@ -19,20 +19,23 @@ #include #include -using chip::Callback::Callback; using chip::DeviceProxy; using chip::FabricInfo; using chip::kInvalidEndpointId; using chip::OperationalDeviceProxy; using chip::PeerId; +using chip::Callback::Callback; static const char *TAG = "esp_matter_client"; -static esp_matter_client_command_callback_t client_command_callback = NULL; +namespace esp_matter { +namespace client { + +static command_callback_t client_command_callback = NULL; static void *client_command_callback_priv_data = NULL; static bool initialize_binding_manager = false; -esp_err_t esp_matter_set_client_command_callback(esp_matter_client_command_callback_t callback, void *priv_data) +esp_err_t set_command_callback(command_callback_t callback, void *priv_data) { client_command_callback = callback; client_command_callback_priv_data = priv_data; @@ -54,7 +57,7 @@ void esp_matter_new_connection_failure_callback(void *context, PeerId peerId, CH ESP_LOGI(TAG, "New connection failure"); } -esp_err_t esp_matter_connect(int fabric_index, int node_id, int remote_endpoint_id) +esp_err_t connect(int fabric_index, int node_id, int remote_endpoint_id) { /* Get info */ FabricInfo *fabric_info = chip::Server::GetInstance().GetFabricTable().FindFabricWithIndex(fabric_index); @@ -88,13 +91,13 @@ static void esp_matter_command_client_binding_callback(const EmberBindingTableEn } } -esp_err_t esp_matter_client_cluster_update(int endpoint_id, int cluster_id) +esp_err_t cluster_update(int endpoint_id, int cluster_id) { chip::BindingManager::GetInstance().NotifyBoundClusterChanged(endpoint_id, cluster_id, NULL); return ESP_OK; } -static void __esp_matter_binding_manager_init(intptr_t arg) +static void __binding_manager_init(intptr_t arg) { auto &server = chip::Server::GetInstance(); struct chip::BindingManagerInitParams binding_init_params = { @@ -107,64 +110,73 @@ static void __esp_matter_binding_manager_init(intptr_t arg) chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(esp_matter_command_client_binding_callback); } -void esp_matter_binding_manager_init() +void binding_manager_init() { if (initialize_binding_manager) { - chip::DeviceLayer::PlatformMgr().ScheduleWork(__esp_matter_binding_manager_init); + chip::DeviceLayer::PlatformMgr().ScheduleWork(__binding_manager_init); } } -void esp_matter_binding_init() +void binding_init() { initialize_binding_manager = true; } +} /* client */ -static void esp_matter_send_command_success_callback(void *context, const chip::app::DataModel::NullObjectType &data) +namespace cluster { +using client::peer_device_t; + +static void send_command_success_callback(void *context, const chip::app::DataModel::NullObjectType &data) { ESP_LOGI(TAG, "Send command success"); } -static void esp_matter_send_command_failure_callback(void *context, CHIP_ERROR error) +static void send_command_failure_callback(void *context, CHIP_ERROR error) { ESP_LOGI(TAG, "FSend command failure"); } -esp_err_t esp_matter_on_off_send_command_on(esp_matter_peer_device_t *remote_device, int remote_endpoint_id) +namespace on_off { +namespace command { + +esp_err_t send_on(peer_device_t *remote_device, int remote_endpoint_id) { chip::Controller::OnOffCluster cluster; chip::app::Clusters::OnOff::Commands::On::Type command_data; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_on_off_send_command_off(esp_matter_peer_device_t *remote_device, int remote_endpoint_id) +esp_err_t send_off(peer_device_t *remote_device, int remote_endpoint_id) { chip::Controller::OnOffCluster cluster; chip::app::Clusters::OnOff::Commands::Off::Type command_data; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_on_off_send_command_toggle(esp_matter_peer_device_t *remote_device, int remote_endpoint_id) +esp_err_t send_toggle(peer_device_t *remote_device, int remote_endpoint_id) { chip::Controller::OnOffCluster cluster; chip::app::Clusters::OnOff::Commands::Toggle::Type command_data; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_level_control_send_command_move(esp_matter_peer_device_t *remote_device, int remote_endpoint_id, - uint8_t move_mode, uint8_t rate, uint8_t option_mask, - uint8_t option_override) +} /* command */ +} /* on_off */ + +namespace level_control { +namespace command { + +esp_err_t send_move(peer_device_t *remote_device, int remote_endpoint_id, uint8_t move_mode, uint8_t rate, + uint8_t option_mask, uint8_t option_override) { chip::Controller::LevelControlCluster cluster; chip::app::Clusters::LevelControl::Commands::Move::Type command_data; @@ -174,15 +186,12 @@ esp_err_t esp_matter_level_control_send_command_move(esp_matter_peer_device_t *r command_data.optionOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_level_control_send_command_move_to_level(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t level, - uint16_t transition_time, uint8_t option_mask, - uint8_t option_override) +esp_err_t send_move_to_level(peer_device_t *remote_device, int remote_endpoint_id, uint8_t level, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override) { chip::Controller::LevelControlCluster cluster; chip::app::Clusters::LevelControl::Commands::MoveToLevel::Type command_data; @@ -192,14 +201,12 @@ esp_err_t esp_matter_level_control_send_command_move_to_level(esp_matter_peer_de command_data.optionOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_level_control_send_command_move_to_level_with_on_off(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t level, - uint16_t transition_time) +esp_err_t send_move_to_level_with_on_off(peer_device_t *remote_device, int remote_endpoint_id, uint8_t level, + uint16_t transition_time) { chip::Controller::LevelControlCluster cluster; chip::app::Clusters::LevelControl::Commands::MoveToLevelWithOnOff::Type command_data; @@ -207,14 +214,11 @@ esp_err_t esp_matter_level_control_send_command_move_to_level_with_on_off(esp_ma command_data.transitionTime = transition_time; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_level_control_send_command_move_with_on_off(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t move_mode, - uint8_t rate) +esp_err_t send_move_with_on_off(peer_device_t *remote_device, int remote_endpoint_id, uint8_t move_mode, uint8_t rate) { chip::Controller::LevelControlCluster cluster; chip::app::Clusters::LevelControl::Commands::MoveWithOnOff::Type command_data; @@ -222,14 +226,12 @@ esp_err_t esp_matter_level_control_send_command_move_with_on_off(esp_matter_peer command_data.rate = rate; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_level_control_send_command_step(esp_matter_peer_device_t *remote_device, int remote_endpoint_id, - uint8_t step_mode, uint8_t step_size, uint16_t transition_time, - uint8_t option_mask, uint8_t option_override) +esp_err_t send_step(peer_device_t *remote_device, int remote_endpoint_id, uint8_t step_mode, uint8_t step_size, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override) { chip::Controller::LevelControlCluster cluster; chip::app::Clusters::LevelControl::Commands::Step::Type command_data; @@ -240,14 +242,12 @@ esp_err_t esp_matter_level_control_send_command_step(esp_matter_peer_device_t *r command_data.optionOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_level_control_send_command_step_with_on_off(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t step_mode, - uint8_t step_size, uint16_t transition_time) +esp_err_t send_step_with_on_off(peer_device_t *remote_device, int remote_endpoint_id, uint8_t step_mode, + uint8_t step_size, uint16_t transition_time) { chip::Controller::LevelControlCluster cluster; chip::app::Clusters::LevelControl::Commands::StepWithOnOff::Type command_data; @@ -256,13 +256,11 @@ esp_err_t esp_matter_level_control_send_command_step_with_on_off(esp_matter_peer command_data.transitionTime = transition_time; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_level_control_send_command_stop(esp_matter_peer_device_t *remote_device, int remote_endpoint_id, - uint8_t option_mask, uint8_t option_override) +esp_err_t send_stop(peer_device_t *remote_device, int remote_endpoint_id, uint8_t option_mask, uint8_t option_override) { chip::Controller::LevelControlCluster cluster; chip::app::Clusters::LevelControl::Commands::Stop::Type command_data; @@ -270,26 +268,28 @@ esp_err_t esp_matter_level_control_send_command_stop(esp_matter_peer_device_t *r command_data.optionOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_level_control_send_command_stop_with_on_off(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id) +esp_err_t send_stop_with_on_off(peer_device_t *remote_device, int remote_endpoint_id) { chip::Controller::LevelControlCluster cluster; chip::app::Clusters::LevelControl::Commands::Stop::Type command_data; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_color_control_send_command_move_hue(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t move_mode, uint8_t rate, - uint8_t option_mask, uint8_t option_override) +} /* command */ +} /* level_control */ + +namespace color_control { +namespace command { + +esp_err_t send_move_hue(peer_device_t *remote_device, int remote_endpoint_id, uint8_t move_mode, uint8_t rate, + uint8_t option_mask, uint8_t option_override) { chip::Controller::ColorControlCluster cluster; chip::app::Clusters::ColorControl::Commands::MoveHue::Type command_data; @@ -299,14 +299,12 @@ esp_err_t esp_matter_color_control_send_command_move_hue(esp_matter_peer_device_ command_data.optionsOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_color_control_send_command_move_saturation(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t move_mode, uint8_t rate, - uint8_t option_mask, uint8_t option_override) +esp_err_t send_move_saturation(peer_device_t *remote_device, int remote_endpoint_id, uint8_t move_mode, uint8_t rate, + uint8_t option_mask, uint8_t option_override) { chip::Controller::ColorControlCluster cluster; chip::app::Clusters::ColorControl::Commands::MoveSaturation::Type command_data; @@ -316,15 +314,12 @@ esp_err_t esp_matter_color_control_send_command_move_saturation(esp_matter_peer_ command_data.optionsOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_color_control_send_command_move_to_hue(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t hue, uint8_t direction, - uint16_t transition_time, uint8_t option_mask, - uint8_t option_override) +esp_err_t send_move_to_hue(peer_device_t *remote_device, int remote_endpoint_id, uint8_t hue, uint8_t direction, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override) { chip::Controller::ColorControlCluster cluster; chip::app::Clusters::ColorControl::Commands::MoveToHue::Type command_data; @@ -335,15 +330,13 @@ esp_err_t esp_matter_color_control_send_command_move_to_hue(esp_matter_peer_devi command_data.optionsOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_color_control_send_command_move_to_hue_and_saturation(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t hue, - uint8_t saturation, uint16_t transition_time, - uint8_t option_mask, uint8_t option_override) +esp_err_t send_move_to_hue_and_saturation(peer_device_t *remote_device, int remote_endpoint_id, uint8_t hue, + uint8_t saturation, uint16_t transition_time, uint8_t option_mask, + uint8_t option_override) { chip::Controller::ColorControlCluster cluster; chip::app::Clusters::ColorControl::Commands::MoveToHueAndSaturation::Type command_data; @@ -354,15 +347,12 @@ esp_err_t esp_matter_color_control_send_command_move_to_hue_and_saturation(esp_m command_data.optionsOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_color_control_send_command_move_to_saturation(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t saturation, - uint16_t transition_time, uint8_t option_mask, - uint8_t option_override) +esp_err_t send_move_to_saturation(peer_device_t *remote_device, int remote_endpoint_id, uint8_t saturation, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override) { chip::Controller::ColorControlCluster cluster; chip::app::Clusters::ColorControl::Commands::MoveToSaturation::Type command_data; @@ -372,15 +362,12 @@ esp_err_t esp_matter_color_control_send_command_move_to_saturation(esp_matter_pe command_data.optionsOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_color_control_send_command_step_hue(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t step_mode, uint8_t step_size, - uint16_t transition_time, uint8_t option_mask, - uint8_t option_override) +esp_err_t send_step_hue(peer_device_t *remote_device, int remote_endpoint_id, uint8_t step_mode, uint8_t step_size, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override) { chip::Controller::ColorControlCluster cluster; chip::app::Clusters::ColorControl::Commands::StepHue::Type command_data; @@ -391,15 +378,13 @@ esp_err_t esp_matter_color_control_send_command_step_hue(esp_matter_peer_device_ command_data.optionsOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } -esp_err_t esp_matter_color_control_send_command_step_saturation(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t step_mode, - uint8_t step_size, uint16_t transition_time, - uint8_t option_mask, uint8_t option_override) +esp_err_t send_step_saturation(peer_device_t *remote_device, int remote_endpoint_id, uint8_t step_mode, + uint8_t step_size, uint16_t transition_time, uint8_t option_mask, + uint8_t option_override) { chip::Controller::ColorControlCluster cluster; chip::app::Clusters::ColorControl::Commands::StepSaturation::Type command_data; @@ -410,7 +395,12 @@ esp_err_t esp_matter_color_control_send_command_step_saturation(esp_matter_peer_ command_data.optionsOverride = option_override; cluster.Associate(remote_device, remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, esp_matter_send_command_success_callback, - esp_matter_send_command_failure_callback); + cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); return ESP_OK; } + +} /* command */ +} /* color_control */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_client.h b/components/esp_matter/esp_matter_client.h index f35c7f6c7..33bdf7e9b 100644 --- a/components/esp_matter/esp_matter_client.h +++ b/components/esp_matter/esp_matter_client.h @@ -17,60 +17,56 @@ #include #include -/* cluster: on_off */ -esp_err_t esp_matter_on_off_send_command_off(esp_matter_peer_device_t *remote_device, int remote_endpoint_id); -esp_err_t esp_matter_on_off_send_command_on(esp_matter_peer_device_t *remote_device, int remote_endpoint_id); -esp_err_t esp_matter_on_off_send_command_toggle(esp_matter_peer_device_t *remote_device, int remote_endpoint_id); +namespace esp_matter { +namespace cluster { +using client::peer_device_t; -/* cluster: level_control */ -esp_err_t esp_matter_level_control_send_command_move(esp_matter_peer_device_t *remote_device, int remote_endpoint_id, - uint8_t move_mode, uint8_t rate, uint8_t option_mask, - uint8_t option_override); -esp_err_t esp_matter_level_control_send_command_move_to_level(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t level, - uint16_t transition_time, uint8_t option_mask, - uint8_t option_override); -esp_err_t esp_matter_level_control_send_command_move_to_level_with_on_off(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t level, - uint16_t transition_time); -esp_err_t esp_matter_level_control_send_command_move_with_on_off(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t move_mode, - uint8_t rate); -esp_err_t esp_matter_level_control_send_command_step(esp_matter_peer_device_t *remote_device, int remote_endpoint_id, - uint8_t step_mode, uint8_t step_size, uint16_t transition_time, - uint8_t option_mask, uint8_t option_override); -esp_err_t esp_matter_level_control_send_command_step_with_on_off(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t step_mode, - uint8_t step_size, uint16_t transition_time); -esp_err_t esp_matter_level_control_send_command_stop(esp_matter_peer_device_t *remote_device, int remote_endpoint_id, - uint8_t option_mask, uint8_t option_override); -esp_err_t esp_matter_level_control_send_command_stop_with_on_off(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id); +namespace on_off { +namespace command { +esp_err_t send_off(peer_device_t *remote_device, int remote_endpoint_id); +esp_err_t send_on(peer_device_t *remote_device, int remote_endpoint_id); +esp_err_t send_toggle(peer_device_t *remote_device, int remote_endpoint_id); +} /* command */ +} /* on_off */ -/* cluster: color_control */ -esp_err_t esp_matter_color_control_send_command_move_hue(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t move_mode, uint8_t rate, - uint8_t option_mask, uint8_t option_override); -esp_err_t esp_matter_color_control_send_command_move_saturation(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t move_mode, uint8_t rate, - uint8_t option_mask, uint8_t option_override); -esp_err_t esp_matter_color_control_send_command_move_to_hue(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t hue, uint8_t direction, - uint16_t transition_time, uint8_t option_mask, - uint8_t option_override); -esp_err_t esp_matter_color_control_send_command_move_to_hue_and_saturation(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t hue, - uint8_t saturation, uint16_t transition_time, - uint8_t option_mask, uint8_t option_override); -esp_err_t esp_matter_color_control_send_command_move_to_saturation(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t saturation, - uint16_t transition_time, uint8_t option_mask, - uint8_t option_override); -esp_err_t esp_matter_color_control_send_command_step_hue(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t step_mode, uint8_t step_size, - uint16_t transition_time, uint8_t option_mask, - uint8_t option_override); -esp_err_t esp_matter_color_control_send_command_step_saturation(esp_matter_peer_device_t *remote_device, - int remote_endpoint_id, uint8_t step_mode, - uint8_t step_size, uint16_t transition_time, - uint8_t option_mask, uint8_t option_override); +namespace level_control { +namespace command { +esp_err_t send_move(peer_device_t *remote_device, int remote_endpoint_id, uint8_t move_mode, uint8_t rate, + uint8_t option_mask, uint8_t option_override); +esp_err_t send_move_to_level(peer_device_t *remote_device, int remote_endpoint_id, uint8_t level, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override); +esp_err_t send_move_to_level_with_on_off(peer_device_t *remote_device, int remote_endpoint_id, uint8_t level, + uint16_t transition_time); +esp_err_t send_move_with_on_off(peer_device_t *remote_device, int remote_endpoint_id, uint8_t move_mode, uint8_t rate); +esp_err_t send_step(peer_device_t *remote_device, int remote_endpoint_id, uint8_t step_mode, uint8_t step_size, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override); +esp_err_t send_step_with_on_off(peer_device_t *remote_device, int remote_endpoint_id, uint8_t step_mode, + uint8_t step_size, uint16_t transition_time); +esp_err_t send_stop(peer_device_t *remote_device, int remote_endpoint_id, uint8_t option_mask, uint8_t option_override); +esp_err_t send_stop_with_on_off(peer_device_t *remote_device, int remote_endpoint_id); +} /* command */ +} /* level_control */ + +namespace color_control { +namespace command { +esp_err_t send_move_hue(peer_device_t *remote_device, int remote_endpoint_id, uint8_t move_mode, uint8_t rate, + uint8_t option_mask, uint8_t option_override); +esp_err_t send_move_saturation(peer_device_t *remote_device, int remote_endpoint_id, uint8_t move_mode, uint8_t rate, + uint8_t option_mask, uint8_t option_override); +esp_err_t send_move_to_hue(peer_device_t *remote_device, int remote_endpoint_id, uint8_t hue, uint8_t direction, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override); +esp_err_t send_move_to_hue_and_saturation(peer_device_t *remote_device, int remote_endpoint_id, uint8_t hue, + uint8_t saturation, uint16_t transition_time, uint8_t option_mask, + uint8_t option_override); +esp_err_t send_move_to_saturation(peer_device_t *remote_device, int remote_endpoint_id, uint8_t saturation, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override); +esp_err_t send_step_hue(peer_device_t *remote_device, int remote_endpoint_id, uint8_t step_mode, uint8_t step_size, + uint16_t transition_time, uint8_t option_mask, uint8_t option_override); +esp_err_t send_step_saturation(peer_device_t *remote_device, int remote_endpoint_id, uint8_t step_mode, + uint8_t step_size, uint16_t transition_time, uint8_t option_mask, + uint8_t option_override); +} /* command */ +} /* color_control */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index 484e2cbac..967e380d4 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -20,799 +20,753 @@ #include #include +#include +#include #include #include -#include -#include static const char *TAG = "esp_matter_cluster"; -const esp_matter_cluster_function_generic_t *esp_matter_cluster_descriptor_function_list = NULL; -const int esp_matter_cluster_descriptor_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; +namespace esp_matter { +namespace cluster { -const esp_matter_cluster_function_generic_t *esp_matter_cluster_ota_provider_function_list = NULL; -const int esp_matter_cluster_ota_provider_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_ota_requestor_function_list = NULL; -const int esp_matter_cluster_ota_requestor_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_general_commissioning_function_list = NULL; -const int esp_matter_cluster_general_commissioning_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_network_commissioning_function_list = NULL; -const int esp_matter_cluster_network_commissioning_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_general_diagnostics_function_list = NULL; -const int esp_matter_cluster_general_diagnostics_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_administrator_commissioning_function_list = NULL; -const int esp_matter_cluster_administrator_commissioning_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_operational_credentials_function_list = NULL; -const int esp_matter_cluster_operational_credentials_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_group_key_management_function_list = NULL; -const int esp_matter_cluster_group_key_management_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_fan_control_function_list = NULL; -const int esp_matter_cluster_fan_control_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_binding_function_list = NULL; -const int esp_matter_cluster_binding_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_bridged_device_basic_function_list = NULL; -const int esp_matter_cluster_bridged_device_basic_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_fixed_label_function_list = NULL; -const int esp_matter_cluster_fixed_label_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_switch_function_list = NULL; -const int esp_matter_cluster_switch_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_time_synchronization_function_list = NULL; -const int esp_matter_cluster_time_synchronization_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_temperature_measurement_function_list = NULL; -const int esp_matter_cluster_temperature_measurement_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t *esp_matter_cluster_access_control_function_list = NULL; -const int esp_matter_cluster_access_control_function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_basic_function_list[] = { - (esp_matter_cluster_function_generic_t)emberAfBasicClusterServerInitCallback, -}; -const int esp_matter_cluster_basic_function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_identify_function_list[] = { - (esp_matter_cluster_function_generic_t)emberAfIdentifyClusterServerInitCallback, - (esp_matter_cluster_function_generic_t)MatterIdentifyClusterServerAttributeChangedCallback, -}; -const int esp_matter_cluster_identify_function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION | - ESP_MATTER_CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_groups_function_list[] = { - (esp_matter_cluster_function_generic_t)emberAfGroupsClusterServerInitCallback, -}; -const int esp_matter_cluster_groups_function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_scenes_function_list[] = { - (esp_matter_cluster_function_generic_t)emberAfScenesClusterServerInitCallback, -}; -const int esp_matter_cluster_scenes_function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_on_off_function_list[] = { - (esp_matter_cluster_function_generic_t)emberAfOnOffClusterServerInitCallback, -}; -const int esp_matter_cluster_on_off_function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_level_control_function_list[] = { - (esp_matter_cluster_function_generic_t)emberAfLevelControlClusterServerInitCallback, -}; -const int esp_matter_cluster_level_control_function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_color_control_function_list[] = { - (esp_matter_cluster_function_generic_t)emberAfColorControlClusterServerInitCallback, -}; -const int esp_matter_cluster_color_control_function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_thermostat_function_list[] = { - (esp_matter_cluster_function_generic_t)emberAfThermostatClusterServerInitCallback, -}; -const int esp_matter_cluster_thermostat_function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; - -const esp_matter_cluster_function_generic_t esp_matter_cluster_door_lock_function_list[] = { - (esp_matter_cluster_function_generic_t) MatterDoorLockClusterServerAttributeChangedCallback, - (esp_matter_cluster_function_generic_t) MatterDoorLockClusterServerPreAttributeChangedCallback, -}; -const int esp_matter_cluster_door_lock_function_flags = ESP_MATTER_CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION | - ESP_MATTER_CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; - -void esp_matter_cluster_plugin_init_callback_common() +void plugin_init_callback_common() { ESP_LOGI(TAG, "Cluster plugin init common callback"); - esp_matter_node_t *node = esp_matter_node_get(); - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get_first(node); + node_t *node = node::get(); + endpoint_t *endpoint = endpoint::get_first(node); while (endpoint) { - esp_matter_cluster_t *cluster = esp_matter_cluster_get_first(endpoint); + cluster_t *cluster = get_first(endpoint); while (cluster) { /* Plugin server init callback */ - esp_matter_cluster_plugin_server_init_callback_t plugin_server_init_callback = - esp_matter_cluster_get_plugin_server_init_callback(cluster); + plugin_server_init_callback_t plugin_server_init_callback = get_plugin_server_init_callback(cluster); if (plugin_server_init_callback) { plugin_server_init_callback(); } /* Plugin client init callback */ - esp_matter_cluster_plugin_client_init_callback_t plugin_client_init_callback = - esp_matter_cluster_get_plugin_client_init_callback(cluster); + plugin_client_init_callback_t plugin_client_init_callback = get_plugin_client_init_callback(cluster); if (plugin_client_init_callback) { plugin_client_init_callback(); } - cluster = esp_matter_cluster_get_next(cluster); + cluster = get_next(cluster); } - endpoint = esp_matter_endpoint_get_next(endpoint); + endpoint = endpoint::get_next(endpoint); } } -esp_matter_cluster_t *esp_matter_cluster_create_descriptor(esp_matter_endpoint_t *endpoint, uint8_t flags) +namespace descriptor { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_DESCRIPTOR_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_DESCRIPTOR_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterDescriptorPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_descriptor_function_list, - esp_matter_cluster_descriptor_function_flags); + set_plugin_server_init_callback(cluster, MatterDescriptorPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterDescriptorPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterDescriptorPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, 0); - esp_matter_attribute_create_device_list(cluster, NULL, 0, 0); - esp_matter_attribute_create_server_list(cluster, NULL, 0, 0); - esp_matter_attribute_create_client_list(cluster, NULL, 0, 0); - esp_matter_attribute_create_parts_list(cluster, NULL, 0, 0); + global::attribute::create_cluster_revision(cluster, 0); + attribute::create_device_list(cluster, NULL, 0, 0); + attribute::create_server_list(cluster, NULL, 0, 0); + attribute::create_client_list(cluster, NULL, 0, 0); + attribute::create_parts_list(cluster, NULL, 0, 0); return cluster; } +} /* descriptor */ -esp_matter_cluster_t *esp_matter_cluster_create_access_control(esp_matter_endpoint_t *endpoint, uint8_t flags) +namespace access_control { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_ACCESS_CONTROL_CLUSTER_ID, - ESP_MATTER_CLUSTER_FLAG_SERVER); + cluster_t *cluster = cluster::create(endpoint, ZCL_ACCESS_CONTROL_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterAccessControlPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_access_control_function_list, - esp_matter_cluster_access_control_function_flags); + set_plugin_server_init_callback(cluster, MatterAccessControlPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterAccessControlPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterAccessControlPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, 0); - esp_matter_attribute_create_acl(cluster, NULL, 0, 0); - esp_matter_attribute_create_extension(cluster, NULL, 0, 0); + global::attribute::create_cluster_revision(cluster, 0); + attribute::create_acl(cluster, NULL, 0, 0); + attribute::create_extension(cluster, NULL, 0, 0); return cluster; } +} /* access_control */ -esp_matter_cluster_t *esp_matter_cluster_create_basic(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_basic_config_t *config, uint8_t flags) +namespace basic { +const function_generic_t function_list[] = { + (function_generic_t)emberAfBasicClusterServerInitCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_BASIC_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_BASIC_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterBasicPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_basic_function_list, - esp_matter_cluster_basic_function_flags); + set_plugin_server_init_callback(cluster, MatterBasicPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterBasicPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterBasicPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_data_model_revision(cluster, 0); - esp_matter_attribute_create_location(cluster, NULL, 0); - esp_matter_attribute_create_vendor_name(cluster, NULL, 0); - esp_matter_attribute_create_vendor_id(cluster, 0); - esp_matter_attribute_create_product_name(cluster, NULL, 0); - esp_matter_attribute_create_product_id(cluster, 0); - esp_matter_attribute_create_hardware_version(cluster, 0); - esp_matter_attribute_create_hardware_version_string(cluster, NULL, 0); - esp_matter_attribute_create_software_version(cluster, 0); - esp_matter_attribute_create_software_version_string(cluster, NULL, 0); + attribute::create_data_model_revision(cluster, 0); + attribute::create_location(cluster, NULL, 0); + attribute::create_vendor_name(cluster, NULL, 0); + attribute::create_vendor_id(cluster, 0); + attribute::create_product_name(cluster, NULL, 0); + attribute::create_product_id(cluster, 0); + attribute::create_hardware_version(cluster, 0); + attribute::create_hardware_version_string(cluster, NULL, 0); + attribute::create_software_version(cluster, 0); + attribute::create_software_version_string(cluster, NULL, 0); /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_node_label(cluster, config->node_label, sizeof(config->node_label)); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_node_label(cluster, config->node_label, sizeof(config->node_label)); return cluster; } +} /* basic */ -esp_matter_cluster_t *esp_matter_cluster_create_binding(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_binding_config_t *config, - uint8_t flags) +namespace binding { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_BINDING_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_BINDING_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterBindingPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_binding_function_list, - esp_matter_cluster_binding_function_flags); + set_plugin_server_init_callback(cluster, MatterBindingPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterBindingPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterBindingPluginClientInitCallback); } - + /* Extra initialization */ - esp_matter_binding_init(); + client::binding_init(); /* Attributes managed internally */ - esp_matter_attribute_create_binding(cluster, NULL, 0, 0); + attribute::create_binding(cluster, NULL, 0, 0); /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); return cluster; } +} /* binding */ -esp_matter_cluster_t *esp_matter_cluster_create_ota_provider(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_ota_provider_config_t *config, - uint8_t flags) +namespace ota_provider { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_OTA_PROVIDER_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_OTA_PROVIDER_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, - MatterOtaSoftwareUpdateProviderPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_ota_provider_function_list, - esp_matter_cluster_ota_provider_function_flags); + set_plugin_server_init_callback(cluster, MatterOtaSoftwareUpdateProviderPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, - MatterOtaSoftwareUpdateProviderPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterOtaSoftwareUpdateProviderPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); /* Commands */ - esp_matter_command_create_query_image(cluster); - esp_matter_command_create_query_image_response(cluster); - esp_matter_command_create_apply_update_request(cluster); - esp_matter_command_create_apply_update_response(cluster); - esp_matter_command_create_notify_update_applied(cluster); + command::create_query_image(cluster); + command::create_query_image_response(cluster); + command::create_apply_update_request(cluster); + command::create_apply_update_response(cluster); + command::create_notify_update_applied(cluster); return cluster; } +} /* ota_provider */ -esp_matter_cluster_t *esp_matter_cluster_create_ota_requestor(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_ota_requestor_config_t *config, - uint8_t flags) +namespace ota_requestor { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_OTA_REQUESTOR_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_OTA_REQUESTOR_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, - MatterOtaSoftwareUpdateRequestorPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_ota_requestor_function_list, - esp_matter_cluster_ota_requestor_function_flags); + set_plugin_server_init_callback(cluster, MatterOtaSoftwareUpdateRequestorPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, - MatterOtaSoftwareUpdateRequestorPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterOtaSoftwareUpdateRequestorPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_default_ota_providers(cluster, NULL, 0); + attribute::create_default_ota_providers(cluster, NULL, 0); /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_update_possible(cluster, config->update_possible); - esp_matter_attribute_create_update_state(cluster, config->update_state); - esp_matter_attribute_create_update_state_progress(cluster, config->update_state_progress); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_update_possible(cluster, config->update_possible); + attribute::create_update_state(cluster, config->update_state); + attribute::create_update_state_progress(cluster, config->update_state_progress); /* Commands */ - esp_matter_command_create_announce_ota_provider(cluster); + command::create_announce_ota_provider(cluster); return cluster; } +} /* ota_requestor */ -esp_matter_cluster_t *esp_matter_cluster_create_general_commissioning(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_general_commissioning_config_t *config, - uint8_t flags) +namespace general_commissioning { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterGeneralCommissioningPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_general_commissioning_function_list, - esp_matter_cluster_general_commissioning_function_flags); + set_plugin_server_init_callback(cluster, MatterGeneralCommissioningPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterGeneralCommissioningPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterGeneralCommissioningPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_regulatory_config(cluster, 0); - esp_matter_attribute_create_location_capability(cluster, 0); - esp_matter_attribute_create_basic_commissioning_info(cluster, NULL, 0, 0); + attribute::create_regulatory_config(cluster, 0); + attribute::create_location_capability(cluster, 0); + attribute::create_basic_commissioning_info(cluster, NULL, 0, 0); /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_breadcrumb(cluster, config->breadcrumb); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_breadcrumb(cluster, config->breadcrumb); /* Commands */ - esp_matter_command_create_arm_fail_safe(cluster); - esp_matter_command_create_arm_fail_safe_response(cluster); - esp_matter_command_create_set_regulatory_config(cluster); - esp_matter_command_create_set_regulatory_config_response(cluster); - esp_matter_command_create_commissioning_complete(cluster); - esp_matter_command_create_commissioning_complete_response(cluster); + command::create_arm_fail_safe(cluster); + command::create_arm_fail_safe_response(cluster); + command::create_set_regulatory_config(cluster); + command::create_set_regulatory_config_response(cluster); + command::create_commissioning_complete(cluster); + command::create_commissioning_complete_response(cluster); return cluster; } +} /* general_commissioning */ -esp_matter_cluster_t *esp_matter_cluster_create_network_commissioning(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_network_commissioning_config_t *config, - uint8_t flags) +namespace network_commissioning { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterNetworkCommissioningPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_network_commissioning_function_list, - esp_matter_cluster_network_commissioning_function_flags); + set_plugin_server_init_callback(cluster, MatterNetworkCommissioningPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterNetworkCommissioningPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterNetworkCommissioningPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_max_networks(cluster, 0); - esp_matter_attribute_create_networks(cluster, NULL, 0, 0); - esp_matter_attribute_create_scan_max_time_seconds(cluster, 0); - esp_matter_attribute_create_connect_max_time_seconds(cluster, 0); - esp_matter_attribute_create_interface_enabled(cluster, 0); - esp_matter_attribute_create_last_networking_status(cluster, 0); - esp_matter_attribute_create_last_network_id(cluster, NULL, 0); - esp_matter_attribute_create_last_connect_error_value(cluster, 0); - esp_matter_attribute_create_feature_map(cluster, 0); + attribute::create_max_networks(cluster, 0); + attribute::create_networks(cluster, NULL, 0, 0); + attribute::create_scan_max_time_seconds(cluster, 0); + attribute::create_connect_max_time_seconds(cluster, 0); + attribute::create_interface_enabled(cluster, 0); + attribute::create_last_networking_status(cluster, 0); + attribute::create_last_network_id(cluster, NULL, 0); + attribute::create_last_connect_error_value(cluster, 0); + global::attribute::create_feature_map(cluster, 0); /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); /* Commands */ - esp_matter_command_create_scan_networks(cluster); - esp_matter_command_create_scan_networks_response(cluster); - esp_matter_command_create_add_or_update_wifi_network(cluster); - esp_matter_command_create_add_or_update_thread_network(cluster); - esp_matter_command_create_remove_network(cluster); - esp_matter_command_create_network_config_response(cluster); - esp_matter_command_create_connect_network(cluster); - esp_matter_command_create_connect_network_response(cluster); - esp_matter_command_create_reorder_network(cluster); + command::create_scan_networks(cluster); + command::create_scan_networks_response(cluster); + command::create_add_or_update_wifi_network(cluster); + command::create_add_or_update_thread_network(cluster); + command::create_remove_network(cluster); + command::create_network_config_response(cluster); + command::create_connect_network(cluster); + command::create_connect_network_response(cluster); + command::create_reorder_network(cluster); return cluster; } +} /* network_commissioning */ -esp_matter_cluster_t *esp_matter_cluster_create_general_diagnostics(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_general_diagnostics_config_t *config, - uint8_t flags) +namespace general_diagnostics { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterGeneralDiagnosticsPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_general_diagnostics_function_list, - esp_matter_cluster_general_diagnostics_function_flags); + set_plugin_server_init_callback(cluster, MatterGeneralDiagnosticsPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterGeneralDiagnosticsPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterGeneralDiagnosticsPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_network_interfaces(cluster, NULL, 0, 0); - esp_matter_attribute_create_reboot_count(cluster, 0); + attribute::create_network_interfaces(cluster, NULL, 0, 0); + attribute::create_reboot_count(cluster, 0); /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); return cluster; } +} /* general_diagnostics */ -esp_matter_cluster_t *esp_matter_cluster_create_administrator_commissioning(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_administrator_commissioning_config_t *config, - uint8_t flags) +namespace administrator_commissioning { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID, - flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, - MatterAdministratorCommissioningPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_administrator_commissioning_function_list, - esp_matter_cluster_administrator_commissioning_function_flags); + set_plugin_server_init_callback(cluster, MatterAdministratorCommissioningPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, - MatterAdministratorCommissioningPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterAdministratorCommissioningPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_window_status(cluster, 0); - esp_matter_attribute_create_admin_fabric_index(cluster, 0); - esp_matter_attribute_create_admin_vendor_id(cluster, 0); + attribute::create_window_status(cluster, 0); + attribute::create_admin_fabric_index(cluster, 0); + attribute::create_admin_vendor_id(cluster, 0); /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); /* Commands */ - esp_matter_command_create_open_commissioning_window(cluster); - esp_matter_command_create_open_basic_commissioning_window(cluster); - esp_matter_command_create_revoke_commissioning(cluster); + command::create_open_commissioning_window(cluster); + command::create_open_basic_commissioning_window(cluster); + command::create_revoke_commissioning(cluster); return cluster; } +} /* administrator_commissioning */ -esp_matter_cluster_t *esp_matter_cluster_create_operational_credentials(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_operational_credentials_config_t *config, - uint8_t flags) +namespace operational_credentials { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, - MatterOperationalCredentialsPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_operational_credentials_function_list, - esp_matter_cluster_operational_credentials_function_flags); + set_plugin_server_init_callback(cluster, MatterOperationalCredentialsPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, - MatterOperationalCredentialsPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterOperationalCredentialsPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_nocs(cluster, NULL, 0, 0); - esp_matter_attribute_create_supported_fabrics(cluster, 0); - esp_matter_attribute_create_commissioned_fabrics(cluster, 0); - esp_matter_attribute_create_fabrics(cluster, NULL, 0, 0); - esp_matter_attribute_create_trusted_root_certificates(cluster, NULL, 0, 0); - esp_matter_attribute_create_current_fabric_index(cluster, 0); + attribute::create_nocs(cluster, NULL, 0, 0); + attribute::create_supported_fabrics(cluster, 0); + attribute::create_commissioned_fabrics(cluster, 0); + attribute::create_fabrics(cluster, NULL, 0, 0); + attribute::create_trusted_root_certificates(cluster, NULL, 0, 0); + attribute::create_current_fabric_index(cluster, 0); /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); /* Commands */ - esp_matter_command_create_attestation_request(cluster); - esp_matter_command_create_attestation_response(cluster); - esp_matter_command_create_certificate_chain_request(cluster); - esp_matter_command_create_certificate_chain_response(cluster); - esp_matter_command_create_csr_request(cluster); - esp_matter_command_create_csr_response(cluster); - esp_matter_command_create_add_noc(cluster); - esp_matter_command_create_update_noc(cluster); - esp_matter_command_create_noc_response(cluster); - esp_matter_command_create_update_fabric_label(cluster); - esp_matter_command_create_remove_fabric(cluster); - esp_matter_command_create_add_trusted_root_certificate(cluster); - esp_matter_command_create_remove_trusted_root_certificate(cluster); + command::create_attestation_request(cluster); + command::create_attestation_response(cluster); + command::create_certificate_chain_request(cluster); + command::create_certificate_chain_response(cluster); + command::create_csr_request(cluster); + command::create_csr_response(cluster); + command::create_add_noc(cluster); + command::create_update_noc(cluster); + command::create_noc_response(cluster); + command::create_update_fabric_label(cluster); + command::create_remove_fabric(cluster); + command::create_add_trusted_root_certificate(cluster); + command::create_remove_trusted_root_certificate(cluster); return cluster; } +} /* operational_credentials */ -esp_matter_cluster_t *esp_matter_cluster_create_group_key_management(esp_matter_endpoint_t *endpoint, uint8_t flags) +namespace group_key_management { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterGroupKeyManagementPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_group_key_management_function_list, - esp_matter_cluster_group_key_management_function_flags); + set_plugin_server_init_callback(cluster, MatterGroupKeyManagementPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterGroupKeyManagementPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterGroupKeyManagementPluginClientInitCallback); } /* Attributes managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, 0); - esp_matter_attribute_create_group_key_map(cluster, NULL, 0, 0); - esp_matter_attribute_create_group_table(cluster, NULL, 0, 0); - esp_matter_attribute_create_max_groups_per_fabric(cluster, 0); - esp_matter_attribute_create_max_group_keys_per_fabric(cluster, 0); + global::attribute::create_cluster_revision(cluster, 0); + attribute::create_group_key_map(cluster, NULL, 0, 0); + attribute::create_group_table(cluster, NULL, 0, 0); + attribute::create_max_groups_per_fabric(cluster, 0); + attribute::create_max_group_keys_per_fabric(cluster, 0); /* Commands */ - esp_matter_command_create_key_set_write(cluster); - esp_matter_command_create_key_set_read(cluster); - esp_matter_command_create_key_set_read_response(cluster); - esp_matter_command_create_key_set_remove(cluster); - esp_matter_command_create_key_set_read_all_indices(cluster); - esp_matter_command_create_key_set_read_all_indices_response(cluster); + command::create_key_set_write(cluster); + command::create_key_set_read(cluster); + command::create_key_set_read_response(cluster); + command::create_key_set_remove(cluster); + command::create_key_set_read_all_indices(cluster); + command::create_key_set_read_all_indices_response(cluster); return cluster; } +} /* group_key_management */ -esp_matter_cluster_t *esp_matter_cluster_create_identify(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_identify_config_t *config, uint8_t flags) +namespace identify { +const function_generic_t function_list[] = { + (function_generic_t)emberAfIdentifyClusterServerInitCallback, + (function_generic_t)MatterIdentifyClusterServerAttributeChangedCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION | ESP_MATTER_CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_IDENTIFY_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_IDENTIFY_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterIdentifyPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_identify_function_list, - esp_matter_cluster_identify_function_flags); + set_plugin_server_init_callback(cluster, MatterIdentifyPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterIdentifyPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterIdentifyPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_identify_time(cluster, config->identify_time, 0x0, 0xFE); - esp_matter_attribute_create_identify_type(cluster, config->identify_type); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_identify_time(cluster, config->identify_time, 0x0, 0xFE); + attribute::create_identify_type(cluster, config->identify_type); /* Commands */ - esp_matter_command_create_identify(cluster); - esp_matter_command_create_identify_query(cluster); - esp_matter_command_create_identify_query_response(cluster); + command::create_identify(cluster); + command::create_identify_query(cluster); + command::create_identify_query_response(cluster); return cluster; } +} /* identify */ -esp_matter_cluster_t *esp_matter_cluster_create_groups(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_groups_config_t *config, uint8_t flags) +namespace groups { +const function_generic_t function_list[] = { + (function_generic_t)emberAfGroupsClusterServerInitCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_GROUPS_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_GROUPS_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterGroupsPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_groups_function_list, - esp_matter_cluster_groups_function_flags); + set_plugin_server_init_callback(cluster, MatterGroupsPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterGroupsPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterGroupsPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_group_name_support(cluster, config->group_name_support); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_group_name_support(cluster, config->group_name_support); /* Commands */ - esp_matter_command_create_add_group(cluster); - esp_matter_command_create_view_group(cluster); - esp_matter_command_create_get_group_membership(cluster); - esp_matter_command_create_remove_group(cluster); - esp_matter_command_create_remove_all_groups(cluster); - esp_matter_command_create_add_group_if_identifying(cluster); - esp_matter_command_create_add_group_response(cluster); - esp_matter_command_create_view_group_response(cluster); - esp_matter_command_create_get_group_membership_response(cluster); - esp_matter_command_create_remove_group_response(cluster); + command::create_add_group(cluster); + command::create_view_group(cluster); + command::create_get_group_membership(cluster); + command::create_remove_group(cluster); + command::create_remove_all_groups(cluster); + command::create_add_group_if_identifying(cluster); + command::create_add_group_response(cluster); + command::create_view_group_response(cluster); + command::create_get_group_membership_response(cluster); + command::create_remove_group_response(cluster); return cluster; } +} /* groups */ -esp_matter_cluster_t *esp_matter_cluster_create_scenes(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_scenes_config_t *config, uint8_t flags) +namespace scenes { +const function_generic_t function_list[] = { + (function_generic_t)emberAfScenesClusterServerInitCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_SCENES_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_SCENES_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterScenesPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_scenes_function_list, - esp_matter_cluster_scenes_function_flags); + set_plugin_server_init_callback(cluster, MatterScenesPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterScenesPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterScenesPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_scene_count(cluster, config->scene_count); - esp_matter_attribute_create_current_scene(cluster, config->current_scene); - esp_matter_attribute_create_current_group(cluster, config->current_group); - esp_matter_attribute_create_scene_valid(cluster, config->scene_valid); - esp_matter_attribute_create_scene_name_support(cluster, config->scene_name_support); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_scene_count(cluster, config->scene_count); + attribute::create_current_scene(cluster, config->current_scene); + attribute::create_current_group(cluster, config->current_group); + attribute::create_scene_valid(cluster, config->scene_valid); + attribute::create_scene_name_support(cluster, config->scene_name_support); /* Commands */ - esp_matter_command_create_add_scene(cluster); - esp_matter_command_create_view_scene(cluster); - esp_matter_command_create_remove_scene(cluster); - esp_matter_command_create_remove_all_scenes(cluster); - esp_matter_command_create_store_scene(cluster); - esp_matter_command_create_recall_scene(cluster); - esp_matter_command_create_get_scene_membership(cluster); - esp_matter_command_create_add_scene_response(cluster); - esp_matter_command_create_view_scene_response(cluster); - esp_matter_command_create_remove_scene_response(cluster); - esp_matter_command_create_remove_all_scenes_response(cluster); - esp_matter_command_create_store_scene_response(cluster); - esp_matter_command_create_get_scene_membership_response(cluster); + command::create_add_scene(cluster); + command::create_view_scene(cluster); + command::create_remove_scene(cluster); + command::create_remove_all_scenes(cluster); + command::create_store_scene(cluster); + command::create_recall_scene(cluster); + command::create_get_scene_membership(cluster); + command::create_add_scene_response(cluster); + command::create_view_scene_response(cluster); + command::create_remove_scene_response(cluster); + command::create_remove_all_scenes_response(cluster); + command::create_store_scene_response(cluster); + command::create_get_scene_membership_response(cluster); return cluster; } +} /* scenes */ -esp_matter_cluster_t *esp_matter_cluster_create_on_off(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_on_off_config_t *config, uint8_t flags, - uint32_t features) +namespace on_off { +const function_generic_t function_list[] = { + (function_generic_t)emberAfOnOffClusterServerInitCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_ON_OFF_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_ON_OFF_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterOnOffPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_on_off_function_list, - esp_matter_cluster_on_off_function_flags); + set_plugin_server_init_callback(cluster, MatterOnOffPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterOnOffPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterOnOffPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_on_off(cluster, config->on_off); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_on_off(cluster, config->on_off); /* Commands */ - esp_matter_command_create_off(cluster); - esp_matter_command_create_on(cluster); - esp_matter_command_create_toggle(cluster); + command::create_off(cluster); + command::create_on(cluster); + command::create_toggle(cluster); /* Features */ - if (features & ESP_MATTER_ON_OFF_CLUSTER_LIGHTING_FEATURE_ID) { - esp_matter_on_off_cluster_add_feature_lighting(cluster, &(config->lighting)); + if (features & feature::lighting::get_id()) { + feature::lighting::add(cluster, &(config->lighting)); } return cluster; } +} /* on_off */ -esp_matter_cluster_t *esp_matter_cluster_create_level_control(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_level_control_config_t *config, - uint8_t flags, uint32_t features) +namespace level_control { +const function_generic_t function_list[] = { + (function_generic_t)emberAfLevelControlClusterServerInitCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterLevelControlPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_level_control_function_list, - esp_matter_cluster_level_control_function_flags); + set_plugin_server_init_callback(cluster, MatterLevelControlPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterLevelControlPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterLevelControlPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_current_level(cluster, config->current_level); - esp_matter_attribute_create_on_level(cluster, config->on_level); - esp_matter_attribute_create_options(cluster, config->options, 0x0, 0x3); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_current_level(cluster, config->current_level); + attribute::create_on_level(cluster, config->on_level); + attribute::create_options(cluster, config->options, 0x0, 0x3); /* Commands */ - esp_matter_command_create_move_to_level(cluster); - esp_matter_command_create_move(cluster); - esp_matter_command_create_step(cluster); - esp_matter_command_create_stop(cluster); - esp_matter_command_create_move_to_level_with_on_off(cluster); - esp_matter_command_create_move_with_on_off(cluster); - esp_matter_command_create_step_with_on_off(cluster); - esp_matter_command_create_stop_with_on_off(cluster); + command::create_move_to_level(cluster); + command::create_move(cluster); + command::create_step(cluster); + command::create_stop(cluster); + command::create_move_to_level_with_on_off(cluster); + command::create_move_with_on_off(cluster); + command::create_step_with_on_off(cluster); + command::create_stop_with_on_off(cluster); /* Features */ - if (features & ESP_MATTER_LEVEL_CONTROL_CLUSTER_ON_OFF_FEATURE_ID) { - esp_matter_level_control_cluster_add_feature_on_off(cluster); + if (features & feature::on_off::get_id()) { + feature::on_off::add(cluster); } - if (features & ESP_MATTER_LEVEL_CONTROL_CLUSTER_LIGHTING_FEATURE_ID) { - esp_matter_level_control_cluster_add_feature_lighting(cluster, &(config->lighting)); + if (features & feature::lighting::get_id()) { + feature::lighting::add(cluster, &(config->lighting)); } return cluster; } +} /* level_control */ -esp_matter_cluster_t *esp_matter_cluster_create_color_control(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_color_control_config_t *config, - uint8_t flags, uint32_t features) +namespace color_control { +const function_generic_t function_list[] = { + (function_generic_t)emberAfColorControlClusterServerInitCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_COLOR_CONTROL_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterColorControlPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_color_control_function_list, - esp_matter_cluster_color_control_function_flags); + set_plugin_server_init_callback(cluster, MatterColorControlPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterColorControlPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterColorControlPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_color_mode(cluster, config->color_mode); - esp_matter_attribute_create_color_control_options(cluster, config->color_control_options); - esp_matter_attribute_create_enhanced_color_mode(cluster, config->enhanced_color_mode); - esp_matter_attribute_create_color_capabilities(cluster, config->color_capabilities); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_color_mode(cluster, config->color_mode); + attribute::create_color_control_options(cluster, config->color_control_options); + attribute::create_enhanced_color_mode(cluster, config->enhanced_color_mode); + attribute::create_color_capabilities(cluster, config->color_capabilities); /* Features */ - if (features & ESP_MATTER_COLOR_CONTROL_CLUSTER_HUE_SATURATION_FEATURE_ID) { - esp_matter_color_control_cluster_add_feature_hue_saturation(cluster, &(config->hue_saturation)); + if (features & feature::hue_saturation::get_id()) { + feature::hue_saturation::add(cluster, &(config->hue_saturation)); } return cluster; } +} /* color_control */ -esp_matter_cluster_t *esp_matter_cluster_create_fan_control(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_fan_control_config_t *config, - uint8_t flags) +namespace fan_control { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_FAN_CONTROL_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_FAN_CONTROL_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; @@ -820,223 +774,247 @@ esp_matter_cluster_t *esp_matter_cluster_create_fan_control(esp_matter_endpoint_ if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { /* not implemented: Setting NULL since the MatterFanControlPluginServerInitCallback is not implemented */ - esp_matter_cluster_set_plugin_server_init_callback(cluster, NULL); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_fan_control_function_list, - esp_matter_cluster_fan_control_function_flags); + set_plugin_server_init_callback(cluster, NULL); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { /* not implemented: Setting NULL since the MatterFanControlPluginClientInitCallback is not implemented */ - esp_matter_cluster_set_plugin_client_init_callback(cluster, NULL); + set_plugin_client_init_callback(cluster, NULL); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_fan_mode(cluster, config->fan_mode); - esp_matter_attribute_create_fan_mode_sequence(cluster, config->fan_mode_sequence); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_fan_mode(cluster, config->fan_mode); + attribute::create_fan_mode_sequence(cluster, config->fan_mode_sequence); /* Not implemented - esp_matter_attribute_create_percent_setting(cluster, config->percent_setting); - esp_matter_attribute_create_percent_current(cluster, config->percent_current); + attribute::create_percent_setting(cluster, config->percent_setting); + attribute::create_percent_current(cluster, config->percent_current); */ return cluster; } +} /* fan_control */ -esp_matter_cluster_t *esp_matter_cluster_create_thermostat(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_thermostat_config_t *config, - uint8_t flags) +namespace thermostat { +const function_generic_t function_list[] = { + (function_generic_t)emberAfThermostatClusterServerInitCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterThermostatPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_thermostat_function_list, - esp_matter_cluster_thermostat_function_flags); + set_plugin_server_init_callback(cluster, MatterThermostatPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterThermostatPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterThermostatPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_local_temperature(cluster, config->local_temperature); - esp_matter_attribute_create_occupied_cooling_setpoint(cluster, config->occupied_cooling_setpoint); - esp_matter_attribute_create_occupied_heating_setpoint(cluster, config->occupied_heating_setpoint); - esp_matter_attribute_create_control_sequence_of_operation(cluster, config->control_sequence_of_operation, 0x0, 0x5); - esp_matter_attribute_create_system_mode(cluster, config->system_mode, 0x0, 0x7); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_local_temperature(cluster, config->local_temperature); + attribute::create_occupied_cooling_setpoint(cluster, config->occupied_cooling_setpoint); + attribute::create_occupied_heating_setpoint(cluster, config->occupied_heating_setpoint); + attribute::create_control_sequence_of_operation(cluster, config->control_sequence_of_operation, 0x0, 0x5); + attribute::create_system_mode(cluster, config->system_mode, 0x0, 0x7); /* Commands */ - esp_matter_command_create_setpoint_raise_lower(cluster); + command::create_setpoint_raise_lower(cluster); return cluster; } +} /* thermostat */ -esp_matter_cluster_t *esp_matter_cluster_create_door_lock(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_door_lock_config_t *config, - uint8_t flags) +namespace door_lock { +const function_generic_t function_list[] = { + (function_generic_t)MatterDoorLockClusterServerAttributeChangedCallback, + (function_generic_t)MatterDoorLockClusterServerPreAttributeChangedCallback, +}; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION | + ESP_MATTER_CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_DOOR_LOCK_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_DOOR_LOCK_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterDoorLockPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_door_lock_function_list, - esp_matter_cluster_door_lock_function_flags); + set_plugin_server_init_callback(cluster, MatterDoorLockPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterDoorLockPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterDoorLockPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_lock_state(cluster, config->lock_state); - esp_matter_attribute_create_lock_type(cluster, config->lock_type); - esp_matter_attribute_create_actuator_enabled(cluster, config->actuator_enabled); - esp_matter_attribute_create_auto_relock_time(cluster, config->auto_relock_time); - esp_matter_attribute_create_operating_mode(cluster, config->operating_mode, 0x0, 0x4); - esp_matter_attribute_create_supported_operating_modes(cluster, config->supported_operating_modes); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_lock_state(cluster, config->lock_state); + attribute::create_lock_type(cluster, config->lock_type); + attribute::create_actuator_enabled(cluster, config->actuator_enabled); + attribute::create_auto_relock_time(cluster, config->auto_relock_time); + attribute::create_operating_mode(cluster, config->operating_mode, 0x0, 0x4); + attribute::create_supported_operating_modes(cluster, config->supported_operating_modes); /* Commands */ - esp_matter_command_create_lock_door(cluster); - esp_matter_command_create_unlock_door(cluster); + command::create_lock_door(cluster); + command::create_unlock_door(cluster); return cluster; } +} /* door_lock */ -esp_matter_cluster_t *esp_matter_cluster_create_time_synchronization(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_time_synchronization_config_t *config, - uint8_t flags) +namespace time_synchronization { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_TIME_SYNCHRONIZATION_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_TIME_SYNCHRONIZATION_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); - return NULL; + return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterTimeSynchronizationPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_time_synchronization_function_list, - esp_matter_cluster_time_synchronization_function_flags); + set_plugin_server_init_callback(cluster, MatterTimeSynchronizationPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterTimeSynchronizationPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterTimeSynchronizationPluginClientInitCallback); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); return cluster; } +} /* time_synchronization */ -esp_matter_cluster_t *esp_matter_cluster_create_bridged_device_basic(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_bridged_device_basic_config_t *config, - uint8_t flags) +namespace bridged_device_basic { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); - return NULL; + return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { // There is not PluginServer(Client)InitCallback for this cluster - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_bridged_device_basic_function_list, - esp_matter_cluster_bridged_device_basic_function_flags); + add_function_list(cluster, function_list, function_flags); } /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_bridged_device_basic_node_label(cluster, config->node_label, - sizeof(config->node_label)); - esp_matter_attribute_create_reachable(cluster, config->reachable); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_bridged_device_basic_node_label(cluster, config->node_label, sizeof(config->node_label)); + attribute::create_reachable(cluster, config->reachable); return cluster; } +} /* bridged_device_basic */ -esp_matter_cluster_t *esp_matter_cluster_create_fixed_label(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_fixed_label_config_t *config, uint8_t flags) +namespace fixed_label { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_FIXED_LABEL_CLUSTER_ID, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } - - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterFixedLabelPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_fixed_label_function_list, - esp_matter_cluster_fixed_label_function_flags); - } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterFixedLabelPluginClientInitCallback); - } - - /* Attributes managed internally */ - esp_matter_attribute_create_label_list(cluster, NULL, 0, 0); - - /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - - return cluster; -} - -esp_matter_cluster_t *esp_matter_cluster_create_switch(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_switch_config_t *config, uint8_t flags) -{ - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_SWITCH_CLUSTER_ID, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } - - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterSwitchPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_switch_function_list, - esp_matter_cluster_switch_function_flags); - } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterSwitchPluginClientInitCallback); - } - - /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_number_of_positions(cluster, config->number_of_positions); - esp_matter_attribute_create_current_position(cluster, config->current_position); - esp_matter_attribute_create_multi_press_max(cluster, config->multi_press_max); - - return cluster; -} - -esp_matter_cluster_t *esp_matter_cluster_create_temperature_measurement(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_temperature_measurement_config_t *config, - uint8_t flags) -{ - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ZCL_TEMP_MEASUREMENT_CLUSTER_ID, flags); + cluster_t *cluster = cluster::create(endpoint, ZCL_FIXED_LABEL_CLUSTER_ID, flags); if (!cluster) { ESP_LOGE(TAG, "Could not create cluster"); return NULL; } if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { - esp_matter_cluster_set_plugin_server_init_callback(cluster, MatterTemperatureMeasurementPluginServerInitCallback); - esp_matter_cluster_add_function_list(cluster, esp_matter_cluster_temperature_measurement_function_list, - esp_matter_cluster_temperature_measurement_function_flags); + set_plugin_server_init_callback(cluster, MatterFixedLabelPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); } if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { - esp_matter_cluster_set_plugin_client_init_callback(cluster, MatterTemperatureMeasurementPluginClientInitCallback); + set_plugin_client_init_callback(cluster, MatterFixedLabelPluginClientInitCallback); } + /* Attributes managed internally */ + attribute::create_label_list(cluster, NULL, 0, 0); + /* Attributes not managed internally */ - esp_matter_attribute_create_cluster_revision(cluster, config->cluster_revision); - esp_matter_attribute_create_temperature_measured_value(cluster, config->measured_value); - esp_matter_attribute_create_temperature_min_measured_value(cluster, config->min_measured_value); - esp_matter_attribute_create_temperature_max_measured_value(cluster, config->max_measured_value); + global::attribute::create_cluster_revision(cluster, config->cluster_revision); return cluster; } +} /* fixed_label */ + +namespace switch_cluster { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) +{ + cluster_t *cluster = cluster::create(endpoint, ZCL_SWITCH_CLUSTER_ID, flags); + if (!cluster) { + ESP_LOGE(TAG, "Could not create cluster"); + return NULL; + } + + if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + set_plugin_server_init_callback(cluster, MatterSwitchPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); + } + if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + set_plugin_client_init_callback(cluster, MatterSwitchPluginClientInitCallback); + } + + /* Attributes not managed internally */ + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_number_of_positions(cluster, config->number_of_positions); + attribute::create_current_position(cluster, config->current_position); + attribute::create_multi_press_max(cluster, config->multi_press_max); + + return cluster; +} +} /* switch_cluster */ + +namespace temperature_measurement { +const function_generic_t *function_list = NULL; +const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) +{ + cluster_t *cluster = cluster::create(endpoint, ZCL_TEMP_MEASUREMENT_CLUSTER_ID, flags); + if (!cluster) { + ESP_LOGE(TAG, "Could not create cluster"); + return NULL; + } + + if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + set_plugin_server_init_callback(cluster, MatterTemperatureMeasurementPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); + } + if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + set_plugin_client_init_callback(cluster, MatterTemperatureMeasurementPluginClientInitCallback); + } + + /* Attributes not managed internally */ + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_temperature_measured_value(cluster, config->measured_value); + attribute::create_temperature_min_measured_value(cluster, config->min_measured_value); + attribute::create_temperature_max_measured_value(cluster, config->max_measured_value); + + return cluster; +} +} /* temperature_measurement */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index 41e6a926f..87b5c41f0 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -18,251 +18,186 @@ #include #include -#define CLUSTER_CONFIG_BASIC_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .node_label = {0}, \ - } +namespace esp_matter { +namespace cluster { -#define CLUSTER_CONFIG_BINDING_DEFAULT() \ - { \ - .cluster_revision = 1, \ - } +void plugin_init_callback_common(); -#define CLUSTER_CONFIG_OTA_PROVIDER_DEFAULT() \ - { \ - .cluster_revision = 1, \ - } +namespace descriptor { +cluster_t *create(endpoint_t *endpoint, uint8_t flags); +} /* descriptor */ -#define CLUSTER_CONFIG_OTA_REQUESTOR_DEFAULT() \ - { \ - .cluster_revision = 1, \ - .update_possible = 0, \ - .update_state = 0, \ - .update_state_progress = 0, \ - } +namespace access_control { +cluster_t *create(endpoint_t *endpoint, uint8_t flags); +} /* access_control */ -#define CLUSTER_CONFIG_GENERAL_COMMISSIONING_DEFAULT() \ - { \ - .cluster_revision = 1, \ - .breadcrumb = 0, \ - } - -#define CLUSTER_CONFIG_NETWORK_COMMISSIONING_DEFAULT() \ - { \ - .cluster_revision = 1, \ - } - -#define CLUSTER_CONFIG_GENERAL_DIAGNOSTICS_DEFAULT() \ - { \ - .cluster_revision = 1, \ - } - -#define CLUSTER_CONFIG_ADMINISTRATOR_COMMISSIONING_DEFAULT() \ - { \ - .cluster_revision = 1, \ - } - -#define CLUSTER_CONFIG_OPERATIONAL_CREDENTIALS_DEFAULT() \ - { \ - .cluster_revision = 1, \ - } - -#define CLUSTER_CONFIG_IDENTIFY_DEFAULT() \ - { \ - .cluster_revision = 2, \ - .identify_time = 0, \ - .identify_type = 0, \ - } - -#define CLUSTER_CONFIG_GROUPS_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .group_name_support = 0, \ - } - -#define CLUSTER_CONFIG_SCENES_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .scene_count = 0, \ - .current_scene = 0, \ - .current_group = 0, \ - .scene_valid = false, \ - .scene_name_support = 0, \ - } - -#define CLUSTER_CONFIG_ON_OFF_DEFAULT() \ - { \ - .cluster_revision = 4, \ - .on_off = false, \ - .lighting = ON_OFF_CLUSTER_LIGHTING_CONFIG_DEFAULT(), \ - } - -#define CLUSTER_CONFIG_LEVEL_CONTROL_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .current_level = 0, \ - .on_level = 0, \ - .options = 0, \ - .lighting = LEVEL_CONTROL_CLUSTER_LIGHTING_CONFIG_DEFAULT(), \ - } - -#define CLUSTER_CONFIG_COLOR_CONTROL_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .color_mode = 1, \ - .color_control_options = 0, \ - .enhanced_color_mode = 1, \ - .color_capabilities = 0, \ - .hue_saturation = COLOR_CONTROL_CLUSTER_HUE_SATURATION_CONFIG_DEFAULT(), \ - } - -#define CLUSTER_CONFIG_FAN_CONTROL_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .fan_mode = 5, \ - .fan_mode_sequence = 2, \ - } - -#define CLUSTER_CONFIG_THERMOSTAT_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .local_temperature = 0, \ - .occupied_cooling_setpoint = 0x0A28, \ - .occupied_heating_setpoint = 0x07D0, \ - .control_sequence_of_operation = 4, \ - .system_mode = 1, \ - } - -#define CLUSTER_CONFIG_DOOR_LOCK_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .lock_state = 0, \ - .lock_type = 0, \ - .actuator_enabled = 0, \ - .auto_relock_time = 0, \ - .operating_mode = 0, \ - .supported_operating_modes = 0, \ - } - -#define CLUSTER_CONFIG_TIME_SYNCHRONIZATION_DEFAULT() \ - { \ - .cluster_revision = 1, \ - } - -#define CLUSTER_CONFIG_BRIDGED_DEVICE_BASIC_DEFAULT() \ - { \ - .cluster_revision = 1, \ - .node_label = {0}, \ - .reachable = true, \ - } - -#define CLUSTER_CONFIG_FIXED_LABEL_DEFAULT() \ - { \ - .cluster_revision = 1, \ - } - -#define CLUSTER_CONFIG_SWITCH_DEFAULT() \ - { \ - .cluster_revision = 1, \ - .number_of_positions = 2, \ - .current_position = 0, \ - .multi_press_max = 2, \ - } - -#define CLUSTER_CONFIG_TEMPERATURE_MEASUREMENT_DEFAULT() \ - { \ - .cluster_revision = 3, \ - .measured_value = -32768, \ - .min_measured_value = -32768, \ - .max_measured_value = -32768, \ - } - -typedef struct esp_matter_cluster_basic_config { +namespace basic { +typedef struct config { uint16_t cluster_revision; char node_label[32]; -} esp_matter_cluster_basic_config_t; + config() : cluster_revision(3), node_label{0} {} +} config_t; -typedef struct esp_matter_cluster_binding_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* basic */ + +namespace binding { +typedef struct config { uint16_t cluster_revision; -} esp_matter_cluster_binding_config_t; + config() : cluster_revision(1) {} +} config_t; -typedef struct esp_matter_cluster_ota_provider_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* binding */ + +namespace ota_provider { +typedef struct config { uint16_t cluster_revision; -} esp_matter_cluster_ota_provider_config_t; + config() : cluster_revision(1) {} +} config_t; -typedef struct esp_matter_cluster_ota_requestor_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* ota_provider */ + +namespace ota_requestor { +typedef struct config { uint16_t cluster_revision; bool update_possible; uint8_t update_state; uint8_t update_state_progress; -} esp_matter_cluster_ota_requestor_config_t; + config() : cluster_revision(1), update_possible(0), update_state(0), update_state_progress(0) {} +} config_t; -typedef struct esp_matter_cluster_general_commissioning_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* ota_requestor */ + +namespace general_commissioning { +typedef struct config { uint16_t cluster_revision; uint64_t breadcrumb; -} esp_matter_cluster_general_commissioning_config_t; + config() : cluster_revision(1), breadcrumb(0) {} +} config_t; -typedef struct esp_matter_cluster_network_commissioning_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* general_commissioning */ + +namespace network_commissioning { +typedef struct config { uint16_t cluster_revision; -} esp_matter_cluster_network_commissioning_config_t; + config() : cluster_revision(1) {} +} config_t; -typedef struct esp_matter_cluster_general_diagnostics_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* network_commissioning */ + +namespace general_diagnostics { +typedef struct config { uint16_t cluster_revision; -} esp_matter_cluster_general_diagnostics_config_t; + config() : cluster_revision(1) {} +} config_t; -typedef struct esp_matter_cluster_administrator_commissioning_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* general_diagnostics */ + +namespace administrator_commissioning { +typedef struct config { uint16_t cluster_revision; -} esp_matter_cluster_administrator_commissioning_config_t; + config() : cluster_revision(1) {} +} config_t; -typedef struct esp_matter_cluster_operational_credentials_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* administrator_commissioning */ + +namespace operational_credentials { +typedef struct config { uint16_t cluster_revision; -} esp_matter_cluster_operational_credentials_config_t; + config() : cluster_revision(1) {} +} config_t; -typedef struct esp_matter_cluster_identify_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* operational_credentials */ + +namespace group_key_management { +cluster_t *create(endpoint_t *endpoint, uint8_t flags); +} /* group_key_management */ + +namespace identify { +typedef struct config { uint16_t cluster_revision; uint16_t identify_time; uint8_t identify_type; -} esp_matter_cluster_identify_config_t; + config() : cluster_revision(2), identify_time(0), identify_type(0) {} +} config_t; -typedef struct esp_matter_cluster_groups_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* identify */ + +namespace groups { +typedef struct config { uint16_t cluster_revision; uint8_t group_name_support; -} esp_matter_cluster_groups_config_t; + config() : cluster_revision(3), group_name_support(0) {} +} config_t; -typedef struct esp_matter_cluster_scenes_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* groups */ + +namespace scenes { +typedef struct config { uint16_t cluster_revision; uint8_t scene_count; uint8_t current_scene; uint16_t current_group; bool scene_valid; uint8_t scene_name_support; -} esp_matter_cluster_scenes_config_t; + config() : cluster_revision(3), scene_count(0), current_scene(0), current_group(0), scene_valid(false), + scene_name_support(0) {} +} config_t; -typedef struct esp_matter_cluster_on_off_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* scenes */ + +namespace on_off { +typedef struct config { uint16_t cluster_revision; bool on_off; - esp_matter_on_off_cluster_lighting_config_t lighting; -} esp_matter_cluster_on_off_config_t; + feature::lighting::config_t lighting; + config() : cluster_revision(4), on_off(false) {} +} config_t; -typedef struct esp_matter_cluster_level_control_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features); +} /* on_off */ + +namespace level_control { +typedef struct config { uint16_t cluster_revision; uint8_t current_level; uint8_t on_level; uint8_t options; - esp_matter_level_control_cluster_lighting_config_t lighting; -} esp_matter_cluster_level_control_config_t; + feature::lighting::config_t lighting; + config() : cluster_revision(3), current_level(0), on_level(0), options(0) {} +} config_t; -typedef struct esp_matter_cluster_color_control_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features); +} /* level_control */ + +namespace color_control { +typedef struct config { uint16_t cluster_revision; uint8_t color_mode; uint8_t color_control_options; uint8_t enhanced_color_mode; uint16_t color_capabilities; - esp_matter_color_control_cluster_hue_saturation_config_t hue_saturation; -} esp_matter_cluster_color_control_config_t; + feature::hue_saturation::config_t hue_saturation; + config() : cluster_revision(3), color_mode(1), color_control_options(0), enhanced_color_mode(1), + color_capabilities(0) {} +} config_t; -typedef struct esp_matter_cluster_fan_control_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features); +} /* color_control */ + +namespace fan_control { +typedef struct config { uint16_t cluster_revision; uint8_t fan_mode; uint8_t fan_mode_sequence; @@ -270,9 +205,29 @@ typedef struct esp_matter_cluster_fan_control_config { uint8_t percent_setting; uint8_t percent_current; */ -} esp_matter_cluster_fan_control_config_t; + config() : cluster_revision(3), fan_mode(5), fan_mode_sequence(2) {} +} config_t; -typedef struct esp_matter_cluster_door_lock_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* fan_control */ + +namespace thermostat { +typedef struct config { + uint16_t cluster_revision; + int16_t local_temperature; + int16_t occupied_cooling_setpoint; + int16_t occupied_heating_setpoint; + uint8_t control_sequence_of_operation; + uint8_t system_mode; + config() : cluster_revision(3), local_temperature(0), occupied_cooling_setpoint(0x0A28), + occupied_heating_setpoint(0x07D0), control_sequence_of_operation(4), system_mode(1) {} +} config_t; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* thermostat */ + +namespace door_lock { +typedef struct config { uint16_t cluster_revision; uint8_t lock_state; uint8_t lock_type; @@ -280,111 +235,65 @@ typedef struct esp_matter_cluster_door_lock_config { uint32_t auto_relock_time; uint8_t operating_mode; uint16_t supported_operating_modes; -} esp_matter_cluster_door_lock_config_t; + config() : cluster_revision(3), lock_state(0), lock_type(0), actuator_enabled(0), auto_relock_time(0), + operating_mode(0), supported_operating_modes(0) {} +} config_t; -typedef struct esp_matter_cluster_time_synchronization_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* door_lock */ + +namespace time_synchronization { +typedef struct config { uint16_t cluster_revision; -} esp_matter_cluster_time_synchronization_config_t; + config() : cluster_revision(1) {} +} config_t; -typedef struct esp_matter_cluster_thermostat_config { - uint16_t cluster_revision; - int16_t local_temperature; - int16_t occupied_cooling_setpoint; - int16_t occupied_heating_setpoint; - uint8_t control_sequence_of_operation; - uint8_t system_mode; -} esp_matter_cluster_thermostat_config_t; +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* time_synchronization */ -typedef struct esp_matter_cluster_bridged_device_basic_config { +namespace bridged_device_basic { +typedef struct config { uint16_t cluster_revision; char node_label[32]; bool reachable; -} esp_matter_cluster_bridged_device_basic_config_t; + config() : cluster_revision(1), node_label{0}, reachable(true) {} +} config_t; -typedef struct esp_matter_cluster_fixed_label_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* bridged_device_basic */ + +namespace fixed_label { +typedef struct config { uint16_t cluster_revision; -} esp_matter_cluster_fixed_label_config_t; + config() : cluster_revision(1) {} +} config_t; -typedef struct esp_matter_cluster_switch_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* fixed_label */ + +namespace switch_cluster { +typedef struct config { uint16_t cluster_revision; uint8_t number_of_positions; uint8_t current_position; uint8_t multi_press_max; -} esp_matter_cluster_switch_config_t; + config() : cluster_revision(1), number_of_positions(2), current_position(0), multi_press_max(2) {} +} config_t; -typedef struct esp_matter_cluster_temperature_measurement_config { +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* switch_cluster */ + +namespace temperature_measurement { +typedef struct config { uint16_t cluster_revision; int16_t measured_value; int16_t min_measured_value; int16_t max_measured_value; -} esp_matter_cluster_temperature_measurement_config_t; + config() : cluster_revision(3), measured_value(-32768), min_measured_value(-32768), max_measured_value(-32768) {} +} config_t; -void esp_matter_cluster_plugin_init_callback_common(); +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* temperature_measurement */ -esp_matter_cluster_t *esp_matter_cluster_create_descriptor(esp_matter_endpoint_t *endpoint, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_access_control(esp_matter_endpoint_t *endpoint, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_basic(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_basic_config_t *config, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_binding(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_binding_config_t *config, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_ota_provider(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_ota_provider_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_ota_requestor(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_ota_requestor_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_general_commissioning(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_general_commissioning_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_network_commissioning(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_network_commissioning_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_general_diagnostics(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_general_diagnostics_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_administrator_commissioning(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_administrator_commissioning_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_operational_credentials(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_operational_credentials_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_group_key_management(esp_matter_endpoint_t *endpoint, uint8_t flags); - -esp_matter_cluster_t *esp_matter_cluster_create_identify(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_identify_config_t *config, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_groups(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_groups_config_t *config, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_scenes(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_scenes_config_t *config, uint8_t flags); - -esp_matter_cluster_t *esp_matter_cluster_create_on_off(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_on_off_config_t *config, uint8_t flags, - uint32_t features); -esp_matter_cluster_t *esp_matter_cluster_create_level_control(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_level_control_config_t *config, - uint8_t flags, uint32_t features); -esp_matter_cluster_t *esp_matter_cluster_create_color_control(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_color_control_config_t *config, - uint8_t flags, uint32_t features); -esp_matter_cluster_t *esp_matter_cluster_create_fan_control(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_fan_control_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_door_lock(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_door_lock_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_time_synchronization(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_time_synchronization_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_thermostat(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_thermostat_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_bridged_device_basic(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_bridged_device_basic_config_t *config, - uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_fixed_label(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_fixed_label_config_t *config, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_switch(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_switch_config_t *config, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_create_temperature_measurement(esp_matter_endpoint_t *endpoint, - esp_matter_cluster_temperature_measurement_config_t *config, - uint8_t flags); +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_command.cpp b/components/esp_matter/esp_matter_command.cpp index fdbdfd1fb..f2964e18e 100644 --- a/components/esp_matter/esp_matter_command.cpp +++ b/components/esp_matter/esp_matter_command.cpp @@ -18,65 +18,51 @@ #include #include -#include #include #include -#include #include -using chip::ByteSpan; -using chip::CharSpan; using chip::app::CommandHandler; -using chip::app::CommandSender; -using chip::app::ConcreteCommandPath; using chip::app::DataModel::Decode; -using chip::TLV::TagNumFromTag; using chip::TLV::TLVReader; #if (FIXED_ENDPOINT_COUNT == 0) static const char *TAG = "esp_matter_command"; -static esp_matter_command_custom_callback_t custom_callback = NULL; -static void *custom_callback_priv_data = NULL; +namespace esp_matter { +namespace command { -esp_err_t esp_matter_command_set_custom_callback(esp_matter_command_custom_callback_t callback, void *priv_data) -{ - custom_callback = callback; - custom_callback_priv_data = priv_data; - return ESP_OK; -} - -void DispatchSingleClusterCommandCommon(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *command_obj) +void DispatchSingleClusterCommandCommon(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *opaque_ptr) { int endpoint_id = command_path.mEndpointId; int cluster_id = command_path.mClusterId; int command_id = command_path.mCommandId; ESP_LOGI(TAG, "Received command 0x%04X for enpoint 0x%04X's cluster 0x%08X", command_id, endpoint_id, cluster_id); - esp_matter_node_t *node = esp_matter_node_get(); - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get(node, endpoint_id); - esp_matter_cluster_t *cluster = esp_matter_cluster_get(endpoint, cluster_id); - esp_matter_command_t *command = esp_matter_command_get(cluster, command_id); + node_t *node = node::get(); + endpoint_t *endpoint = endpoint::get(node, endpoint_id); + cluster_t *cluster = cluster::get(endpoint, cluster_id); + command_t *command = get(cluster, command_id); if (!command) { ESP_LOGE(TAG, "Command 0x%04X not found", command_id); return; } - int flags = esp_matter_command_get_flags(command); + esp_err_t err = ESP_OK; + callback_t callback = get_callback(command); + if (callback) { + err = callback(command_path, tlv_data, opaque_ptr); + } + int flags = get_flags(command); if (flags & ESP_MATTER_COMMAND_FLAG_CUSTOM) { - if (custom_callback) { - esp_err_t err = custom_callback(endpoint_id, cluster_id, command_id, tlv_data, custom_callback_priv_data); - EmberAfStatus status = (err == ESP_OK) ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); - } - } else { - esp_matter_command_callback_t callback = esp_matter_command_get_callback(command); - if (callback) { - callback(command_obj, command_path, tlv_data); - } + EmberAfStatus status = (err == ESP_OK) ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; + emberAfSendImmediateDefaultResponse(status); } } +} /* command */ +} /* esp_matter */ + namespace chip { namespace app { @@ -85,7 +71,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath &command_path, TLVRe { Compatibility::SetupEmberAfCommandHandler(command_obj, command_path); - DispatchSingleClusterCommandCommon(command_path, tlv_data, command_obj); + esp_matter::command::DispatchSingleClusterCommandCommon(command_path, tlv_data, command_obj); Compatibility::ResetEmberAfObjects(); } @@ -93,1328 +79,1483 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath &command_path, TLVRe } /* namespace app */ } /* namespace chip */ -static void esp_matter_command_callback_key_set_write(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_key_set_write(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupKeyManagementClusterKeySetWriteCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupKeyManagementClusterKeySetWriteCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_key_set_read(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_key_set_read(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupKeyManagementClusterKeySetReadCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupKeyManagementClusterKeySetReadCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_key_set_remove(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_key_set_remove(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupKeyManagementClusterKeySetRemoveCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupKeyManagementClusterKeySetRemoveCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_key_set_read_all_indices(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_key_set_read_all_indices(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndices::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupKeyManagementClusterKeySetReadAllIndicesCallback((CommandHandler *)command_obj, command_path, + emberAfGroupKeyManagementClusterKeySetReadAllIndicesCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_arm_fail_safe(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_arm_fail_safe(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafe::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGeneralCommissioningClusterArmFailSafeCallback((CommandHandler *)command_obj, command_path, - command_data); + emberAfGeneralCommissioningClusterArmFailSafeCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_set_regulatory_config(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_set_regulatory_config(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfig::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback((CommandHandler *)command_obj, command_path, + emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_commissioning_complete(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_commissioning_complete(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::GeneralCommissioning::Commands::CommissioningComplete::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGeneralCommissioningClusterCommissioningCompleteCallback((CommandHandler *)command_obj, command_path, + emberAfGeneralCommissioningClusterCommissioningCompleteCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_scan_networks(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_scan_networks(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworks::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfNetworkCommissioningClusterScanNetworksCallback((CommandHandler *)command_obj, command_path, + emberAfNetworkCommissioningClusterScanNetworksCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_add_or_update_wifi_network(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_add_or_update_wifi_network(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfNetworkCommissioningClusterAddOrUpdateWiFiNetworkCallback((CommandHandler *)command_obj, command_path, + emberAfNetworkCommissioningClusterAddOrUpdateWiFiNetworkCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_add_or_update_thread_network(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_add_or_update_thread_network(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfNetworkCommissioningClusterAddOrUpdateThreadNetworkCallback((CommandHandler *)command_obj, command_path, + emberAfNetworkCommissioningClusterAddOrUpdateThreadNetworkCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_remove_network(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_remove_network(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::NetworkCommissioning::Commands::RemoveNetwork::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfNetworkCommissioningClusterRemoveNetworkCallback((CommandHandler *)command_obj, command_path, + emberAfNetworkCommissioningClusterRemoveNetworkCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_connect_network(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_connect_network(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetwork::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfNetworkCommissioningClusterConnectNetworkCallback((CommandHandler *)command_obj, command_path, + emberAfNetworkCommissioningClusterConnectNetworkCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_reorder_network(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_reorder_network(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::NetworkCommissioning::Commands::ReorderNetwork::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfNetworkCommissioningClusterReorderNetworkCallback((CommandHandler *)command_obj, command_path, + emberAfNetworkCommissioningClusterReorderNetworkCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_open_commissioning_window(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_open_commissioning_window(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfAdministratorCommissioningClusterOpenCommissioningWindowCallback((CommandHandler *)command_obj, + emberAfAdministratorCommissioningClusterOpenCommissioningWindowCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_open_basic_commissioning_window(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_open_basic_commissioning_window(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfAdministratorCommissioningClusterOpenBasicCommissioningWindowCallback((CommandHandler *)command_obj, + emberAfAdministratorCommissioningClusterOpenBasicCommissioningWindowCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_revoke_commissioning(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_revoke_commissioning(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::AdministratorCommissioning::Commands::RevokeCommissioning::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfAdministratorCommissioningClusterRevokeCommissioningCallback((CommandHandler *)command_obj, command_path, + emberAfAdministratorCommissioningClusterRevokeCommissioningCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_attestation_request(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_attestation_request(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::AttestationRequest::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterAttestationRequestCallback((CommandHandler *)command_obj, command_path, + emberAfOperationalCredentialsClusterAttestationRequestCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_certificate_chain_request(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_certificate_chain_request(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::CertificateChainRequest::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterCertificateChainRequestCallback((CommandHandler *)command_obj, command_path, + emberAfOperationalCredentialsClusterCertificateChainRequestCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_csr_request(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_csr_request(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::CSRRequest::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterCSRRequestCallback((CommandHandler *)command_obj, command_path, + emberAfOperationalCredentialsClusterCSRRequestCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_add_noc(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_add_noc(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::AddNOC::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterAddNOCCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfOperationalCredentialsClusterAddNOCCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_update_noc(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_update_noc(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::UpdateNOC::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterUpdateNOCCallback((CommandHandler *)command_obj, command_path, - command_data); + emberAfOperationalCredentialsClusterUpdateNOCCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_update_fabric_label(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_update_fabric_label(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::UpdateFabricLabel::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterUpdateFabricLabelCallback((CommandHandler *)command_obj, command_path, + emberAfOperationalCredentialsClusterUpdateFabricLabelCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_remove_fabric(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_remove_fabric(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::RemoveFabric::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterRemoveFabricCallback((CommandHandler *)command_obj, command_path, + emberAfOperationalCredentialsClusterRemoveFabricCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_add_trusted_root_certificate(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_add_trusted_root_certificate(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::AddTrustedRootCertificate::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback((CommandHandler *)command_obj, + emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_remove_trusted_root_certificate(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_remove_trusted_root_certificate(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OperationalCredentials::Commands::RemoveTrustedRootCertificate::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback((CommandHandler *)command_obj, + emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_query_image(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_query_image(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImage::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback((CommandHandler *)command_obj, command_path, + emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_apply_update_request(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_apply_update_request(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOtaSoftwareUpdateProviderClusterApplyUpdateRequestCallback((CommandHandler *)command_obj, command_path, + emberAfOtaSoftwareUpdateProviderClusterApplyUpdateRequestCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_notify_update_applied(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_notify_update_applied(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOtaSoftwareUpdateProviderClusterNotifyUpdateAppliedCallback((CommandHandler *)command_obj, command_path, + emberAfOtaSoftwareUpdateProviderClusterNotifyUpdateAppliedCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_announce_ota_provider(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_announce_ota_provider(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback((CommandHandler *)command_obj, command_path, + emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_identify(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_identify(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Identify::Commands::Identify::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfIdentifyClusterIdentifyCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfIdentifyClusterIdentifyCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_identify_query(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_identify_query(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::Identify::Commands::IdentifyQuery::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfIdentifyClusterIdentifyQueryCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfIdentifyClusterIdentifyQueryCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_add_group(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_add_group(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Groups::Commands::AddGroup::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupsClusterAddGroupCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupsClusterAddGroupCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_view_group(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_view_group(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Groups::Commands::ViewGroup::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupsClusterViewGroupCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupsClusterViewGroupCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_get_group_membership(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_get_group_membership(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::Groups::Commands::GetGroupMembership::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupsClusterGetGroupMembershipCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupsClusterGetGroupMembershipCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_remove_group(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_remove_group(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Groups::Commands::RemoveGroup::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupsClusterRemoveGroupCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupsClusterRemoveGroupCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_remove_all_groups(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_remove_all_groups(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::Groups::Commands::RemoveAllGroups::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupsClusterRemoveAllGroupsCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupsClusterRemoveAllGroupsCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_add_group_if_identifying(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_add_group_if_identifying(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::Groups::Commands::AddGroupIfIdentifying::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfGroupsClusterAddGroupIfIdentifyingCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfGroupsClusterAddGroupIfIdentifyingCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_add_scene(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_add_scene(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Scenes::Commands::AddScene::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfScenesClusterAddSceneCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfScenesClusterAddSceneCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_view_scene(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_view_scene(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Scenes::Commands::ViewScene::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfScenesClusterViewSceneCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfScenesClusterViewSceneCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_remove_scene(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_remove_scene(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Scenes::Commands::RemoveScene::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfScenesClusterRemoveSceneCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfScenesClusterRemoveSceneCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_remove_all_scenes(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_remove_all_scenes(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::Scenes::Commands::RemoveAllScenes::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfScenesClusterRemoveAllScenesCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfScenesClusterRemoveAllScenesCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_store_scene(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_store_scene(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Scenes::Commands::StoreScene::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfScenesClusterStoreSceneCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfScenesClusterStoreSceneCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_recall_scene(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_recall_scene(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::Scenes::Commands::RecallScene::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfScenesClusterRecallSceneCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfScenesClusterRecallSceneCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_get_scene_membership(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_get_scene_membership(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::Scenes::Commands::GetSceneMembership::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfScenesClusterGetSceneMembershipCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfScenesClusterGetSceneMembershipCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_off(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_off(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::OnOff::Commands::Off::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOnOffClusterOffCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfOnOffClusterOffCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_on(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_on(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::OnOff::Commands::On::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOnOffClusterOnCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfOnOffClusterOnCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_toggle(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_toggle(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::OnOff::Commands::Toggle::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOnOffClusterToggleCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfOnOffClusterToggleCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_off_with_effect(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_off_with_effect(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OnOff::Commands::OffWithEffect::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOnOffClusterOffWithEffectCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfOnOffClusterOffWithEffectCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_on_with_recall_global_scene(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_on_with_recall_global_scene(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OnOff::Commands::OnWithRecallGlobalScene::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOnOffClusterOnWithRecallGlobalSceneCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfOnOffClusterOnWithRecallGlobalSceneCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_on_with_timed_off(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_on_with_timed_off(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::OnOff::Commands::OnWithTimedOff::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfOnOffClusterOnWithTimedOffCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfOnOffClusterOnWithTimedOffCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move_to_level(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move_to_level(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::LevelControl::Commands::MoveToLevel::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfLevelControlClusterMoveToLevelCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfLevelControlClusterMoveToLevelCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::LevelControl::Commands::Move::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfLevelControlClusterMoveCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfLevelControlClusterMoveCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_step(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_step(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::LevelControl::Commands::Step::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfLevelControlClusterStepCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfLevelControlClusterStepCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_stop(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_stop(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::LevelControl::Commands::Stop::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfLevelControlClusterStopCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfLevelControlClusterStopCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move_to_level_with_on_off(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move_to_level_with_on_off(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::LevelControl::Commands::MoveToLevelWithOnOff::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfLevelControlClusterMoveToLevelWithOnOffCallback((CommandHandler *)command_obj, command_path, + emberAfLevelControlClusterMoveToLevelWithOnOffCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move_with_on_off(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move_with_on_off(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::LevelControl::Commands::MoveWithOnOff::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfLevelControlClusterMoveWithOnOffCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfLevelControlClusterMoveWithOnOffCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_step_with_on_off(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_step_with_on_off(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::LevelControl::Commands::StepWithOnOff::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfLevelControlClusterStepWithOnOffCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfLevelControlClusterStepWithOnOffCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_stop_with_on_off(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_stop_with_on_off(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::LevelControl::Commands::StopWithOnOff::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfLevelControlClusterStopWithOnOffCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfLevelControlClusterStopWithOnOffCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move_to_hue(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move_to_hue(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::ColorControl::Commands::MoveToHue::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfColorControlClusterMoveToHueCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfColorControlClusterMoveToHueCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move_hue(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move_hue(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::ColorControl::Commands::MoveHue::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfColorControlClusterMoveHueCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfColorControlClusterMoveHueCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_step_hue(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_step_hue(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::ColorControl::Commands::StepHue::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfColorControlClusterStepHueCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfColorControlClusterStepHueCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move_to_saturation(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move_to_saturation(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::ColorControl::Commands::MoveToSaturation::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfColorControlClusterMoveToSaturationCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfColorControlClusterMoveToSaturationCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move_saturation(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move_saturation(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::ColorControl::Commands::MoveSaturation::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfColorControlClusterMoveSaturationCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfColorControlClusterMoveSaturationCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_step_saturation(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_step_saturation(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::ColorControl::Commands::StepSaturation::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfColorControlClusterStepSaturationCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfColorControlClusterStepSaturationCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_move_to_hue_and_saturation(void *command_obj, - const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_move_to_hue_and_saturation(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::ColorControl::Commands::MoveToHueAndSaturation::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfColorControlClusterMoveToHueAndSaturationCallback((CommandHandler *)command_obj, command_path, + emberAfColorControlClusterMoveToHueAndSaturationCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_stop_move_step(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_stop_move_step(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::ColorControl::Commands::StopMoveStep::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfColorControlClusterStopMoveStepCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfColorControlClusterStopMoveStepCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_lock_door(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_lock_door(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::DoorLock::Commands::LockDoor::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfDoorLockClusterLockDoorCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfDoorLockClusterLockDoorCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_unlock_door(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_unlock_door(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { chip::app::Clusters::DoorLock::Commands::UnlockDoor::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfDoorLockClusterUnlockDoorCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfDoorLockClusterUnlockDoorCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -static void esp_matter_command_callback_setpoint_raise_lower(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data) +static esp_err_t esp_matter_command_callback_setpoint_raise_lower(const ConcreteCommandPath &command_path, + TLVReader &tlv_data, void *opaque_ptr) { chip::app::Clusters::Thermostat::Commands::SetpointRaiseLower::DecodableType command_data; CHIP_ERROR error = Decode(tlv_data, command_data); if (error == CHIP_NO_ERROR) { - emberAfThermostatClusterSetpointRaiseLowerCallback((CommandHandler *)command_obj, command_path, command_data); + emberAfThermostatClusterSetpointRaiseLowerCallback((CommandHandler *)opaque_ptr, command_path, command_data); } + return ESP_OK; } -esp_matter_command_t *esp_matter_command_create_key_set_write(esp_matter_cluster_t *cluster) +namespace esp_matter { +namespace cluster { + +namespace group_key_management { +namespace command { + +command_t *create_key_set_write(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_KEY_SET_WRITE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_key_set_write); + return esp_matter::command::create(cluster, ZCL_KEY_SET_WRITE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_key_set_write); } -esp_matter_command_t *esp_matter_command_create_key_set_read(esp_matter_cluster_t *cluster) +command_t *create_key_set_read(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_KEY_SET_READ_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_key_set_read); + return esp_matter::command::create(cluster, ZCL_KEY_SET_READ_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_key_set_read); } -esp_matter_command_t *esp_matter_command_create_key_set_remove(esp_matter_cluster_t *cluster) +command_t *create_key_set_remove(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_KEY_SET_REMOVE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_key_set_remove); + return esp_matter::command::create(cluster, ZCL_KEY_SET_REMOVE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_key_set_remove); } -esp_matter_command_t *esp_matter_command_create_key_set_read_all_indices(esp_matter_cluster_t *cluster) +command_t *create_key_set_read_all_indices(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_KEY_SET_READ_ALL_INDICES_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_key_set_read_all_indices); + return esp_matter::command::create(cluster, ZCL_KEY_SET_READ_ALL_INDICES_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_key_set_read_all_indices); } -esp_matter_command_t *esp_matter_command_create_arm_fail_safe(esp_matter_cluster_t *cluster) +command_t *create_key_set_read_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ARM_FAIL_SAFE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_arm_fail_safe); + return esp_matter::command::create(cluster, ZCL_KEY_SET_READ_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_set_regulatory_config(esp_matter_cluster_t *cluster) +command_t *create_key_set_read_all_indices_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_SET_REGULATORY_CONFIG_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_set_regulatory_config); + return esp_matter::command::create(cluster, ZCL_KEY_SET_READ_ALL_INDICES_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_commissioning_complete(esp_matter_cluster_t *cluster) +} /* command */ +} /* group_key_management */ + +namespace general_commissioning { +namespace command { + +command_t *create_arm_fail_safe(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_COMMISSIONING_COMPLETE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_commissioning_complete); + return esp_matter::command::create(cluster, ZCL_ARM_FAIL_SAFE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_arm_fail_safe); } -esp_matter_command_t *esp_matter_command_create_scan_networks(esp_matter_cluster_t *cluster) +command_t *create_set_regulatory_config(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_SCAN_NETWORKS_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_scan_networks); + return esp_matter::command::create(cluster, ZCL_SET_REGULATORY_CONFIG_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_set_regulatory_config); } -esp_matter_command_t *esp_matter_command_create_add_or_update_wifi_network(esp_matter_cluster_t *cluster) +command_t *create_commissioning_complete(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_OR_UPDATE_WI_FI_NETWORK_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_add_or_update_wifi_network); + return esp_matter::command::create(cluster, ZCL_COMMISSIONING_COMPLETE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_commissioning_complete); } -esp_matter_command_t *esp_matter_command_create_add_or_update_thread_network(esp_matter_cluster_t *cluster) +command_t *create_arm_fail_safe_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_OR_UPDATE_THREAD_NETWORK_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_add_or_update_thread_network); + return esp_matter::command::create(cluster, ZCL_ARM_FAIL_SAFE_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_remove_network(esp_matter_cluster_t *cluster) +command_t *create_set_regulatory_config_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_NETWORK_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_remove_network); + return esp_matter::command::create(cluster, ZCL_SET_REGULATORY_CONFIG_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_connect_network(esp_matter_cluster_t *cluster) +command_t *create_commissioning_complete_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_CONNECT_NETWORK_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_connect_network); + return esp_matter::command::create(cluster, ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_reorder_network(esp_matter_cluster_t *cluster) +} /* command */ +} /* general_commissioning */ + +namespace network_commissioning { +namespace command { + +command_t *create_scan_networks(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REORDER_NETWORK_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_reorder_network); + return esp_matter::command::create(cluster, ZCL_SCAN_NETWORKS_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_scan_networks); } -esp_matter_command_t *esp_matter_command_create_open_commissioning_window(esp_matter_cluster_t *cluster) +command_t *create_add_or_update_wifi_network(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_OPEN_COMMISSIONING_WINDOW_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_open_commissioning_window); + return esp_matter::command::create(cluster, ZCL_ADD_OR_UPDATE_WI_FI_NETWORK_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_add_or_update_wifi_network); } -esp_matter_command_t *esp_matter_command_create_open_basic_commissioning_window(esp_matter_cluster_t *cluster) +command_t *create_add_or_update_thread_network(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_OPEN_BASIC_COMMISSIONING_WINDOW_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_open_basic_commissioning_window); + return esp_matter::command::create(cluster, ZCL_ADD_OR_UPDATE_THREAD_NETWORK_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_add_or_update_thread_network); } -esp_matter_command_t *esp_matter_command_create_revoke_commissioning(esp_matter_cluster_t *cluster) +command_t *create_remove_network(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REVOKE_COMMISSIONING_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_revoke_commissioning); + return esp_matter::command::create(cluster, ZCL_REMOVE_NETWORK_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_remove_network); } -esp_matter_command_t *esp_matter_command_create_attestation_request(esp_matter_cluster_t *cluster) +command_t *create_connect_network(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ATTESTATION_REQUEST_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_attestation_request); + return esp_matter::command::create(cluster, ZCL_CONNECT_NETWORK_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_connect_network); } -esp_matter_command_t *esp_matter_command_create_certificate_chain_request(esp_matter_cluster_t *cluster) +command_t *create_reorder_network(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_CERTIFICATE_CHAIN_REQUEST_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_certificate_chain_request); + return esp_matter::command::create(cluster, ZCL_REORDER_NETWORK_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_reorder_network); } -esp_matter_command_t *esp_matter_command_create_csr_request(esp_matter_cluster_t *cluster) +command_t *create_scan_networks_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_CSR_REQUEST_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_csr_request); + return esp_matter::command::create(cluster, ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_add_noc(esp_matter_cluster_t *cluster) +command_t *create_network_config_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_NOC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_add_noc); + return esp_matter::command::create(cluster, ZCL_NETWORK_CONFIG_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_update_noc(esp_matter_cluster_t *cluster) +command_t *create_connect_network_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_UPDATE_NOC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_update_noc); + return esp_matter::command::create(cluster, ZCL_CONNECT_NETWORK_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_update_fabric_label(esp_matter_cluster_t *cluster) +} /* command */ +} /* network_commissioning */ + +namespace administrator_commissioning { +namespace command { + +command_t *create_open_commissioning_window(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_update_fabric_label); + return esp_matter::command::create(cluster, ZCL_OPEN_COMMISSIONING_WINDOW_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_open_commissioning_window); } -esp_matter_command_t *esp_matter_command_create_remove_fabric(esp_matter_cluster_t *cluster) +command_t *create_open_basic_commissioning_window(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_FABRIC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_remove_fabric); + return esp_matter::command::create(cluster, ZCL_OPEN_BASIC_COMMISSIONING_WINDOW_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_open_basic_commissioning_window); } -esp_matter_command_t *esp_matter_command_create_add_trusted_root_certificate(esp_matter_cluster_t *cluster) +command_t *create_revoke_commissioning(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_TRUSTED_ROOT_CERTIFICATE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_add_trusted_root_certificate); + return esp_matter::command::create(cluster, ZCL_REVOKE_COMMISSIONING_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_revoke_commissioning); } -esp_matter_command_t *esp_matter_command_create_remove_trusted_root_certificate(esp_matter_cluster_t *cluster) +} /* command */ +} /* administrator_commissioning */ + +namespace operational_credentials { +namespace command { + +command_t *create_attestation_request(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_TRUSTED_ROOT_CERTIFICATE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_remove_trusted_root_certificate); + return esp_matter::command::create(cluster, ZCL_ATTESTATION_REQUEST_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_attestation_request); } -esp_matter_command_t *esp_matter_command_create_query_image(esp_matter_cluster_t *cluster) +command_t *create_certificate_chain_request(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_QUERY_IMAGE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_query_image); + return esp_matter::command::create(cluster, ZCL_CERTIFICATE_CHAIN_REQUEST_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_certificate_chain_request); } -esp_matter_command_t *esp_matter_command_create_apply_update_request(esp_matter_cluster_t *cluster) +command_t *create_csr_request(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_APPLY_UPDATE_REQUEST_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_apply_update_request); + return esp_matter::command::create(cluster, ZCL_CSR_REQUEST_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_csr_request); } -esp_matter_command_t *esp_matter_command_create_notify_update_applied(esp_matter_cluster_t *cluster) +command_t *create_add_noc(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_NOTIFY_UPDATE_APPLIED_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_notify_update_applied); + return esp_matter::command::create(cluster, ZCL_ADD_NOC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_add_noc); } -esp_matter_command_t *esp_matter_command_create_announce_ota_provider(esp_matter_cluster_t *cluster) +command_t *create_update_noc(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ANNOUNCE_OTA_PROVIDER_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_announce_ota_provider); + return esp_matter::command::create(cluster, ZCL_UPDATE_NOC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_update_noc); } -esp_matter_command_t *esp_matter_command_create_identify(esp_matter_cluster_t *cluster) +command_t *create_update_fabric_label(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_IDENTIFY_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_identify); + return esp_matter::command::create(cluster, ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_update_fabric_label); } -esp_matter_command_t *esp_matter_command_create_identify_query(esp_matter_cluster_t *cluster) +command_t *create_remove_fabric(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_IDENTIFY_QUERY_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_identify_query); + return esp_matter::command::create(cluster, ZCL_REMOVE_FABRIC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_remove_fabric); } -esp_matter_command_t *esp_matter_command_create_add_group(esp_matter_cluster_t *cluster) +command_t *create_add_trusted_root_certificate(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_add_group); + return esp_matter::command::create(cluster, ZCL_ADD_TRUSTED_ROOT_CERTIFICATE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_add_trusted_root_certificate); } -esp_matter_command_t *esp_matter_command_create_view_group(esp_matter_cluster_t *cluster) +command_t *create_remove_trusted_root_certificate(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_VIEW_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_view_group); + return esp_matter::command::create(cluster, ZCL_REMOVE_TRUSTED_ROOT_CERTIFICATE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_remove_trusted_root_certificate); } -esp_matter_command_t *esp_matter_command_create_get_group_membership(esp_matter_cluster_t *cluster) +command_t *create_attestation_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_GET_GROUP_MEMBERSHIP_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_get_group_membership); + return esp_matter::command::create(cluster, ZCL_ATTESTATION_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_remove_group(esp_matter_cluster_t *cluster) +command_t *create_certificate_chain_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_remove_group); + return esp_matter::command::create(cluster, ZCL_CERTIFICATE_CHAIN_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_remove_all_groups(esp_matter_cluster_t *cluster) +command_t *create_csr_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_ALL_GROUPS_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_remove_all_groups); + return esp_matter::command::create(cluster, ZCL_CSR_RESPONSE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, + NULL); } -esp_matter_command_t *esp_matter_command_create_add_group_if_identifying(esp_matter_cluster_t *cluster) +command_t *create_noc_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_add_group_if_identifying); + return esp_matter::command::create(cluster, ZCL_NOC_RESPONSE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, + NULL); } -esp_matter_command_t *esp_matter_command_create_add_scene(esp_matter_cluster_t *cluster) +} /* command */ +} /* operational_credentials */ + +namespace ota_provider { +namespace command { + +command_t *create_query_image(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_add_scene); + return esp_matter::command::create(cluster, ZCL_QUERY_IMAGE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_query_image); } -esp_matter_command_t *esp_matter_command_create_view_scene(esp_matter_cluster_t *cluster) +command_t *create_apply_update_request(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_VIEW_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_view_scene); + return esp_matter::command::create(cluster, ZCL_APPLY_UPDATE_REQUEST_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_apply_update_request); } -esp_matter_command_t *esp_matter_command_create_remove_scene(esp_matter_cluster_t *cluster) +command_t *create_notify_update_applied(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_remove_scene); + return esp_matter::command::create(cluster, ZCL_NOTIFY_UPDATE_APPLIED_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_notify_update_applied); } -esp_matter_command_t *esp_matter_command_create_remove_all_scenes(esp_matter_cluster_t *cluster) +command_t *create_query_image_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_ALL_SCENES_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_remove_all_scenes); + return esp_matter::command::create(cluster, ZCL_QUERY_IMAGE_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_store_scene(esp_matter_cluster_t *cluster) +command_t *create_apply_update_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STORE_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_store_scene); + return esp_matter::command::create(cluster, ZCL_APPLY_UPDATE_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_recall_scene(esp_matter_cluster_t *cluster) +} /* command */ +} /* ota_provider */ + +namespace ota_requestor { +namespace command { + +command_t *create_announce_ota_provider(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_RECALL_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_recall_scene); + return esp_matter::command::create(cluster, ZCL_ANNOUNCE_OTA_PROVIDER_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_announce_ota_provider); } -esp_matter_command_t *esp_matter_command_create_get_scene_membership(esp_matter_cluster_t *cluster) +} /* command */ +} /* ota_requestor */ + +namespace identify { +namespace command { + +command_t *create_identify(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_GET_SCENE_MEMBERSHIP_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_get_scene_membership); + return esp_matter::command::create(cluster, ZCL_IDENTIFY_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_identify); } -esp_matter_command_t *esp_matter_command_create_off(esp_matter_cluster_t *cluster) +command_t *create_identify_query(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_OFF_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_off); + return esp_matter::command::create(cluster, ZCL_IDENTIFY_QUERY_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_identify_query); } -esp_matter_command_t *esp_matter_command_create_on(esp_matter_cluster_t *cluster) +command_t *create_identify_query_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ON_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_on); + return esp_matter::command::create(cluster, ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_toggle(esp_matter_cluster_t *cluster) +} /* command */ +} /* identify */ + +namespace groups { +namespace command { + +command_t *create_add_group(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_TOGGLE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_toggle); + return esp_matter::command::create(cluster, ZCL_ADD_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_add_group); } -esp_matter_command_t *esp_matter_command_create_off_with_effect(esp_matter_cluster_t *cluster) +command_t *create_view_group(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_OFF_WITH_EFFECT_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_off_with_effect); + return esp_matter::command::create(cluster, ZCL_VIEW_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_view_group); } -esp_matter_command_t *esp_matter_command_create_on_with_recall_global_scene(esp_matter_cluster_t *cluster) +command_t *create_get_group_membership(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_on_with_recall_global_scene); + return esp_matter::command::create(cluster, ZCL_GET_GROUP_MEMBERSHIP_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_get_group_membership); } -esp_matter_command_t *esp_matter_command_create_on_with_timed_off(esp_matter_cluster_t *cluster) +command_t *create_remove_group(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ON_WITH_TIMED_OFF_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_on_with_timed_off); + return esp_matter::command::create(cluster, ZCL_REMOVE_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_remove_group); } -esp_matter_command_t *esp_matter_command_create_move_to_level(esp_matter_cluster_t *cluster) +command_t *create_remove_all_groups(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_TO_LEVEL_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move_to_level); + return esp_matter::command::create(cluster, ZCL_REMOVE_ALL_GROUPS_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_remove_all_groups); } -esp_matter_command_t *esp_matter_command_create_move(esp_matter_cluster_t *cluster) +command_t *create_add_group_if_identifying(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move); + return esp_matter::command::create(cluster, ZCL_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_add_group_if_identifying); } -esp_matter_command_t *esp_matter_command_create_step(esp_matter_cluster_t *cluster) +command_t *create_add_group_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STEP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_step); + return esp_matter::command::create(cluster, ZCL_ADD_GROUP_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_stop(esp_matter_cluster_t *cluster) +command_t *create_view_group_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STOP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_stop); + return esp_matter::command::create(cluster, ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_move_to_level_with_on_off(esp_matter_cluster_t *cluster) +command_t *create_get_group_membership_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_TO_LEVEL_WITH_ON_OFF_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move_to_level_with_on_off); + return esp_matter::command::create(cluster, ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_move_with_on_off(esp_matter_cluster_t *cluster) +command_t *create_remove_group_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_WITH_ON_OFF_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move_with_on_off); + return esp_matter::command::create(cluster, ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_step_with_on_off(esp_matter_cluster_t *cluster) +} /* command */ +} /* groups */ + +namespace scenes { +namespace command { + +command_t *create_add_scene(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STEP_WITH_ON_OFF_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_step_with_on_off); + return esp_matter::command::create(cluster, ZCL_ADD_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_add_scene); } -esp_matter_command_t *esp_matter_command_create_stop_with_on_off(esp_matter_cluster_t *cluster) +command_t *create_view_scene(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STOP_WITH_ON_OFF_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_stop_with_on_off); + return esp_matter::command::create(cluster, ZCL_VIEW_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_view_scene); } -esp_matter_command_t *esp_matter_command_create_move_to_hue(esp_matter_cluster_t *cluster) +command_t *create_remove_scene(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_TO_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move_to_hue); + return esp_matter::command::create(cluster, ZCL_REMOVE_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_remove_scene); } -esp_matter_command_t *esp_matter_command_create_move_hue(esp_matter_cluster_t *cluster) +command_t *create_remove_all_scenes(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move_hue); + return esp_matter::command::create(cluster, ZCL_REMOVE_ALL_SCENES_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_remove_all_scenes); } -esp_matter_command_t *esp_matter_command_create_step_hue(esp_matter_cluster_t *cluster) +command_t *create_store_scene(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STEP_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_step_hue); + return esp_matter::command::create(cluster, ZCL_STORE_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_store_scene); } -esp_matter_command_t *esp_matter_command_create_move_to_saturation(esp_matter_cluster_t *cluster) +command_t *create_recall_scene(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_TO_SATURATION_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move_to_saturation); + return esp_matter::command::create(cluster, ZCL_RECALL_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_recall_scene); } -esp_matter_command_t *esp_matter_command_create_move_saturation(esp_matter_cluster_t *cluster) +command_t *create_get_scene_membership(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_SATURATION_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move_saturation); + return esp_matter::command::create(cluster, ZCL_GET_SCENE_MEMBERSHIP_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_get_scene_membership); } -esp_matter_command_t *esp_matter_command_create_step_saturation(esp_matter_cluster_t *cluster) +command_t *create_add_scene_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STEP_SATURATION_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_step_saturation); + return esp_matter::command::create(cluster, ZCL_ADD_SCENE_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_move_to_hue_and_saturation(esp_matter_cluster_t *cluster) +command_t *create_view_scene_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_move_to_hue_and_saturation); + return esp_matter::command::create(cluster, ZCL_VIEW_SCENE_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_stop_move_step(esp_matter_cluster_t *cluster) +command_t *create_remove_scene_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STOP_MOVE_STEP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_stop_move_step); + return esp_matter::command::create(cluster, ZCL_REMOVE_SCENE_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_lock_door(esp_matter_cluster_t *cluster) +command_t *create_remove_all_scenes_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_LOCK_DOOR_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_lock_door); + return esp_matter::command::create(cluster, ZCL_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_unlock_door(esp_matter_cluster_t *cluster) +command_t *create_store_scene_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_UNLOCK_DOOR_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_unlock_door); + return esp_matter::command::create(cluster, ZCL_STORE_SCENE_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_setpoint_raise_lower(esp_matter_cluster_t *cluster) +command_t *create_get_scene_membership_response(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_SETPOINT_RAISE_LOWER_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, - esp_matter_command_callback_setpoint_raise_lower); + return esp_matter::command::create(cluster, ZCL_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); } -esp_matter_command_t *esp_matter_command_create_key_set_read_response(esp_matter_cluster_t *cluster) +} /* command */ +} /* scenes */ + +namespace on_off { +namespace command { + +command_t *create_off(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_KEY_SET_READ_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_OFF_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_off); } -esp_matter_command_t *esp_matter_command_create_key_set_read_all_indices_response(esp_matter_cluster_t *cluster) +command_t *create_on(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_KEY_SET_READ_ALL_INDICES_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_ON_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_on); } -esp_matter_command_t *esp_matter_command_create_arm_fail_safe_response(esp_matter_cluster_t *cluster) +command_t *create_toggle(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ARM_FAIL_SAFE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_TOGGLE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_toggle); } -esp_matter_command_t *esp_matter_command_create_set_regulatory_config_response(esp_matter_cluster_t *cluster) +command_t *create_off_with_effect(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_SET_REGULATORY_CONFIG_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_OFF_WITH_EFFECT_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_off_with_effect); } -esp_matter_command_t *esp_matter_command_create_commissioning_complete_response(esp_matter_cluster_t *cluster) +command_t *create_on_with_recall_global_scene(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_on_with_recall_global_scene); } -esp_matter_command_t *esp_matter_command_create_scan_networks_response(esp_matter_cluster_t *cluster) +command_t *create_on_with_timed_off(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_ON_WITH_TIMED_OFF_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_on_with_timed_off); } -esp_matter_command_t *esp_matter_command_create_network_config_response(esp_matter_cluster_t *cluster) +} /* command */ +} /* on_off */ + +namespace level_control { +namespace command { + +command_t *create_move_to_level(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_NETWORK_CONFIG_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_TO_LEVEL_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move_to_level); } -esp_matter_command_t *esp_matter_command_create_connect_network_response(esp_matter_cluster_t *cluster) +command_t *create_move(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_CONNECT_NETWORK_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move); } -esp_matter_command_t *esp_matter_command_create_attestation_response(esp_matter_cluster_t *cluster) +command_t *create_step(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ATTESTATION_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_STEP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_step); } -esp_matter_command_t *esp_matter_command_create_certificate_chain_response(esp_matter_cluster_t *cluster) +command_t *create_stop(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_CERTIFICATE_CHAIN_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_STOP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_stop); } -esp_matter_command_t *esp_matter_command_create_csr_response(esp_matter_cluster_t *cluster) +command_t *create_move_to_level_with_on_off(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_CSR_RESPONSE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, - NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_TO_LEVEL_WITH_ON_OFF_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move_to_level_with_on_off); } -esp_matter_command_t *esp_matter_command_create_noc_response(esp_matter_cluster_t *cluster) +command_t *create_move_with_on_off(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_NOC_RESPONSE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, - NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_WITH_ON_OFF_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move_with_on_off); } -esp_matter_command_t *esp_matter_command_create_query_image_response(esp_matter_cluster_t *cluster) +command_t *create_step_with_on_off(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_QUERY_IMAGE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_STEP_WITH_ON_OFF_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_step_with_on_off); } -esp_matter_command_t *esp_matter_command_create_apply_update_response(esp_matter_cluster_t *cluster) +command_t *create_stop_with_on_off(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_APPLY_UPDATE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_STOP_WITH_ON_OFF_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_stop_with_on_off); } -esp_matter_command_t *esp_matter_command_create_identify_query_response(esp_matter_cluster_t *cluster) +} /* command */ +} /* level_control */ + +namespace color_control { +namespace command { + +command_t *create_move_to_hue(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_TO_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move_to_hue); } -esp_matter_command_t *esp_matter_command_create_add_group_response(esp_matter_cluster_t *cluster) +command_t *create_move_hue(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_GROUP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move_hue); } -esp_matter_command_t *esp_matter_command_create_view_group_response(esp_matter_cluster_t *cluster) +command_t *create_step_hue(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_STEP_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_step_hue); } -esp_matter_command_t *esp_matter_command_create_get_group_membership_response(esp_matter_cluster_t *cluster) +command_t *create_move_to_saturation(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_TO_SATURATION_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move_to_saturation); } -esp_matter_command_t *esp_matter_command_create_remove_group_response(esp_matter_cluster_t *cluster) +command_t *create_move_saturation(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_SATURATION_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move_saturation); } -esp_matter_command_t *esp_matter_command_create_add_scene_response(esp_matter_cluster_t *cluster) +command_t *create_step_saturation(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_ADD_SCENE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_STEP_SATURATION_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_step_saturation); } -esp_matter_command_t *esp_matter_command_create_view_scene_response(esp_matter_cluster_t *cluster) +command_t *create_move_to_hue_and_saturation(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_VIEW_SCENE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_move_to_hue_and_saturation); } -esp_matter_command_t *esp_matter_command_create_remove_scene_response(esp_matter_cluster_t *cluster) +command_t *create_stop_move_step(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_SCENE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_STOP_MOVE_STEP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_stop_move_step); } -esp_matter_command_t *esp_matter_command_create_remove_all_scenes_response(esp_matter_cluster_t *cluster) +} /* command */ +} /* color_control */ + +namespace thermostat { +namespace command { + +command_t *create_setpoint_raise_lower(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_SETPOINT_RAISE_LOWER_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_setpoint_raise_lower); } -esp_matter_command_t *esp_matter_command_create_store_scene_response(esp_matter_cluster_t *cluster) +} /* command */ +} /* thermostat */ + +namespace door_lock { +namespace command { + +command_t *create_lock_door(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_STORE_SCENE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_LOCK_DOOR_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_lock_door); } -esp_matter_command_t *esp_matter_command_create_get_scene_membership_response(esp_matter_cluster_t *cluster) +command_t *create_unlock_door(cluster_t *cluster) { - return esp_matter_command_create(cluster, ZCL_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + return esp_matter::command::create(cluster, ZCL_UNLOCK_DOOR_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + esp_matter_command_callback_unlock_door); } +} /* command */ +} /* door_lock */ + +} /* cluster */ +} /* esp_matter */ + #endif /* FIXED_ENDPOINT_COUNT */ diff --git a/components/esp_matter/esp_matter_command.h b/components/esp_matter/esp_matter_command.h index ea47664d7..effd844f3 100644 --- a/components/esp_matter/esp_matter_command.h +++ b/components/esp_matter/esp_matter_command.h @@ -16,126 +16,177 @@ #include -/** cluster: group key management */ -esp_matter_command_t *esp_matter_command_create_key_set_write(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_key_set_read(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_key_set_remove(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_key_set_read_all_indices(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_key_set_read_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_key_set_read_all_indices_response(esp_matter_cluster_t *cluster); +namespace esp_matter { +namespace cluster { -/** cluster: general commissioning */ -esp_matter_command_t *esp_matter_command_create_arm_fail_safe(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_set_regulatory_config(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_commissioning_complete(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_arm_fail_safe_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_set_regulatory_config_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_commissioning_complete_response(esp_matter_cluster_t *cluster); +namespace group_key_management { +namespace command { +command_t *create_key_set_write(cluster_t *cluster); +command_t *create_key_set_read(cluster_t *cluster); +command_t *create_key_set_remove(cluster_t *cluster); +command_t *create_key_set_read_all_indices(cluster_t *cluster); +command_t *create_key_set_read_response(cluster_t *cluster); +command_t *create_key_set_read_all_indices_response(cluster_t *cluster); +} /* command */ +} /* group_key_management */ -/** cluster: network commissioning */ -esp_matter_command_t *esp_matter_command_create_scan_networks(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_add_or_update_wifi_network(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_add_or_update_thread_network(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_network(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_connect_network(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_reorder_network(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_scan_networks_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_network_config_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_connect_network_response(esp_matter_cluster_t *cluster); +namespace general_commissioning { +namespace command { +command_t *create_arm_fail_safe(cluster_t *cluster); +command_t *create_set_regulatory_config(cluster_t *cluster); +command_t *create_commissioning_complete(cluster_t *cluster); +command_t *create_arm_fail_safe_response(cluster_t *cluster); +command_t *create_set_regulatory_config_response(cluster_t *cluster); +command_t *create_commissioning_complete_response(cluster_t *cluster); +} /* command */ +} /* general_commissioning */ -/** cluster: administrator commissioning */ -esp_matter_command_t *esp_matter_command_create_open_commissioning_window(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_open_basic_commissioning_window(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_revoke_commissioning(esp_matter_cluster_t *cluster); +namespace network_commissioning { +namespace command { +command_t *create_scan_networks(cluster_t *cluster); +command_t *create_add_or_update_wifi_network(cluster_t *cluster); +command_t *create_add_or_update_thread_network(cluster_t *cluster); +command_t *create_remove_network(cluster_t *cluster); +command_t *create_connect_network(cluster_t *cluster); +command_t *create_reorder_network(cluster_t *cluster); +command_t *create_scan_networks_response(cluster_t *cluster); +command_t *create_network_config_response(cluster_t *cluster); +command_t *create_connect_network_response(cluster_t *cluster); +} /* command */ +} /* network_commissioning */ -/** cluster: operational credentials */ -esp_matter_command_t *esp_matter_command_create_attestation_request(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_certificate_chain_request(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_csr_request(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_add_noc(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_update_noc(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_update_fabric_label(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_fabric(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_add_trusted_root_certificate(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_trusted_root_certificate(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_attestation_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_certificate_chain_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_csr_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_noc_response(esp_matter_cluster_t *cluster); +namespace administrator_commissioning { +namespace command { +command_t *create_open_commissioning_window(cluster_t *cluster); +command_t *create_open_basic_commissioning_window(cluster_t *cluster); +command_t *create_revoke_commissioning(cluster_t *cluster); +} /* command */ +} /* administrator_commissioning */ -/** cluster: ota provider */ -esp_matter_command_t *esp_matter_command_create_query_image(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_apply_update_request(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_notify_update_applied(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_query_image_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_apply_update_response(esp_matter_cluster_t *cluster); +namespace operational_credentials { +namespace command { +command_t *create_attestation_request(cluster_t *cluster); +command_t *create_certificate_chain_request(cluster_t *cluster); +command_t *create_csr_request(cluster_t *cluster); +command_t *create_add_noc(cluster_t *cluster); +command_t *create_update_noc(cluster_t *cluster); +command_t *create_update_fabric_label(cluster_t *cluster); +command_t *create_remove_fabric(cluster_t *cluster); +command_t *create_add_trusted_root_certificate(cluster_t *cluster); +command_t *create_remove_trusted_root_certificate(cluster_t *cluster); +command_t *create_attestation_response(cluster_t *cluster); +command_t *create_certificate_chain_response(cluster_t *cluster); +command_t *create_csr_response(cluster_t *cluster); +command_t *create_noc_response(cluster_t *cluster); +} /* command */ +} /* operational_credentials */ -/** cluster: ota requestor */ -esp_matter_command_t *esp_matter_command_create_announce_ota_provider(esp_matter_cluster_t *cluster); +namespace ota_provider { +namespace command { +command_t *create_query_image(cluster_t *cluster); +command_t *create_apply_update_request(cluster_t *cluster); +command_t *create_notify_update_applied(cluster_t *cluster); +command_t *create_query_image_response(cluster_t *cluster); +command_t *create_apply_update_response(cluster_t *cluster); +} /* command */ +} /* ota_provider */ -/** cluster: identify */ -esp_matter_command_t *esp_matter_command_create_identify(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_identify_query(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_identify_query_response(esp_matter_cluster_t *cluster); +namespace ota_requestor { +namespace command { +command_t *create_announce_ota_provider(cluster_t *cluster); +} /* command */ +} /* ota_requestor */ -/** cluster: groups */ -esp_matter_command_t *esp_matter_command_create_add_group(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_view_group(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_get_group_membership(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_group(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_all_groups(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_add_group_if_identifying(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_add_group_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_view_group_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_get_group_membership_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_group_response(esp_matter_cluster_t *cluster); +namespace identify { +namespace command { +command_t *create_identify(cluster_t *cluster); +command_t *create_identify_query(cluster_t *cluster); +command_t *create_identify_query_response(cluster_t *cluster); +} /* command */ +} /* identify */ -/** cluster: scenes */ -esp_matter_command_t *esp_matter_command_create_add_scene(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_view_scene(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_scene(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_all_scenes(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_store_scene(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_recall_scene(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_get_scene_membership(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_add_scene_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_view_scene_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_scene_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_remove_all_scenes_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_store_scene_response(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_get_scene_membership_response(esp_matter_cluster_t *cluster); +namespace groups { +namespace command { +command_t *create_add_group(cluster_t *cluster); +command_t *create_view_group(cluster_t *cluster); +command_t *create_get_group_membership(cluster_t *cluster); +command_t *create_remove_group(cluster_t *cluster); +command_t *create_remove_all_groups(cluster_t *cluster); +command_t *create_add_group_if_identifying(cluster_t *cluster); +command_t *create_add_group_response(cluster_t *cluster); +command_t *create_view_group_response(cluster_t *cluster); +command_t *create_get_group_membership_response(cluster_t *cluster); +command_t *create_remove_group_response(cluster_t *cluster); +} /* command */ +} /* groups */ -/** cluster: on off */ -esp_matter_command_t *esp_matter_command_create_off(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_on(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_toggle(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_off_with_effect(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_on_with_recall_global_scene(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_on_with_timed_off(esp_matter_cluster_t *cluster); +namespace scenes { +namespace command { +command_t *create_add_scene(cluster_t *cluster); +command_t *create_view_scene(cluster_t *cluster); +command_t *create_remove_scene(cluster_t *cluster); +command_t *create_remove_all_scenes(cluster_t *cluster); +command_t *create_store_scene(cluster_t *cluster); +command_t *create_recall_scene(cluster_t *cluster); +command_t *create_get_scene_membership(cluster_t *cluster); +command_t *create_add_scene_response(cluster_t *cluster); +command_t *create_view_scene_response(cluster_t *cluster); +command_t *create_remove_scene_response(cluster_t *cluster); +command_t *create_remove_all_scenes_response(cluster_t *cluster); +command_t *create_store_scene_response(cluster_t *cluster); +command_t *create_get_scene_membership_response(cluster_t *cluster); +} /* command */ +} /* scenes */ -/** cluster: level control */ -esp_matter_command_t *esp_matter_command_create_move_to_level(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_move(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_step(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_stop(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_move_to_level_with_on_off(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_move_with_on_off(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_step_with_on_off(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_stop_with_on_off(esp_matter_cluster_t *cluster); +namespace on_off { +namespace command { +command_t *create_off(cluster_t *cluster); +command_t *create_on(cluster_t *cluster); +command_t *create_toggle(cluster_t *cluster); +command_t *create_off_with_effect(cluster_t *cluster); +command_t *create_on_with_recall_global_scene(cluster_t *cluster); +command_t *create_on_with_timed_off(cluster_t *cluster); +} /* command */ +} /* on_off */ -/** cluster: color control */ -esp_matter_command_t *esp_matter_command_create_move_to_hue(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_move_hue(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_step_hue(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_move_to_saturation(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_move_saturation(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_step_saturation(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_move_to_hue_and_saturation(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_stop_move_step(esp_matter_cluster_t *cluster); +namespace level_control { +namespace command { +command_t *create_move_to_level(cluster_t *cluster); +command_t *create_move(cluster_t *cluster); +command_t *create_step(cluster_t *cluster); +command_t *create_stop(cluster_t *cluster); +command_t *create_move_to_level_with_on_off(cluster_t *cluster); +command_t *create_move_with_on_off(cluster_t *cluster); +command_t *create_step_with_on_off(cluster_t *cluster); +command_t *create_stop_with_on_off(cluster_t *cluster); +} /* command */ +} /* level_control */ -/** cluster: thermostat */ -esp_matter_command_t *esp_matter_command_create_setpoint_raise_lower(esp_matter_cluster_t *cluster); +namespace color_control { +namespace command { +command_t *create_move_to_hue(cluster_t *cluster); +command_t *create_move_hue(cluster_t *cluster); +command_t *create_step_hue(cluster_t *cluster); +command_t *create_move_to_saturation(cluster_t *cluster); +command_t *create_move_saturation(cluster_t *cluster); +command_t *create_step_saturation(cluster_t *cluster); +command_t *create_move_to_hue_and_saturation(cluster_t *cluster); +command_t *create_stop_move_step(cluster_t *cluster); +} /* command */ +} /* color_control */ -/** cluster: door lock */ -esp_matter_command_t *esp_matter_command_create_lock_door(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_create_unlock_door(esp_matter_cluster_t *cluster); +namespace thermostat { +namespace command { +command_t *create_setpoint_raise_lower(cluster_t *cluster); +} /* command */ +} /* thermostat */ + +namespace door_lock { +namespace command { +command_t *create_lock_door(cluster_t *cluster); +command_t *create_unlock_door(cluster_t *cluster); +} /* command */ +} /* door_lock */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index 20df19c7d..f56a4c557 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -54,52 +54,52 @@ using chip::DeviceLayer::ThreadStackMgr; static const char *TAG = "esp_matter_core"; -typedef struct esp_matter_attribute { +namespace esp_matter { +typedef struct _attribute { int attribute_id; uint8_t flags; esp_matter_attr_val_t val; esp_matter_attr_bounds_t *bounds; EmberAfDefaultOrMinMaxAttributeValue default_value; uint16_t default_value_size; - struct esp_matter_attribute *next; -} _esp_matter_attribute_t; + struct _attribute *next; +} _attribute_t; -typedef struct esp_matter_command { +typedef struct _command { int command_id; uint8_t flags; - esp_matter_command_callback_t callback; - struct esp_matter_command *next; -} _esp_matter_command_t; + command::callback_t callback; + struct _command *next; +} _command_t; -typedef struct esp_matter_cluster { +typedef struct _cluster { int cluster_id; uint8_t flags; - const esp_matter_cluster_function_generic_t *function_list; - esp_matter_cluster_plugin_server_init_callback_t plugin_server_init_callback; - esp_matter_cluster_plugin_client_init_callback_t plugin_client_init_callback; - _esp_matter_attribute_t *attribute_list; - _esp_matter_command_t *command_list; - struct esp_matter_cluster *next; -} _esp_matter_cluster_t; + const cluster::function_generic_t *function_list; + cluster::plugin_server_init_callback_t plugin_server_init_callback; + cluster::plugin_client_init_callback_t plugin_client_init_callback; + _attribute_t *attribute_list; + _command_t *command_list; + struct _cluster *next; +} _cluster_t; -typedef struct esp_matter_endpoint { +typedef struct _endpoint { int endpoint_id; int device_type_id; uint8_t flags; - _esp_matter_cluster_t *cluster_list; + _cluster_t *cluster_list; EmberAfEndpointType *endpoint_type; DataVersion *data_versions_ptr; - struct esp_matter_endpoint *next; -} _esp_matter_endpoint_t; + struct _endpoint *next; +} _endpoint_t; -typedef struct esp_matter_node { - _esp_matter_endpoint_t *endpoint_list; +typedef struct _node { + _endpoint_t *endpoint_list; int current_endpoint_id; -} _esp_matter_node_t; +} _node_t; -static _esp_matter_node_t *node = NULL; - -static int cluster_get_count(_esp_matter_cluster_t *current) +namespace cluster { +static int get_count(_cluster_t *current) { int count = 0; while (current) { @@ -108,18 +108,10 @@ static int cluster_get_count(_esp_matter_cluster_t *current) } return count; } +} /* cluster */ -static int attribute_get_count(_esp_matter_attribute_t *current) -{ - int count = 0; - while (current) { - current = current->next; - count++; - } - return count; -} - -static int command_get_count(_esp_matter_command_t *current, int command_flag) +namespace command { +static int get_count(_command_t *current, int command_flag) { int count = 0; while (current) { @@ -130,29 +122,30 @@ static int command_get_count(_esp_matter_command_t *current, int command_flag) } return count; } +} /* command */ -static int endpoint_get_next_index() -{ - int endpoint_id = 0; - for (int index = 0; index < MAX_ENDPOINT_COUNT; index++) { - endpoint_id = emberAfEndpointFromIndex(index); - if (endpoint_id == kInvalidEndpointId) { - return index; - } - } - return 0xFFFF; -} +namespace attribute { extern esp_err_t get_data_from_attr_val(esp_matter_attr_val_t *val, EmberAfAttributeType *attribute_type, uint16_t *attribute_size, uint8_t *value); -static esp_err_t attribute_free_default_value(esp_matter_attribute_t *attribute) +static int get_count(_attribute_t *current) +{ + int count = 0; + while (current) { + current = current->next; + count++; + } + return count; +} + +static esp_err_t free_default_value(attribute_t *attribute) { if (!attribute) { ESP_LOGE(TAG, "Attribute cannot be NULL"); return ESP_FAIL; } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; + _attribute_t *current_attribute = (_attribute_t *)attribute; /* Free value if data is more than 2 bytes or if it is min max attribute */ if (current_attribute->flags & ESP_MATTER_ATTRIBUTE_FLAG_MIN_MAX) { @@ -206,13 +199,13 @@ static EmberAfDefaultAttributeValue get_default_value_from_data(esp_matter_attr_ return default_value; } -static esp_err_t attribute_set_default_value_from_current_val(esp_matter_attribute_t *attribute) +static esp_err_t set_default_value_from_current_val(attribute_t *attribute) { if (!attribute) { ESP_LOGE(TAG, "Attribute cannot be NULL"); return ESP_FAIL; } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; + _attribute_t *current_attribute = (_attribute_t *)attribute; esp_matter_attr_val_t *val = ¤t_attribute->val; /* Get size */ @@ -229,10 +222,10 @@ static esp_err_t attribute_set_default_value_from_current_val(esp_matter_attribu return ESP_FAIL; } temp_value->defaultValue = get_default_value_from_data(val, attribute_type, attribute_size); - temp_value->minValue = get_default_value_from_data(¤t_attribute->bounds->min, - attribute_type, attribute_size); - temp_value->maxValue = get_default_value_from_data(¤t_attribute->bounds->max, - attribute_type, attribute_size); + temp_value->minValue = get_default_value_from_data(¤t_attribute->bounds->min, attribute_type, + attribute_size); + temp_value->maxValue = get_default_value_from_data(¤t_attribute->bounds->max, attribute_type, + attribute_size); current_attribute->default_value.ptrToMinMaxValue = temp_value; } else if (attribute_size > 2) { EmberAfDefaultAttributeValue temp_value = get_default_value_from_data(val, attribute_type, attribute_size); @@ -244,8 +237,23 @@ static esp_err_t attribute_set_default_value_from_current_val(esp_matter_attribu current_attribute->default_value_size = attribute_size; return ESP_OK; } +} /* attribute */ -static esp_err_t esp_matter_endpoint_disable(esp_matter_endpoint_t *endpoint) +namespace endpoint { + +static int get_next_index() +{ + int endpoint_id = 0; + for (int index = 0; index < MAX_ENDPOINT_COUNT; index++) { + endpoint_id = emberAfEndpointFromIndex(index); + if (endpoint_id == kInvalidEndpointId) { + return index; + } + } + return 0xFFFF; +} + +static esp_err_t disable(endpoint_t *endpoint) { if (!endpoint) { ESP_LOGE(TAG, "Endpoint cannot be NULL"); @@ -253,26 +261,26 @@ static esp_err_t esp_matter_endpoint_disable(esp_matter_endpoint_t *endpoint) } /* Take lock if not already taken */ - esp_matter_lock_status_t lock_status = esp_matter_chip_stack_lock(portMAX_DELAY); - if (lock_status == ESP_MATTER_LOCK_FAILED) { + lock::status_t lock_status = lock::chip_stack_lock(portMAX_DELAY); + if (lock_status == lock::FAILED) { ESP_LOGE(TAG, "Could not get task context"); return ESP_FAIL; } /* Remove endpoint */ - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)endpoint; + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; int endpoint_index = emberAfGetDynamicIndexFromEndpoint(current_endpoint->endpoint_id); if (endpoint_index == 0xFFFF) { ESP_LOGE(TAG, "Could not find endpoint index"); - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } return ESP_FAIL; } emberAfClearDynamicEndpoint(endpoint_index); - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } if (!(current_endpoint->endpoint_type)) { ESP_LOGE(TAG, "endpoint %d's endpoint_type is NULL", current_endpoint->endpoint_id); @@ -306,13 +314,13 @@ static esp_err_t esp_matter_endpoint_disable(esp_matter_endpoint_t *endpoint) return ESP_OK; } -esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint) +esp_err_t enable(endpoint_t *endpoint) { if (!endpoint) { ESP_LOGE(TAG, "Endpoint cannot be NULL"); return ESP_ERR_INVALID_ARG; } - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)endpoint; + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; /* Endpoint Type */ EmberAfEndpointType *endpoint_type = (EmberAfEndpointType *)calloc(1, sizeof(EmberAfEndpointType)); @@ -324,8 +332,8 @@ esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint) current_endpoint->endpoint_type = endpoint_type; /* Clusters */ - _esp_matter_cluster_t *cluster = current_endpoint->cluster_list; - int cluster_count = cluster_get_count(cluster); + _cluster_t *cluster = current_endpoint->cluster_list; + int cluster_count = cluster::get_count(cluster); int cluster_index = 0; DataVersion *data_versions_ptr = (DataVersion *)calloc(1, cluster_count * sizeof(DataVersion)); @@ -342,20 +350,21 @@ esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint) /* Variables */ /* This is needed to avoid 'crosses initialization' errors because of goto */ esp_err_t err = ESP_OK; - esp_matter_lock_status_t lock_status = ESP_MATTER_LOCK_FAILED; + lock::status_t lock_status = lock::FAILED; EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; EmberAfCluster *matter_clusters = NULL; - _esp_matter_attribute_t *attribute = NULL; + _attribute_t *attribute = NULL; int attribute_count = 0; int attribute_index = 0; EmberAfAttributeMetadata *matter_attributes = NULL; CommandId *client_generated_command_ids = NULL; CommandId *server_generated_command_ids = NULL; - _esp_matter_command_t *command = NULL; + _command_t *command = NULL; int command_count = 0; int command_index = 0; int command_flag = ESP_MATTER_COMMAND_FLAG_NONE; int endpoint_index = 0; + int default_device_version = 1; matter_clusters = (EmberAfCluster *)calloc(1, cluster_count * sizeof(EmberAfCluster)); if (!matter_clusters) { @@ -367,10 +376,9 @@ esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint) while (cluster) { /* Attributes */ attribute = cluster->attribute_list; - attribute_count = attribute_get_count(attribute); + attribute_count = attribute::get_count(attribute); attribute_index = 0; - matter_attributes = (EmberAfAttributeMetadata *)calloc(1, - attribute_count * sizeof(EmberAfAttributeMetadata)); + matter_attributes = (EmberAfAttributeMetadata *)calloc(1, attribute_count * sizeof(EmberAfAttributeMetadata)); if (!matter_attributes) { ESP_LOGE(TAG, "Couldn't allocate matter_attributes"); err = ESP_ERR_NO_MEM; @@ -381,8 +389,8 @@ esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint) matter_attributes[attribute_index].attributeId = attribute->attribute_id; matter_attributes[attribute_index].mask = attribute->flags; matter_attributes[attribute_index].defaultValue = attribute->default_value; - get_data_from_attr_val(&attribute->val, &matter_attributes[attribute_index].attributeType, - &matter_attributes[attribute_index].size, NULL); + attribute::get_data_from_attr_val(&attribute->val, &matter_attributes[attribute_index].attributeType, + &matter_attributes[attribute_index].size, NULL); matter_clusters[cluster_index].clusterSize += matter_attributes[attribute_index].size; attribute = attribute->next; @@ -400,7 +408,7 @@ esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint) /* Client Generated Commands */ command_flag = ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED; command = cluster->command_list; - command_count = command_get_count(command, command_flag); + command_count = command::get_count(command, command_flag); if (command_count > 0) { command_index = 0; client_generated_command_ids = (CommandId *)calloc(1, (command_count + 1) * sizeof(CommandId)); @@ -422,7 +430,7 @@ esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint) /* Server Generated Commands */ command_flag = ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED; command = cluster->command_list; - command_count = command_get_count(command, command_flag); + command_count = command::get_count(command, command_flag); if (command_count > 0) { command_index = 0; server_generated_command_ids = (CommandId *)calloc(1, (command_count + 1) * sizeof(CommandId)); @@ -468,28 +476,29 @@ esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint) endpoint_type->clusterCount = cluster_count; /* Take lock if not already taken */ - lock_status = esp_matter_chip_stack_lock(portMAX_DELAY); - if (lock_status == ESP_MATTER_LOCK_FAILED) { + lock_status = lock::chip_stack_lock(portMAX_DELAY); + if (lock_status == lock::FAILED) { ESP_LOGE(TAG, "Could not get task context"); goto cleanup; } /* Add Endpoint */ - endpoint_index = endpoint_get_next_index(); + endpoint_index = endpoint::get_next_index(); status = emberAfSetDynamicEndpoint(endpoint_index, current_endpoint->endpoint_id, endpoint_type, - current_endpoint->device_type_id, 1, - chip::Span(data_versions)); + current_endpoint->device_type_id, default_device_version, + chip::Span(data_versions)); if (status != EMBER_ZCL_STATUS_SUCCESS) { - ESP_LOGE(TAG, "Error adding dynamic endpoint %d: %d", current_endpoint->endpoint_id, err); + ESP_LOGE(TAG, "Error adding dynamic endpoint %d: 0x%x", current_endpoint->endpoint_id, status); err = ESP_FAIL; - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } goto cleanup; } - if (lock_status == ESP_MATTER_LOCK_SUCCESS) { - esp_matter_chip_stack_unlock(); + if (lock_status == lock::SUCCESS) { + lock::chip_stack_unlock(); } + ESP_LOGI(TAG, "Dynamic endpoint %d added", current_endpoint->endpoint_id); return err; cleanup: @@ -529,37 +538,40 @@ cleanup: return err; } -static esp_err_t esp_matter_endpoint_enable_all() +static esp_err_t enable_all() { + node_t *node = node::get(); if (!node) { /* Not returning error, since the node will not be initialized for application using the data model from zap */ return ESP_OK; } - _esp_matter_endpoint_t *endpoint = node->endpoint_list; + endpoint_t *endpoint = get_first(node); while (endpoint) { - esp_matter_endpoint_enable((esp_matter_endpoint_t *)endpoint); - endpoint = endpoint->next; + enable(endpoint); + endpoint = get_next(endpoint); } return ESP_OK; } +} /* endpoint */ +namespace lock { #define DEFAULT_TICKS (500 / portTICK_PERIOD_MS) /* 500 ms in ticks */ -esp_matter_lock_status_t esp_matter_chip_stack_lock(uint32_t ticks_to_wait) +status_t chip_stack_lock(uint32_t ticks_to_wait) { if (PlatformMgr().IsChipStackLockedByCurrentThread()) { - return ESP_MATTER_LOCK_ALREADY_TAKEN; + return ALREADY_TAKEN; } if (ticks_to_wait == portMAX_DELAY) { /* Special handling for max delay */ PlatformMgr().LockChipStack(); - return ESP_MATTER_LOCK_SUCCESS; + return SUCCESS; } uint32_t ticks_remaining = ticks_to_wait; uint32_t ticks = DEFAULT_TICKS; while (ticks_remaining > 0) { if (PlatformMgr().TryLockChipStack()) { - return ESP_MATTER_LOCK_SUCCESS; + return SUCCESS; } ticks = ticks_remaining < DEFAULT_TICKS ? ticks_remaining : DEFAULT_TICKS; ticks_remaining -= ticks; @@ -567,14 +579,15 @@ esp_matter_lock_status_t esp_matter_chip_stack_lock(uint32_t ticks_to_wait) vTaskDelay(ticks); } ESP_LOGE(TAG, "Could not get lock"); - return ESP_MATTER_LOCK_FAILED; + return FAILED; } -esp_err_t esp_matter_chip_stack_unlock() +esp_err_t chip_stack_unlock() { PlatformMgr().UnlockChipStack(); return ESP_OK; } +} /* lock */ static void esp_matter_chip_init_task(intptr_t context) { @@ -588,27 +601,26 @@ static void esp_matter_chip_init_task(intptr_t context) #if CHIP_DEVICE_CONFIG_ENABLE_THREAD // If Thread is Provisioned, publish the dns service if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() && - (chip::Server::GetInstance().GetFabricTable().FabricCount() != 0)) - { + (chip::Server::GetInstance().GetFabricTable().FabricCount() != 0)) { chip::app::DnssdServer::Instance().StartServer(); } #endif - if (esp_matter_endpoint_enable_all() != ESP_OK) { + if (endpoint::enable_all() != ESP_OK) { ESP_LOGE(TAG, "Enable all endpoints failure"); } #if CHIP_DEVICE_CONFIG_ENABLE_WIFI { - static chip::app::Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0 /* Endpoint Id*/, - &(chip::DeviceLayer::NetworkCommissioning::ESPWiFiDriver::GetInstance())); + static chip::app::Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0, + &(chip::DeviceLayer::NetworkCommissioning::ESPWiFiDriver::GetInstance())); sWiFiNetworkCommissioningInstance.Init(); } #endif /* Initialize binding manager */ - esp_matter_binding_manager_init(); + client::binding_manager_init(); xTaskNotifyGive(task_to_notify); } -esp_err_t esp_matter_chip_init(esp_matter_event_callback_t callback) +static esp_err_t chip_init(event_callback_t callback) { if (chip::Platform::MemoryInit() != CHIP_NO_ERROR) { ESP_LOGE(TAG, "Failed to initialize CHIP memory pool"); @@ -644,9 +656,9 @@ esp_err_t esp_matter_chip_init(esp_matter_event_callback_t callback) return ESP_OK; } -esp_err_t esp_matter_start(esp_matter_event_callback_t callback) +esp_err_t start(event_callback_t callback) { - esp_err_t err = esp_matter_chip_init(callback); + esp_err_t err = chip_init(callback); if (err != ESP_OK) { ESP_LOGE(TAG, "Error initializing matter"); return err; @@ -658,279 +670,133 @@ esp_err_t esp_matter_start(esp_matter_event_callback_t callback) return err; } -esp_matter_node_t *esp_matter_node_get() +namespace attribute { +attribute_t *create(cluster_t *cluster, int attribute_id, uint8_t flags, esp_matter_attr_val_t val) { - return (esp_matter_node_t *)node; -} - -esp_matter_endpoint_t *esp_matter_endpoint_get(esp_matter_node_t *node, int endpoint_id) -{ - if (!node) { - ESP_LOGE(TAG, "Node cannot be NULL"); + /* Find */ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); return NULL; } - _esp_matter_node_t *current_node = (_esp_matter_node_t *)node; - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)current_node->endpoint_list; - while (current_endpoint) { - if (current_endpoint->endpoint_id == endpoint_id) { - break; - } - current_endpoint = current_endpoint->next; - } - return (esp_matter_endpoint_t *)current_endpoint; -} + _cluster_t *current_cluster = (_cluster_t *)cluster; -esp_matter_cluster_t *esp_matter_cluster_get(esp_matter_endpoint_t *endpoint, int cluster_id) -{ - if (!endpoint) { - ESP_LOGE(TAG, "Endpoint cannot be NULL"); + /* Allocate */ + _attribute_t *attribute = (_attribute_t *)calloc(1, sizeof(_attribute_t)); + if (!attribute) { + ESP_LOGE(TAG, "Couldn't allocate _attribute_t"); return NULL; } - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)endpoint; - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)current_endpoint->cluster_list; - while (current_cluster) { - if (current_cluster->cluster_id == cluster_id) { - break; - } - current_cluster = current_cluster->next; + + /* Set */ + attribute->attribute_id = attribute_id; + attribute->flags = flags; + attribute->flags |= ESP_MATTER_ATTRIBUTE_FLAG_EXTERNAL_STORAGE; + set_val((attribute_t *)attribute, &val); + set_default_value_from_current_val((attribute_t *)attribute); + + /* Add */ + _attribute_t *previous_attribute = NULL; + _attribute_t *current_attribute = current_cluster->attribute_list; + while (current_attribute) { + previous_attribute = current_attribute; + current_attribute = current_attribute->next; } - return (esp_matter_cluster_t *)current_cluster; + if (previous_attribute == NULL) { + current_cluster->attribute_list = attribute; + } else { + previous_attribute->next = attribute; + } + + return (attribute_t *)attribute; } -esp_matter_attribute_t *esp_matter_attribute_get(esp_matter_cluster_t *cluster, int attribute_id) +static esp_err_t destroy(attribute_t *attribute) +{ + if (!attribute) { + ESP_LOGE(TAG, "Attribute cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + _attribute_t *current_attribute = (_attribute_t *)attribute; + + /* Default value needs to be deleted first since it uses the current val. */ + free_default_value(attribute); + + /* Delete val here, if required */ + if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING || + current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING || + current_attribute->val.type == ESP_MATTER_VAL_TYPE_ARRAY) { + /* Free buf */ + if (current_attribute->val.val.a.b) { + free(current_attribute->val.val.a.b); + } + } + + /* Free bounds */ + if (current_attribute->bounds) { + free(current_attribute->bounds); + } + + /* Free */ + free(current_attribute); + return ESP_OK; +} + +attribute_t *get(cluster_t *cluster, int attribute_id) { if (!cluster) { ESP_LOGE(TAG, "Cluster cannot be NULL"); return NULL; } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)current_cluster->attribute_list; + _cluster_t *current_cluster = (_cluster_t *)cluster; + _attribute_t *current_attribute = (_attribute_t *)current_cluster->attribute_list; while (current_attribute) { if (current_attribute->attribute_id == attribute_id) { break; } current_attribute = current_attribute->next; } - return (esp_matter_attribute_t *)current_attribute; + return (attribute_t *)current_attribute; } -esp_matter_command_t *esp_matter_command_get(esp_matter_cluster_t *cluster, int command_id) +attribute_t *get_first(cluster_t *cluster) { if (!cluster) { ESP_LOGE(TAG, "Cluster cannot be NULL"); return NULL; } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - _esp_matter_command_t *current_command = (_esp_matter_command_t *)current_cluster->command_list; - while (current_command) { - if (current_command->command_id == command_id) { - break; - } - current_command = current_command->next; - } - return (esp_matter_command_t *)current_command; + _cluster_t *current_cluster = (_cluster_t *)cluster; + return (attribute_t *)current_cluster->attribute_list; } -esp_matter_endpoint_t *esp_matter_endpoint_get_first(esp_matter_node_t *node) -{ - if (!node) { - ESP_LOGE(TAG, "Node cannot be NULL"); - return NULL; - } - _esp_matter_node_t *current_node = (_esp_matter_node_t *)node; - return (esp_matter_endpoint_t *)current_node->endpoint_list; -} - -esp_matter_cluster_t *esp_matter_cluster_get_first(esp_matter_endpoint_t *endpoint) -{ - if (!endpoint) { - ESP_LOGE(TAG, "Endpoint cannot be NULL"); - return NULL; - } - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)endpoint; - return (esp_matter_cluster_t *)current_endpoint->cluster_list; -} - -esp_matter_attribute_t *esp_matter_attribute_get_first(esp_matter_cluster_t *cluster) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return NULL; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - return (esp_matter_attribute_t *)current_cluster->attribute_list; -} - -esp_matter_command_t *esp_matter_command_get_first(esp_matter_cluster_t *cluster) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return NULL; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - return (esp_matter_command_t *)current_cluster->command_list; -} - -esp_matter_endpoint_t *esp_matter_endpoint_get_next(esp_matter_endpoint_t *endpoint) -{ - if (!endpoint) { - ESP_LOGE(TAG, "Endpoint cannot be NULL"); - return NULL; - } - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)endpoint; - return (esp_matter_endpoint_t *)current_endpoint->next; -} - -esp_matter_cluster_t *esp_matter_cluster_get_next(esp_matter_cluster_t *cluster) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return NULL; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - return (esp_matter_cluster_t *)current_cluster->next; -} - -esp_matter_attribute_t *esp_matter_attribute_get_next(esp_matter_attribute_t *attribute) +attribute_t *get_next(attribute_t *attribute) { if (!attribute) { ESP_LOGE(TAG, "Attribute cannot be NULL"); return NULL; } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; - return (esp_matter_attribute_t *)current_attribute->next; + _attribute_t *current_attribute = (_attribute_t *)attribute; + return (attribute_t *)current_attribute->next; } -esp_matter_command_t *esp_matter_command_get_next(esp_matter_command_t *command) -{ - if (!command) { - ESP_LOGE(TAG, "Command cannot be NULL"); - return NULL; - } - _esp_matter_command_t *current_command = (_esp_matter_command_t *)command; - return (esp_matter_command_t *)current_command->next; -} - -int esp_matter_endpoint_get_id(esp_matter_endpoint_t *endpoint) -{ - if (!endpoint) { - ESP_LOGE(TAG, "Endpoint cannot be NULL"); - return -1; - } - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)endpoint; - return current_endpoint->endpoint_id; -} - -int esp_matter_cluster_get_id(esp_matter_cluster_t *cluster) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return -1; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - return current_cluster->cluster_id; -} - -int esp_matter_attribute_get_id(esp_matter_attribute_t *attribute) +int get_id(attribute_t *attribute) { if (!attribute) { ESP_LOGE(TAG, "Attribute cannot be NULL"); return -1; } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; + _attribute_t *current_attribute = (_attribute_t *)attribute; return current_attribute->attribute_id; } -int esp_matter_command_get_id(esp_matter_command_t *command) -{ - if (!command) { - ESP_LOGE(TAG, "Command cannot be NULL"); - return -1; - } - _esp_matter_command_t *current_command = (_esp_matter_command_t *)command; - return current_command->command_id; -} - -esp_err_t esp_matter_cluster_set_plugin_server_init_callback(esp_matter_cluster_t *cluster, - esp_matter_cluster_plugin_server_init_callback_t callback) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - current_cluster->plugin_server_init_callback = callback; - return ESP_OK; -} - -esp_err_t esp_matter_cluster_set_plugin_client_init_callback(esp_matter_cluster_t *cluster, - esp_matter_cluster_plugin_client_init_callback_t callback) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - current_cluster->plugin_client_init_callback = callback; - return ESP_OK; -} - -esp_matter_cluster_plugin_server_init_callback_t esp_matter_cluster_get_plugin_server_init_callback( - esp_matter_cluster_t *cluster) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return NULL; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - return current_cluster->plugin_server_init_callback; -} - -esp_matter_cluster_plugin_client_init_callback_t esp_matter_cluster_get_plugin_client_init_callback( - esp_matter_cluster_t *cluster) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return NULL; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - return current_cluster->plugin_client_init_callback; -} - -esp_err_t esp_matter_cluster_add_function_list(esp_matter_cluster_t *cluster, - const esp_matter_cluster_function_generic_t *function_list, - int function_flags) -{ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - current_cluster->function_list = function_list; - current_cluster->flags |= function_flags; - return ESP_OK; -} - -esp_err_t esp_matter_attribute_get_val(esp_matter_attribute_t *attribute, esp_matter_attr_val_t *val) -{ - if (!attribute) { - ESP_LOGE(TAG, "Attribute cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; - memcpy((void *)val, (void *)¤t_attribute->val, sizeof(esp_matter_attr_val_t)); - return ESP_OK; -} - -esp_err_t esp_matter_attribute_set_val(esp_matter_attribute_t *attribute, esp_matter_attr_val_t *val) +esp_err_t set_val(attribute_t *attribute, esp_matter_attr_val_t *val) { if (!attribute) { ESP_LOGE(TAG, "Attribute cannot be NULL"); return ESP_FAIL; } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; - if (val->type == ESP_MATTER_VAL_TYPE_CHAR_STRING || val->type == ESP_MATTER_VAL_TYPE_OCTET_STRING - || val->type == ESP_MATTER_VAL_TYPE_ARRAY) { + _attribute_t *current_attribute = (_attribute_t *)attribute; + if (val->type == ESP_MATTER_VAL_TYPE_CHAR_STRING || val->type == ESP_MATTER_VAL_TYPE_OCTET_STRING || + val->type == ESP_MATTER_VAL_TYPE_ARRAY) { /* Free old buf */ if (current_attribute->val.val.a.b) { free(current_attribute->val.val.a.b); @@ -954,19 +820,29 @@ esp_err_t esp_matter_attribute_set_val(esp_matter_attribute_t *attribute, esp_ma return ESP_OK; } -esp_err_t esp_matter_attribute_add_bounds(esp_matter_attribute_t *attribute, esp_matter_attr_val_t min, - esp_matter_attr_val_t max) +esp_err_t get_val(attribute_t *attribute, esp_matter_attr_val_t *val) { if (!attribute) { ESP_LOGE(TAG, "Attribute cannot be NULL"); return ESP_ERR_INVALID_ARG; } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; + _attribute_t *current_attribute = (_attribute_t *)attribute; + memcpy((void *)val, (void *)¤t_attribute->val, sizeof(esp_matter_attr_val_t)); + return ESP_OK; +} + +esp_err_t add_bounds(attribute_t *attribute, esp_matter_attr_val_t min, esp_matter_attr_val_t max) +{ + if (!attribute) { + ESP_LOGE(TAG, "Attribute cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + _attribute_t *current_attribute = (_attribute_t *)attribute; /* Check if bounds can be set */ - if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING - || current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING - || current_attribute->val.type == ESP_MATTER_VAL_TYPE_ARRAY) { + if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING || + current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING || + current_attribute->val.type == ESP_MATTER_VAL_TYPE_ARRAY) { ESP_LOGE(TAG, "Bounds cannot be set for string/array type attributes"); return ESP_ERR_INVALID_ARG; } @@ -977,7 +853,7 @@ esp_err_t esp_matter_attribute_add_bounds(esp_matter_attribute_t *attribute, esp } /* Free the default value before setting the new bounds */ - attribute_free_default_value(attribute); + free_default_value(attribute); /* Allocate and set */ current_attribute->bounds = (esp_matter_attr_bounds_t *)calloc(1, sizeof(esp_matter_attr_bounds_t)); @@ -990,155 +866,36 @@ esp_err_t esp_matter_attribute_add_bounds(esp_matter_attribute_t *attribute, esp current_attribute->flags |= ESP_MATTER_ATTRIBUTE_FLAG_MIN_MAX; /* Set the default value again after setting the bounds and the flag */ - attribute_set_default_value_from_current_val(attribute); + set_default_value_from_current_val(attribute); return ESP_OK; } -esp_matter_attr_bounds_t *esp_matter_attribute_get_bounds(esp_matter_attribute_t *attribute) +esp_matter_attr_bounds_t *get_bounds(attribute_t *attribute) { if (!attribute) { ESP_LOGE(TAG, "Attribute cannot be NULL"); return NULL; } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; + _attribute_t *current_attribute = (_attribute_t *)attribute; return current_attribute->bounds; } -esp_matter_command_callback_t esp_matter_command_get_callback(esp_matter_command_t *command) -{ - if (!command) { - ESP_LOGE(TAG, "Command cannot be NULL"); - return NULL; - } - _esp_matter_command_t *current_command = (_esp_matter_command_t *)command; - return current_command->callback; -} +} /* attribute */ -int esp_matter_command_get_flags(esp_matter_command_t *command) -{ - if (!command) { - ESP_LOGE(TAG, "Command cannot be NULL"); - return 0; - } - _esp_matter_command_t *current_command = (_esp_matter_command_t *)command; - return current_command->flags; -} - -esp_err_t esp_matter_endpoint_set_device_type_id(esp_matter_endpoint_t *endpoint, int device_type_id) -{ - if (!endpoint) { - ESP_LOGE(TAG, "Endpoint cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)endpoint; - current_endpoint->device_type_id = device_type_id; - return ESP_OK; -} - -int esp_matter_endpoint_get_device_type_id(int endpoint_id) -{ - int device_type_id = emberAfGetDeviceIdForEndpoint(endpoint_id); - return device_type_id; -} - -static esp_err_t esp_matter_attribute_delete(esp_matter_attribute_t *attribute) -{ - if (!attribute) { - ESP_LOGE(TAG, "Attribute cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - _esp_matter_attribute_t *current_attribute = (_esp_matter_attribute_t *)attribute; - - /* Default value needs to be deleted first since it uses the current val. */ - attribute_free_default_value(attribute); - - /* Delete val here, if required */ - if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING - || current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING - || current_attribute->val.type == ESP_MATTER_VAL_TYPE_ARRAY) { - /* Free buf */ - if (current_attribute->val.val.a.b) { - free(current_attribute->val.val.a.b); - } - } - - /* Free bounds */ - if (current_attribute->bounds) { - free(current_attribute->bounds); - } - - /* Free */ - free(current_attribute); - return ESP_OK; -} - -esp_matter_attribute_t *esp_matter_attribute_create(esp_matter_cluster_t *cluster, int attribute_id, uint8_t flags, - esp_matter_attr_val_t val) +namespace command { +command_t *create(cluster_t *cluster, int command_id, uint8_t flags, callback_t callback) { /* Find */ if (!cluster) { ESP_LOGE(TAG, "Cluster cannot be NULL"); return NULL; } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; + _cluster_t *current_cluster = (_cluster_t *)cluster; /* Allocate */ - _esp_matter_attribute_t *attribute = (_esp_matter_attribute_t *)calloc(1, sizeof(_esp_matter_attribute_t)); - if (!attribute) { - ESP_LOGE(TAG, "Couldn't allocate _esp_matter_attribute_t"); - return NULL; - } - - /* Set */ - attribute->attribute_id = attribute_id; - attribute->flags = flags; - attribute->flags |= ESP_MATTER_ATTRIBUTE_FLAG_EXTERNAL_STORAGE; - esp_matter_attribute_set_val((esp_matter_attribute_t *)attribute, &val); - attribute_set_default_value_from_current_val((esp_matter_attribute_t *)attribute); - - /* Add */ - _esp_matter_attribute_t *previous_attribute = NULL; - _esp_matter_attribute_t *current_attribute = current_cluster->attribute_list; - while (current_attribute) { - previous_attribute = current_attribute; - current_attribute = current_attribute->next; - } - if (previous_attribute == NULL) { - current_cluster->attribute_list = attribute; - } else { - previous_attribute->next = attribute; - } - - return (esp_matter_attribute_t *)attribute; -} - -static esp_err_t esp_matter_command_delete(esp_matter_command_t *command) -{ + _command_t *command = (_command_t *)calloc(1, sizeof(_command_t)); if (!command) { - ESP_LOGE(TAG, "Command cannot be NULL"); - return ESP_ERR_INVALID_ARG; - } - _esp_matter_command_t *current_command = (_esp_matter_command_t *)command; - - /* Free */ - free(current_command); - return ESP_OK; -} - -esp_matter_command_t *esp_matter_command_create(esp_matter_cluster_t *cluster, int command_id, uint8_t flags, - esp_matter_command_callback_t callback) -{ - /* Find */ - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); - return NULL; - } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - - /* Allocate */ - _esp_matter_command_t *command = (_esp_matter_command_t *)calloc(1, sizeof(_esp_matter_command_t)); - if (!command) { - ESP_LOGE(TAG, "Couldn't allocate _esp_matter_command_t"); + ESP_LOGE(TAG, "Couldn't allocate _command_t"); return NULL; } @@ -1148,8 +905,8 @@ esp_matter_command_t *esp_matter_command_create(esp_matter_cluster_t *cluster, i command->callback = callback; /* Add */ - _esp_matter_command_t *previous_command = NULL; - _esp_matter_command_t *current_command = current_cluster->command_list; + _command_t *previous_command = NULL; + _command_t *current_command = current_cluster->command_list; while (current_command) { previous_command = current_command; current_command = current_command->next; @@ -1160,51 +917,106 @@ esp_matter_command_t *esp_matter_command_create(esp_matter_cluster_t *cluster, i previous_command->next = command; } - return (esp_matter_command_t *)command; + return (command_t *)command; } -static esp_err_t esp_matter_cluster_delete(esp_matter_cluster_t *cluster) +static esp_err_t destroy(command_t *command) { - if (!cluster) { - ESP_LOGE(TAG, "Cluster cannot be NULL"); + if (!command) { + ESP_LOGE(TAG, "Command cannot be NULL"); return ESP_ERR_INVALID_ARG; } - _esp_matter_cluster_t *current_cluster = (_esp_matter_cluster_t *)cluster; - - /* Parse and delete all commands */ - _esp_matter_command_t *command = current_cluster->command_list; - while (command) { - _esp_matter_command_t *next_command = command->next; - esp_matter_command_delete((esp_matter_command_t *)command); - command = next_command; - } - - /* Parse and delete all attributes */ - _esp_matter_attribute_t *attribute = current_cluster->attribute_list; - while (attribute) { - _esp_matter_attribute_t *next_attribute = attribute->next; - esp_matter_attribute_delete((esp_matter_attribute_t *)attribute); - attribute = next_attribute; - } + _command_t *current_command = (_command_t *)command; /* Free */ - free(current_cluster); + free(current_command); return ESP_OK; } -esp_matter_cluster_t *esp_matter_cluster_create(esp_matter_endpoint_t *endpoint, int cluster_id, uint8_t flags) +command_t *get(cluster_t *cluster, int command_id) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return NULL; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + _command_t *current_command = (_command_t *)current_cluster->command_list; + while (current_command) { + if (current_command->command_id == command_id) { + break; + } + current_command = current_command->next; + } + return (command_t *)current_command; +} + +command_t *get_first(cluster_t *cluster) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return NULL; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + return (command_t *)current_cluster->command_list; +} + +command_t *get_next(command_t *command) +{ + if (!command) { + ESP_LOGE(TAG, "Command cannot be NULL"); + return NULL; + } + _command_t *current_command = (_command_t *)command; + return (command_t *)current_command->next; +} + +int get_id(command_t *command) +{ + if (!command) { + ESP_LOGE(TAG, "Command cannot be NULL"); + return -1; + } + _command_t *current_command = (_command_t *)command; + return current_command->command_id; +} + +callback_t get_callback(command_t *command) +{ + if (!command) { + ESP_LOGE(TAG, "Command cannot be NULL"); + return NULL; + } + _command_t *current_command = (_command_t *)command; + return current_command->callback; +} + +int get_flags(command_t *command) +{ + if (!command) { + ESP_LOGE(TAG, "Command cannot be NULL"); + return 0; + } + _command_t *current_command = (_command_t *)command; + return current_command->flags; +} + +} /* command */ + +namespace cluster { + +cluster_t *create(endpoint_t *endpoint, int cluster_id, uint8_t flags) { /* Find */ if (!endpoint) { ESP_LOGE(TAG, "Endpoint cannot be NULL"); return NULL; } - _esp_matter_endpoint_t *current_endpoint = (_esp_matter_endpoint_t *)endpoint; + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; /* Allocate */ - _esp_matter_cluster_t *cluster = (_esp_matter_cluster_t *)calloc(1, sizeof(_esp_matter_cluster_t)); + _cluster_t *cluster = (_cluster_t *)calloc(1, sizeof(_cluster_t)); if (!cluster) { - ESP_LOGE(TAG, "Couldn't allocate _esp_matter_cluster_t"); + ESP_LOGE(TAG, "Couldn't allocate _cluster_t"); return NULL; } @@ -1213,8 +1025,8 @@ esp_matter_cluster_t *esp_matter_cluster_create(esp_matter_endpoint_t *endpoint, cluster->flags = flags; /* Add */ - _esp_matter_cluster_t *previous_cluster = NULL; - _esp_matter_cluster_t *current_cluster = current_endpoint->cluster_list; + _cluster_t *previous_cluster = NULL; + _cluster_t *current_cluster = current_endpoint->cluster_list; while (current_cluster) { previous_cluster = current_cluster; current_cluster = current_cluster->next; @@ -1225,17 +1037,188 @@ esp_matter_cluster_t *esp_matter_cluster_create(esp_matter_endpoint_t *endpoint, previous_cluster->next = cluster; } - return (esp_matter_cluster_t *)cluster; + return (cluster_t *)cluster; } -esp_err_t esp_matter_endpoint_delete(esp_matter_node_t *node, esp_matter_endpoint_t *endpoint) +static esp_err_t destroy(cluster_t *cluster) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + + /* Parse and delete all commands */ + _command_t *command = current_cluster->command_list; + while (command) { + _command_t *next_command = command->next; + command::destroy((command_t *)command); + command = next_command; + } + + /* Parse and delete all attributes */ + _attribute_t *attribute = current_cluster->attribute_list; + while (attribute) { + _attribute_t *next_attribute = attribute->next; + attribute::destroy((attribute_t *)attribute); + attribute = next_attribute; + } + + /* Free */ + free(current_cluster); + return ESP_OK; +} + +cluster_t *get(endpoint_t *endpoint, int cluster_id) +{ + if (!endpoint) { + ESP_LOGE(TAG, "Endpoint cannot be NULL"); + return NULL; + } + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; + _cluster_t *current_cluster = (_cluster_t *)current_endpoint->cluster_list; + while (current_cluster) { + if (current_cluster->cluster_id == cluster_id) { + break; + } + current_cluster = current_cluster->next; + } + return (cluster_t *)current_cluster; +} + +cluster_t *get_first(endpoint_t *endpoint) +{ + if (!endpoint) { + ESP_LOGE(TAG, "Endpoint cannot be NULL"); + return NULL; + } + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; + return (cluster_t *)current_endpoint->cluster_list; +} + +cluster_t *get_next(cluster_t *cluster) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return NULL; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + return (cluster_t *)current_cluster->next; +} + +int get_id(cluster_t *cluster) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return -1; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + return current_cluster->cluster_id; +} + +esp_err_t set_plugin_server_init_callback(cluster_t *cluster, plugin_server_init_callback_t callback) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + current_cluster->plugin_server_init_callback = callback; + return ESP_OK; +} + +esp_err_t set_plugin_client_init_callback(cluster_t *cluster, plugin_client_init_callback_t callback) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + current_cluster->plugin_client_init_callback = callback; + return ESP_OK; +} + +plugin_server_init_callback_t get_plugin_server_init_callback(cluster_t *cluster) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return NULL; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + return current_cluster->plugin_server_init_callback; +} + +plugin_client_init_callback_t get_plugin_client_init_callback(cluster_t *cluster) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return NULL; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + return current_cluster->plugin_client_init_callback; +} + +esp_err_t add_function_list(cluster_t *cluster, const function_generic_t *function_list, int function_flags) +{ + if (!cluster) { + ESP_LOGE(TAG, "Cluster cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + _cluster_t *current_cluster = (_cluster_t *)cluster; + current_cluster->function_list = function_list; + current_cluster->flags |= function_flags; + return ESP_OK; +} + +} /* cluster */ + +namespace endpoint { + +endpoint_t *create(node_t *node, uint8_t flags) +{ + /* Find */ + if (!node) { + ESP_LOGE(TAG, "Node cannot be NULL"); + return NULL; + } + _node_t *current_node = (_node_t *)node; + + /* Allocate */ + _endpoint_t *endpoint = (_endpoint_t *)calloc(1, sizeof(_endpoint_t)); + if (!endpoint) { + ESP_LOGE(TAG, "Couldn't allocate _endpoint_t"); + return NULL; + } + + /* Set */ + endpoint->endpoint_id = current_node->current_endpoint_id++; + endpoint->device_type_id = 0xFFFF; + endpoint->flags = flags; + + /* Add */ + _endpoint_t *previous_endpoint = NULL; + _endpoint_t *current_endpoint = current_node->endpoint_list; + while (current_endpoint) { + previous_endpoint = current_endpoint; + current_endpoint = current_endpoint->next; + } + if (previous_endpoint == NULL) { + current_node->endpoint_list = endpoint; + } else { + previous_endpoint->next = endpoint; + } + + return (endpoint_t *)endpoint; +} + +esp_err_t destroy(node_t *node, endpoint_t *endpoint) { if (!node || !endpoint) { ESP_LOGE(TAG, "Node or endpoint cannot be NULL"); return ESP_ERR_INVALID_ARG; } - _esp_matter_node_t *current_node = (_esp_matter_node_t *)node; - _esp_matter_endpoint_t *_endpoint = (_esp_matter_endpoint_t *)endpoint; + _node_t *current_node = (_node_t *)node; + _endpoint_t *_endpoint = (_endpoint_t *)endpoint; if (!(_endpoint->flags & ESP_MATTER_ENDPOINT_FLAG_DELETABLE)) { ESP_LOGE(TAG, "This endpoint cannot be deleted since the ESP_MATTER_ENDPOINT_FLAG_DELETABLE is not set"); @@ -1243,8 +1226,8 @@ esp_err_t esp_matter_endpoint_delete(esp_matter_node_t *node, esp_matter_endpoin } /* Find current endpoint and remove from list */ - _esp_matter_endpoint_t *current_endpoint = current_node->endpoint_list; - _esp_matter_endpoint_t *previous_endpoint = NULL; + _endpoint_t *current_endpoint = current_node->endpoint_list; + _endpoint_t *previous_endpoint = NULL; while (current_endpoint) { if (current_endpoint == _endpoint) { break; @@ -1263,13 +1246,13 @@ esp_err_t esp_matter_endpoint_delete(esp_matter_node_t *node, esp_matter_endpoin } /* Disable */ - esp_matter_endpoint_disable(endpoint); + disable(endpoint); /* Parse and delete all clusters */ - _esp_matter_cluster_t *cluster = current_endpoint->cluster_list; + _cluster_t *cluster = current_endpoint->cluster_list; while (cluster) { - _esp_matter_cluster_t *next_cluster = cluster->next; - esp_matter_cluster_delete((esp_matter_cluster_t *)cluster); + _cluster_t *next_cluster = cluster->next; + cluster::destroy((cluster_t *)cluster); cluster = next_cluster; } @@ -1278,49 +1261,90 @@ esp_err_t esp_matter_endpoint_delete(esp_matter_node_t *node, esp_matter_endpoin return ESP_OK; } -esp_matter_endpoint_t *esp_matter_endpoint_create_raw(esp_matter_node_t *node, uint8_t flags) +endpoint_t *get(node_t *node, int endpoint_id) { - /* Find */ if (!node) { ESP_LOGE(TAG, "Node cannot be NULL"); return NULL; } - _esp_matter_node_t *current_node = (_esp_matter_node_t *)node; - - /* Allocate */ - _esp_matter_endpoint_t *endpoint = (_esp_matter_endpoint_t *)calloc(1, sizeof(_esp_matter_endpoint_t)); - if (!endpoint) { - ESP_LOGE(TAG, "Couldn't allocate _esp_matter_endpoint_t"); - return NULL; - } - - /* Set */ - endpoint->endpoint_id = current_node->current_endpoint_id++; - endpoint->device_type_id = 0xFFFF; - endpoint->flags = flags; - - /* Add */ - _esp_matter_endpoint_t *previous_endpoint = NULL; - _esp_matter_endpoint_t *current_endpoint = current_node->endpoint_list; + _node_t *current_node = (_node_t *)node; + _endpoint_t *current_endpoint = (_endpoint_t *)current_node->endpoint_list; while (current_endpoint) { - previous_endpoint = current_endpoint; + if (current_endpoint->endpoint_id == endpoint_id) { + break; + } current_endpoint = current_endpoint->next; } - if (previous_endpoint == NULL) { - current_node->endpoint_list = endpoint; - } else { - previous_endpoint->next = endpoint; - } - - return (esp_matter_endpoint_t *)endpoint; + return (endpoint_t *)current_endpoint; } -esp_matter_node_t *esp_matter_node_create_raw() +endpoint_t *get_first(node_t *node) { - node = (_esp_matter_node_t *)calloc(1, sizeof(_esp_matter_node_t)); if (!node) { - ESP_LOGE(TAG, "Couldn't allocate _esp_matter_node_t"); + ESP_LOGE(TAG, "Node cannot be NULL"); return NULL; } - return (esp_matter_node_t *)node; + _node_t *current_node = (_node_t *)node; + return (endpoint_t *)current_node->endpoint_list; } + +endpoint_t *get_next(endpoint_t *endpoint) +{ + if (!endpoint) { + ESP_LOGE(TAG, "Endpoint cannot be NULL"); + return NULL; + } + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; + return (endpoint_t *)current_endpoint->next; +} + +int get_id(endpoint_t *endpoint) +{ + if (!endpoint) { + ESP_LOGE(TAG, "Endpoint cannot be NULL"); + return -1; + } + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; + return current_endpoint->endpoint_id; +} + +esp_err_t set_device_type_id(endpoint_t *endpoint, int device_type_id) +{ + if (!endpoint) { + ESP_LOGE(TAG, "Endpoint cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; + current_endpoint->device_type_id = device_type_id; + return ESP_OK; +} + +int get_device_type_id(int endpoint_id) +{ + int device_type_id = emberAfGetDeviceIdForEndpoint(endpoint_id); + return device_type_id; +} + +} /* endpoint */ + +namespace node { + +static _node_t *node = NULL; + +node_t *create_raw() +{ + node = (_node_t *)calloc(1, sizeof(_node_t)); + if (!node) { + ESP_LOGE(TAG, "Couldn't allocate _node_t"); + return NULL; + } + return (node_t *)node; +} + +node_t *get() +{ + return (node_t *)node; +} + +} /* node */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_core.h b/components/esp_matter/esp_matter_core.h index 4e85364d9..56bbcb5e2 100644 --- a/components/esp_matter/esp_matter_core.h +++ b/components/esp_matter/esp_matter_core.h @@ -14,133 +14,129 @@ #pragma once +#include +#include +#include #include #include -#include -#include -#include -using chip::DeviceLayer::ChipDeviceEvent; using chip::app::ConcreteCommandPath; +using chip::DeviceLayer::ChipDeviceEvent; using chip::TLV::TLVReader; -typedef size_t esp_matter_handle_t; -typedef esp_matter_handle_t esp_matter_node_t; -typedef esp_matter_handle_t esp_matter_endpoint_t; -typedef esp_matter_handle_t esp_matter_cluster_t; -typedef esp_matter_handle_t esp_matter_attribute_t; -typedef esp_matter_handle_t esp_matter_command_t; +namespace esp_matter { -typedef enum esp_matter_callback_type { - ESP_MATTER_CALLBACK_TYPE_PRE_ATTRIBUTE, - ESP_MATTER_CALLBACK_TYPE_POST_ATTRIBUTE, -} esp_matter_callback_type_t; +typedef size_t handle_t; +typedef handle_t node_t; +typedef handle_t endpoint_t; +typedef handle_t cluster_t; +typedef handle_t attribute_t; +typedef handle_t command_t; + +typedef void (*event_callback_t)(const ChipDeviceEvent *event, intptr_t arg); + +esp_err_t start(event_callback_t callback); + +namespace lock { +typedef enum status { + FAILED, + ALREADY_TAKEN, + SUCCESS, +} status_t; + +status_t chip_stack_lock(uint32_t ticks_to_wait); +/* unlock() should only be called if chip_stack_lock() returns SUCCESS */ +esp_err_t chip_stack_unlock(); +} /* lock */ + +namespace node { +node_t *create_raw(); +node_t *get(); +} /* node */ + +namespace endpoint { +endpoint_t *create(node_t *node, uint8_t flags); +esp_err_t destroy(node_t *node, endpoint_t *endpoint); +endpoint_t *get(node_t *node, int endpoint_id); +endpoint_t *get_first(node_t *node); +endpoint_t *get_next(endpoint_t *endpoint); +int get_id(endpoint_t *endpoint); +esp_err_t set_device_type_id(endpoint_t *endpoint, int device_type_id); +int get_device_type_id(int endpoint_id); +/* Endpoint enable: It only needs to be called for endpoints created after calling esp_matter::start(). It should be + * called after all the clusters, attributes and commands have been added to the created endpoint. */ +esp_err_t enable(endpoint_t *endpoint); +} /* endpoint */ + +namespace cluster { +typedef void (*plugin_server_init_callback_t)(); +typedef void (*plugin_client_init_callback_t)(); +typedef void (*function_generic_t)(); + +cluster_t *create(endpoint_t *endpoint, int cluster_id, uint8_t flags); +cluster_t *get(endpoint_t *endpoint, int cluster_id); +cluster_t *get_first(endpoint_t *endpoint); +cluster_t *get_next(cluster_t *cluster); +int get_id(cluster_t *cluster); +esp_err_t set_plugin_server_init_callback(cluster_t *cluster, plugin_server_init_callback_t callback); +esp_err_t set_plugin_client_init_callback(cluster_t *cluster, plugin_client_init_callback_t callback); +plugin_server_init_callback_t get_plugin_server_init_callback(cluster_t *cluster); +plugin_client_init_callback_t get_plugin_client_init_callback(cluster_t *cluster); +esp_err_t add_function_list(cluster_t *cluster, const function_generic_t *function_list, int function_flags); +} /* cluster */ + +namespace attribute { +typedef enum callback_type { + PRE_ATTRIBUTE, + POST_ATTRIBUTE, +} callback_type_t; /** Callback for attribute value changed * * @return ESP_OK on success. * @return error in case of failure. */ -typedef esp_err_t (*esp_matter_attribute_callback_t)(esp_matter_callback_type_t type, int endpoint_id, int cluster_id, - int attribute_id, esp_matter_attr_val_t *val, void *priv_data); +typedef esp_err_t (*callback_t)(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id, + esp_matter_attr_val_t *val, void *priv_data); +esp_err_t set_callback(callback_t callback, void *priv_data); -typedef void (*esp_matter_event_callback_t)(const ChipDeviceEvent *event, intptr_t arg); - -typedef void (*esp_matter_cluster_plugin_server_init_callback_t)(); - -typedef void (*esp_matter_cluster_plugin_client_init_callback_t)(); - -typedef void (*esp_matter_cluster_function_generic_t)(); - -typedef esp_err_t (*esp_matter_command_custom_callback_t)(int endpoint_id, int cluster_id, int command_id, - TLVReader &tlv_data, void *priv_data); - -typedef void (*esp_matter_command_callback_t)(void *command_obj, const ConcreteCommandPath &command_path, - TLVReader &tlv_data); - -typedef chip::DeviceProxy esp_matter_peer_device_t; -typedef void (*esp_matter_client_command_callback_t)(esp_matter_peer_device_t *peer_device, int remote_endpoint_id, void *priv_data); - -/** Initializing APIs */ -esp_err_t esp_matter_attribute_callback_set(esp_matter_attribute_callback_t callback, void *priv_data); -esp_err_t esp_matter_start(esp_matter_event_callback_t callback); - -/* Supporting APIs */ -typedef enum esp_matter_lock_status { - ESP_MATTER_LOCK_FAILED, - ESP_MATTER_LOCK_ALREADY_TAKEN, - ESP_MATTER_LOCK_SUCCESS, -} esp_matter_lock_status_t; -esp_matter_lock_status_t esp_matter_chip_stack_lock(uint32_t ticks_to_wait); -/* unlock() should only be called if lock() returns ESP_MATTER_LOCK_SUCCESS */ -esp_err_t esp_matter_chip_stack_unlock(); - -/** Node APIs */ -esp_matter_node_t *esp_matter_node_create_raw(); -esp_matter_node_t *esp_matter_node_get(); - -/** Endpoint APIs */ -esp_matter_endpoint_t *esp_matter_endpoint_create_raw(esp_matter_node_t *node, uint8_t flags); -esp_err_t esp_matter_endpoint_delete(esp_matter_node_t *node, esp_matter_endpoint_t *endpoint); -esp_matter_endpoint_t *esp_matter_endpoint_get(esp_matter_node_t *node, int endpoint_id); -esp_matter_endpoint_t *esp_matter_endpoint_get_first(esp_matter_node_t *node); -esp_matter_endpoint_t *esp_matter_endpoint_get_next(esp_matter_endpoint_t *endpoint); -int esp_matter_endpoint_get_id(esp_matter_endpoint_t *endpoint); -esp_err_t esp_matter_endpoint_set_device_type_id(esp_matter_endpoint_t *endpoint, int device_type_id); -int esp_matter_endpoint_get_device_type_id(int endpoint_id); -/* Endpoint enable: It only needs to be called for endpoints created after calling esp_matter_start(). It should be - * called after all the clusters, attributes and commands have been added to the created endpoint. */ -esp_err_t esp_matter_endpoint_enable(esp_matter_endpoint_t *endpoint); - -/** Cluster APIs */ -esp_matter_cluster_t *esp_matter_cluster_create(esp_matter_endpoint_t *endpoint, int cluster_id, uint8_t flags); -esp_matter_cluster_t *esp_matter_cluster_get(esp_matter_endpoint_t *endpoint, int cluster_id); -esp_matter_cluster_t *esp_matter_cluster_get_first(esp_matter_endpoint_t *endpoint); -esp_matter_cluster_t *esp_matter_cluster_get_next(esp_matter_cluster_t *cluster); -int esp_matter_cluster_get_id(esp_matter_cluster_t *cluster); -esp_err_t esp_matter_cluster_set_plugin_server_init_callback(esp_matter_cluster_t *cluster, - esp_matter_cluster_plugin_server_init_callback_t callback); -esp_err_t esp_matter_cluster_set_plugin_client_init_callback(esp_matter_cluster_t *cluster, - esp_matter_cluster_plugin_client_init_callback_t callback); -esp_matter_cluster_plugin_server_init_callback_t esp_matter_cluster_get_plugin_server_init_callback( - esp_matter_cluster_t *cluster); -esp_matter_cluster_plugin_client_init_callback_t esp_matter_cluster_get_plugin_client_init_callback( - esp_matter_cluster_t *cluster); -esp_err_t esp_matter_cluster_add_function_list(esp_matter_cluster_t *cluster, - const esp_matter_cluster_function_generic_t *function_list, - int function_flags); - -/** Attribute APIs */ -esp_matter_attribute_t *esp_matter_attribute_create(esp_matter_cluster_t *cluster, int attribute_id, uint8_t flags, - esp_matter_attr_val_t val); -esp_matter_attribute_t *esp_matter_attribute_get(esp_matter_cluster_t *cluster, int attribute_id); -esp_matter_attribute_t *esp_matter_attribute_get_first(esp_matter_cluster_t *cluster); -esp_matter_attribute_t *esp_matter_attribute_get_next(esp_matter_attribute_t *attribute); -int esp_matter_attribute_get_id(esp_matter_attribute_t *attribute); +attribute_t *create(cluster_t *cluster, int attribute_id, uint8_t flags, esp_matter_attr_val_t val); +attribute_t *get(cluster_t *cluster, int attribute_id); +attribute_t *get_first(cluster_t *cluster); +attribute_t *get_next(attribute_t *attribute); +int get_id(attribute_t *attribute); /** Attribute val APIs */ -esp_err_t esp_matter_attribute_set_val(esp_matter_attribute_t *attribute, esp_matter_attr_val_t *val); -esp_err_t esp_matter_attribute_get_val(esp_matter_attribute_t *attribute, esp_matter_attr_val_t *val); -esp_err_t esp_matter_attribute_get_val_raw(int endpoint_id, int cluster_id, int attribute_id, uint8_t *value, - uint16_t attribute_size); -esp_err_t esp_matter_attribute_add_bounds(esp_matter_attribute_t *attribute, esp_matter_attr_val_t min, - esp_matter_attr_val_t max); -esp_matter_attr_bounds_t *esp_matter_attribute_get_bounds(esp_matter_attribute_t *attribute); +esp_err_t set_val(attribute_t *attribute, esp_matter_attr_val_t *val); +esp_err_t get_val(attribute_t *attribute, esp_matter_attr_val_t *val); +esp_err_t get_val_raw(int endpoint_id, int cluster_id, int attribute_id, uint8_t *value, uint16_t attribute_size); +esp_err_t add_bounds(attribute_t *attribute, esp_matter_attr_val_t min, esp_matter_attr_val_t max); +esp_matter_attr_bounds_t *get_bounds(attribute_t *attribute); -/** Command APIs */ -esp_matter_command_t *esp_matter_command_create(esp_matter_cluster_t *cluster, int command_id, uint8_t flags, - esp_matter_command_callback_t callback); -esp_matter_command_t *esp_matter_command_get(esp_matter_cluster_t *cluster, int command_id); -esp_matter_command_t *esp_matter_command_get_first(esp_matter_cluster_t *cluster); -esp_matter_command_t *esp_matter_command_get_next(esp_matter_command_t *command); -int esp_matter_command_get_id(esp_matter_command_t *command); -esp_matter_command_callback_t esp_matter_command_get_callback(esp_matter_command_t *command); -int esp_matter_command_get_flags(esp_matter_command_t *command); -esp_err_t esp_matter_command_set_custom_callback(esp_matter_command_custom_callback_t callback, void *priv_data); +} /* attribute */ + +namespace command { +typedef esp_err_t (*callback_t)(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *opaque_ptr); + +command_t *create(cluster_t *cluster, int command_id, uint8_t flags, callback_t callback); +command_t *get(cluster_t *cluster, int command_id); +command_t *get_first(cluster_t *cluster); +command_t *get_next(command_t *command); +int get_id(command_t *command); +callback_t get_callback(command_t *command); +int get_flags(command_t *command); + +} /* command */ /* Client APIs */ -void esp_matter_binding_init(); -void esp_matter_binding_manager_init(); -esp_err_t esp_matter_connect(int fabric_index, int node_id, int remote_endpoint_id); -esp_err_t esp_matter_set_client_command_callback(esp_matter_client_command_callback_t callback, void *priv_data); -esp_err_t esp_matter_client_cluster_update(int endpoint_id, int cluster_id); +namespace client { +typedef chip::DeviceProxy peer_device_t; +typedef void (*command_callback_t)(peer_device_t *peer_device, int remote_endpoint_id, void *priv_data); + +void binding_init(); +void binding_manager_init(); +esp_err_t connect(int fabric_index, int node_id, int remote_endpoint_id); +esp_err_t set_command_callback(command_callback_t callback, void *priv_data); +esp_err_t cluster_update(int endpoint_id, int cluster_id); +} /* client */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index 738933f9f..c841b0a0c 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -16,247 +16,307 @@ #include #include +/* Replace these with IDs from submodule whenever they are implemented */ +#define ESP_MATTER_ROOT_NODE_DEVICE_TYPE_ID 0x0016 +#define ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_ID 0x0100 +#define ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID 0x0101 +#define ESP_MATTER_COLOR_DIMMABLE_LIGHT_DEVICE_TYPE_ID 0x0102 +#define ESP_MATTER_ON_OFF_SWITCH_DEVICE_TYPE_ID 0x0103 +#define ESP_MATTER_FAN_DEVICE_TYPE_ID 0x002B +#define ESP_MATTER_THERMOSTAT_DEVICE_TYPE_ID 0x0301 +#define ESP_MATTER_BRIDGED_NODE_DEVICE_TYPE_ID 0x0013 +#define ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_ID 0x000A +#define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID 0x0302 + static const char *TAG = "esp_matter_endpoint"; -esp_matter_endpoint_t *esp_matter_endpoint_create_root_node(esp_matter_node_t *node, - esp_matter_endpoint_root_node_config_t *config, - uint8_t flags) +namespace esp_matter { +using namespace cluster; + +namespace endpoint { +namespace root_node { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_ROOT_NODE_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_ROOT_NODE_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_access_control(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_basic(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_ota_provider(endpoint, &(config->ota_provider), ESP_MATTER_CLUSTER_FLAG_CLIENT); - esp_matter_cluster_create_ota_requestor(endpoint, &(config->ota_requestor), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_general_commissioning(endpoint, &(config->general_commissioning), - ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_network_commissioning(endpoint, &(config->network_commissioning), - ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_general_diagnostics(endpoint, &(config->general_diagnostics), - ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_administrator_commissioning(endpoint, &(config->administrator_commissioning), - ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_operational_credentials(endpoint, &(config->operational_credentials), - ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_group_key_management(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + access_control::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + basic::create(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); + ota_provider::create(endpoint, &(config->ota_provider), ESP_MATTER_CLUSTER_FLAG_CLIENT); + ota_requestor::create(endpoint, &(config->ota_requestor), ESP_MATTER_CLUSTER_FLAG_SERVER); + general_commissioning::create(endpoint, &(config->general_commissioning), ESP_MATTER_CLUSTER_FLAG_SERVER); + network_commissioning::create(endpoint, &(config->network_commissioning), ESP_MATTER_CLUSTER_FLAG_SERVER); + general_diagnostics::create(endpoint, &(config->general_diagnostics), ESP_MATTER_CLUSTER_FLAG_SERVER); + administrator_commissioning::create(endpoint, &(config->administrator_commissioning), + ESP_MATTER_CLUSTER_FLAG_SERVER); + operational_credentials::create(endpoint, &(config->operational_credentials), ESP_MATTER_CLUSTER_FLAG_SERVER); + group_key_management::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* root_node */ -esp_matter_endpoint_t *esp_matter_endpoint_create_on_off_light(esp_matter_node_t *node, - esp_matter_endpoint_on_off_light_config_t *config, - uint8_t flags) +namespace on_off_light { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_identify(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_groups(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_scenes(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_on_off(endpoint, &(config->on_off), ESP_MATTER_CLUSTER_FLAG_SERVER, - ESP_MATTER_ON_OFF_CLUSTER_LIGHTING_FEATURE_ID); - esp_matter_cluster_create_basic(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); + scenes::create(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), ESP_MATTER_CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + basic::create(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* on_off_light */ -esp_matter_endpoint_t *esp_matter_endpoint_create_dimmable_light(esp_matter_node_t *node, - esp_matter_endpoint_dimmable_light_config_t *config, - uint8_t flags) +namespace dimmable_light { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_identify(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_groups(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_scenes(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_on_off(endpoint, &(config->on_off), ESP_MATTER_CLUSTER_FLAG_SERVER, - ESP_MATTER_ON_OFF_CLUSTER_LIGHTING_FEATURE_ID); - esp_matter_cluster_create_level_control(endpoint, &(config->level_control), ESP_MATTER_CLUSTER_FLAG_SERVER, - ESP_MATTER_LEVEL_CONTROL_CLUSTER_ON_OFF_FEATURE_ID | - ESP_MATTER_LEVEL_CONTROL_CLUSTER_LIGHTING_FEATURE_ID); - esp_matter_cluster_create_basic(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); + scenes::create(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), ESP_MATTER_CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + level_control::create(endpoint, &(config->level_control), ESP_MATTER_CLUSTER_FLAG_SERVER, + level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); + basic::create(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* dimmable_light */ -esp_matter_endpoint_t *esp_matter_endpoint_create_color_dimmable_light(esp_matter_node_t *node, - esp_matter_endpoint_color_dimmable_light_config_t *config, - uint8_t flags) +namespace color_dimmable_light { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_COLOR_DIMMABLE_LIGHT_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_COLOR_DIMMABLE_LIGHT_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_identify(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_groups(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_scenes(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_on_off(endpoint, &(config->on_off), ESP_MATTER_CLUSTER_FLAG_SERVER, - ESP_MATTER_ON_OFF_CLUSTER_LIGHTING_FEATURE_ID); - esp_matter_cluster_create_level_control(endpoint, &(config->level_control), ESP_MATTER_CLUSTER_FLAG_SERVER, - ESP_MATTER_LEVEL_CONTROL_CLUSTER_ON_OFF_FEATURE_ID | - ESP_MATTER_LEVEL_CONTROL_CLUSTER_LIGHTING_FEATURE_ID); - esp_matter_cluster_create_basic(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_color_control(endpoint, &(config->color_control), ESP_MATTER_CLUSTER_FLAG_SERVER, - ESP_MATTER_COLOR_CONTROL_CLUSTER_HUE_SATURATION_FEATURE_ID); + identify::create(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); + scenes::create(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), ESP_MATTER_CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + level_control::create(endpoint, &(config->level_control), ESP_MATTER_CLUSTER_FLAG_SERVER, + level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); + basic::create(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + color_control::create(endpoint, &(config->color_control), ESP_MATTER_CLUSTER_FLAG_SERVER, + color_control::feature::hue_saturation::get_id()); return endpoint; } +} /* color_dimmable_light */ -esp_matter_endpoint_t *esp_matter_endpoint_create_on_off_switch(esp_matter_node_t *node, - esp_matter_endpoint_on_off_switch_config_t *config, - uint8_t flags) +namespace on_off_switch { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_ON_OFF_SWITCH_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_ON_OFF_SWITCH_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_identify(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_groups(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_CLIENT); - esp_matter_cluster_create_scenes(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_CLIENT); - esp_matter_cluster_create_on_off(endpoint, &(config->on_off), ESP_MATTER_CLUSTER_FLAG_CLIENT, - ESP_MATTER_NONE_FEATURE_ID); - esp_matter_cluster_create_basic(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_binding(endpoint, &(config->binding), ESP_MATTER_CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_CLIENT); + scenes::create(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_CLIENT); + on_off::create(endpoint, &(config->on_off), ESP_MATTER_CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); + basic::create(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + binding::create(endpoint, &(config->binding), ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* on_off_switch */ -esp_matter_endpoint_t *esp_matter_endpoint_create_fan(esp_matter_node_t *node, - esp_matter_endpoint_fan_config_t *config, - uint8_t flags) +namespace fan { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_FAN_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_FAN_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_identify(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_groups(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_fan_control(endpoint, &(config->fan_control), ESP_MATTER_CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + fan_control::create(endpoint, &(config->fan_control), ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* fan */ -esp_matter_endpoint_t *esp_matter_endpoint_create_thermostat(esp_matter_node_t *node, - esp_matter_endpoint_thermostat_config_t *config, - uint8_t flags) +namespace thermostat { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_THERMOSTAT_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_THERMOSTAT_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_identify(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_groups(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_scenes(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_basic(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_thermostat(endpoint, &(config->thermostat), ESP_MATTER_CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_SERVER); + scenes::create(endpoint, &(config->scenes), ESP_MATTER_CLUSTER_FLAG_SERVER); + basic::create(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + cluster::thermostat::create(endpoint, &(config->thermostat), ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* thermostat */ -esp_matter_endpoint_t *esp_matter_endpoint_create_bridged_node(esp_matter_node_t *node, - esp_matter_endpoint_bridged_node_config_t *config, - uint8_t flags) +namespace bridged_node { +int get_device_type_id() +{ + return ESP_MATTER_BRIDGED_NODE_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) { // bridged node endpoints are always deletable - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags | ESP_MATTER_ENDPOINT_FLAG_DELETABLE); + endpoint_t *endpoint = endpoint::create(node, flags | ESP_MATTER_ENDPOINT_FLAG_DELETABLE); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_BRIDGED_NODE_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_bridged_device_basic(endpoint, &(config->bridged_device_basic), - ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_fixed_label(endpoint, &(config->fixed_label), ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + bridged_device_basic::create(endpoint, &(config->bridged_device_basic), ESP_MATTER_CLUSTER_FLAG_SERVER); + fixed_label::create(endpoint, &(config->fixed_label), ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* bridged_node */ -esp_matter_endpoint_t *esp_matter_endpoint_create_door_lock(esp_matter_node_t *node, - esp_matter_endpoint_door_lock_config_t *config, - uint8_t flags) +namespace door_lock { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_identify(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_descriptor(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_door_lock(endpoint, &(config->door_lock), ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_cluster_create_time_synchronization(endpoint, &(config->time_synchronization), ESP_MATTER_CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + cluster::door_lock::create(endpoint, &(config->door_lock), ESP_MATTER_CLUSTER_FLAG_SERVER); + time_synchronization::create(endpoint, &(config->time_synchronization), ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* door_lock */ -esp_matter_endpoint_t *esp_matter_endpoint_create_temperature_sensor(esp_matter_node_t *node, - esp_matter_endpoint_temperature_sensor_config_t *config, - uint8_t flags) +namespace temperature_sensor { +int get_device_type_id() { - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_raw(node, flags); + return ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags) +{ + endpoint_t *endpoint = endpoint::create(node, flags); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - esp_matter_endpoint_set_device_type_id(endpoint, ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID); + set_device_type_id(endpoint, get_device_type_id()); - esp_matter_cluster_create_identify(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER|ESP_MATTER_CLUSTER_FLAG_CLIENT); - esp_matter_cluster_create_groups(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_CLIENT); - esp_matter_cluster_create_temperature_measurement(endpoint, &(config->temperature_measurement), ESP_MATTER_CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), ESP_MATTER_CLUSTER_FLAG_SERVER | ESP_MATTER_CLUSTER_FLAG_CLIENT); + groups::create(endpoint, &(config->groups), ESP_MATTER_CLUSTER_FLAG_CLIENT); + temperature_measurement::create(endpoint, &(config->temperature_measurement), ESP_MATTER_CLUSTER_FLAG_SERVER); return endpoint; } +} /* temperature_sensor */ +} /* endpoint */ -esp_matter_node_t *esp_matter_node_create(esp_matter_node_config_t *config, esp_matter_attribute_callback_t callback, - void *priv_data) +namespace node { + +node_t *create(config_t *config, attribute::callback_t callback, void *priv_data) { - esp_matter_attribute_callback_set(callback, priv_data); + attribute::set_callback(callback, priv_data); - esp_matter_node_t *node = esp_matter_node_create_raw(); + node_t *node = create_raw(); if (!node) { ESP_LOGE(TAG, "Could not create node"); return NULL; } - esp_matter_endpoint_create_root_node(node, &(config->root_node), ESP_MATTER_ENDPOINT_FLAG_NONE); + endpoint::root_node::create(node, &(config->root_node), ESP_MATTER_ENDPOINT_FLAG_NONE); return node; } + +} /* node */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index 7820d2c7b..7dcf1873d 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -17,223 +17,145 @@ #include #include -#define ESP_MATTER_ROOT_NODE_DEVICE_TYPE_ID 0x0016 -#define ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_ID 0x0100 -#define ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID 0x0101 -#define ESP_MATTER_COLOR_DIMMABLE_LIGHT_DEVICE_TYPE_ID 0x0102 -#define ESP_MATTER_ON_OFF_SWITCH_DEVICE_TYPE_ID 0x0103 -#define ESP_MATTER_THERMOSTAT_DEVICE_TYPE_ID 0x0301 -#define ESP_MATTER_BRIDGED_NODE_DEVICE_TYPE_ID 0x0013 -#define ESP_MATTER_FAN_DEVICE_TYPE_ID 0x002B -#define ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_ID 0x000A -#define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID 0x0302 +namespace esp_matter { +using namespace cluster; -#define ENDPOINT_CONFIG_ROOT_NODE_DEFAULT() \ - { \ - .basic = CLUSTER_CONFIG_BASIC_DEFAULT(), \ - .ota_provider = CLUSTER_CONFIG_OTA_PROVIDER_DEFAULT(), \ - .ota_requestor = CLUSTER_CONFIG_OTA_REQUESTOR_DEFAULT(), \ - .general_commissioning = CLUSTER_CONFIG_GENERAL_COMMISSIONING_DEFAULT(), \ - .network_commissioning = CLUSTER_CONFIG_NETWORK_COMMISSIONING_DEFAULT(), \ - .general_diagnostics = CLUSTER_CONFIG_GENERAL_DIAGNOSTICS_DEFAULT(), \ - .administrator_commissioning = CLUSTER_CONFIG_ADMINISTRATOR_COMMISSIONING_DEFAULT(), \ - .operational_credentials = CLUSTER_CONFIG_OPERATIONAL_CREDENTIALS_DEFAULT(), \ - } +namespace endpoint { +namespace root_node { +typedef struct config { + basic::config_t basic; + ota_provider::config_t ota_provider; + ota_requestor::config_t ota_requestor; + general_commissioning::config_t general_commissioning; + network_commissioning::config_t network_commissioning; + general_diagnostics::config_t general_diagnostics; + administrator_commissioning::config_t administrator_commissioning; + operational_credentials::config_t operational_credentials; +} config_t; -#define ENDPOINT_CONFIG_ON_OFF_LIGHT_DEFAULT() \ - { \ - .identify = CLUSTER_CONFIG_IDENTIFY_DEFAULT(), \ - .groups = CLUSTER_CONFIG_GROUPS_DEFAULT(), \ - .scenes = CLUSTER_CONFIG_SCENES_DEFAULT(), \ - .on_off = CLUSTER_CONFIG_ON_OFF_DEFAULT(), \ - .basic = CLUSTER_CONFIG_BASIC_DEFAULT(), \ - } +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* root_node */ -#define ENDPOINT_CONFIG_DIMMABLE_LIGHT_DEFAULT() \ - { \ - .identify = CLUSTER_CONFIG_IDENTIFY_DEFAULT(), \ - .groups = CLUSTER_CONFIG_GROUPS_DEFAULT(), \ - .scenes = CLUSTER_CONFIG_SCENES_DEFAULT(), \ - .on_off = CLUSTER_CONFIG_ON_OFF_DEFAULT(), \ - .level_control = CLUSTER_CONFIG_LEVEL_CONTROL_DEFAULT(), \ - .basic = CLUSTER_CONFIG_BASIC_DEFAULT(), \ - } +namespace on_off_light { +typedef struct config { + identify::config_t identify; + groups::config_t groups; + scenes::config_t scenes; + on_off::config_t on_off; + basic::config_t basic; +} config_t; -#define ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT() \ - { \ - .identify = CLUSTER_CONFIG_IDENTIFY_DEFAULT(), \ - .groups = CLUSTER_CONFIG_GROUPS_DEFAULT(), \ - .scenes = CLUSTER_CONFIG_SCENES_DEFAULT(), \ - .on_off = CLUSTER_CONFIG_ON_OFF_DEFAULT(), \ - .level_control = CLUSTER_CONFIG_LEVEL_CONTROL_DEFAULT(), \ - .basic = CLUSTER_CONFIG_BASIC_DEFAULT(), \ - .color_control = CLUSTER_CONFIG_COLOR_CONTROL_DEFAULT(), \ - } +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* on_off_light */ -#define ENDPOINT_CONFIG_ON_OFF_SWITCH_DEFAULT() \ - { \ - .identify = CLUSTER_CONFIG_IDENTIFY_DEFAULT(), \ - .groups = CLUSTER_CONFIG_GROUPS_DEFAULT(), \ - .scenes = CLUSTER_CONFIG_SCENES_DEFAULT(), \ - .on_off = CLUSTER_CONFIG_ON_OFF_DEFAULT(), \ - .basic = CLUSTER_CONFIG_BASIC_DEFAULT(), \ - .binding = CLUSTER_CONFIG_BINDING_DEFAULT(), \ - } +namespace dimmable_light { +typedef struct config { + identify::config_t identify; + groups::config_t groups; + scenes::config_t scenes; + on_off::config_t on_off; + level_control::config_t level_control; + basic::config_t basic; +} config_t; -#define ENDPOINT_CONFIG_FAN_DEFAULT() \ - { \ - .identify = CLUSTER_CONFIG_IDENTIFY_DEFAULT(), \ - .groups = CLUSTER_CONFIG_GROUPS_DEFAULT(), \ - .fan_control = CLUSTER_CONFIG_FAN_CONTROL_DEFAULT(), \ - } +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* dimmable_light */ -#define ENDPOINT_CONFIG_THERMOSTAT_DEFAULT() \ - { \ - .identify = CLUSTER_CONFIG_IDENTIFY_DEFAULT(), \ - .groups = CLUSTER_CONFIG_GROUPS_DEFAULT(), \ - .scenes = CLUSTER_CONFIG_SCENES_DEFAULT(), \ - .basic = CLUSTER_CONFIG_BASIC_DEFAULT(), \ - .thermostat = CLUSTER_CONFIG_THERMOSTAT_DEFAULT(), \ - } +namespace color_dimmable_light { +typedef struct config { + identify::config_t identify; + groups::config_t groups; + scenes::config_t scenes; + on_off::config_t on_off; + level_control::config_t level_control; + basic::config_t basic; + color_control::config_t color_control; +} config_t; -#define ENDPOINT_CONFIG_DOOR_LOCK_DEFAULT() \ - { \ - .identify = CLUSTER_CONFIG_IDENTIFY_DEFAULT(), \ - .door_lock = CLUSTER_CONFIG_DOOR_LOCK_DEFAULT(), \ - .time_synchronization = CLUSTER_CONFIG_TIME_SYNCHRONIZATION_DEFAULT(), \ - } +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* color_dimmable_light */ -#define ENDPOINT_CONFIG_BRIDGED_NODE_DEFAULT() \ - { \ - .bridged_device_basic = CLUSTER_CONFIG_BRIDGED_DEVICE_BASIC_DEFAULT(), \ - .fixed_label = CLUSTER_CONFIG_FIXED_LABEL_DEFAULT(), \ - } +namespace on_off_switch { +typedef struct config { + identify::config_t identify; + groups::config_t groups; + scenes::config_t scenes; + on_off::config_t on_off; + basic::config_t basic; + binding::config_t binding; +} config_t; -#define ENDPOINT_CONFIG_TEMPERATURE_SENSOR_DEFAULT() \ - { \ - .identify = CLUSTER_CONFIG_IDENTIFY_DEFAULT(), \ - .groups = CLUSTER_CONFIG_GROUPS_DEFAULT(), \ - .temperature_measurement = CLUSTER_CONFIG_TEMPERATURE_MEASUREMENT_DEFAULT(), \ - } +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* on_off_switch */ -#define NODE_CONFIG_DEFAULT() \ - { \ - .root_node = ENDPOINT_CONFIG_ROOT_NODE_DEFAULT(), \ - } +namespace fan { +typedef struct config { + identify::config_t identify; + groups::config_t groups; + fan_control::config_t fan_control; +} config_t; -typedef struct esp_matter_endpoint_root_node_config { - esp_matter_cluster_basic_config_t basic; - esp_matter_cluster_ota_provider_config_t ota_provider; - esp_matter_cluster_ota_requestor_config_t ota_requestor; - esp_matter_cluster_general_commissioning_config_t general_commissioning; - esp_matter_cluster_network_commissioning_config_t network_commissioning; - esp_matter_cluster_general_diagnostics_config_t general_diagnostics; - esp_matter_cluster_administrator_commissioning_config_t administrator_commissioning; - esp_matter_cluster_operational_credentials_config_t operational_credentials; -} esp_matter_endpoint_root_node_config_t; +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* fan */ -typedef struct esp_matter_endpoint_on_off_light_config { - esp_matter_cluster_identify_config_t identify; - esp_matter_cluster_groups_config_t groups; - esp_matter_cluster_scenes_config_t scenes; - esp_matter_cluster_on_off_config_t on_off; - esp_matter_cluster_basic_config_t basic; -} esp_matter_endpoint_on_off_light_config_t; +namespace thermostat { +typedef struct config { + identify::config_t identify; + groups::config_t groups; + scenes::config_t scenes; + basic::config_t basic; + cluster::thermostat::config_t thermostat; +} config_t; -typedef struct esp_matter_endpoint_dimmable_light_config { - esp_matter_cluster_identify_config_t identify; - esp_matter_cluster_groups_config_t groups; - esp_matter_cluster_scenes_config_t scenes; - esp_matter_cluster_on_off_config_t on_off; - esp_matter_cluster_level_control_config_t level_control; - esp_matter_cluster_basic_config_t basic; -} esp_matter_endpoint_dimmable_light_config_t; +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* thermostat */ -typedef struct esp_matter_endpoint_color_dimmable_light_config { - esp_matter_cluster_identify_config_t identify; - esp_matter_cluster_groups_config_t groups; - esp_matter_cluster_scenes_config_t scenes; - esp_matter_cluster_on_off_config_t on_off; - esp_matter_cluster_level_control_config_t level_control; - esp_matter_cluster_basic_config_t basic; - esp_matter_cluster_color_control_config_t color_control; -} esp_matter_endpoint_color_dimmable_light_config_t; +namespace bridged_node { +typedef struct config { + bridged_device_basic::config_t bridged_device_basic; + fixed_label::config_t fixed_label; +} config_t; -typedef struct esp_matter_endpoint_on_off_switch_config { - esp_matter_cluster_identify_config_t identify; - esp_matter_cluster_groups_config_t groups; - esp_matter_cluster_scenes_config_t scenes; - esp_matter_cluster_on_off_config_t on_off; - esp_matter_cluster_basic_config_t basic; - esp_matter_cluster_binding_config_t binding; -} esp_matter_endpoint_on_off_switch_config_t; +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* bridged_node */ -typedef struct esp_matter_endpoint_fan_config { - esp_matter_cluster_identify_config_t identify; - esp_matter_cluster_groups_config_t groups; - esp_matter_cluster_fan_control_config_t fan_control; -} esp_matter_endpoint_fan_config_t; +namespace door_lock { +typedef struct config { + identify::config_t identify; + cluster::door_lock::config_t door_lock; + time_synchronization::config_t time_synchronization; +} config_t; -typedef struct esp_matter_endpoint_thermostat_config { - esp_matter_cluster_identify_config_t identify; - esp_matter_cluster_groups_config_t groups; - esp_matter_cluster_scenes_config_t scenes; - esp_matter_cluster_basic_config_t basic; - esp_matter_cluster_thermostat_config_t thermostat; -} esp_matter_endpoint_thermostat_config_t; +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* door_lock */ -typedef struct esp_matter_endpoint_bridged_node_config { - esp_matter_cluster_bridged_device_basic_config_t bridged_device_basic; - esp_matter_cluster_fixed_label_config_t fixed_label; -} esp_matter_endpoint_bridged_node_config_t; +namespace temperature_sensor { +typedef struct config { + identify::config_t identify; + groups::config_t groups; + temperature_measurement::config_t temperature_measurement; +} config_t; -typedef struct esp_matter_endpoint_door_lock_config { - esp_matter_cluster_identify_config_t identify; - esp_matter_cluster_door_lock_config_t door_lock; - esp_matter_cluster_time_synchronization_config_t time_synchronization; -} esp_matter_endpoint_door_lock_config_t; +int get_device_type_id(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags); +} /* temperature_sensor */ +} /* endpoint */ -typedef struct esp_matter_endpoint_temperature_sensor_config { - esp_matter_cluster_identify_config_t identify; - esp_matter_cluster_groups_config_t groups; - esp_matter_cluster_temperature_measurement_config_t temperature_measurement; -} esp_matter_endpoint_temperature_sensor_config_t; +namespace node { +typedef struct config { + endpoint::root_node::config_t root_node; +} config_t; -typedef struct esp_matter_node_config { - esp_matter_endpoint_root_node_config_t root_node; -} esp_matter_node_config_t; +node_t *create(config_t *config, attribute::callback_t callback, void *priv_data); -esp_matter_endpoint_t *esp_matter_endpoint_create_root_node(esp_matter_node_t *node, - esp_matter_endpoint_root_node_config_t *config, - uint8_t flags); -esp_matter_endpoint_t *esp_matter_endpoint_create_on_off_light(esp_matter_node_t *node, - esp_matter_endpoint_on_off_light_config_t *config, - uint8_t flags); -esp_matter_endpoint_t *esp_matter_endpoint_create_dimmable_light(esp_matter_node_t *node, - esp_matter_endpoint_dimmable_light_config_t *config, - uint8_t flags); -esp_matter_endpoint_t *esp_matter_endpoint_create_color_dimmable_light(esp_matter_node_t *node, - esp_matter_endpoint_color_dimmable_light_config_t *config, - uint8_t flags); -esp_matter_endpoint_t *esp_matter_endpoint_create_on_off_switch(esp_matter_node_t *node, - esp_matter_endpoint_on_off_switch_config_t *config, - uint8_t flags); -esp_matter_endpoint_t *esp_matter_endpoint_create_fan(esp_matter_node_t *node, - esp_matter_endpoint_fan_config_t *config, - uint8_t flags); -esp_matter_endpoint_t *esp_matter_endpoint_create_thermostat(esp_matter_node_t *node, - esp_matter_endpoint_thermostat_config_t *config, - uint8_t flags); -esp_matter_endpoint_t *esp_matter_endpoint_create_door_lock(esp_matter_node_t *node, - esp_matter_endpoint_door_lock_config_t *config, - uint8_t flags); -esp_matter_endpoint_t *esp_matter_endpoint_create_bridged_node(esp_matter_node_t *node, - esp_matter_endpoint_bridged_node_config_t *config, - uint8_t flags); - -esp_matter_endpoint_t *esp_matter_endpoint_create_temperature_sensor(esp_matter_node_t *node, - esp_matter_endpoint_temperature_sensor_config_t *config, - uint8_t flags); - -esp_matter_node_t *esp_matter_node_create(esp_matter_node_config_t *config, esp_matter_attribute_callback_t callback, - void *priv_data); +} /* node */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_event.cpp b/components/esp_matter/esp_matter_event.cpp index f3419901a..e40ecebb3 100644 --- a/components/esp_matter/esp_matter_event.cpp +++ b/components/esp_matter/esp_matter_event.cpp @@ -22,141 +22,156 @@ static const char *TAG = "esp_matter_event"; using chip::DeviceLayer::DeviceControlServer; using chip::DeviceLayer::SwitchDeviceControlDelegate; -/** cluster: door_lock */ -esp_err_t esp_matter_door_lock_send_event_door_lock_alarm() +namespace esp_matter { +namespace cluster { + +namespace door_lock { +namespace event { + +esp_err_t send_door_lock_alarm() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_door_lock_send_event_door_state_change() +esp_err_t send_door_state_change() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_door_lock_send_event_lock_operation() +esp_err_t send_lock_operation() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_door_lock_send_event_lock_operation_error() +esp_err_t send_lock_operation_error() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_door_lock_send_event_lock_user_change() +esp_err_t send_lock_user_change() { /* Not implemented */ return ESP_OK; } -/** cluster: pump_configuration_and_control */ -esp_err_t esp_matter_pump_configuration_and_control_send_event_supply_voltage_low() +} /* event */ +} /* door_lock */ + +namespace pump_configuration_and_control { +namespace event { + +esp_err_t send_supply_voltage_low() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_supply_voltage_high() +esp_err_t send_supply_voltage_high() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_power_missing_phase() +esp_err_t send_power_missing_phase() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_system_pressure_low() +esp_err_t send_system_pressure_low() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_system_pressure_high() +esp_err_t send_system_pressure_high() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_dry_running() +esp_err_t send_dry_running() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_motor_temperature_high() +esp_err_t send_motor_temperature_high() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_pump_motor_fatal_failure() +esp_err_t send_pump_motor_fatal_failure() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_electronic_temperature_high() +esp_err_t send_electronic_temperature_high() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_pump_blocked() +esp_err_t send_pump_blocked() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_sensor_failure() +esp_err_t send_sensor_failure() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_electronic_non_fatal_failure() +esp_err_t send_electronic_non_fatal_failure() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_electronic_fatal_failure() +esp_err_t send_electronic_fatal_failure() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_general_fault() +esp_err_t send_general_fault() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_leakage() +esp_err_t send_leakage() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_air_detection() +esp_err_t send_air_detection() { /* Not implemented */ return ESP_OK; } -esp_err_t esp_matter_pump_configuration_and_control_send_event_turbine_operation() +esp_err_t send_turbine_operation() { /* Not implemented */ return ESP_OK; } -/** cluster: switch */ +} /* event */ +} /* pump_configuration_and_control */ + +namespace switch_cluster { +namespace event { + static SwitchDeviceControlDelegate *get_switch_delegate() { SwitchDeviceControlDelegate *delegate = DeviceControlServer::DeviceControlSvr().GetSwitchDelegate(); @@ -166,7 +181,7 @@ static SwitchDeviceControlDelegate *get_switch_delegate() return delegate; } -esp_err_t esp_matter_switch_send_event_switch_latched(uint8_t new_position) +esp_err_t send_switch_latched(uint8_t new_position) { SwitchDeviceControlDelegate *delegate = get_switch_delegate(); if (!delegate) { @@ -176,7 +191,7 @@ esp_err_t esp_matter_switch_send_event_switch_latched(uint8_t new_position) return ESP_OK; } -esp_err_t esp_matter_switch_send_event_initial_press(uint8_t new_position) +esp_err_t send_initial_press(uint8_t new_position) { SwitchDeviceControlDelegate *delegate = get_switch_delegate(); if (!delegate) { @@ -186,7 +201,7 @@ esp_err_t esp_matter_switch_send_event_initial_press(uint8_t new_position) return ESP_OK; } -esp_err_t esp_matter_switch_send_event_long_press(uint8_t new_position) +esp_err_t send_long_press(uint8_t new_position) { SwitchDeviceControlDelegate *delegate = get_switch_delegate(); if (!delegate) { @@ -196,7 +211,7 @@ esp_err_t esp_matter_switch_send_event_long_press(uint8_t new_position) return ESP_OK; } -esp_err_t esp_matter_switch_send_event_short_release(uint8_t previous_position) +esp_err_t send_short_release(uint8_t previous_position) { SwitchDeviceControlDelegate *delegate = get_switch_delegate(); if (!delegate) { @@ -206,7 +221,7 @@ esp_err_t esp_matter_switch_send_event_short_release(uint8_t previous_position) return ESP_OK; } -esp_err_t esp_matter_switch_send_event_long_release(uint8_t previous_position) +esp_err_t send_long_release(uint8_t previous_position) { SwitchDeviceControlDelegate *delegate = get_switch_delegate(); if (!delegate) { @@ -216,7 +231,7 @@ esp_err_t esp_matter_switch_send_event_long_release(uint8_t previous_position) return ESP_OK; } -esp_err_t esp_matter_switch_send_event_multi_press_ongoing(uint8_t new_position, uint8_t count) +esp_err_t send_multi_press_ongoing(uint8_t new_position, uint8_t count) { SwitchDeviceControlDelegate *delegate = get_switch_delegate(); if (!delegate) { @@ -226,7 +241,7 @@ esp_err_t esp_matter_switch_send_event_multi_press_ongoing(uint8_t new_position, return ESP_OK; } -esp_err_t esp_matter_switch_send_event_multi_press_complete(uint8_t new_position, uint8_t count) +esp_err_t send_multi_press_complete(uint8_t new_position, uint8_t count) { SwitchDeviceControlDelegate *delegate = get_switch_delegate(); if (!delegate) { @@ -235,3 +250,9 @@ esp_err_t esp_matter_switch_send_event_multi_press_complete(uint8_t new_position delegate->OnMultiPressComplete(new_position, count); return ESP_OK; } + +} /* event */ +} /* switch_cluster */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_event.h b/components/esp_matter/esp_matter_event.h index 4c3d6c437..0ee1a8ffa 100644 --- a/components/esp_matter/esp_matter_event.h +++ b/components/esp_matter/esp_matter_event.h @@ -16,17 +16,26 @@ #include -/** +/** * NOTE: These events are currently sent on all the endpoints where the corresponding cluster exists. * Once this behaviour is changed, the event APIs here would have the endpoint_id as an argument. - * Issue: https://github.com/project-chip/connectedhomeip/issues/14624 -*/ + * Issue: https://github.com/project-chip/connectedhomeip/issues/14624 + */ -/** cluster: switch */ -esp_err_t esp_matter_switch_send_event_switch_latched(uint8_t new_position); -esp_err_t esp_matter_switch_send_event_initial_press(uint8_t new_position); -esp_err_t esp_matter_switch_send_event_long_press(uint8_t new_position); -esp_err_t esp_matter_switch_send_event_short_release(uint8_t previous_position); -esp_err_t esp_matter_switch_send_event_long_release(uint8_t previous_position); -esp_err_t esp_matter_switch_send_event_multi_press_ongoing(uint8_t new_position, uint8_t count); -esp_err_t esp_matter_switch_send_event_multi_press_complete(uint8_t new_position, uint8_t count); +namespace esp_matter { +namespace cluster { + +namespace switch_cluster { +namespace event { +esp_err_t send_switch_latched(uint8_t new_position); +esp_err_t send_initial_press(uint8_t new_position); +esp_err_t send_long_press(uint8_t new_position); +esp_err_t send_short_release(uint8_t previous_position); +esp_err_t send_long_release(uint8_t previous_position); +esp_err_t send_multi_press_ongoing(uint8_t new_position, uint8_t count); +esp_err_t send_multi_press_complete(uint8_t new_position, uint8_t count); +} /* event */ +} /* switch_cluster */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_feature.cpp b/components/esp_matter/esp_matter_feature.cpp index 22e063e69..b040e895a 100644 --- a/components/esp_matter/esp_matter_feature.cpp +++ b/components/esp_matter/esp_matter_feature.cpp @@ -16,9 +16,14 @@ #include #include -static const char *TAG = "esp_matter_cluster"; +#include -esp_err_t esp_matter_cluster_update_feature_map(esp_matter_cluster_t *cluster, uint32_t value) +static const char *TAG = "esp_matter_feature"; + +namespace esp_matter { +namespace cluster { + +static esp_err_t update_feature_map(cluster_t *cluster, uint32_t value) { if (!cluster) { ESP_LOGE(TAG, "Cluster cannot be NULL"); @@ -26,11 +31,11 @@ esp_err_t esp_matter_cluster_update_feature_map(esp_matter_cluster_t *cluster, u } /* Get the attribute */ - esp_matter_attribute_t *attribute = esp_matter_attribute_get(cluster, ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID); + attribute_t *attribute = attribute::get(cluster, ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID); /* Create the attribute with the new value if it does not exist */ if (!attribute) { - attribute = esp_matter_attribute_create_feature_map(cluster, value); + attribute = global::attribute::create_feature_map(cluster, value); if (!attribute) { ESP_LOGE(TAG, "Could not create feature map attribute"); return ESP_FAIL; @@ -40,87 +45,135 @@ esp_err_t esp_matter_cluster_update_feature_map(esp_matter_cluster_t *cluster, u /* Update the value if the attribute already exists */ esp_matter_attr_val_t val = esp_matter_invalid(NULL); - esp_matter_attribute_get_val(attribute, &val); + attribute::get_val(attribute, &val); val.val.u32 |= value; - /* Here we can't call esp_matter_attribute_update() since the chip stack would not have started yet, since we are - still creating the data model. So, we are directly using esp_matter_attribute_set_val(). */ - return esp_matter_attribute_set_val(attribute, &val); + /* Here we can't call attribute::update() since the chip stack would not have started yet, since we are + still creating the data model. So, we are directly using attribute::set_val(). */ + return attribute::set_val(attribute, &val); } -esp_err_t esp_matter_on_off_cluster_add_feature_lighting(esp_matter_cluster_t *cluster, - esp_matter_on_off_cluster_lighting_config_t *config) +namespace on_off { +namespace feature { +namespace lighting { + +uint32_t get_id() +{ + return (uint32_t)chip::app::Clusters::OnOff::OnOffFeature::kLighting; +} + +esp_err_t add(cluster_t *cluster, config_t *config) { if (!cluster) { ESP_LOGE(TAG, "Cluster cannot be NULL"); return ESP_ERR_INVALID_ARG; } - esp_matter_cluster_update_feature_map(cluster, ESP_MATTER_ON_OFF_CLUSTER_LIGHTING_FEATURE_ID); + update_feature_map(cluster, get_id()); /* Attributes not managed internally */ - esp_matter_attribute_create_global_scene_control(cluster, config->global_scene_control); - esp_matter_attribute_create_on_time(cluster, config->on_time); - esp_matter_attribute_create_off_wait_time(cluster, config->off_wait_time); - esp_matter_attribute_create_start_up_on_off(cluster, config->start_up_on_off); + attribute::create_global_scene_control(cluster, config->global_scene_control); + attribute::create_on_time(cluster, config->on_time); + attribute::create_off_wait_time(cluster, config->off_wait_time); + attribute::create_start_up_on_off(cluster, config->start_up_on_off); /* Commands */ - esp_matter_command_create_off_with_effect(cluster); - esp_matter_command_create_on_with_recall_global_scene(cluster); - esp_matter_command_create_on_with_timed_off(cluster); + command::create_off_with_effect(cluster); + command::create_on_with_recall_global_scene(cluster); + command::create_on_with_timed_off(cluster); return ESP_OK; } -esp_err_t esp_matter_level_control_cluster_add_feature_on_off(esp_matter_cluster_t *cluster) +} /* lighting */ +} /* feature */ +} /* on_off */ + +namespace level_control { +namespace feature { +namespace on_off { + +uint32_t get_id() +{ + return (uint32_t)chip::app::Clusters::LevelControl::LevelControlFeature::kOnOff; +} + +esp_err_t add(cluster_t *cluster) { if (!cluster) { ESP_LOGE(TAG, "Cluster cannot be NULL"); return ESP_ERR_INVALID_ARG; } - esp_matter_cluster_update_feature_map(cluster, ESP_MATTER_LEVEL_CONTROL_CLUSTER_ON_OFF_FEATURE_ID); + update_feature_map(cluster, get_id()); return ESP_OK; } -esp_err_t esp_matter_level_control_cluster_add_feature_lighting(esp_matter_cluster_t *cluster, - esp_matter_level_control_cluster_lighting_config_t *config) +} /* on_off */ + +namespace lighting { + +uint32_t get_id() +{ + return (uint32_t)chip::app::Clusters::LevelControl::LevelControlFeature::kLighting; +} + +esp_err_t add(cluster_t *cluster, config_t *config) { if (!cluster) { ESP_LOGE(TAG, "Cluster cannot be NULL"); return ESP_ERR_INVALID_ARG; } - esp_matter_cluster_update_feature_map(cluster, ESP_MATTER_LEVEL_CONTROL_CLUSTER_LIGHTING_FEATURE_ID); + update_feature_map(cluster, get_id()); /* Attributes not managed internally */ - esp_matter_attribute_create_remaining_time(cluster, config->remaining_time); - esp_matter_attribute_create_min_level(cluster, config->min_level); - esp_matter_attribute_create_max_level(cluster, config->max_level); - esp_matter_attribute_create_start_up_current_level(cluster, config->start_up_current_level); + attribute::create_remaining_time(cluster, config->remaining_time); + attribute::create_min_level(cluster, config->min_level); + attribute::create_max_level(cluster, config->max_level); + attribute::create_start_up_current_level(cluster, config->start_up_current_level); return ESP_OK; } -esp_err_t esp_matter_color_control_cluster_add_feature_hue_saturation(esp_matter_cluster_t *cluster, - esp_matter_color_control_cluster_hue_saturation_config_t *config) +} /* lighting */ +} /* feature */ +} /* level_control */ + +namespace color_control { +namespace feature { +namespace hue_saturation { + +uint32_t get_id() +{ + return (uint32_t)chip::app::Clusters::ColorControl::ColorCapabilities::kHueSaturationSupported; +} + +esp_err_t add(cluster_t *cluster, config_t *config) { if (!cluster) { ESP_LOGE(TAG, "Cluster cannot be NULL"); return ESP_ERR_INVALID_ARG; } - esp_matter_cluster_update_feature_map(cluster, ESP_MATTER_COLOR_CONTROL_CLUSTER_HUE_SATURATION_FEATURE_ID); + update_feature_map(cluster, get_id()); /* Attributes not managed internally */ - esp_matter_attribute_create_current_hue(cluster, config->current_hue); - esp_matter_attribute_create_current_saturation(cluster, config->current_saturation); + attribute::create_current_hue(cluster, config->current_hue); + attribute::create_current_saturation(cluster, config->current_saturation); /* Commands */ - esp_matter_command_create_move_to_hue(cluster); - esp_matter_command_create_move_hue(cluster); - esp_matter_command_create_step_hue(cluster); - esp_matter_command_create_move_to_saturation(cluster); - esp_matter_command_create_move_saturation(cluster); - esp_matter_command_create_step_saturation(cluster); - esp_matter_command_create_move_to_hue_and_saturation(cluster); - esp_matter_command_create_stop_move_step(cluster); + command::create_move_to_hue(cluster); + command::create_move_hue(cluster); + command::create_step_hue(cluster); + command::create_move_to_saturation(cluster); + command::create_move_saturation(cluster); + command::create_step_saturation(cluster); + command::create_move_to_hue_and_saturation(cluster); + command::create_stop_move_step(cluster); return ESP_OK; } + +} /* hue_saturation */ +} /* feature */ +} /* color_control */ + +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_feature.h b/components/esp_matter/esp_matter_feature.h index 29bad15aa..c6d8e786f 100644 --- a/components/esp_matter/esp_matter_feature.h +++ b/components/esp_matter/esp_matter_feature.h @@ -18,58 +18,71 @@ #include #define ESP_MATTER_NONE_FEATURE_ID 0x0000 -#define ESP_MATTER_ON_OFF_CLUSTER_LIGHTING_FEATURE_ID 0x0001 -#define ESP_MATTER_LEVEL_CONTROL_CLUSTER_ON_OFF_FEATURE_ID 0x0001 -#define ESP_MATTER_LEVEL_CONTROL_CLUSTER_LIGHTING_FEATURE_ID 0x0002 -#define ESP_MATTER_COLOR_CONTROL_CLUSTER_HUE_SATURATION_FEATURE_ID 0x0001 -#define ON_OFF_CLUSTER_LIGHTING_CONFIG_DEFAULT() \ - { \ - .global_scene_control = 1, \ - .on_time = 0, \ - .off_wait_time = 0, \ - .start_up_on_off = 0, \ - } +namespace esp_matter { +namespace cluster { -#define LEVEL_CONTROL_CLUSTER_LIGHTING_CONFIG_DEFAULT() \ - { \ - .remaining_time = 0, \ - .min_level = 1, \ - .max_level = 254, \ - .start_up_current_level = 0, \ - } +namespace on_off { +namespace feature { +namespace lighting { -#define COLOR_CONTROL_CLUSTER_HUE_SATURATION_CONFIG_DEFAULT() \ - { \ - .current_hue = 0, \ - .current_saturation = 0, \ - } - -typedef struct esp_matter_on_off_cluster_lighting_config { +typedef struct config { bool global_scene_control; uint16_t on_time; uint16_t off_wait_time; uint8_t start_up_on_off; -} esp_matter_on_off_cluster_lighting_config_t; + config() : global_scene_control(1), on_time(0), off_wait_time(0), start_up_on_off(0) {} +} config_t; -typedef struct esp_matter_level_control_cluster_lighting_config { +uint32_t get_id(); +esp_err_t add(cluster_t *cluster, config_t *config); + +} /* lighting */ +} /* feature */ +} /* on_off */ + +namespace level_control { +namespace feature { +namespace on_off { + +uint32_t get_id(); +esp_err_t add(cluster_t *cluster); + +} /* on_off */ + +namespace lighting { + +typedef struct config { uint16_t remaining_time; uint8_t min_level; uint8_t max_level; uint8_t start_up_current_level; -} esp_matter_level_control_cluster_lighting_config_t; + config() : remaining_time(0), min_level(1), max_level(254), start_up_current_level(0) {} +} config_t; -typedef struct esp_matter_color_control_cluster_hue_saturation_config { +uint32_t get_id(); +esp_err_t add(cluster_t *cluster, config_t *config); + +} /* lighting */ +} /* feature */ +} /* level_control */ + +namespace color_control { +namespace feature { +namespace hue_saturation { + +typedef struct config { uint8_t current_hue; uint8_t current_saturation; -} esp_matter_color_control_cluster_hue_saturation_config_t; + config() : current_hue(0), current_saturation(0) {} +} config_t; -esp_err_t esp_matter_on_off_cluster_add_feature_lighting(esp_matter_cluster_t *cluster, - esp_matter_on_off_cluster_lighting_config_t *config); +uint32_t get_id(); +esp_err_t add(cluster_t *cluster, config_t *config); -esp_err_t esp_matter_level_control_cluster_add_feature_on_off(esp_matter_cluster_t *cluster); -esp_err_t esp_matter_level_control_cluster_add_feature_lighting(esp_matter_cluster_t *cluster, - esp_matter_level_control_cluster_lighting_config_t *config); +} /* hue_saturation */ +} /* feature */ +} /* color_control */ -esp_err_t esp_matter_color_control_cluster_add_feature_hue_saturation(esp_matter_cluster_t *cluster, - esp_matter_color_control_cluster_hue_saturation_config_t *config); +} /* cluster */ +} /* esp_matter */ diff --git a/components/esp_matter_bridge/esp_matter_bridge.cpp b/components/esp_matter_bridge/esp_matter_bridge.cpp index 1d19373b3..22cb9b0f3 100644 --- a/components/esp_matter_bridge/esp_matter_bridge.cpp +++ b/components/esp_matter_bridge/esp_matter_bridge.cpp @@ -20,18 +20,21 @@ static const char *TAG = "esp_matter_bridge"; -esp_matter_bridge_device_t *esp_matter_bridge_create_device(esp_matter_node_t *node) +using namespace esp_matter; +using namespace esp_matter::endpoint; + +esp_matter_bridge_device_t *esp_matter_bridge_create_device(node_t *node) { esp_matter_bridge_device_t *dev = (esp_matter_bridge_device_t *)calloc(1, sizeof(esp_matter_bridge_device_t)); dev->node = node; - esp_matter_endpoint_bridged_node_config_t bridged_node_config = ENDPOINT_CONFIG_BRIDGED_NODE_DEFAULT(); - dev->endpoint = esp_matter_endpoint_create_bridged_node(node, &bridged_node_config, ESP_MATTER_ENDPOINT_FLAG_DELETABLE); + bridged_node::config_t bridged_node_config; + dev->endpoint = bridged_node::create(node, &bridged_node_config, ESP_MATTER_ENDPOINT_FLAG_DELETABLE); if (!(dev->endpoint)) { ESP_LOGE(TAG, "Could not create esp_matter endpoint for bridged device"); free(dev); return NULL; } - dev->endpoint_id = esp_matter_endpoint_get_id(dev->endpoint); + dev->endpoint_id = endpoint::get_id(dev->endpoint); return dev; } @@ -40,7 +43,7 @@ esp_err_t esp_matter_bridge_remove_device(esp_matter_bridge_device_t *bridged_de if (!bridged_device) { return ESP_ERR_INVALID_ARG; } - esp_err_t error = esp_matter_endpoint_delete(bridged_device->node, bridged_device->endpoint); + esp_err_t error = endpoint::destroy(bridged_device->node, bridged_device->endpoint); if (error != ESP_OK) { ESP_LOGE(TAG, "Failed to delete bridged endpoint"); } diff --git a/components/esp_matter_bridge/esp_matter_bridge.h b/components/esp_matter_bridge/esp_matter_bridge.h index a7b7b2ef8..891d03f80 100644 --- a/components/esp_matter_bridge/esp_matter_bridge.h +++ b/components/esp_matter_bridge/esp_matter_bridge.h @@ -21,12 +21,14 @@ #define MAX_BRIDGED_DEVICE_COUNT CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT - 1 // There is an endpoint reserved as root endpoint +using namespace esp_matter; + typedef struct esp_matter_bridge_device { - esp_matter_node_t *node; - esp_matter_endpoint_t *endpoint; + node_t *node; + endpoint_t *endpoint; int endpoint_id; } esp_matter_bridge_device_t; -esp_matter_bridge_device_t *esp_matter_bridge_create_device(esp_matter_node_t *node); +esp_matter_bridge_device_t *esp_matter_bridge_create_device(node_t *node); esp_err_t esp_matter_bridge_remove_device(esp_matter_bridge_device_t *bridged_device); diff --git a/components/esp_matter_rainmaker/esp_matter_rainmaker.cpp b/components/esp_matter_rainmaker/esp_matter_rainmaker.cpp index ae02a5921..6dd9b6d0a 100644 --- a/components/esp_matter_rainmaker/esp_matter_rainmaker.cpp +++ b/components/esp_matter_rainmaker/esp_matter_rainmaker.cpp @@ -21,6 +21,8 @@ #include #include +using namespace esp_matter; + static const char *TAG = "esp_matter_rainmaker"; static esp_err_t esp_matter_rainmaker_console_handler(int argc, char **argv) @@ -48,13 +50,13 @@ static void esp_matter_rainmaker_register_commands() esp_matter_console_add_command(&command); } -#define ESP_MATTER_RAINMAKER_ENDPOINT_ID 0x0 /* Same as root node endpoint. This will always be endpoint_id 0. */ -#define ESP_MATTER_RAINMAKER_CLUSTER_ID 0x131B0000 /* 0x131B == manufacturer code */ +#define ESP_MATTER_RAINMAKER_ENDPOINT_ID 0x0 /* Same as root node endpoint. This will always be endpoint_id 0. */ +#define ESP_MATTER_RAINMAKER_CLUSTER_ID 0x131B0000 /* 0x131B == manufacturer code */ #define ESP_MATTER_RAINMAKER_STATUS_ATTRIBUTE_ID 0x0 #define ESP_MATTER_RAINMAKER_NODE_ID_ATTRIBUTE_ID 0x1 #define ESP_MATTER_RAINMAKER_CONFIGURATION_COMMAND_ID 0x0 #define ESP_MATTER_RAINMAKER_CLUSTER_REVISION 1 -#define ESP_MATTER_RAINMAKER_COMMAND_LIMIT 5 /* This command can be called 5 times per reboot */ +#define ESP_MATTER_RAINMAKER_COMMAND_LIMIT 5 /* This command can be called 5 times per reboot */ #define ESP_MATTER_RAINMAKER_MAX_DATA_LEN 40 static esp_err_t rainmaker_status_attribute_update(bool status) @@ -63,7 +65,7 @@ static esp_err_t rainmaker_status_attribute_update(bool status) int cluster_id = ESP_MATTER_RAINMAKER_CLUSTER_ID; int attribute_id = ESP_MATTER_RAINMAKER_STATUS_ATTRIBUTE_ID; esp_matter_attr_val_t val = esp_matter_bool(status); - return esp_matter_attribute_update(endpoint_id, cluster_id, attribute_id, &val); + return attribute::update(endpoint_id, cluster_id, attribute_id, &val); } static esp_err_t app_rainmaker_node_id_attribute_update(char *node_id) @@ -72,11 +74,11 @@ static esp_err_t app_rainmaker_node_id_attribute_update(char *node_id) int cluster_id = ESP_MATTER_RAINMAKER_CLUSTER_ID; int attribute_id = ESP_MATTER_RAINMAKER_NODE_ID_ATTRIBUTE_ID; esp_matter_attr_val_t val = esp_matter_char_str(node_id, strlen(node_id)); - return esp_matter_attribute_update(endpoint_id, cluster_id, attribute_id, &val); + return attribute::update(endpoint_id, cluster_id, attribute_id, &val); } -static void user_node_association_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, - void* event_data) +static void user_node_association_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, + void *event_data) { /* This event handler is only for user node association status */ if (event_base == RMAKER_EVENT) { @@ -90,13 +92,19 @@ static void user_node_association_event_handler(void* arg, esp_event_base_t even } } -esp_err_t esp_matter_rainmaker_command_callback(int endpoint_id, int cluster_id, int command_id, TLVReader &tlv_data, - void *priv_data) +static esp_err_t esp_matter_rainmaker_command_callback(const ConcreteCommandPath &command_path, TLVReader &tlv_data, + void *opaque_ptr) { + /* Get ids */ + int endpoint_id = command_path.mEndpointId; + int cluster_id = command_path.mClusterId; + int command_id = command_path.mCommandId; + /* Return if this is not the rainmaker configuration command */ - if (endpoint_id != ESP_MATTER_RAINMAKER_ENDPOINT_ID || cluster_id != ESP_MATTER_RAINMAKER_CLUSTER_ID - || command_id != ESP_MATTER_RAINMAKER_CONFIGURATION_COMMAND_ID) { - return ESP_OK; + if (endpoint_id != ESP_MATTER_RAINMAKER_ENDPOINT_ID || cluster_id != ESP_MATTER_RAINMAKER_CLUSTER_ID || + command_id != ESP_MATTER_RAINMAKER_CONFIGURATION_COMMAND_ID) { + ESP_LOGE(TAG, "Got rainmaker command callback for some other command. This should not happen."); + return ESP_FAIL; } ESP_LOGI(TAG, "RainMaker configuration command callback"); static int command_count = ESP_MATTER_RAINMAKER_COMMAND_LIMIT; @@ -128,11 +136,11 @@ esp_err_t esp_matter_rainmaker_command_callback(int endpoint_id, int cluster_id, /* Get sizes */ int user_id_index = 0; - int user_id_len = (int)(strchr(data, (int)ch) - data); /* (first ':') - (start of string) */ - int secret_key_index = (int)(strrchr(data, (int)ch) - data) + 1; /* (last ':') - (start of string) + 1 */ + int user_id_len = (int)(strchr(data, (int)ch) - data); /* (first ':') - (start of string) */ + int secret_key_index = (int)(strrchr(data, (int)ch) - data) + 1; /* (last ':') - (start of string) + 1 */ int secret_key_len = size - secret_key_index; - if (user_id_len <= 0 || user_id_len >= ESP_MATTER_RAINMAKER_MAX_DATA_LEN || secret_key_len <= 0 - || secret_key_len >= ESP_MATTER_RAINMAKER_MAX_DATA_LEN) { + if (user_id_len <= 0 || user_id_len >= ESP_MATTER_RAINMAKER_MAX_DATA_LEN || secret_key_len <= 0 || + secret_key_len >= ESP_MATTER_RAINMAKER_MAX_DATA_LEN) { ESP_LOGE(TAG, "User id or secret key length invalid: user_id_len: %d, secret_key_len: %d", user_id_len, secret_key_len); return ESP_FAIL; @@ -155,29 +163,29 @@ esp_err_t esp_matter_rainmaker_command_callback(int endpoint_id, int cluster_id, static esp_err_t rainmaker_custom_cluster_create() { /* Get the endpoint */ - esp_matter_node_t *node = esp_matter_node_get(); - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get(node, ESP_MATTER_RAINMAKER_ENDPOINT_ID); + node_t *node = node::get(); + endpoint_t *endpoint = endpoint::get(node, ESP_MATTER_RAINMAKER_ENDPOINT_ID); /* Create custom rainmaker cluster */ - esp_matter_cluster_t *cluster = esp_matter_cluster_create(endpoint, ESP_MATTER_RAINMAKER_CLUSTER_ID, - ESP_MATTER_CLUSTER_FLAG_SERVER); - esp_matter_attribute_create(cluster, ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_uint16(ESP_MATTER_RAINMAKER_CLUSTER_REVISION)); + cluster_t *cluster = cluster::create(endpoint, ESP_MATTER_RAINMAKER_CLUSTER_ID, ESP_MATTER_CLUSTER_FLAG_SERVER); + attribute::create(cluster, ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_uint16(ESP_MATTER_RAINMAKER_CLUSTER_REVISION)); /* Create custom status attribute */ /* Update the value of the attribute after esp_rmaker_node_init() is done */ - esp_matter_attribute_create(cluster, ESP_MATTER_RAINMAKER_STATUS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_bool(false)); + attribute::create(cluster, ESP_MATTER_RAINMAKER_STATUS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_bool(false)); /* Create custom node_id attribute */ /* Update the value of the attribute after esp_rmaker_node_init() is done */ char node_id[32] = {0}; - esp_matter_attribute_create(cluster, ESP_MATTER_RAINMAKER_NODE_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, - esp_matter_char_str(node_id, sizeof(node_id))); + attribute::create(cluster, ESP_MATTER_RAINMAKER_NODE_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + esp_matter_char_str(node_id, sizeof(node_id))); /* Create custom configuration command */ - esp_matter_command_create(cluster, ESP_MATTER_RAINMAKER_CONFIGURATION_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED | ESP_MATTER_COMMAND_FLAG_CUSTOM, NULL); + command::create(cluster, ESP_MATTER_RAINMAKER_CONFIGURATION_COMMAND_ID, + ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED | ESP_MATTER_COMMAND_FLAG_CUSTOM, + esp_matter_rainmaker_command_callback); return ESP_OK; } @@ -196,8 +204,8 @@ esp_err_t esp_matter_rainmaker_start() } /* Register an event handler and update the state later */ - esp_event_handler_register(RMAKER_EVENT, RMAKER_EVENT_USER_NODE_MAPPING_DONE, - &user_node_association_event_handler, NULL); + esp_event_handler_register(RMAKER_EVENT, RMAKER_EVENT_USER_NODE_MAPPING_DONE, &user_node_association_event_handler, + NULL); esp_event_handler_register(RMAKER_EVENT, RMAKER_EVENT_USER_NODE_MAPPING_RESET, &user_node_association_event_handler, NULL); diff --git a/components/esp_matter_rainmaker/esp_matter_rainmaker.h b/components/esp_matter_rainmaker/esp_matter_rainmaker.h index ed5b3fd94..979ee715f 100644 --- a/components/esp_matter_rainmaker/esp_matter_rainmaker.h +++ b/components/esp_matter_rainmaker/esp_matter_rainmaker.h @@ -37,20 +37,3 @@ esp_err_t esp_matter_rainmaker_init(void); * @return error in case of failure. */ esp_err_t esp_matter_rainmaker_start(void); - -/** Custom Command callback - * - * Command callback for custom commands. - * This should be called when the application receives the custom command callback. - * - * @param[in] endpoint_id Endpoint ID of the command. - * @param[in] cluster_id Cluster ID of the command. - * @param[in] command_id Command ID. - * @param[in] tlv_data Command data which can be parsed. - * @param[in] priv_data Pointer to the private data paassed while setting the command callback. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_matter_rainmaker_command_callback(int endpoint_id, int cluster_id, int command_id, TLVReader &tlv_data, - void *priv_data); diff --git a/examples/bridge_zigbee/main/app_main.cpp b/examples/bridge_zigbee/main/app_main.cpp index 8d0c1f736..91789beed 100644 --- a/examples/bridge_zigbee/main/app_main.cpp +++ b/examples/bridge_zigbee/main/app_main.cpp @@ -22,6 +22,9 @@ #include "zigbee_bridge.h" static const char *TAG = "app_main"; +using namespace esp_matter; +using namespace esp_matter::attribute; + static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { @@ -31,12 +34,12 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } -static esp_err_t app_attribute_update_cb(esp_matter_callback_type_t type, int endpoint_id, int cluster_id, +static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val, void *priv_data) { esp_err_t err = ESP_OK; - if (type == ESP_MATTER_CALLBACK_TYPE_PRE_ATTRIBUTE) { + if (type == PRE_ATTRIBUTE) { err = zigbee_bridge_attribute_update(endpoint_id, cluster_id, attribute_id, val); } return err; @@ -50,8 +53,8 @@ extern "C" void app_main() nvs_flash_init(); /* Create matter device */ - esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT(); - esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL); + node::config_t node_config; + node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); /* These node and endpoint handles can be used to create/add other endpoints and clusters. */ if (!node) { @@ -59,8 +62,7 @@ extern "C" void app_main() } /* Matter start */ - err = esp_matter_start(app_event_cb); - + err = esp_matter::start(app_event_cb); if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); } diff --git a/examples/bridge_zigbee/main/app_zboss.c b/examples/bridge_zigbee/main/app_zboss.cpp similarity index 100% rename from examples/bridge_zigbee/main/app_zboss.c rename to examples/bridge_zigbee/main/app_zboss.cpp diff --git a/examples/bridge_zigbee/main/zap-generated/PluginApplicationCallbacks.h b/examples/bridge_zigbee/main/zap-generated/PluginApplicationCallbacks.h index 7ab176d68..3fb313fc9 100644 --- a/examples/bridge_zigbee/main/zap-generated/PluginApplicationCallbacks.h +++ b/examples/bridge_zigbee/main/zap-generated/PluginApplicationCallbacks.h @@ -21,4 +21,4 @@ #include -#define MATTER_PLUGINS_INIT esp_matter_cluster_plugin_init_callback_common(); +#define MATTER_PLUGINS_INIT esp_matter::cluster::plugin_init_callback_common(); diff --git a/examples/bridge_zigbee/main/zigbee_bridge.cpp b/examples/bridge_zigbee/main/zigbee_bridge.cpp index d7b071934..68a08b332 100644 --- a/examples/bridge_zigbee/main/zigbee_bridge.cpp +++ b/examples/bridge_zigbee/main/zigbee_bridge.cpp @@ -20,17 +20,20 @@ static const char *TAG = "zigbee_bridge"; +using namespace esp_matter; +using namespace esp_matter::cluster; + static esp_err_t init_bridged_onoff_light(esp_matter_bridge_device_t *dev) { if (!dev) { ESP_LOGE(TAG, "Invalid bridge device to be initialized"); return ESP_ERR_INVALID_ARG; } - esp_matter_cluster_on_off_config_t on_off_config = CLUSTER_CONFIG_ON_OFF_DEFAULT(); - esp_matter_cluster_create_on_off(dev->endpoint, &on_off_config, CLUSTER_MASK_SERVER, ESP_MATTER_NONE_FEATURE_ID); - if (esp_matter_endpoint_enable(dev->endpoint) != ESP_OK) { + on_off::config_t config; + on_off::create(dev->endpoint, &config, CLUSTER_MASK_SERVER, ESP_MATTER_NONE_FEATURE_ID); + if (endpoint::enable(dev->endpoint) != ESP_OK) { ESP_LOGE(TAG, "ESP Matter enable dynamic endpoint failed"); - esp_matter_endpoint_delete(dev->node, dev->endpoint); + endpoint::destroy(dev->node, dev->endpoint); return ESP_FAIL; } return ESP_OK; @@ -46,7 +49,7 @@ void zigbee_bridge_match_bridged_onoff_light_cb(zb_bufid_t bufid) if ((p_resp->status == ZB_ZDP_STATUS_SUCCESS) && (p_resp->match_len > 0)) { p_match_ep = (zb_uint8_t *)(p_resp + 1); - esp_matter_node_t *node = esp_matter_node_get(); + node_t *node = node::get(); ESP_GOTO_ON_FALSE(node, ESP_ERR_INVALID_STATE, exit, TAG, "Could not find esp_matter node"); if (app_bridge_get_zigbee_device_by_zigbee_shortaddr(p_ind->src_addr)) { ESP_LOGI(TAG, "Bridged node for 0x%04x zigbee device on endpoint %d has been created", p_ind->src_addr, diff --git a/examples/common/app_bridge/app_bridge_zigbee_device.cpp b/examples/common/app_bridge/app_bridge_zigbee_device.cpp index 5e9a288a0..41b8b0015 100644 --- a/examples/common/app_bridge/app_bridge_zigbee_device.cpp +++ b/examples/common/app_bridge/app_bridge_zigbee_device.cpp @@ -18,11 +18,13 @@ #include +using esp_matter::node_t; + static const char *TAG = "esp_matter_bridge_zigbee"; static app_bridge_zigbee_device_t *device_list = NULL; static uint8_t current_bridged_device_count = 0; -app_bridge_zigbee_device_t *app_bridge_create_zigbee_device(esp_matter_node_t *node, uint8_t zigbee_endpointid, +app_bridge_zigbee_device_t *app_bridge_create_zigbee_device(node_t *node, uint8_t zigbee_endpointid, uint16_t zigbee_shortaddr) { if (current_bridged_device_count >= MAX_BRIDGED_DEVICE_COUNT) { diff --git a/examples/common/app_bridge/app_bridge_zigbee_device.h b/examples/common/app_bridge/app_bridge_zigbee_device.h index 6cb744108..2471b7ca4 100644 --- a/examples/common/app_bridge/app_bridge_zigbee_device.h +++ b/examples/common/app_bridge/app_bridge_zigbee_device.h @@ -17,6 +17,8 @@ #if CONFIG_ZB_ENABLED #include +using esp_matter::node_t; + typedef struct app_bridge_zigbee_device { esp_matter_bridge_device_t *dev; uint8_t zigbee_endpointid; @@ -24,7 +26,7 @@ typedef struct app_bridge_zigbee_device { struct app_bridge_zigbee_device *next; } app_bridge_zigbee_device_t; -app_bridge_zigbee_device_t *app_bridge_create_zigbee_device(esp_matter_node_t *node, uint8_t zigbee_endpointid, +app_bridge_zigbee_device_t *app_bridge_create_zigbee_device(node_t *node, uint8_t zigbee_endpointid, uint16_t zigbee_shortaddr); uint16_t app_bridge_get_zigbee_shortaddr_by_matter_endpointid(int matter_endpointid); diff --git a/examples/light/main/app_driver.cpp b/examples/light/main/app_driver.cpp index 82f8f6b43..925c7c0e1 100644 --- a/examples/light/main/app_driver.cpp +++ b/examples/light/main/app_driver.cpp @@ -16,6 +16,8 @@ #include +using namespace esp_matter; + static const char *TAG = "app_driver"; extern int light_endpoint_id; @@ -70,24 +72,24 @@ static esp_err_t app_driver_attribute_set_defaults() { /* Get the default value (current value) from esp_matter and update the app_driver */ esp_err_t err = ESP_OK; - esp_matter_node_t *node = esp_matter_node_get(); - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get_first(node); + node_t *node = node::get(); + endpoint_t *endpoint = endpoint::get_first(node); while (endpoint) { - int endpoint_id = esp_matter_endpoint_get_id(endpoint); - esp_matter_cluster_t *cluster = esp_matter_cluster_get_first(endpoint); + int endpoint_id = endpoint::get_id(endpoint); + cluster_t *cluster = cluster::get_first(endpoint); while (cluster) { - int cluster_id = esp_matter_cluster_get_id(cluster); - esp_matter_attribute_t *attribute = esp_matter_attribute_get_first(cluster); + int cluster_id = cluster::get_id(cluster); + attribute_t *attribute = attribute::get_first(cluster); while (attribute) { - int attribute_id = esp_matter_attribute_get_id(attribute); + int attribute_id = attribute::get_id(attribute); esp_matter_attr_val_t val = esp_matter_invalid(NULL); - err |= esp_matter_attribute_get_val(attribute, &val); + err |= attribute::get_val(attribute, &val); err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val); - attribute = esp_matter_attribute_get_next(attribute); + attribute = attribute::get_next(attribute); } - cluster = esp_matter_cluster_get_next(cluster); + cluster = cluster::get_next(cluster); } - endpoint = esp_matter_endpoint_get_next(endpoint); + endpoint = endpoint::get_next(endpoint); } return err; } diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index 74e499260..6b843ec8c 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -21,6 +21,10 @@ static const char *TAG = "app_main"; int light_endpoint_id = 0; +using namespace esp_matter; +using namespace esp_matter::attribute; +using namespace esp_matter::endpoint; + static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { @@ -32,15 +36,15 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } -static esp_err_t app_attribute_update_cb(esp_matter_callback_type_t type, int endpoint_id, int cluster_id, - int attribute_id, esp_matter_attr_val_t *val, void *priv_data) +static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id, + esp_matter_attr_val_t *val, void *priv_data) { esp_err_t err = ESP_OK; - if (type == ESP_MATTER_CALLBACK_TYPE_PRE_ATTRIBUTE) { + if (type == PRE_ATTRIBUTE) { /* Driver update */ err = app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, val); - } else if (type == ESP_MATTER_CALLBACK_TYPE_POST_ATTRIBUTE) { + } else if (type == POST_ATTRIBUTE) { /* Other ecosystems update */ } @@ -55,17 +59,16 @@ extern "C" void app_main() nvs_flash_init(); /* Create matter device */ - esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT(); - esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL); + node::config_t node_config; + node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); - esp_matter_endpoint_color_dimmable_light_config_t light_config = ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT(); + color_dimmable_light::config_t light_config; light_config.on_off.on_off = DEFAULT_POWER; light_config.level_control.current_level = DEFAULT_BRIGHTNESS; light_config.color_control.hue_saturation.current_hue = DEFAULT_HUE; light_config.color_control.hue_saturation.current_saturation = DEFAULT_SATURATION; - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_color_dimmable_light(node, &light_config, - ESP_MATTER_ENDPOINT_FLAG_NONE); - light_endpoint_id = esp_matter_endpoint_get_id(endpoint); + endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, ESP_MATTER_ENDPOINT_FLAG_NONE); + light_endpoint_id = endpoint::get_id(endpoint); /* These node and endpoint handles can be used to create/add other endpoints and clusters. */ if (!node || !endpoint) { @@ -77,8 +80,7 @@ extern "C" void app_main() app_driver_init(); /* Matter start */ - err = esp_matter_start(app_event_cb); - + err = esp_matter::start(app_event_cb); if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); } diff --git a/examples/light/main/zap-generated/PluginApplicationCallbacks.h b/examples/light/main/zap-generated/PluginApplicationCallbacks.h index 1f87e5c0d..e6a3f4755 100644 --- a/examples/light/main/zap-generated/PluginApplicationCallbacks.h +++ b/examples/light/main/zap-generated/PluginApplicationCallbacks.h @@ -21,4 +21,4 @@ #include -#define MATTER_PLUGINS_INIT esp_matter_cluster_plugin_init_callback_common(); +#define MATTER_PLUGINS_INIT esp_matter::cluster::plugin_init_callback_common(); diff --git a/examples/rainmaker_light/main/app_driver.cpp b/examples/rainmaker_light/main/app_driver.cpp index 82f8f6b43..925c7c0e1 100644 --- a/examples/rainmaker_light/main/app_driver.cpp +++ b/examples/rainmaker_light/main/app_driver.cpp @@ -16,6 +16,8 @@ #include +using namespace esp_matter; + static const char *TAG = "app_driver"; extern int light_endpoint_id; @@ -70,24 +72,24 @@ static esp_err_t app_driver_attribute_set_defaults() { /* Get the default value (current value) from esp_matter and update the app_driver */ esp_err_t err = ESP_OK; - esp_matter_node_t *node = esp_matter_node_get(); - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get_first(node); + node_t *node = node::get(); + endpoint_t *endpoint = endpoint::get_first(node); while (endpoint) { - int endpoint_id = esp_matter_endpoint_get_id(endpoint); - esp_matter_cluster_t *cluster = esp_matter_cluster_get_first(endpoint); + int endpoint_id = endpoint::get_id(endpoint); + cluster_t *cluster = cluster::get_first(endpoint); while (cluster) { - int cluster_id = esp_matter_cluster_get_id(cluster); - esp_matter_attribute_t *attribute = esp_matter_attribute_get_first(cluster); + int cluster_id = cluster::get_id(cluster); + attribute_t *attribute = attribute::get_first(cluster); while (attribute) { - int attribute_id = esp_matter_attribute_get_id(attribute); + int attribute_id = attribute::get_id(attribute); esp_matter_attr_val_t val = esp_matter_invalid(NULL); - err |= esp_matter_attribute_get_val(attribute, &val); + err |= attribute::get_val(attribute, &val); err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val); - attribute = esp_matter_attribute_get_next(attribute); + attribute = attribute::get_next(attribute); } - cluster = esp_matter_cluster_get_next(cluster); + cluster = cluster::get_next(cluster); } - endpoint = esp_matter_endpoint_get_next(endpoint); + endpoint = endpoint::get_next(endpoint); } return err; } diff --git a/examples/rainmaker_light/main/app_main.cpp b/examples/rainmaker_light/main/app_main.cpp index ff9c830ba..682427456 100644 --- a/examples/rainmaker_light/main/app_main.cpp +++ b/examples/rainmaker_light/main/app_main.cpp @@ -21,6 +21,10 @@ static const char *TAG = "app_main"; int light_endpoint_id = 0; +using namespace esp_matter; +using namespace esp_matter::attribute; +using namespace esp_matter::endpoint; + static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { @@ -32,15 +36,15 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } -static esp_err_t app_attribute_update_cb(esp_matter_callback_type_t type, int endpoint_id, int cluster_id, - int attribute_id, esp_matter_attr_val_t *val, void *priv_data) +static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id, + esp_matter_attr_val_t *val, void *priv_data) { esp_err_t err = ESP_OK; - if (type == ESP_MATTER_CALLBACK_TYPE_PRE_ATTRIBUTE) { + if (type == PRE_ATTRIBUTE) { /* Driver update */ err = app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, val); - } else if (type == ESP_MATTER_CALLBACK_TYPE_POST_ATTRIBUTE) { + } else if (type == POST_ATTRIBUTE) { /* Other ecosystems update */ err = app_rainmaker_attribute_update(endpoint_id, cluster_id, attribute_id, val); } @@ -48,14 +52,6 @@ static esp_err_t app_attribute_update_cb(esp_matter_callback_type_t type, int en return err; } -esp_err_t app_command_callback(int endpoint_id, int cluster_id, int command_id, TLVReader &tlv_data, void *priv_data) -{ - esp_err_t err = ESP_OK; - /* Pass all the commands to all the ecosystems, if their command callbacks exist */ - err = app_rainmaker_command_callback(endpoint_id, cluster_id, command_id, tlv_data, priv_data); - return err; -} - extern "C" void app_main() { esp_err_t err = ESP_OK; @@ -64,17 +60,16 @@ extern "C" void app_main() nvs_flash_init(); /* Create matter device */ - esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT(); - esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL); + node::config_t node_config; + node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); - esp_matter_endpoint_color_dimmable_light_config_t light_config = ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT(); + color_dimmable_light::config_t light_config; light_config.on_off.on_off = DEFAULT_POWER; light_config.level_control.current_level = DEFAULT_BRIGHTNESS; light_config.color_control.hue_saturation.current_hue = DEFAULT_HUE; light_config.color_control.hue_saturation.current_saturation = DEFAULT_SATURATION; - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_color_dimmable_light(node, &light_config, - ESP_MATTER_ENDPOINT_FLAG_NONE); - light_endpoint_id = esp_matter_endpoint_get_id(endpoint); + endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, ESP_MATTER_ENDPOINT_FLAG_NONE); + light_endpoint_id = endpoint::get_id(endpoint); /* These node and endpoint handles can be used to create/add other endpoints and clusters. */ if (!node || !endpoint) { @@ -86,11 +81,10 @@ extern "C" void app_main() app_driver_init(); /* Initialize rainmaker */ - esp_matter_command_set_custom_callback(app_command_callback, NULL); app_rainmaker_init(); /* Matter start */ - err = esp_matter_start(app_event_cb); + err = esp_matter::start(app_event_cb); if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); } diff --git a/examples/rainmaker_light/main/app_rainmaker.cpp b/examples/rainmaker_light/main/app_rainmaker.cpp index 45f4e2b8f..bc8db5dd4 100644 --- a/examples/rainmaker_light/main/app_rainmaker.cpp +++ b/examples/rainmaker_light/main/app_rainmaker.cpp @@ -25,6 +25,8 @@ #include #include +using namespace esp_matter; + static const char *TAG = "app_rainmaker"; extern int light_endpoint_id; @@ -108,7 +110,7 @@ static const char *app_rainmaker_get_device_name_from_id(int endpoint_id) static const char *app_rainmaker_get_device_type_from_id(int device_type_id) { - if (device_type_id == ESP_MATTER_COLOR_DIMMABLE_LIGHT_DEVICE_TYPE_ID) { + if (device_type_id == endpoint::color_dimmable_light::get_device_type_id()) { return ESP_RMAKER_DEVICE_LIGHTBULB; } return NULL; @@ -207,11 +209,10 @@ static bool app_rainmaker_get_param_bounds_from_id(int cluster_id, int attribute return false; } -static esp_err_t app_rainmaker_param_add_ui_type(esp_rmaker_param_t *param, esp_matter_cluster_t *cluster, - esp_matter_attribute_t *attribute) +static esp_err_t app_rainmaker_param_add_ui_type(esp_rmaker_param_t *param, cluster_t *cluster, attribute_t *attribute) { - int cluster_id = esp_matter_cluster_get_id(cluster); - int attribute_id = esp_matter_attribute_get_id(attribute); + int cluster_id = cluster::get_id(cluster); + int attribute_id = attribute::get_id(attribute); const char *ui_type = app_rainmaker_get_param_ui_type_from_id(cluster_id, attribute_id); if (!ui_type) { return ESP_OK; @@ -219,12 +220,11 @@ static esp_err_t app_rainmaker_param_add_ui_type(esp_rmaker_param_t *param, esp_ return esp_rmaker_param_add_ui_type(param, ui_type); } -static esp_err_t app_rainmaker_param_add_bounds(esp_rmaker_param_t *param, esp_matter_cluster_t *cluster, - esp_matter_attribute_t *attribute) +static esp_err_t app_rainmaker_param_add_bounds(esp_rmaker_param_t *param, cluster_t *cluster, attribute_t *attribute) { - int cluster_id = esp_matter_cluster_get_id(cluster); - int attribute_id = esp_matter_attribute_get_id(attribute); - esp_matter_attr_bounds_t *bounds = esp_matter_attribute_get_bounds(attribute); + int cluster_id = cluster::get_id(cluster); + int attribute_id = attribute::get_id(attribute); + esp_matter_attr_bounds_t *bounds = attribute::get_bounds(attribute); if (bounds) { esp_rmaker_param_val_t min_val = app_rainmaker_get_rmaker_val(&bounds->min, cluster_id, attribute_id); esp_rmaker_param_val_t max_val = app_rainmaker_get_rmaker_val(&bounds->max, cluster_id, attribute_id); @@ -294,12 +294,6 @@ esp_err_t app_rainmaker_attribute_update(int endpoint_id, int cluster_id, int at return esp_rmaker_param_update_and_report(param, rmaker_val); } -esp_err_t app_rainmaker_command_callback(int endpoint_id, int cluster_id, int command_id, TLVReader &tlv_data, - void *priv_data) -{ - return esp_matter_rainmaker_command_callback(endpoint_id, cluster_id, command_id, tlv_data, priv_data); -} - /* Callback to handle commands received from the RainMaker cloud */ static esp_err_t write_cb(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param, const esp_rmaker_param_val_t val, void *priv_data, esp_rmaker_write_ctx_t *ctx) @@ -314,20 +308,21 @@ static esp_err_t write_cb(const esp_rmaker_device_t *device, const esp_rmaker_pa int endpoint_id = app_rainmaker_get_endpoint_id_from_name(device_name); int cluster_id = app_rainmaker_get_cluster_id_from_name(param_name); int attribute_id = app_rainmaker_get_attribute_id_from_name(param_name); - esp_matter_attr_val_t matter_val = app_rainmaker_get_matter_val((esp_rmaker_param_val_t *)&val, cluster_id, attribute_id); + esp_matter_attr_val_t matter_val = app_rainmaker_get_matter_val((esp_rmaker_param_val_t *)&val, cluster_id, + attribute_id); - return esp_matter_attribute_update(endpoint_id, cluster_id, attribute_id, &matter_val); + return attribute::update(endpoint_id, cluster_id, attribute_id, &matter_val); } -static esp_rmaker_device_t *app_rainmaker_device_create(const esp_rmaker_node_t *node, esp_matter_endpoint_t *endpoint) +static esp_rmaker_device_t *app_rainmaker_device_create(const esp_rmaker_node_t *node, endpoint_t *endpoint) { - int endpoint_id = esp_matter_endpoint_get_id(endpoint); + int endpoint_id = endpoint::get_id(endpoint); const char *device_name = app_rainmaker_get_device_name_from_id(endpoint_id); if (!device_name) { return NULL; } /* Add this device only if endpoint_id has been handled */ - int device_type_id = esp_matter_endpoint_get_device_type_id(endpoint_id); + int device_type_id = endpoint::get_device_type_id(endpoint_id); const char *device_type = app_rainmaker_get_device_type_from_id(device_type_id); esp_rmaker_device_t *device = esp_rmaker_device_create(device_name, device_type, NULL); if (!device) { @@ -339,11 +334,11 @@ static esp_rmaker_device_t *app_rainmaker_device_create(const esp_rmaker_node_t return device; } -static esp_rmaker_param_t *app_rainmaker_param_create(esp_rmaker_device_t *device, esp_matter_cluster_t *cluster, - esp_matter_attribute_t *attribute) +static esp_rmaker_param_t *app_rainmaker_param_create(esp_rmaker_device_t *device, cluster_t *cluster, + attribute_t *attribute) { - int cluster_id = esp_matter_cluster_get_id(cluster); - int attribute_id = esp_matter_attribute_get_id(attribute); + int cluster_id = cluster::get_id(cluster); + int attribute_id = attribute::get_id(attribute); const char *param_name = app_rainmaker_get_param_name_from_id(cluster_id, attribute_id); if (!param_name) { return NULL; @@ -351,7 +346,7 @@ static esp_rmaker_param_t *app_rainmaker_param_create(esp_rmaker_device_t *devic /* Add this param only if attribute_id corresponding to the cluster_id is handled */ const char *param_type = app_rainmaker_get_param_type_from_id(cluster_id, attribute_id); esp_matter_attr_val_t val = esp_matter_invalid(NULL); - esp_matter_attribute_get_val(attribute, &val); + attribute::get_val(attribute, &val); esp_rmaker_param_val_t rmaker_val = app_rainmaker_get_rmaker_val(&val, cluster_id, attribute_id); esp_rmaker_param_t *param = esp_rmaker_param_create(param_name, param_type, rmaker_val, PROP_FLAG_READ | PROP_FLAG_WRITE); @@ -369,27 +364,27 @@ static esp_rmaker_param_t *app_rainmaker_param_create(esp_rmaker_device_t *devic static void app_rainmaker_data_model_create() { const esp_rmaker_node_t *node = esp_rmaker_get_node(); - esp_matter_node_t *matter_node = esp_matter_node_get(); - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get_first(matter_node); + node_t *matter_node = node::get(); + endpoint_t *endpoint = endpoint::get_first(matter_node); /* Parse all endpoints */ while (endpoint) { esp_rmaker_device_t *device = app_rainmaker_device_create(node, endpoint); /* Proceed only if the device has been handled */ if (device) { - esp_matter_cluster_t *cluster = esp_matter_cluster_get_first(endpoint); + cluster_t *cluster = cluster::get_first(endpoint); /* Parse all clusters */ while (cluster) { - esp_matter_attribute_t *attribute = esp_matter_attribute_get_first(cluster); + attribute_t *attribute = attribute::get_first(cluster); /* Parse all attributes */ while (attribute) { app_rainmaker_param_create(device, cluster, attribute); - attribute = esp_matter_attribute_get_next(attribute); + attribute = attribute::get_next(attribute); } - cluster = esp_matter_cluster_get_next(cluster); + cluster = cluster::get_next(cluster); } } - endpoint = esp_matter_endpoint_get_next(endpoint); + endpoint = endpoint::get_next(endpoint); } } diff --git a/examples/rainmaker_light/main/app_rainmaker.h b/examples/rainmaker_light/main/app_rainmaker.h index 0b319d045..d74ea6ce5 100644 --- a/examples/rainmaker_light/main/app_rainmaker.h +++ b/examples/rainmaker_light/main/app_rainmaker.h @@ -36,9 +36,6 @@ esp_err_t app_rainmaker_start(void); esp_err_t app_rainmaker_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); -esp_err_t app_rainmaker_command_callback(int endpoint_id, int cluster_id, int command_id, TLVReader &tlv_data, - void *priv_data); - #ifdef __cplusplus } #endif diff --git a/examples/rainmaker_light/main/zap-generated/PluginApplicationCallbacks.h b/examples/rainmaker_light/main/zap-generated/PluginApplicationCallbacks.h index 1f87e5c0d..e6a3f4755 100644 --- a/examples/rainmaker_light/main/zap-generated/PluginApplicationCallbacks.h +++ b/examples/rainmaker_light/main/zap-generated/PluginApplicationCallbacks.h @@ -21,4 +21,4 @@ #include -#define MATTER_PLUGINS_INIT esp_matter_cluster_plugin_init_callback_common(); +#define MATTER_PLUGINS_INIT esp_matter::cluster::plugin_init_callback_common(); diff --git a/examples/switch/main/app_driver.cpp b/examples/switch/main/app_driver.cpp index fb0604687..c00280805 100644 --- a/examples/switch/main/app_driver.cpp +++ b/examples/switch/main/app_driver.cpp @@ -18,7 +18,10 @@ #include using chip::kInvalidClusterId; -static constexpr chip::CommandId kInvalidCommandId = 0xFFFF'FFFF; +static constexpr chip::CommandId kInvalidCommandId = 0xFFFF'FFFF; + +using namespace esp_matter; +using namespace esp_matter::cluster; static const char *TAG = "app_driver"; extern int switch_endpoint_id; @@ -41,7 +44,7 @@ static esp_err_t app_driver_console_handler(int argc, char **argv) g_cluster_id = cluster_id; g_command_id = command_id; - esp_matter_client_cluster_update(endpoint_id, cluster_id); + client::cluster_update(endpoint_id, cluster_id); } else if (argc == 6 && strncmp(argv[0], "send", sizeof("send")) == 0) { int fabric_index = strtol((const char *)&argv[1][2], NULL, 16); int node_id = strtol((const char *)&argv[2][2], NULL, 16); @@ -51,7 +54,7 @@ static esp_err_t app_driver_console_handler(int argc, char **argv) g_cluster_id = cluster_id; g_command_id = command_id; - esp_matter_connect(fabric_index, node_id, remote_endpoint_id); + client::connect(fabric_index, node_id, remote_endpoint_id); } else { ESP_LOGE(TAG, "Incorrect arguments. Check help for more details."); return ESP_ERR_INVALID_ARG; @@ -70,17 +73,17 @@ static void app_driver_register_commands() esp_matter_console_add_command(&command); } -void app_driver_client_command_callback(esp_matter_peer_device_t *peer_device, int remote_endpoint_id, void *priv_data) +void app_driver_client_command_callback(client::peer_device_t *peer_device, int remote_endpoint_id, void *priv_data) { /** TODO: Find a better way to get the cluster_id and command_id. Once done, move the console commands to esp_matter_client. */ if (g_cluster_id == ZCL_ON_OFF_CLUSTER_ID) { if (g_command_id == ZCL_OFF_COMMAND_ID) { - esp_matter_on_off_send_command_off(peer_device, remote_endpoint_id); + on_off::command::send_off(peer_device, remote_endpoint_id); } else if (g_command_id == ZCL_ON_COMMAND_ID) { - esp_matter_on_off_send_command_on(peer_device, remote_endpoint_id); + on_off::command::send_on(peer_device, remote_endpoint_id); } else if (g_command_id == ZCL_TOGGLE_COMMAND_ID) { - esp_matter_on_off_send_command_toggle(peer_device, remote_endpoint_id); + on_off::command::send_toggle(peer_device, remote_endpoint_id); } } } @@ -95,24 +98,24 @@ static esp_err_t app_driver_attribute_set_defaults() { /* Get the default value (current value) from esp_matter and update the app_driver */ esp_err_t err = ESP_OK; - esp_matter_node_t *node = esp_matter_node_get(); - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_get_first(node); + node_t *node = node::get(); + endpoint_t *endpoint = endpoint::get_first(node); while (endpoint) { - int endpoint_id = esp_matter_endpoint_get_id(endpoint); - esp_matter_cluster_t *cluster = esp_matter_cluster_get_first(endpoint); + int endpoint_id = endpoint::get_id(endpoint); + cluster_t *cluster = cluster::get_first(endpoint); while (cluster) { - int cluster_id = esp_matter_cluster_get_id(cluster); - esp_matter_attribute_t *attribute = esp_matter_attribute_get_first(cluster); + int cluster_id = cluster::get_id(cluster); + attribute_t *attribute = attribute::get_first(cluster); while (attribute) { - int attribute_id = esp_matter_attribute_get_id(attribute); + int attribute_id = attribute::get_id(attribute); esp_matter_attr_val_t val = esp_matter_invalid(NULL); - err |= esp_matter_attribute_get_val(attribute, &val); + err |= attribute::get_val(attribute, &val); err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val); - attribute = esp_matter_attribute_get_next(attribute); + attribute = attribute::get_next(attribute); } - cluster = esp_matter_cluster_get_next(cluster); + cluster = cluster::get_next(cluster); } - endpoint = esp_matter_endpoint_get_next(endpoint); + endpoint = endpoint::get_next(endpoint); } return err; } @@ -123,6 +126,6 @@ esp_err_t app_driver_init() // device_init(); app_driver_attribute_set_defaults(); app_driver_register_commands(); - esp_matter_set_client_command_callback(app_driver_client_command_callback, NULL); + client::set_command_callback(app_driver_client_command_callback, NULL); return ESP_OK; } diff --git a/examples/switch/main/app_main.cpp b/examples/switch/main/app_main.cpp index 52f93ffbb..4d3ae73a9 100644 --- a/examples/switch/main/app_main.cpp +++ b/examples/switch/main/app_main.cpp @@ -21,6 +21,10 @@ static const char *TAG = "app_main"; int switch_endpoint_id = 0; +using namespace esp_matter; +using namespace esp_matter::attribute; +using namespace esp_matter::endpoint; + static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { @@ -32,15 +36,15 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } -static esp_err_t app_attribute_update_cb(esp_matter_callback_type_t type, int endpoint_id, int cluster_id, - int attribute_id, esp_matter_attr_val_t *val, void *priv_data) +static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id, + esp_matter_attr_val_t *val, void *priv_data) { esp_err_t err = ESP_OK; - if (type == ESP_MATTER_CALLBACK_TYPE_PRE_ATTRIBUTE) { + if (type == PRE_ATTRIBUTE) { /* Driver update */ err = app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, val); - } else if (type == ESP_MATTER_CALLBACK_TYPE_POST_ATTRIBUTE) { + } else if (type == POST_ATTRIBUTE) { /* Other ecosystems update */ } @@ -55,13 +59,12 @@ extern "C" void app_main() nvs_flash_init(); /* Create matter device */ - esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT(); - esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL); + node::config_t node_config; + node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); - esp_matter_endpoint_on_off_switch_config_t switch_config = ENDPOINT_CONFIG_ON_OFF_SWITCH_DEFAULT(); - esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_on_off_switch(node, &switch_config, - ESP_MATTER_ENDPOINT_FLAG_NONE); - switch_endpoint_id = esp_matter_endpoint_get_id(endpoint); + on_off_switch::config_t switch_config; + endpoint_t *endpoint = on_off_switch::create(node, &switch_config, ESP_MATTER_ENDPOINT_FLAG_NONE); + switch_endpoint_id = endpoint::get_id(endpoint); /* These node and endpoint handles can be used to create/add other endpoints and clusters. */ if (!node || !endpoint) { @@ -73,8 +76,7 @@ extern "C" void app_main() app_driver_init(); /* Matter start */ - err = esp_matter_start(app_event_cb); - + err = esp_matter::start(app_event_cb); if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); } diff --git a/examples/switch/main/zap-generated/PluginApplicationCallbacks.h b/examples/switch/main/zap-generated/PluginApplicationCallbacks.h index 1f87e5c0d..e6a3f4755 100644 --- a/examples/switch/main/zap-generated/PluginApplicationCallbacks.h +++ b/examples/switch/main/zap-generated/PluginApplicationCallbacks.h @@ -21,4 +21,4 @@ #include -#define MATTER_PLUGINS_INIT esp_matter_cluster_plugin_init_callback_common(); +#define MATTER_PLUGINS_INIT esp_matter::cluster::plugin_init_callback_common(); diff --git a/examples/zap_light/main/app_driver.cpp b/examples/zap_light/main/app_driver.cpp index a54962759..d4884e1e2 100644 --- a/examples/zap_light/main/app_driver.cpp +++ b/examples/zap_light/main/app_driver.cpp @@ -16,6 +16,8 @@ #include +using namespace esp_matter; + static const char *TAG = "app_driver"; extern int light_endpoint_id; @@ -69,7 +71,7 @@ esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attri esp_err_t app_driver_attribute_set_defaults() { /* When using static endpoints, i.e. using the data model from zap-generated, this needs to be done - after esp_matter_start() */ + after esp_matter::start() */ /* Get the default value (current value) from matter submodule and update the app_driver */ esp_err_t err = ESP_OK; uint8_t value; @@ -81,28 +83,28 @@ esp_err_t app_driver_attribute_set_defaults() endpoint_id = light_endpoint_id; cluster_id = ZCL_ON_OFF_CLUSTER_ID; attribute_id = ZCL_ON_OFF_ATTRIBUTE_ID; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t)); + attribute::get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t)); val = esp_matter_bool(value); err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val); endpoint_id = light_endpoint_id; cluster_id = ZCL_LEVEL_CONTROL_CLUSTER_ID; attribute_id = ZCL_CURRENT_LEVEL_ATTRIBUTE_ID; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t)); + attribute::get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t)); val = esp_matter_uint8(value); err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val); endpoint_id = light_endpoint_id; cluster_id = ZCL_COLOR_CONTROL_CLUSTER_ID; attribute_id = ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t)); + attribute::get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t)); val = esp_matter_uint8(value); err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val); endpoint_id = light_endpoint_id; cluster_id = ZCL_COLOR_CONTROL_CLUSTER_ID; attribute_id = ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID; - esp_matter_attribute_get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t)); + attribute::get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t)); val = esp_matter_uint8(value); err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val); @@ -113,6 +115,6 @@ esp_err_t app_driver_init() { ESP_LOGI(TAG, "Initialising driver"); device_init(); - /* Attribute defaults are set after esp_matter_start() from app_main() */ + /* Attribute defaults are set after esp_matter::start() from app_main() */ return ESP_OK; } diff --git a/examples/zap_light/main/app_main.cpp b/examples/zap_light/main/app_main.cpp index d05fed0c5..0c72d3c25 100644 --- a/examples/zap_light/main/app_main.cpp +++ b/examples/zap_light/main/app_main.cpp @@ -13,9 +13,13 @@ #include #include #include + #include #include +using namespace esp_matter; +using namespace esp_matter::attribute; + static const char *TAG = "app_main"; int light_endpoint_id = 0; @@ -30,15 +34,15 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } -static esp_err_t app_attribute_update_cb(esp_matter_callback_type_t type, int endpoint_id, int cluster_id, - int attribute_id, esp_matter_attr_val_t *val, void *priv_data) +static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id, + esp_matter_attr_val_t *val, void *priv_data) { esp_err_t err = ESP_OK; - if (type == ESP_MATTER_CALLBACK_TYPE_PRE_ATTRIBUTE) { + if (type == PRE_ATTRIBUTE) { /* Driver update */ err = app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, val); - } else if (type == ESP_MATTER_CALLBACK_TYPE_POST_ATTRIBUTE) { + } else if (type == POST_ATTRIBUTE) { /* Other ecosystems update */ } @@ -53,14 +57,14 @@ extern "C" void app_main() nvs_flash_init(); /* Initialize matter callback */ - esp_matter_attribute_callback_set(app_attribute_update_cb, NULL); - light_endpoint_id = 1; /* This is from zap-generated/endpoint_config.h */ + attribute::set_callback(app_attribute_update_cb, NULL); + light_endpoint_id = 1; /* This is from zap-generated/endpoint_config.h */ /* Initialize driver */ app_driver_init(); /* Matter start */ - err = esp_matter_start(app_event_cb); + err = esp_matter::start(app_event_cb); if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); }