diff --git a/components/esp_matter/esp_matter.h b/components/esp_matter/esp_matter.h index 68fbfd3a9..59a17bd12 100644 --- a/components/esp_matter/esp_matter.h +++ b/components/esp_matter/esp_matter.h @@ -37,39 +37,68 @@ application. #include #include -typedef enum esp_matter_endpoint_flags { - ESP_MATTER_ENDPOINT_FLAG_NONE = 0x00, - ESP_MATTER_ENDPOINT_FLAG_DELETABLE = 0x01, -} esp_matter_endpoint_flags_t; +namespace esp_matter { -typedef enum esp_matter_cluster_flags { - ESP_MATTER_CLUSTER_FLAG_NONE = 0x00, - ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION = CLUSTER_MASK_INIT_FUNCTION, /* 0x01 */ - 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 = +/** Endpoint flags */ +typedef enum endpoint_flags { + /** No specific flags */ + ENDPOINT_FLAG_NONE = 0x00, + /** The endpoint can be destroyed using `endpoint::destroy()` */ + ENDPOINT_FLAG_DESTROYABLE = 0x01, +} endpoint_flags_t; + +/** Cluster flags */ +typedef enum cluster_flags { + /** No specific flags */ + CLUSTER_FLAG_NONE = 0x00, + /** The cluster has an init function (function_flag) */ + CLUSTER_FLAG_INIT_FUNCTION = CLUSTER_MASK_INIT_FUNCTION, /* 0x01 */ + /** The cluster has an attribute changed function (function_flag) */ + CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION = CLUSTER_MASK_ATTRIBUTE_CHANGED_FUNCTION, /* 0x02 */ + /** The cluster has a default response function (function_flag) */ + CLUSTER_FLAG_DEFAULT_RESPONSE_FUNCTION = CLUSTER_MASK_DEFAULT_RESPONSE_FUNCTION, /* 0x04 */ + /** The cluster has a message sent function (function_flag) */ + CLUSTER_FLAG_MESSAGE_SENT_FUNCTION = CLUSTER_MASK_MESSAGE_SENT_FUNCTION, /* 0x08 */ + /** The cluster has a manufacturer specific attribute changed function (function_flag) */ + 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 */ -} esp_matter_cluster_flags_t; + /** The cluster has a pre attribute changed function (function_flag) */ + CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION = CLUSTER_MASK_PRE_ATTRIBUTE_CHANGED_FUNCTION, /* 0x20 */ + /** The cluster is a server cluster */ + CLUSTER_FLAG_SERVER = CLUSTER_MASK_SERVER, /* 0x40 */ + /** The cluster is a client cluster */ + CLUSTER_FLAG_CLIENT = CLUSTER_MASK_CLIENT, /* 0x80 */ +} cluster_flags_t; -typedef enum esp_matter_attribute_flags { - ESP_MATTER_ATTRIBUTE_FLAG_NONE = 0x00, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE = ATTRIBUTE_MASK_WRITABLE, /* 0x01 */ - ESP_MATTER_ATTRIBUTE_FLAG_NONVOLATILE = ATTRIBUTE_MASK_NONVOLATILE, /* 0x02 */ - ESP_MATTER_ATTRIBUTE_FLAG_MIN_MAX = ATTRIBUTE_MASK_MIN_MAX, /* 0x04 */ - ESP_MATTER_ATTRIBUTE_FLAG_MUST_USE_TIMED_WRITE = ATTRIBUTE_MASK_MUST_USE_TIMED_WRITE, /* 0x08 */ - ESP_MATTER_ATTRIBUTE_FLAG_EXTERNAL_STORAGE = ATTRIBUTE_MASK_EXTERNAL_STORAGE, /* 0x10 */ - ESP_MATTER_ATTRIBUTE_FLAG_SINGLETON = ATTRIBUTE_MASK_SINGLETON, /* 0x20 */ - ESP_MATTER_ATTRIBUTE_FLAG_CLIENT = ATTRIBUTE_MASK_CLIENT, /* 0x40 */ - ESP_MATTER_ATTRIBUTE_FLAG_NULLABLE = ATTRIBUTE_MASK_NULLABLE, /* 0x80 */ -} esp_matter_attribute_flags_t; +/** Attribute flags */ +typedef enum attribute_flags { + /** No specific flags */ + ATTRIBUTE_FLAG_NONE = 0x00, + /** The attribute is writable and can be directly changed by clients */ + ATTRIBUTE_FLAG_WRITABLE = ATTRIBUTE_MASK_WRITABLE, /* 0x01 */ + /** The attribute is non volatile and its value will be stored in NVS */ + ATTRIBUTE_FLAG_NONVOLATILE = ATTRIBUTE_MASK_NONVOLATILE, /* 0x02 */ + /** The attribute has bounds */ + ATTRIBUTE_FLAG_MIN_MAX = ATTRIBUTE_MASK_MIN_MAX, /* 0x04 */ + ATTRIBUTE_FLAG_MUST_USE_TIMED_WRITE = ATTRIBUTE_MASK_MUST_USE_TIMED_WRITE, /* 0x08 */ + /** The attribute uses external storage for its value. If the ESP Matter data model is used, all the attributes + have this flag enabled, as all of them are stored in the ESP Matter database. */ + ATTRIBUTE_FLAG_EXTERNAL_STORAGE = ATTRIBUTE_MASK_EXTERNAL_STORAGE, /* 0x10 */ + ATTRIBUTE_FLAG_SINGLETON = ATTRIBUTE_MASK_SINGLETON, /* 0x20 */ + ATTRIBUTE_FLAG_CLIENT = ATTRIBUTE_MASK_CLIENT, /* 0x40 */ + ATTRIBUTE_FLAG_NULLABLE = ATTRIBUTE_MASK_NULLABLE, /* 0x80 */ +} attribute_flags_t; -typedef enum esp_matter_command_flags { - ESP_MATTER_COMMAND_FLAG_NONE = 0x00, - ESP_MATTER_COMMAND_FLAG_CUSTOM = 0x01, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED = 0x02, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED = 0x04, -} esp_matter_command_flags_t; +/** Command flags */ +typedef enum command_flags { + /** No specific flags */ + COMMAND_FLAG_NONE = 0x00, + /** The command is not a standard command */ + COMMAND_FLAG_CUSTOM = 0x01, + /** The command is client generated */ + COMMAND_FLAG_CLIENT_GENERATED = 0x02, + /** The command is server generated */ + COMMAND_FLAG_SERVER_GENERATED = 0x04, +} command_flags_t; + +} /* esp_matter */ diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index c7047e313..e924ef184 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -25,12 +25,12 @@ 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint16(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, + return esp_matter::attribute::create(cluster, ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_bitmap32(value)); } @@ -42,25 +42,25 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_DEVICE_LIST_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, 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, + return esp_matter::attribute::create(cluster, ZCL_SERVER_LIST_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, 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, + return esp_matter::attribute::create(cluster, ZCL_CLIENT_LIST_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, 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, + return esp_matter::attribute::create(cluster, ZCL_PARTS_LIST_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } @@ -72,13 +72,13 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_ACL_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_array(value, length, 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, + return esp_matter::attribute::create(cluster, ZCL_EXTENSION_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_array(value, length, count)); } @@ -90,68 +90,68 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_DATA_MODEL_REVISION_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } 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, + return esp_matter::attribute::create(cluster, ZCL_VENDOR_NAME_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); } 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, + return esp_matter::attribute::create(cluster, ZCL_VENDOR_ID_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } 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, + return esp_matter::attribute::create(cluster, ZCL_PRODUCT_NAME_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); } 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, + return esp_matter::attribute::create(cluster, ZCL_PRODUCT_ID_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } 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, + return esp_matter::attribute::create(cluster, ZCL_NODE_LABEL_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_char_str(value, 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, + return esp_matter::attribute::create(cluster, ZCL_LOCATION_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_char_str(value, length)); } 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, + return esp_matter::attribute::create(cluster, ZCL_HARDWARE_VERSION_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); } 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, + return esp_matter::attribute::create(cluster, ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value)); } 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); } } /* attribute */ @@ -162,7 +162,7 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_BINDING_LIST_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_array(value, length, count)); } @@ -175,25 +175,25 @@ 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)); + ATTRIBUTE_FLAG_WRITABLE, esp_matter_octet_str(value, length)); } 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, + return esp_matter::attribute::create(cluster, ZCL_UPDATE_POSSIBLE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_bool(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, + return esp_matter::attribute::create(cluster, ZCL_UPDATE_STATE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } } /* attribute */ @@ -204,25 +204,25 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_BREADCRUMB_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint64(value)); } 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } 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, + return esp_matter::attribute::create(cluster, ZCL_REGULATORYCONFIG_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(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, + return esp_matter::attribute::create(cluster, ZCL_LOCATIONCAPABILITY_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } @@ -234,50 +234,50 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_MAX_NETWORKS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } 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, + return esp_matter::attribute::create(cluster, ZCL_NETWORKS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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)); + ATTRIBUTE_FLAG_WRITABLE, esp_matter_bool(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } 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, + return esp_matter::attribute::create(cluster, ZCL_LAST_NETWORK_ID_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_octet_str(value, length)); } 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value)); } } /* attribute */ @@ -288,13 +288,13 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_NETWORK_INTERFACES_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } 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, + return esp_matter::attribute::create(cluster, ZCL_REBOOT_COUNT_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } @@ -306,19 +306,19 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_WINDOW_STATUS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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, + return esp_matter::attribute::create(cluster, ZCL_ADMIN_FABRIC_INDEX_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(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, + return esp_matter::attribute::create(cluster, ZCL_ADMIN_VENDOR_ID_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } @@ -330,37 +330,37 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_NOCS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, 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, + return esp_matter::attribute::create(cluster, ZCL_FABRICS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } 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, + return esp_matter::attribute::create(cluster, ZCL_SUPPORTED_FABRICS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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, + return esp_matter::attribute::create(cluster, ZCL_COMMISSIONED_FABRICS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } 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, + return esp_matter::attribute::create(cluster, ZCL_TRUSTED_ROOTS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } 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, + return esp_matter::attribute::create(cluster, ZCL_CURRENT_FABRIC_INDEX_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } @@ -372,26 +372,26 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_GROUP_KEY_MAP_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_array(value, length, 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, + return esp_matter::attribute::create(cluster, ZCL_GROUP_TABLE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint16(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } } /* attribute */ @@ -403,7 +403,7 @@ namespace attribute { attribute_t *create_identify_time(cluster_t *cluster, uint16_t value, uint16_t min, uint16_t max) { attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); @@ -415,7 +415,7 @@ attribute_t *create_identify_time(cluster_t *cluster, uint16_t value, uint16_t m 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, + return esp_matter::attribute::create(cluster, ZCL_IDENTIFY_TYPE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } @@ -427,7 +427,7 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_GROUP_NAME_SUPPORT_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_bitmap8(value)); } @@ -439,31 +439,31 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_SCENE_COUNT_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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, + return esp_matter::attribute::create(cluster, ZCL_CURRENT_SCENE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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, + return esp_matter::attribute::create(cluster, ZCL_CURRENT_GROUP_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(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, + return esp_matter::attribute::create(cluster, ZCL_SCENE_VALID_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_bool(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, + return esp_matter::attribute::create(cluster, ZCL_SCENE_NAME_SUPPORT_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_bitmap8(value)); } @@ -475,31 +475,31 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_ON_OFF_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_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, + return esp_matter::attribute::create(cluster, ZCL_GLOBAL_SCENE_CONTROL_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_bool(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, + return esp_matter::attribute::create(cluster, ZCL_ON_TIME_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(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, + return esp_matter::attribute::create(cluster, ZCL_OFF_WAIT_TIME_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(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, + return esp_matter::attribute::create(cluster, ZCL_START_UP_ON_OFF_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value)); } @@ -511,20 +511,20 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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, + return esp_matter::attribute::create(cluster, ZCL_ON_LEVEL_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value)); } attribute_t *create_options(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_OPTIONS_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + ATTRIBUTE_FLAG_WRITABLE, esp_matter_bitmap8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); @@ -536,26 +536,26 @@ attribute_t *create_options(cluster_t *cluster, uint8_t value, uint8_t min, uint 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, + return esp_matter::attribute::create(cluster, ZCL_REMAINING_TIME_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value)); } attribute_t *create_min_level(cluster_t *cluster, uint8_t value) { - return esp_matter::attribute::create(cluster, ZCL_MINIMUM_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + return esp_matter::attribute::create(cluster, ZCL_MINIMUM_LEVEL_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } attribute_t *create_max_level(cluster_t *cluster, uint8_t value) { - return esp_matter::attribute::create(cluster, ZCL_MAXIMUM_LEVEL_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + return esp_matter::attribute::create(cluster, ZCL_MAXIMUM_LEVEL_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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)); + ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value)); } } /* attribute */ @@ -567,37 +567,37 @@ 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_enum8(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)); + ATTRIBUTE_FLAG_WRITABLE, esp_matter_bitmap8(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_enum8(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_bitmap16(value)); } } /* attribute */ @@ -608,14 +608,14 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } } /* attribute */ @@ -626,26 +626,26 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint16(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)); + ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(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)); + ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value)); } attribute_t *create_control_sequence_of_operation(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_CONTROL_SEQUENCE_OF_OPERATION_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); @@ -658,7 +658,7 @@ attribute_t *create_control_sequence_of_operation(cluster_t *cluster, uint8_t va attribute_t *create_system_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_SYSTEM_MODE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_WRITABLE, + ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); @@ -676,32 +676,32 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_LOCK_STATE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(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, + return esp_matter::attribute::create(cluster, ZCL_LOCK_TYPE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(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, + return esp_matter::attribute::create(cluster, ZCL_ACTUATOR_ENABLED_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_bool(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, + return esp_matter::attribute::create(cluster, ZCL_AUTO_RELOCK_TIME_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_bitmap32(value)); } attribute_t *create_operating_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max) { attribute_t *attribute = esp_matter::attribute::create(cluster, ZCL_OPERATING_MODE_ATTRIBUTE_ID, - ESP_MATTER_ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); + ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; @@ -713,7 +713,7 @@ attribute_t *create_operating_mode(cluster_t *cluster, uint8_t value, uint8_t mi 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)); + ATTRIBUTE_FLAG_NONE, esp_matter_bitmap16(value)); } } /* attribute */ @@ -724,13 +724,13 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_NODE_LABEL_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length)); } attribute_t *create_reachable(cluster_t *cluster, bool value) { - return esp_matter::attribute::create(cluster, ZCL_REACHABLE_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + return esp_matter::attribute::create(cluster, ZCL_REACHABLE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_bool(value)); } @@ -742,7 +742,7 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_LABEL_LIST_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE, esp_matter_array(value, length, count)); } @@ -754,19 +754,19 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_NUMBER_OF_POSITIONS_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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, + return esp_matter::attribute::create(cluster, ZCL_CURRENT_POSITION_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(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, + return esp_matter::attribute::create(cluster, ZCL_MULTI_PRESS_MAX_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_uint8(value)); } @@ -778,20 +778,20 @@ 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, + return esp_matter::attribute::create(cluster, ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_int16(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_int16(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)); + ATTRIBUTE_FLAG_NONE, esp_matter_int16(value)); } } /* attribute */ diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index d19e80afe..f1ecb6ab8 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -20,6 +20,12 @@ namespace esp_matter { namespace cluster { +/** Specific attribute create APIs + * + * If some standard attribute is not present here, it can be added. + * If a custom attribute needs to be created, the low level esp_matter::attribute::create() API can be used. + */ + namespace global { namespace attribute { attribute_t *create_cluster_revision(cluster_t *cluster, uint16_t value); diff --git a/components/esp_matter/esp_matter_attribute_utils.cpp b/components/esp_matter/esp_matter_attribute_utils.cpp index 7f1c81170..27c724fa9 100644 --- a/components/esp_matter/esp_matter_attribute_utils.cpp +++ b/components/esp_matter/esp_matter_attribute_utils.cpp @@ -252,7 +252,7 @@ static esp_err_t console_handler(int argc, char **argv) /* Get type from matter_attribute */ const EmberAfAttributeMetadata *matter_attribute = emberAfLocateAttributeMetadata(endpoint_id, cluster_id, - attribute_id, ESP_MATTER_CLUSTER_FLAG_SERVER); + attribute_id, CLUSTER_FLAG_SERVER); if (!matter_attribute) { ESP_LOGE(TAG, "Matter attribute not found"); return ESP_ERR_INVALID_ARG; @@ -306,7 +306,7 @@ static esp_err_t console_handler(int argc, char **argv) /* Get type from matter_attribute */ const EmberAfAttributeMetadata *matter_attribute = emberAfLocateAttributeMetadata(endpoint_id, cluster_id, - attribute_id, ESP_MATTER_CLUSTER_FLAG_SERVER); + attribute_id, CLUSTER_FLAG_SERVER); if (!matter_attribute) { ESP_LOGE(TAG, "Matter attribute not found"); return ESP_ERR_INVALID_ARG; @@ -922,7 +922,7 @@ Status MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attribute::val_print(endpoint_id, cluster_id, attribute_id, &val); /* Callback to application */ - esp_err_t err = send_callback(attribute::PRE_ATTRIBUTE, endpoint_id, cluster_id, attribute_id, &val); + esp_err_t err = send_callback(attribute::PRE_UPDATE, endpoint_id, cluster_id, attribute_id, &val); if (err != ESP_OK) { return Status::Failure; } @@ -939,7 +939,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &p attribute::get_attr_val_from_data(&val, type, size, value); /* Callback to application */ - send_callback(attribute::POST_ATTRIBUTE, endpoint_id, cluster_id, attribute_id, &val); + send_callback(attribute::POST_UPDATE, endpoint_id, cluster_id, attribute_id, &val); } EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint_id, ClusterId cluster_id, diff --git a/components/esp_matter/esp_matter_attribute_utils.h b/components/esp_matter/esp_matter_attribute_utils.h index a571527d7..a76e4401f 100644 --- a/components/esp_matter/esp_matter_attribute_utils.h +++ b/components/esp_matter/esp_matter_attribute_utils.h @@ -18,6 +18,11 @@ #include #include +/** Remap attribute values + * + * This can be used to remap attribute values to different ranges. + * Example: To convert the brightness value (0-255) into brightness percentage (0-100) and vice-versa. + */ #define REMAP_TO_RANGE(value, from, to) ((value * to) / from) /** ESP Matter Attribute Value type */ @@ -58,7 +63,7 @@ typedef enum { ESP_MATTER_VAL_TYPE_BITMAP32, } esp_matter_val_type_t; -/* ESP Matter Value */ +/** ESP Matter Value */ typedef union { /** Boolean */ bool b; @@ -93,7 +98,7 @@ typedef union { void *p; } esp_matter_val_t; -/* ESP Matter Attribute Value */ +/** ESP Matter Attribute Value */ typedef struct { /** Type of Value */ esp_matter_val_type_t type; @@ -101,11 +106,11 @@ typedef struct { esp_matter_val_t val; } esp_matter_attr_val_t; -/* ESP Matter Attribute Bounds */ +/** ESP Matter Attribute Bounds */ typedef struct esp_matter_attr_bounds { - /* Minimum Value */ + /** Minimum Value */ esp_matter_attr_val_t min; - /* Maximum Value */ + /** Maximum Value */ esp_matter_attr_val_t max; /** TODO: Step Value might be needed here later */ } esp_matter_attr_bounds_t; @@ -165,15 +170,70 @@ esp_matter_attr_val_t esp_matter_array(uint8_t *val, uint16_t data_size, uint16_ namespace esp_matter { namespace attribute { +/** Attribute update callback type */ +typedef enum callback_type { + /** Callback before updating the value in the database */ + PRE_UPDATE, + /** Callback after updating the value in the database */ + POST_UPDATE, +} callback_type_t; + +/** Callback for attribute update + * + * @note If the callback type is `PRE_UPDATE` and an error is returned from the callback, the attribute will + * not be updated. + * + * @param[in] type callback type. + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type. + * @param[in] priv_data Pointer to the private data passed while setting the callback. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +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); + +/** Set attribute callback + * + * Set the common attribute update callback. Whenever an attribute managed by the application is updated, the callback + * will be called with the appropriate `callback_type_t`. + * + * @param[in] callback attribute update callback. + * @param[in] priv_data (Optional) Private data associated with the callback. This will be passed to callback. It + * should stay allocated throughout the lifetime of the device. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t set_callback(callback_t callback, void *priv_data); + /** Attribute update * - * This API updates the attribute value + * This API updates the attribute value. + * After this API is called, the application gets the attribute update callback with `PRE_UPDATE`, then the + * attribute is updated in the database, then the application get the callback with `POST_UPDATE`. + * + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Appropriate elements should be used as per the value type. + * + * @return ESP_OK on success. + * @return error in case of failure. */ 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 + * This API prints the attribute value according to the type. + * + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Appropriate elements should be used as per the value type. */ void val_print(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); diff --git a/components/esp_matter/esp_matter_client.h b/components/esp_matter/esp_matter_client.h index 33bdf7e9b..336330790 100644 --- a/components/esp_matter/esp_matter_client.h +++ b/components/esp_matter/esp_matter_client.h @@ -21,6 +21,11 @@ namespace esp_matter { namespace cluster { using client::peer_device_t; +/** Specific command send APIs + * + * If some standard command is not present here, it can be added. + */ + namespace on_off { namespace command { esp_err_t send_off(peer_device_t *remote_device, int remote_endpoint_id); diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index 967e380d4..89c6fdf25 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -56,7 +56,7 @@ void plugin_init_callback_common() namespace descriptor { const function_generic_t *function_list = NULL; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, uint8_t flags) { @@ -66,11 +66,11 @@ cluster_t *create(endpoint_t *endpoint, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterDescriptorPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterDescriptorPluginClientInitCallback); } @@ -87,7 +87,7 @@ cluster_t *create(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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, uint8_t flags) { @@ -96,11 +96,11 @@ cluster_t *create(endpoint_t *endpoint, uint8_t flags) ESP_LOGE(TAG, "Could not create cluster"); return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterAccessControlPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterAccessControlPluginClientInitCallback); } @@ -116,7 +116,7 @@ namespace basic { const function_generic_t function_list[] = { (function_generic_t)emberAfBasicClusterServerInitCallback, }; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -126,11 +126,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterBasicPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterBasicPluginClientInitCallback); } @@ -156,7 +156,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) namespace binding { const function_generic_t *function_list = NULL; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -166,11 +166,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterBindingPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterBindingPluginClientInitCallback); } @@ -189,7 +189,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -199,11 +199,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterOtaSoftwareUpdateProviderPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterOtaSoftwareUpdateProviderPluginClientInitCallback); } @@ -223,7 +223,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -233,11 +233,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterOtaSoftwareUpdateRequestorPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterOtaSoftwareUpdateRequestorPluginClientInitCallback); } @@ -259,7 +259,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -269,11 +269,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterGeneralCommissioningPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterGeneralCommissioningPluginClientInitCallback); } @@ -300,7 +300,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -310,11 +310,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterNetworkCommissioningPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterNetworkCommissioningPluginClientInitCallback); } @@ -349,7 +349,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -359,11 +359,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterGeneralDiagnosticsPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterGeneralDiagnosticsPluginClientInitCallback); } @@ -380,7 +380,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -390,11 +390,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterAdministratorCommissioningPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterAdministratorCommissioningPluginClientInitCallback); } @@ -417,7 +417,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -427,11 +427,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterOperationalCredentialsPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterOperationalCredentialsPluginClientInitCallback); } @@ -467,7 +467,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) namespace group_key_management { const function_generic_t *function_list = NULL; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, uint8_t flags) { @@ -477,11 +477,11 @@ cluster_t *create(endpoint_t *endpoint, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterGroupKeyManagementPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterGroupKeyManagementPluginClientInitCallback); } @@ -509,7 +509,7 @@ 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; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -519,11 +519,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterIdentifyPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterIdentifyPluginClientInitCallback); } @@ -545,7 +545,7 @@ namespace groups { const function_generic_t function_list[] = { (function_generic_t)emberAfGroupsClusterServerInitCallback, }; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -555,11 +555,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterGroupsPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterGroupsPluginClientInitCallback); } @@ -587,7 +587,7 @@ namespace scenes { const function_generic_t function_list[] = { (function_generic_t)emberAfScenesClusterServerInitCallback, }; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -597,11 +597,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterScenesPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterScenesPluginClientInitCallback); } @@ -636,7 +636,7 @@ namespace on_off { const function_generic_t function_list[] = { (function_generic_t)emberAfOnOffClusterServerInitCallback, }; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { @@ -646,11 +646,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterOnOffPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterOnOffPluginClientInitCallback); } @@ -676,7 +676,7 @@ namespace level_control { const function_generic_t function_list[] = { (function_generic_t)emberAfLevelControlClusterServerInitCallback, }; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { @@ -686,11 +686,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterLevelControlPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterLevelControlPluginClientInitCallback); } @@ -726,7 +726,7 @@ namespace color_control { const function_generic_t function_list[] = { (function_generic_t)emberAfColorControlClusterServerInitCallback, }; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { @@ -736,11 +736,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterColorControlPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterColorControlPluginClientInitCallback); } @@ -762,7 +762,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ namespace fan_control { const function_generic_t *function_list = NULL; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -772,12 +772,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { /* not implemented: Setting NULL since the MatterFanControlPluginServerInitCallback is not implemented */ set_plugin_server_init_callback(cluster, NULL); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { /* not implemented: Setting NULL since the MatterFanControlPluginClientInitCallback is not implemented */ set_plugin_client_init_callback(cluster, NULL); } @@ -799,7 +799,7 @@ namespace thermostat { const function_generic_t function_list[] = { (function_generic_t)emberAfThermostatClusterServerInitCallback, }; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_INIT_FUNCTION; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -809,11 +809,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterThermostatPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterThermostatPluginClientInitCallback); } @@ -837,8 +837,8 @@ 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; +const int function_flags = CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION | + CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -848,11 +848,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterDoorLockPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterDoorLockPluginClientInitCallback); } @@ -875,7 +875,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -885,11 +885,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterTimeSynchronizationPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterTimeSynchronizationPluginClientInitCallback); } @@ -902,7 +902,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -912,7 +912,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { // There is not PluginServer(Client)InitCallback for this cluster add_function_list(cluster, function_list, function_flags); } @@ -928,7 +928,7 @@ cluster_t *create(endpoint_t *endpoint, 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; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -938,11 +938,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, MatterFixedLabelPluginServerInitCallback); add_function_list(cluster, function_list, function_flags); } - if (flags & ESP_MATTER_CLUSTER_FLAG_CLIENT) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterFixedLabelPluginClientInitCallback); } @@ -958,7 +958,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) namespace switch_cluster { const function_generic_t *function_list = NULL; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -968,11 +968,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & 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) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterSwitchPluginClientInitCallback); } @@ -988,7 +988,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) namespace temperature_measurement { const function_generic_t *function_list = NULL; -const int function_flags = ESP_MATTER_CLUSTER_FLAG_NONE; +const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { @@ -998,11 +998,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) return NULL; } - if (flags & ESP_MATTER_CLUSTER_FLAG_SERVER) { + if (flags & 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) { + if (flags & CLUSTER_FLAG_CLIENT) { set_plugin_client_init_callback(cluster, MatterTemperatureMeasurementPluginClientInitCallback); } diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index 87b5c41f0..361c68d37 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -21,8 +21,25 @@ namespace esp_matter { namespace cluster { +/** Common cluster plugin init callback + * + * This is the common plugin init callback which calls the plugin init callbacks in the clusters. + * + * This common API has been added so that the specific APIs in zap-generated/PluginApplicationCallbacks.h can be + * removed. + */ void plugin_init_callback_common(); +/** Specific cluster create APIs + * + * These APIs also create the mandatory attributes and commands for the cluster. If the mandatory attribute is not + * managed internally, then a config is present for that attribute. The constructor for the config will set the + * attribute to the default value from the spec. + * + * If some standard cluster is not present here, it can be added. + * If a custom cluster needs to be created, the low level esp_matter::cluster::create() API can be used. + */ + namespace descriptor { cluster_t *create(endpoint_t *endpoint, uint8_t flags); } /* descriptor */ diff --git a/components/esp_matter/esp_matter_command.cpp b/components/esp_matter/esp_matter_command.cpp index f2964e18e..e1f0570bc 100644 --- a/components/esp_matter/esp_matter_command.cpp +++ b/components/esp_matter/esp_matter_command.cpp @@ -54,7 +54,7 @@ void DispatchSingleClusterCommandCommon(const ConcreteCommandPath &command_path, err = callback(command_path, tlv_data, opaque_ptr); } int flags = get_flags(command); - if (flags & ESP_MATTER_COMMAND_FLAG_CUSTOM) { + if (flags & COMMAND_FLAG_CUSTOM) { EmberAfStatus status = (err == ESP_OK) ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); } @@ -871,39 +871,39 @@ 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, + return esp_matter::command::create(cluster, ZCL_KEY_SET_WRITE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_key_set_write); } 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, + return esp_matter::command::create(cluster, ZCL_KEY_SET_READ_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_key_set_read); } 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, + return esp_matter::command::create(cluster, ZCL_KEY_SET_REMOVE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_key_set_remove); } 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, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_key_set_read_all_indices); } command_t *create_key_set_read_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_KEY_SET_READ_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_key_set_read_all_indices_response(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); + COMMAND_FLAG_SERVER_GENERATED, NULL); } } /* command */ @@ -914,40 +914,40 @@ namespace command { command_t *create_arm_fail_safe(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_ARM_FAIL_SAFE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_ARM_FAIL_SAFE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_arm_fail_safe); } command_t *create_set_regulatory_config(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_SET_REGULATORY_CONFIG_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_set_regulatory_config); } command_t *create_commissioning_complete(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_COMMISSIONING_COMPLETE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_commissioning_complete); } command_t *create_arm_fail_safe_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ARM_FAIL_SAFE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_set_regulatory_config_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_SET_REGULATORY_CONFIG_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_commissioning_complete_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } } /* command */ @@ -958,60 +958,60 @@ namespace command { command_t *create_scan_networks(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_SCAN_NETWORKS_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_SCAN_NETWORKS_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_scan_networks); } command_t *create_add_or_update_wifi_network(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ADD_OR_UPDATE_WI_FI_NETWORK_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_add_or_update_wifi_network); } command_t *create_add_or_update_thread_network(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ADD_OR_UPDATE_THREAD_NETWORK_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_add_or_update_thread_network); } command_t *create_remove_network(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_REMOVE_NETWORK_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_REMOVE_NETWORK_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_remove_network); } command_t *create_connect_network(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_CONNECT_NETWORK_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_connect_network); } command_t *create_reorder_network(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_REORDER_NETWORK_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_reorder_network); } command_t *create_scan_networks_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_network_config_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_NETWORK_CONFIG_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_connect_network_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_CONNECT_NETWORK_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } } /* command */ @@ -1023,21 +1023,21 @@ namespace command { command_t *create_open_commissioning_window(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_OPEN_COMMISSIONING_WINDOW_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_open_commissioning_window); } command_t *create_open_basic_commissioning_window(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_OPEN_BASIC_COMMISSIONING_WINDOW_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_open_basic_commissioning_window); } command_t *create_revoke_commissioning(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_REVOKE_COMMISSIONING_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_revoke_commissioning); } @@ -1050,83 +1050,83 @@ namespace command { command_t *create_attestation_request(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ATTESTATION_REQUEST_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_attestation_request); } command_t *create_certificate_chain_request(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_CERTIFICATE_CHAIN_REQUEST_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_certificate_chain_request); } command_t *create_csr_request(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_CSR_REQUEST_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_CSR_REQUEST_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_csr_request); } command_t *create_add_noc(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_ADD_NOC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_ADD_NOC_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_add_noc); } command_t *create_update_noc(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_UPDATE_NOC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_UPDATE_NOC_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_update_noc); } command_t *create_update_fabric_label(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_update_fabric_label); } command_t *create_remove_fabric(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_REMOVE_FABRIC_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_REMOVE_FABRIC_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_remove_fabric); } command_t *create_add_trusted_root_certificate(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ADD_TRUSTED_ROOT_CERTIFICATE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_add_trusted_root_certificate); } command_t *create_remove_trusted_root_certificate(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_REMOVE_TRUSTED_ROOT_CERTIFICATE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_remove_trusted_root_certificate); } command_t *create_attestation_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ATTESTATION_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_certificate_chain_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_CERTIFICATE_CHAIN_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_csr_response(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_CSR_RESPONSE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, + return esp_matter::command::create(cluster, ZCL_CSR_RESPONSE_COMMAND_ID, COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_noc_response(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_NOC_RESPONSE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, + return esp_matter::command::create(cluster, ZCL_NOC_RESPONSE_COMMAND_ID, COMMAND_FLAG_SERVER_GENERATED, NULL); } @@ -1138,34 +1138,34 @@ namespace command { command_t *create_query_image(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_QUERY_IMAGE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_QUERY_IMAGE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_query_image); } command_t *create_apply_update_request(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_APPLY_UPDATE_REQUEST_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_apply_update_request); } command_t *create_notify_update_applied(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_NOTIFY_UPDATE_APPLIED_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_notify_update_applied); } command_t *create_query_image_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_QUERY_IMAGE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_apply_update_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_APPLY_UPDATE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } } /* command */ @@ -1177,7 +1177,7 @@ namespace command { command_t *create_announce_ota_provider(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ANNOUNCE_OTA_PROVIDER_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_announce_ota_provider); } @@ -1189,20 +1189,20 @@ namespace command { command_t *create_identify(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_IDENTIFY_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_IDENTIFY_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_identify); } command_t *create_identify_query(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_IDENTIFY_QUERY_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_IDENTIFY_QUERY_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_identify_query); } command_t *create_identify_query_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } } /* command */ @@ -1213,65 +1213,65 @@ namespace command { command_t *create_add_group(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_ADD_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_ADD_GROUP_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_add_group); } command_t *create_view_group(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_VIEW_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_VIEW_GROUP_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_view_group); } command_t *create_get_group_membership(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_GET_GROUP_MEMBERSHIP_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_get_group_membership); } command_t *create_remove_group(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_REMOVE_GROUP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_REMOVE_GROUP_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_remove_group); } command_t *create_remove_all_groups(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_REMOVE_ALL_GROUPS_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_remove_all_groups); } command_t *create_add_group_if_identifying(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_add_group_if_identifying); } command_t *create_add_group_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ADD_GROUP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_view_group_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_get_group_membership_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_remove_group_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } } /* command */ @@ -1282,82 +1282,82 @@ namespace command { command_t *create_add_scene(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_ADD_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_ADD_SCENE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_add_scene); } command_t *create_view_scene(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_VIEW_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_VIEW_SCENE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_view_scene); } command_t *create_remove_scene(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_REMOVE_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_REMOVE_SCENE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_remove_scene); } command_t *create_remove_all_scenes(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_REMOVE_ALL_SCENES_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_remove_all_scenes); } command_t *create_store_scene(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_STORE_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_STORE_SCENE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_store_scene); } command_t *create_recall_scene(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_RECALL_SCENE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_RECALL_SCENE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_recall_scene); } command_t *create_get_scene_membership(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_GET_SCENE_MEMBERSHIP_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_get_scene_membership); } command_t *create_add_scene_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ADD_SCENE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_view_scene_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_VIEW_SCENE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_remove_scene_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_REMOVE_SCENE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_remove_all_scenes_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_store_scene_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_STORE_SCENE_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } command_t *create_get_scene_membership_response(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED, NULL); + COMMAND_FLAG_SERVER_GENERATED, NULL); } } /* command */ @@ -1368,40 +1368,40 @@ namespace command { command_t *create_off(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_OFF_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_OFF_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_off); } command_t *create_on(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_ON_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_ON_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_on); } command_t *create_toggle(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_TOGGLE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_TOGGLE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_toggle); } command_t *create_off_with_effect(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_OFF_WITH_EFFECT_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_off_with_effect); } command_t *create_on_with_recall_global_scene(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_on_with_recall_global_scene); } command_t *create_on_with_timed_off(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_ON_WITH_TIMED_OFF_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_on_with_timed_off); } @@ -1413,53 +1413,53 @@ namespace command { command_t *create_move_to_level(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_MOVE_TO_LEVEL_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_MOVE_TO_LEVEL_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move_to_level); } command_t *create_move(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_MOVE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_MOVE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move); } command_t *create_step(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_STEP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_STEP_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_step); } command_t *create_stop(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_STOP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_STOP_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_stop); } command_t *create_move_to_level_with_on_off(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_MOVE_TO_LEVEL_WITH_ON_OFF_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move_to_level_with_on_off); } command_t *create_move_with_on_off(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_MOVE_WITH_ON_OFF_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move_with_on_off); } command_t *create_step_with_on_off(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_STEP_WITH_ON_OFF_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_step_with_on_off); } command_t *create_stop_with_on_off(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_STOP_WITH_ON_OFF_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_stop_with_on_off); } @@ -1471,53 +1471,53 @@ namespace command { command_t *create_move_to_hue(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_MOVE_TO_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_MOVE_TO_HUE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move_to_hue); } command_t *create_move_hue(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_MOVE_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_MOVE_HUE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move_hue); } command_t *create_step_hue(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_STEP_HUE_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_STEP_HUE_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_step_hue); } command_t *create_move_to_saturation(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_MOVE_TO_SATURATION_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move_to_saturation); } command_t *create_move_saturation(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_MOVE_SATURATION_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move_saturation); } command_t *create_step_saturation(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_STEP_SATURATION_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_step_saturation); } command_t *create_move_to_hue_and_saturation(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_move_to_hue_and_saturation); } command_t *create_stop_move_step(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_STOP_MOVE_STEP_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_STOP_MOVE_STEP_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_stop_move_step); } @@ -1530,7 +1530,7 @@ namespace command { command_t *create_setpoint_raise_lower(cluster_t *cluster) { return esp_matter::command::create(cluster, ZCL_SETPOINT_RAISE_LOWER_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_setpoint_raise_lower); } @@ -1542,13 +1542,13 @@ namespace command { command_t *create_lock_door(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_LOCK_DOOR_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_LOCK_DOOR_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_lock_door); } command_t *create_unlock_door(cluster_t *cluster) { - return esp_matter::command::create(cluster, ZCL_UNLOCK_DOOR_COMMAND_ID, ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED, + return esp_matter::command::create(cluster, ZCL_UNLOCK_DOOR_COMMAND_ID, COMMAND_FLAG_CLIENT_GENERATED, esp_matter_command_callback_unlock_door); } diff --git a/components/esp_matter/esp_matter_command.h b/components/esp_matter/esp_matter_command.h index effd844f3..350f30026 100644 --- a/components/esp_matter/esp_matter_command.h +++ b/components/esp_matter/esp_matter_command.h @@ -19,6 +19,12 @@ namespace esp_matter { namespace cluster { +/** Specific command create APIs + * + * If some standard command is not present here, it can be added. + * If a custom command needs to be created, the low level esp_matter::command::create() API can be used. + */ + namespace group_key_management { namespace command { command_t *create_key_set_write(cluster_t *cluster); diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index f56a4c557..dcd882c20 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -148,7 +148,7 @@ static esp_err_t free_default_value(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) { + if (current_attribute->flags & ATTRIBUTE_FLAG_MIN_MAX) { if (current_attribute->default_value_size > 2) { if (current_attribute->default_value.ptrToMinMaxValue->defaultValue.ptrToDefaultValue) { free((void *)current_attribute->default_value.ptrToMinMaxValue->defaultValue.ptrToDefaultValue); @@ -214,7 +214,7 @@ static esp_err_t set_default_value_from_current_val(attribute_t *attribute) get_data_from_attr_val(val, &attribute_type, &attribute_size, NULL); /* Get and set value */ - if (current_attribute->flags & ESP_MATTER_ATTRIBUTE_FLAG_MIN_MAX) { + if (current_attribute->flags & ATTRIBUTE_FLAG_MIN_MAX) { EmberAfAttributeMinMaxValue *temp_value = (EmberAfAttributeMinMaxValue *)calloc(1, sizeof(EmberAfAttributeMinMaxValue)); if (!temp_value) { @@ -362,7 +362,7 @@ esp_err_t enable(endpoint_t *endpoint) _command_t *command = NULL; int command_count = 0; int command_index = 0; - int command_flag = ESP_MATTER_COMMAND_FLAG_NONE; + int command_flag = COMMAND_FLAG_NONE; int endpoint_index = 0; int default_device_version = 1; @@ -401,12 +401,12 @@ esp_err_t enable(endpoint_t *endpoint) command = NULL; command_count = 0; command_index = 0; - command_flag = ESP_MATTER_COMMAND_FLAG_NONE; + command_flag = COMMAND_FLAG_NONE; client_generated_command_ids = NULL; server_generated_command_ids = NULL; /* Client Generated Commands */ - command_flag = ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED; + command_flag = COMMAND_FLAG_CLIENT_GENERATED; command = cluster->command_list; command_count = command::get_count(command, command_flag); if (command_count > 0) { @@ -428,7 +428,7 @@ esp_err_t enable(endpoint_t *endpoint) } /* Server Generated Commands */ - command_flag = ESP_MATTER_COMMAND_FLAG_SERVER_GENERATED; + command_flag = COMMAND_FLAG_SERVER_GENERATED; command = cluster->command_list; command_count = command::get_count(command, command_flag); if (command_count > 0) { @@ -690,7 +690,7 @@ attribute_t *create(cluster_t *cluster, int attribute_id, uint8_t flags, esp_mat /* Set */ attribute->attribute_id = attribute_id; attribute->flags = flags; - attribute->flags |= ESP_MATTER_ATTRIBUTE_FLAG_EXTERNAL_STORAGE; + attribute->flags |= ATTRIBUTE_FLAG_EXTERNAL_STORAGE; set_val((attribute_t *)attribute, &val); set_default_value_from_current_val((attribute_t *)attribute); @@ -863,7 +863,7 @@ esp_err_t add_bounds(attribute_t *attribute, esp_matter_attr_val_t min, esp_matt } memcpy((void *)¤t_attribute->bounds->min, (void *)&min, sizeof(esp_matter_attr_val_t)); memcpy((void *)¤t_attribute->bounds->max, (void *)&max, sizeof(esp_matter_attr_val_t)); - current_attribute->flags |= ESP_MATTER_ATTRIBUTE_FLAG_MIN_MAX; + current_attribute->flags |= ATTRIBUTE_FLAG_MIN_MAX; /* Set the default value again after setting the bounds and the flag */ set_default_value_from_current_val(attribute); @@ -1220,8 +1220,8 @@ esp_err_t destroy(node_t *node, 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"); + if (!(_endpoint->flags & ENDPOINT_FLAG_DESTROYABLE)) { + ESP_LOGE(TAG, "This endpoint cannot be deleted since the ENDPOINT_FLAG_DESTROYABLE is not set"); return ESP_FAIL; } diff --git a/components/esp_matter/esp_matter_core.h b/components/esp_matter/esp_matter_core.h index 56bbcb5e2..27b72da01 100644 --- a/components/esp_matter/esp_matter_core.h +++ b/components/esp_matter/esp_matter_core.h @@ -26,117 +26,654 @@ using chip::TLV::TLVReader; namespace esp_matter { +/** Generic handle */ typedef size_t handle_t; +/** Node handle */ typedef handle_t node_t; +/** Endpoint handle */ typedef handle_t endpoint_t; +/** Cluster handle */ typedef handle_t cluster_t; +/** Attribute handle */ typedef handle_t attribute_t; +/** Command handle */ typedef handle_t command_t; +/** Event callback + * + * @param[in] event event data pointer. + * @param[in] arg Pointer to the private data passed while setting the callback. + */ +/** TODO: Change this */ 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 +/** ESP Matter Start + * + * Initialize and start the matter thread. + * + * @param[in] callback event callback. * * @return ESP_OK on success. * @return error in case of failure. */ -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); +esp_err_t start(event_callback_t callback); +namespace lock { + +/** Lock status */ +typedef enum status { + /** Lock failed */ + FAILED, + /** Lock was already taken */ + ALREADY_TAKEN, + /** Lock success */ + SUCCESS, +} status_t; + +/** Stack lock + * + * This API should be called before calling any upstream APIs. + * + * @param[in] ticks_to_wait number of ticks to wait for trying to take the lock. Accepted values: 0 to portMAX_DELAY. + * + * @return FAILED if the lock was not taken within the specified ticks. + * @return ALREADY_TAKEN if the lock was already taken by the same task context. + * @return SUCCESS if the lock was taken successfully. + */ +status_t chip_stack_lock(uint32_t ticks_to_wait); + +/** Stack unlock + * + * This API should be called after the upstream APIs have been done calling. + * + * @note: This should only be called if `chip_stack_lock()` returns `SUCCESS`. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t chip_stack_unlock(); + +} /* lock */ + +namespace node { + +/** Create raw node + * + * @return Node handle on success. + * @return NULL in case of failure. + */ +node_t *create_raw(); + +/** Get node + * + * @return Node handle on success. + * @return NULL in case of failure. + */ +node_t *get(); + +} /* node */ + +namespace endpoint { + +/** Create endpoint + * + * This will create a new endpoint with a unique endpoint_id and add the endpoint to the node. + * + * @param[in] node Node handle. + * @param[in] flags Bitmap of `endpoint_flags_t`. + * + * @return Endpoint handle on success. + * @return NULL in case of failure. + */ +endpoint_t *create(node_t *node, uint8_t flags); + +/** Destroy endpoint + * + * This will destroy the endpoint which has been created and added to the node. It also destroys the associated + * clusters, attributes and commands. + * + * @param[in] node Node handle. + * @param[in] endpoint Endpoint handle. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t destroy(node_t *node, endpoint_t *endpoint); + +/** Get endpoint + * + * Get the endpoint present on the node. + * + * @param[in] node Node handle. + * @param[in] endpoint_id Endpoint ID of the endpoint. + * + * @return Endpoint handle on success. + * @return NULL in case of failure. + */ +endpoint_t *get(node_t *node, int endpoint_id); + +/** Get first endpoint + * + * Get the first endpoint present on the node. + * + * @param[in] node Node handle. + * + * @return Endpoint handle on success. + * @return NULL in case of failure. + */ +endpoint_t *get_first(node_t *node); + +/** Get next endpoint + * + * Get the next endpoint present on the node. + * + * @param[in] endpoint Endpoint handle. + * + * @return Endpoint handle on success. + * @return NULL in case of failure. + */ +endpoint_t *get_next(endpoint_t *endpoint); + +/** Get endpoint ID + * + * Get the endpoint ID for the endpoint. + * + * @param[in] endpoint Endpoint handle. + * + * @return Endpoint ID on success. + * @return -1 in case of failure. + */ +int get_id(endpoint_t *endpoint); + +/** Set device type ID + * + * Set the device type ID for the endpoint. + * + * @param[in] endpoint Endpoint handle. + * @param[in] device_type_id Device type ID. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t set_device_type_id(endpoint_t *endpoint, int device_type_id); + +/** Get device type ID + * + * Get the device type ID for the endpoint. + * + * @param[in] endpoint_id Endpoint ID for the endpoint. + * + * @return device type ID on success. + * @return 0xFFFF in case of failure or if the device type ID was not set. + */ +int get_device_type_id(int endpoint_id); + +/** Enable endpoint + * + * Enable the endpoint which has been previously created. + * + * @note: This API 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. + * + * @param[in] endpoint Endpoint handle. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t enable(endpoint_t *endpoint); + +} /* endpoint */ + +namespace cluster { + +/** Cluster plugin server init callback + * + * This callback will be called when the endpoints are initialised. This should be set to upstream's + * `MatterPluginServerInitCallback` API, if it exists. + */ +typedef void (*plugin_server_init_callback_t)(); + +/** Cluster plugin client init callback + * + * This callback will be called when the endpoints are initialised. This should be set to upstream's + * `MatterPluginClientInitCallback` API, if it exists. + */ +typedef void (*plugin_client_init_callback_t)(); + +/** Generic function + * + * This can be used to add additional functions based on `cluster_flags_t`. + */ +typedef void (*function_generic_t)(); + +/** Create cluster + * + * This will create a new cluster and add it to the endpoint. + * + * @param[in] endpoint Endpoint handle. + * @param[in] cluster_id Cluster ID for the cluster. + * @param[in] flags Bitmap of `cluster_flags_t`. + * + * @return Cluster handle on success. + * @return NULL in case of failure. + */ +cluster_t *create(endpoint_t *endpoint, int cluster_id, uint8_t flags); + +/** Get cluster + * + * Get the cluster present on the endpoint. + * + * @param[in] endpoint Endpoint handle. + * @param[in] cluster_id Cluster ID for the cluster. + * + * @return Cluster handle on success. + * @return NULL in case of failure. + */ +cluster_t *get(endpoint_t *endpoint, int cluster_id); + +/** Get first cluster + * + * Get the first cluster present on the endpoint. + * + * @param[in] endpoint Endpoint handle. + * + * @return Cluster handle on success. + * @return NULL in case of failure. + */ +cluster_t *get_first(endpoint_t *endpoint); + +/** Get next cluster + * + * Get the next cluster present on the endpoint. + * + * @param[in] cluster Cluster handle. + * + * @return Cluster handle on success. + * @return NULL in case of failure. + */ +cluster_t *get_next(cluster_t *cluster); + +/** Get cluster ID + * + * Get the cluster ID for the cluster. + * + * @param[in] cluster Cluster handle. + * + * @return Cluster ID on success. + * @return -1 in case of failure. + */ +int get_id(cluster_t *cluster); + +/** Set cluster plugin server init callback + * + * Set the cluster plugin server init callback. This callback will be called when the endpoints are initialised. The + * callback should be set to upstream's `MatterPluginServerInitCallback` API for the cluster, if it + * exists. + * + * @param[in] cluster Cluster handle. + * @param[in] callback Plugin server init callback. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t set_plugin_server_init_callback(cluster_t *cluster, plugin_server_init_callback_t callback); + +/** Set cluster plugin client init callback + * + * Set the cluster plugin client init callback. This callback will be called when the endpoints are initialised. The + * callback should be set to upstream's `MatterPluginClientInitCallback` API for the cluster, if it + * exists. + * + * @param[in] cluster Cluster handle. + * @param[in] callback Plugin client init callback. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t set_plugin_client_init_callback(cluster_t *cluster, plugin_client_init_callback_t callback); + +/** Get cluster plugin server init callback + * + * Get the cluster plugin server init callback which has previously been set. + * + * @param[in] cluster Cluster handle. + * + * @return Plugin server init callback. + * @return NULL in case of failure or if it has not been set. + */ +plugin_server_init_callback_t get_plugin_server_init_callback(cluster_t *cluster); + +/** Get cluster plugin client init callback + * + * Get the cluster plugin client init callback which has previously been set. + * + * @param[in] cluster Cluster handle. + * + * @return Plugin client init callback. + * @return NULL in case of failure or if it has not been set. + */ +plugin_client_init_callback_t get_plugin_client_init_callback(cluster_t *cluster); + +/** Add cluster function list + * + * This API can be used to add additional cluster functions based on `cluster_flags_t`. This should be set + * to upstream's `MatterServerCallback` or + * `emberAfServerCallback` API, if it exists. The corresponding function_flags must be be + * set. + * + * @param[in] cluster Cluster handle. + * @param[in] function_list Array of function_generic_t. + * @param[in] function_flags Bitmap of cluster flags corresponding to the function_list. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t add_function_list(cluster_t *cluster, const function_generic_t *function_list, int function_flags); + +} /* cluster */ + +namespace attribute { + +/** Create attribute + * + * This will create a new attribute and add it to the cluster. + * + * @param[in] cluster Cluster handle. + * @param[in] attribute_id Attribute ID for the attribute. + * @param[in] flags Bitmap of `attribute_flags_t`. + * @param[in] val Default type and value of the attribute. Use appropriate elements as per the value type. + * + * @return Attribute handle on success. + * @return NULL in case of failure. + */ attribute_t *create(cluster_t *cluster, int attribute_id, uint8_t flags, esp_matter_attr_val_t val); + +/** Get attribute + * + * Get the attribute present on the cluster. + * + * @param[in] cluster Cluster handle. + * @param[in] attribute_id Attribute ID for the attribute. + * + * @return Attribute handle on success. + * @return NULL in case of failure. + */ attribute_t *get(cluster_t *cluster, int attribute_id); + +/** Get first attribute + * + * Get the first attribute present on the cluster. + * + * @param[in] cluster Cluster handle. + * + * @return Attribute handle on success. + * @return NULL in case of failure. + */ attribute_t *get_first(cluster_t *cluster); + +/** Get next attribute + * + * Get the next attribute present on the cluster. + * + * @param[in] attribute Attribute handle. + * + * @return Attribute handle on success. + * @return NULL in case of failure. + */ attribute_t *get_next(attribute_t *attribute); + +/** Get attribute ID + * + * Get the attribute ID for the attribute. + * + * @param[in] attribute Attribute handle. + * + * @return Attribute ID on success. + * @return -1 in case of failure. + */ int get_id(attribute_t *attribute); -/** Attribute val APIs */ +/** Set attribute val + * + * Set/Update the value of the attribute in the database. + * + * @note: Once `esp_matter::start()` is done, `attribute::update()` should be used to update the attribute value. + * + * @param[in] attribute Attribute handle. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t set_val(attribute_t *attribute, esp_matter_attr_val_t *val); + +/** Get attribute val + * + * Get the value of the attribute from the database. + * + * @param[in] attribute Attribute handle. + * @param[out] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t get_val(attribute_t *attribute, esp_matter_attr_val_t *val); + +/** Get attribute val raw + * + * Get the value of the attribute in the database, without the attribute handle. + * + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[out] value Pointer to an allocated buffer for the attribute value. + * @param[in] attribute_size Size of the allocated buffer. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t get_val_raw(int endpoint_id, int cluster_id, int attribute_id, uint8_t *value, uint16_t attribute_size); + +/** Add attribute bounds + * + * Add bounds to the attribute. Bounds cannot be added to string/array type attributes. + * + * @param[in] attribute Attribute handle. + * @param[in] min Minimum allowed value. + * @param[in] max Maximum allowed value. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t add_bounds(attribute_t *attribute, esp_matter_attr_val_t min, esp_matter_attr_val_t max); + +/** Get attribute bounds + * + * Get the bounds which have been added to the attribute. + * + * @param[in] attribute Attribute handle. + * + * @return Pointer to the attribute bounds structure. + * @return NULL in case of failure or if the bounds were not added. + */ esp_matter_attr_bounds_t *get_bounds(attribute_t *attribute); } /* attribute */ namespace command { + +/** Command callback + * + * Command callback which is called when the command is invoked. + * + * @note: If the `COMMAND_FLAG_CUSTOM` is set, the default command response is sent internally based on the + * return value from the callback. + * + * @param[in] command_path Common structure for endpoint, cluster and commands IDs. + * @param[in] tlv_data Command data in TLV format. + * @param[in] opaque_ptr This is a pointer which is used internally. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ typedef esp_err_t (*callback_t)(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *opaque_ptr); +/** Create command + * + * This will create a new command and add it to the cluster. + * + * @note: For commands which are not defined in the spec the `COMMAND_FLAG_CUSTOM` flag must be set. This + * will send the command response internally, after the command callback is called. + * + * @param[in] cluster Cluster handle. + * @param[in] command_id Command ID for the command. + * @param[in] flags Bitmap of `command_flags_t`. + * @param[in] callback Command callback + * + * @return Command handle on success. + * @return NULL in case of failure. + */ command_t *create(cluster_t *cluster, int command_id, uint8_t flags, callback_t callback); + +/** Get command + * + * Get the command present on the cluster. + * + * @param[in] cluster Cluster handle. + * @param[in] command_id Command ID for the command. + * + * @return Command handle on success. + * @return NULL in case of failure. + */ command_t *get(cluster_t *cluster, int command_id); + +/** Get first command + * + * Get the first command present on the cluster. + * + * @param[in] cluster Cluster handle. + * + * @return Command handle on success. + * @return NULL in case of failure. + */ command_t *get_first(cluster_t *cluster); + +/** Get next command + * + * Get the next command present on the cluster. + * + * @param[in] command Command handle. + * + * @return Command handle on success. + * @return NULL in case of failure. + */ command_t *get_next(command_t *command); + +/** Get command ID + * + * Get the command ID for the command. + * + * @param[in] command Command handle. + * + * @return Command ID on success. + * @return -1 in case of failure. + */ int get_id(command_t *command); + +/** Get command callback + * + * Get the command callback for the command. + * + * @param[in] command Command handle. + * + * @return Command callback on success. + * @return NULL in case of failure or if the callback was not set when creating the command. + */ callback_t get_callback(command_t *command); + +/** Get command flags + * + * Get the command flags for the command. + * + * @param[in] command Command handle. + * + * @return Command flags. + */ int get_flags(command_t *command); } /* command */ /* Client APIs */ namespace client { + +/** Peer device handle */ typedef chip::DeviceProxy peer_device_t; + +/** Command send callback + * + * This callback will be called when `connect()` or `cluster_update()` is called and the connection completes. The + * send_command APIs can then be called from the callback. + * + * @param[in] peer_device Peer device handle. This can be passed to the send_command APIs. + * @param[in] remote_endpoint_id Endpoint ID of the other device. This can be passed to the send_command APIs. + * @param[in] priv_data (Optional) Private data associated with the callback. This will be passed to callback. It + * should stay allocated throughout the lifetime of the device. + */ typedef void (*command_callback_t)(peer_device_t *peer_device, int remote_endpoint_id, void *priv_data); +/** Initialize binding + * + * This should be called if the Binding cluster has been created. It just sets a flag for the binding manager to be + * initialized. + * If the cluster::binding::create() is being used, this is called internally. + */ void binding_init(); + +/** Initialize binding manager + * + * This initializes the binding manager. It is called after the matter thread has been started. + */ void binding_manager_init(); + +/** Connect + * + * Connect to another device on the same fabric to send a command. + * + * @param[in] fabric_index Fabric index. + * @param[in] node_id Node ID of the other device. + * @param[in] remote_endpoint_id Endpoint ID of the other device. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t connect(int fabric_index, int node_id, int remote_endpoint_id); + +/** Set command send callback + * + * Set the common command send callback. This callback will be called when `connect()` or `cluster_update()` is called + * and the connection completes. + * + * @param[in] callback command send callback. + * @param[in] priv_data (Optional) Private data associated with the callback. This will be passed to callback. It + * should stay allocated throughout the lifetime of the device. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t set_command_callback(command_callback_t callback, void *priv_data); + +/** Cluster update + * + * For an already binded device, this API can be used to get the command send callback, and the send_command APIs can + * then be called from the callback. + * + * @param[in] endpoint_id Local endpoint ID of the command. + * @param[in] cluster_id Cluster ID of the command. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ 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 c841b0a0c..003142750 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -49,18 +49,18 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); - 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); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + access_control::create(endpoint, CLUSTER_FLAG_SERVER); + basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); + ota_provider::create(endpoint, &(config->ota_provider), CLUSTER_FLAG_CLIENT); + ota_requestor::create(endpoint, &(config->ota_requestor), CLUSTER_FLAG_SERVER); + general_commissioning::create(endpoint, &(config->general_commissioning), CLUSTER_FLAG_SERVER); + network_commissioning::create(endpoint, &(config->network_commissioning), CLUSTER_FLAG_SERVER); + general_diagnostics::create(endpoint, &(config->general_diagnostics), 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); + CLUSTER_FLAG_SERVER); + operational_credentials::create(endpoint, &(config->operational_credentials), CLUSTER_FLAG_SERVER); + group_key_management::create(endpoint, CLUSTER_FLAG_SERVER); return endpoint; } @@ -81,12 +81,12 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_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()); - basic::create(endpoint, &(config->basic), ESP_MATTER_CLUSTER_FLAG_SERVER); - descriptor::create(endpoint, ESP_MATTER_CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); + scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); return endpoint; } @@ -107,14 +107,14 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_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, + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); + scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + level_control::create(endpoint, &(config->level_control), 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); + basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); return endpoint; } @@ -135,15 +135,15 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_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, + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); + scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + level_control::create(endpoint, &(config->level_control), 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, + basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER, color_control::feature::hue_saturation::get_id()); return endpoint; @@ -165,13 +165,13 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); - 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); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_CLIENT); + scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_CLIENT); + on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); + basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); return endpoint; } @@ -192,10 +192,10 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); - 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); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + fan_control::create(endpoint, &(config->fan_control), CLUSTER_FLAG_SERVER); return endpoint; } @@ -216,12 +216,12 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_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); - 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); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); + scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); + basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + cluster::thermostat::create(endpoint, &(config->thermostat), CLUSTER_FLAG_SERVER); return endpoint; } @@ -236,7 +236,7 @@ int get_device_type_id() endpoint_t *create(node_t *node, config_t *config, uint8_t flags) { // bridged node endpoints are always deletable - endpoint_t *endpoint = endpoint::create(node, flags | ESP_MATTER_ENDPOINT_FLAG_DELETABLE); + endpoint_t *endpoint = endpoint::create(node, flags | ENDPOINT_FLAG_DESTROYABLE); if (!endpoint) { ESP_LOGE(TAG, "Could not create endpoint"); return NULL; @@ -244,9 +244,9 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) set_device_type_id(endpoint, get_device_type_id()); - 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); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + bridged_device_basic::create(endpoint, &(config->bridged_device_basic), CLUSTER_FLAG_SERVER); + fixed_label::create(endpoint, &(config->fixed_label), CLUSTER_FLAG_SERVER); return endpoint; } @@ -268,10 +268,10 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) set_device_type_id(endpoint, get_device_type_id()); - 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); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + cluster::door_lock::create(endpoint, &(config->door_lock), CLUSTER_FLAG_SERVER); + time_synchronization::create(endpoint, &(config->time_synchronization), CLUSTER_FLAG_SERVER); return endpoint; } @@ -292,9 +292,9 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); - 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); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_CLIENT); + temperature_measurement::create(endpoint, &(config->temperature_measurement), CLUSTER_FLAG_SERVER); return endpoint; } @@ -313,7 +313,7 @@ node_t *create(config_t *config, attribute::callback_t callback, void *priv_data return NULL; } - endpoint::root_node::create(node, &(config->root_node), ESP_MATTER_ENDPOINT_FLAG_NONE); + endpoint::root_node::create(node, &(config->root_node), ENDPOINT_FLAG_NONE); return node; } diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index 7dcf1873d..adba5b3fc 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -20,6 +20,15 @@ namespace esp_matter { using namespace cluster; +/** Specific endpoint (device type) create APIs + * + * These APIs also create the mandatory clusters and the mandatory attributes and commands for the clusters. + * The configs has the cluster configs for the mandatory clusters, if it exists. + * + * If some standard endpoint (device type) is not present here, it can be added. + * If a custom endpoint needs to be created, the low level esp_matter::endpoint::create() API can be used. + */ + namespace endpoint { namespace root_node { typedef struct config { @@ -151,6 +160,12 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags); } /* endpoint */ namespace node { +/** Standard node create + * + * This creates the node, sets the attribute callback and also adds the root node device type, which is by default + * added to endpoint 0 (since this is the first endpoint which is created). + */ + typedef struct config { endpoint::root_node::config_t root_node; } config_t; diff --git a/components/esp_matter/esp_matter_event.h b/components/esp_matter/esp_matter_event.h index 0ee1a8ffa..19351b160 100644 --- a/components/esp_matter/esp_matter_event.h +++ b/components/esp_matter/esp_matter_event.h @@ -25,6 +25,11 @@ namespace esp_matter { namespace cluster { +/** Specific event send APIs + * + * If some standard event is not present here, it can be added. + */ + namespace switch_cluster { namespace event { esp_err_t send_switch_latched(uint8_t new_position); diff --git a/components/esp_matter/esp_matter_feature.h b/components/esp_matter/esp_matter_feature.h index c6d8e786f..022c8abb2 100644 --- a/components/esp_matter/esp_matter_feature.h +++ b/components/esp_matter/esp_matter_feature.h @@ -19,6 +19,15 @@ #define ESP_MATTER_NONE_FEATURE_ID 0x0000 +/** Specific feature APIs + * + * These APIs also create the mandatory attributes and commands for the cluster for that particular feature. If the + * mandatory attribute is not managed internally, then a config is present for that attribute. The constructor for the + * config will set the attribute to the default value from the spec. + * + * If some standard feature is not present here, it can be added. + */ + namespace esp_matter { namespace cluster { diff --git a/components/esp_matter_bridge/esp_matter_bridge.cpp b/components/esp_matter_bridge/esp_matter_bridge.cpp index 22cb9b0f3..6bb12d7e7 100644 --- a/components/esp_matter_bridge/esp_matter_bridge.cpp +++ b/components/esp_matter_bridge/esp_matter_bridge.cpp @@ -28,7 +28,7 @@ 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; bridged_node::config_t bridged_node_config; - dev->endpoint = bridged_node::create(node, &bridged_node_config, ESP_MATTER_ENDPOINT_FLAG_DELETABLE); + dev->endpoint = bridged_node::create(node, &bridged_node_config, ENDPOINT_FLAG_DESTROYABLE); if (!(dev->endpoint)) { ESP_LOGE(TAG, "Could not create esp_matter endpoint for bridged device"); free(dev); diff --git a/components/esp_matter_rainmaker/esp_matter_rainmaker.cpp b/components/esp_matter_rainmaker/esp_matter_rainmaker.cpp index 6dd9b6d0a..ccd20381f 100644 --- a/components/esp_matter_rainmaker/esp_matter_rainmaker.cpp +++ b/components/esp_matter_rainmaker/esp_matter_rainmaker.cpp @@ -167,24 +167,24 @@ static esp_err_t rainmaker_custom_cluster_create() endpoint_t *endpoint = endpoint::get(node, ESP_MATTER_RAINMAKER_ENDPOINT_ID); /* Create custom rainmaker cluster */ - 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, + cluster_t *cluster = cluster::create(endpoint, ESP_MATTER_RAINMAKER_CLUSTER_ID, CLUSTER_FLAG_SERVER); + attribute::create(cluster, ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID, 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 */ - attribute::create(cluster, ESP_MATTER_RAINMAKER_STATUS_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + attribute::create(cluster, ESP_MATTER_RAINMAKER_STATUS_ATTRIBUTE_ID, 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}; - attribute::create(cluster, ESP_MATTER_RAINMAKER_NODE_ID_ATTRIBUTE_ID, ESP_MATTER_ATTRIBUTE_FLAG_NONE, + attribute::create(cluster, ESP_MATTER_RAINMAKER_NODE_ID_ATTRIBUTE_ID, ATTRIBUTE_FLAG_NONE, esp_matter_char_str(node_id, sizeof(node_id))); /* Create custom configuration command */ command::create(cluster, ESP_MATTER_RAINMAKER_CONFIGURATION_COMMAND_ID, - ESP_MATTER_COMMAND_FLAG_CLIENT_GENERATED | ESP_MATTER_COMMAND_FLAG_CUSTOM, + COMMAND_FLAG_CLIENT_GENERATED | COMMAND_FLAG_CUSTOM, esp_matter_rainmaker_command_callback); return ESP_OK; } diff --git a/examples/bridge_zigbee/main/app_main.cpp b/examples/bridge_zigbee/main/app_main.cpp index 91789beed..39ecadb9a 100644 --- a/examples/bridge_zigbee/main/app_main.cpp +++ b/examples/bridge_zigbee/main/app_main.cpp @@ -39,7 +39,7 @@ static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, { esp_err_t err = ESP_OK; - if (type == PRE_ATTRIBUTE) { + if (type == PRE_UPDATE) { err = zigbee_bridge_attribute_update(endpoint_id, cluster_id, attribute_id, val); } return err; diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index 6b843ec8c..2ca037137 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -41,10 +41,10 @@ static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, { esp_err_t err = ESP_OK; - if (type == PRE_ATTRIBUTE) { + if (type == PRE_UPDATE) { /* Driver update */ err = app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, val); - } else if (type == POST_ATTRIBUTE) { + } else if (type == POST_UPDATE) { /* Other ecosystems update */ } @@ -67,7 +67,7 @@ extern "C" void app_main() 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; - endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, ESP_MATTER_ENDPOINT_FLAG_NONE); + endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, 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. */ diff --git a/examples/light/main/app_priv.h b/examples/light/main/app_priv.h index 7893878ae..d5274e8f6 100644 --- a/examples/light/main/app_priv.h +++ b/examples/light/main/app_priv.h @@ -11,14 +11,17 @@ #include #include +/** Standard max values (used for remapping attributes) */ #define STANDARD_BRIGHTNESS 100 #define STANDARD_HUE 360 #define STANDARD_SATURATION 100 +/** Matter max values (used for remapping attributes) */ #define MATTER_BRIGHTNESS 254 #define MATTER_HUE 255 #define MATTER_SATURATION 255 +/** Default attribute values used during initialization */ #define DEFAULT_POWER true #define DEFAULT_BRIGHTNESS 64 #define DEFAULT_HUE 128 @@ -33,4 +36,17 @@ */ esp_err_t app_driver_init(void); +/** Driver Update + * + * This API should be called to update the driver for the attribute being updated. + * This is usually called from the common `app_attribute_update_cb()`. + * + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); diff --git a/examples/rainmaker_light/main/app_main.cpp b/examples/rainmaker_light/main/app_main.cpp index 682427456..2ebdb897a 100644 --- a/examples/rainmaker_light/main/app_main.cpp +++ b/examples/rainmaker_light/main/app_main.cpp @@ -41,10 +41,10 @@ static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, { esp_err_t err = ESP_OK; - if (type == PRE_ATTRIBUTE) { + if (type == PRE_UPDATE) { /* Driver update */ err = app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, val); - } else if (type == POST_ATTRIBUTE) { + } else if (type == POST_UPDATE) { /* Other ecosystems update */ err = app_rainmaker_attribute_update(endpoint_id, cluster_id, attribute_id, val); } @@ -68,7 +68,7 @@ extern "C" void app_main() 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; - endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, ESP_MATTER_ENDPOINT_FLAG_NONE); + endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, 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. */ diff --git a/examples/rainmaker_light/main/app_priv.h b/examples/rainmaker_light/main/app_priv.h index 7893878ae..d5274e8f6 100644 --- a/examples/rainmaker_light/main/app_priv.h +++ b/examples/rainmaker_light/main/app_priv.h @@ -11,14 +11,17 @@ #include #include +/** Standard max values (used for remapping attributes) */ #define STANDARD_BRIGHTNESS 100 #define STANDARD_HUE 360 #define STANDARD_SATURATION 100 +/** Matter max values (used for remapping attributes) */ #define MATTER_BRIGHTNESS 254 #define MATTER_HUE 255 #define MATTER_SATURATION 255 +/** Default attribute values used during initialization */ #define DEFAULT_POWER true #define DEFAULT_BRIGHTNESS 64 #define DEFAULT_HUE 128 @@ -33,4 +36,17 @@ */ esp_err_t app_driver_init(void); +/** Driver Update + * + * This API should be called to update the driver for the attribute being updated. + * This is usually called from the common `app_attribute_update_cb()`. + * + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); diff --git a/examples/rainmaker_light/main/app_rainmaker.h b/examples/rainmaker_light/main/app_rainmaker.h index d74ea6ce5..93ffe000a 100644 --- a/examples/rainmaker_light/main/app_rainmaker.h +++ b/examples/rainmaker_light/main/app_rainmaker.h @@ -34,6 +34,19 @@ esp_err_t app_rainmaker_init(void); */ esp_err_t app_rainmaker_start(void); +/** ESP RainMaker Update + * + * This API should be called to update ESP RainMaker for the attribute being updated. + * This is usually called from the common `app_attribute_update_cb()`. + * + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t app_rainmaker_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); #ifdef __cplusplus diff --git a/examples/switch/main/app_main.cpp b/examples/switch/main/app_main.cpp index 4d3ae73a9..9db0cc4fc 100644 --- a/examples/switch/main/app_main.cpp +++ b/examples/switch/main/app_main.cpp @@ -41,10 +41,10 @@ static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, { esp_err_t err = ESP_OK; - if (type == PRE_ATTRIBUTE) { + if (type == PRE_UPDATE) { /* Driver update */ err = app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, val); - } else if (type == POST_ATTRIBUTE) { + } else if (type == POST_UPDATE) { /* Other ecosystems update */ } @@ -63,7 +63,7 @@ extern "C" void app_main() node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); on_off_switch::config_t switch_config; - endpoint_t *endpoint = on_off_switch::create(node, &switch_config, ESP_MATTER_ENDPOINT_FLAG_NONE); + endpoint_t *endpoint = on_off_switch::create(node, &switch_config, 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. */ diff --git a/examples/switch/main/app_priv.h b/examples/switch/main/app_priv.h index 74d586985..6d3351821 100644 --- a/examples/switch/main/app_priv.h +++ b/examples/switch/main/app_priv.h @@ -20,4 +20,17 @@ */ esp_err_t app_driver_init(void); +/** Driver Update + * + * This API should be called to update the driver for the attribute being updated. + * This is usually called from the common `app_attribute_update_cb()`. + * + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); diff --git a/examples/zap_light/main/app_main.cpp b/examples/zap_light/main/app_main.cpp index 0c72d3c25..d6b87a27e 100644 --- a/examples/zap_light/main/app_main.cpp +++ b/examples/zap_light/main/app_main.cpp @@ -39,10 +39,10 @@ static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, { esp_err_t err = ESP_OK; - if (type == PRE_ATTRIBUTE) { + if (type == PRE_UPDATE) { /* Driver update */ err = app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, val); - } else if (type == POST_ATTRIBUTE) { + } else if (type == POST_UPDATE) { /* Other ecosystems update */ } diff --git a/examples/zap_light/main/app_priv.h b/examples/zap_light/main/app_priv.h index dbe85c504..70387a317 100644 --- a/examples/zap_light/main/app_priv.h +++ b/examples/zap_light/main/app_priv.h @@ -11,10 +11,12 @@ #include #include +/** Standard max values (used for remapping attributes) */ #define STANDARD_BRIGHTNESS 100 #define STANDARD_HUE 360 #define STANDARD_SATURATION 100 +/** Matter max values (used for remapping attributes) */ #define MATTER_BRIGHTNESS 254 #define MATTER_HUE 255 #define MATTER_SATURATION 255 @@ -28,6 +30,28 @@ */ esp_err_t app_driver_init(void); +/** Driver Update + * + * This API should be called to update the driver for the attribute being updated. + * This is usually called from the common `app_attribute_update_cb()`. + * + * @param[in] endpoint_id Endpoint ID of the attribute. + * @param[in] cluster_id Cluster ID of the attribute. + * @param[in] attribute_id Attribute ID of the attribute. + * @param[in] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val); +/** Set driver defaults + * + * Set the attribute drivers to their default values. + * This API should be called after esp_matter::start() because, for zap data model, the attribute defaults are a part + * of zap-generated and they are initialized in esp_matter::start(). + * + * @return ESP_OK on success. + * @return error in case of failure. + */ esp_err_t app_driver_attribute_set_defaults();