From d34c6f8dc23f2cb7f74fbfaef6c43282e3332bcd Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Mon, 26 Sep 2022 13:20:54 +0800 Subject: [PATCH] esp-matter: add device type version for all the supported device types --- components/esp_matter/esp_matter_core.cpp | 22 ++- components/esp_matter/esp_matter_core.h | 21 ++- components/esp_matter/esp_matter_endpoint.cpp | 160 +++++++++++++++--- components/esp_matter/esp_matter_endpoint.h | 20 +++ .../blemesh_bridge/main/blemesh_bridge.cpp | 3 +- examples/zigbee_bridge/main/zigbee_bridge.cpp | 3 +- 6 files changed, 200 insertions(+), 29 deletions(-) diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index d8274a32d..e15ad8a05 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -141,6 +141,7 @@ typedef struct _endpoint { uint16_t endpoint_id; uint8_t device_type_count; uint32_t device_type_ids[ESP_MATTER_MAX_DEVICE_TYPE_COUNT]; + uint8_t device_type_versions[ESP_MATTER_MAX_DEVICE_TYPE_COUNT]; uint16_t flags; _cluster_t *cluster_list; EmberAfEndpointType *endpoint_type; @@ -395,7 +396,6 @@ esp_err_t enable(endpoint_t *endpoint, uint16_t parent_endpoint_id) current_endpoint->endpoint_type = endpoint_type; /* Device types */ - int default_device_version = 1; EmberAfDeviceType *device_types_ptr = (EmberAfDeviceType *)calloc(current_endpoint->device_type_count, sizeof(EmberAfDeviceType)); if (!device_types_ptr) { ESP_LOGE(TAG, "Couldn't allocate device_types"); @@ -406,7 +406,7 @@ esp_err_t enable(endpoint_t *endpoint, uint16_t parent_endpoint_id) } for (size_t i = 0; i < current_endpoint->device_type_count; ++i) { device_types_ptr[i].deviceId = current_endpoint->device_type_ids[i]; - device_types_ptr[i].deviceVersion = default_device_version; + device_types_ptr[i].deviceVersion = current_endpoint->device_type_versions[i]; } chip::Span device_types(device_types_ptr, current_endpoint->device_type_count); current_endpoint->device_types_ptr = device_types_ptr; @@ -1670,7 +1670,7 @@ uint16_t get_id(endpoint_t *endpoint) return current_endpoint->endpoint_id; } -esp_err_t add_device_type_id(endpoint_t *endpoint, uint32_t device_type_id) +esp_err_t add_device_type(endpoint_t *endpoint, uint32_t device_type_id, uint8_t device_type_version) { if (!endpoint) { ESP_LOGE(TAG, "Endpoint cannot be NULL"); @@ -1682,6 +1682,7 @@ esp_err_t add_device_type_id(endpoint_t *endpoint, uint32_t device_type_id) return ESP_FAIL; } current_endpoint->device_type_ids[current_endpoint->device_type_count] = device_type_id; + current_endpoint->device_type_versions[current_endpoint->device_type_count] = device_type_version; current_endpoint->device_type_count++; return ESP_OK; } @@ -1701,6 +1702,21 @@ uint32_t *get_device_type_ids(endpoint_t *endpoint, uint8_t *device_type_count_p return current_endpoint->device_type_ids; } +uint8_t *get_device_type_versions(endpoint_t *endpoint, uint8_t *device_type_count_ptr) +{ + if (!endpoint) { + ESP_LOGE(TAG, "Endpoint cannot be NULL"); + return NULL; + } + if (!device_type_count_ptr) { + ESP_LOGE(TAG, "device type count pointer cannot be NULL"); + return NULL; + } + _endpoint_t *current_endpoint = (_endpoint_t *)endpoint; + *device_type_count_ptr = current_endpoint->device_type_count; + return current_endpoint->device_type_versions; +} + void *get_priv_data(uint16_t endpoint_id) { node_t *node = node::get(); diff --git a/components/esp_matter/esp_matter_core.h b/components/esp_matter/esp_matter_core.h index 0e4651ef5..0ec05fcc2 100644 --- a/components/esp_matter/esp_matter_core.h +++ b/components/esp_matter/esp_matter_core.h @@ -196,21 +196,22 @@ endpoint_t *get_next(endpoint_t *endpoint); */ uint16_t get_id(endpoint_t *endpoint); -/** Add device type ID +/** Add device type ID and verision * - * Add the device type ID for the endpoint. + * Add the device type ID and version for the endpoint. * * @param[in] endpoint Endpoint handle. * @param[in] device_type_id Device type ID. + * @parma[in] device_type_version Device type version. * * @return ESP_OK on success. * @return error in case of failure. */ -esp_err_t add_device_type_id(endpoint_t *endpoint, uint32_t device_type_id); +esp_err_t add_device_type(endpoint_t *endpoint, uint32_t device_type_id, uint8_t device_type_version); /** Get device type ID array * - * Get the device type ID array for the endpoint. + * Get the device type ID array for the endpoint. This array is aligned with the device type version array. * * @param[in] endpoint Endpoint handle. * @param[out] device_type_count_ptr the pointer of device type ID array length. @@ -220,6 +221,18 @@ esp_err_t add_device_type_id(endpoint_t *endpoint, uint32_t device_type_id); */ uint32_t *get_device_type_ids(endpoint_t *endpoint, uint8_t *device_type_count_ptr); +/** Get device type version array + * + * Get the device type version array for the endpoint. This array is aligned with the device type ID array. + * + * @param[in] endpoint Endpoint handle. + * @param[out] device_type_count_ptr the pointer of device type version array length. + * + * @return device type version array on success. + * @return NULL when the endpoint or the device_type_count_ptr is NULL. + */ +uint8_t *get_device_type_versions(endpoint_t *endpoint, uint8_t *device_type_count_ptr); + /** Get private data * * Get the private data passed while creating the endpoint. diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index a392e1903..98d86ffaa 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -18,30 +18,50 @@ /* Replace these with IDs from submodule whenever they are implemented */ #define ESP_MATTER_ROOT_NODE_DEVICE_TYPE_ID 0x0016 +#define ESP_MATTER_ROOT_NODE_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_AGGREGATOR_DEVICE_TYPE_ID 0x000E +#define ESP_MATTER_AGGREGATOR_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_BRIDGED_NODE_DEVICE_TYPE_ID 0x0013 +#define ESP_MATTER_BRIDGED_NODE_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_ID 0x0100 +#define ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID 0x0101 +#define ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_COLOR_TEMPERATURE_LIGHT_DEVICE_TYPE_ID 0x010C +#define ESP_MATTER_COLOR_TEMPERATURE_LIGHT_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_ID 0x010D +#define ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_ON_OFF_SWITCH_DEVICE_TYPE_ID 0x0103 +#define ESP_MATTER_ON_OFF_SWITCH_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_DIMMER_SWITCH_DEVICE_TYPE_ID 0x0104 +#define ESP_MATTER_DIMMER_SWITCH_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_COLOR_DIMMER_SWITCH_DEVICE_TYPE_ID 0x0105 +#define ESP_MATTER_COLOR_DIMMER_SWITCH_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_GENERIC_SWITCH_DEVICE_TYPE_ID 0x000F +#define ESP_MATTER_GENERIC_SWITCH_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_ON_OFF_PLUGIN_UNIT_DEVICE_TYPE_ID 0x010A +#define ESP_MATTER_ON_OFF_PLUGIN_UNIT_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_ID 0x010B +#define ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID 0x0302 +#define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_OCCUPANCY_SENSOR_DEVICE_TYPE_ID 0x0107 +#define ESP_MATTER_OCCUPANCY_SENSOR_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_CONTACT_SENSOR_DEVICE_TYPE_ID 0x0015 +#define ESP_MATTER_CONTACT_SENSOR_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_FAN_DEVICE_TYPE_ID 0x002B +#define ESP_MATTER_FAN_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_THERMOSTAT_DEVICE_TYPE_ID 0x0301 +#define ESP_MATTER_THERMOSTAT_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_ID 0x000A +#define ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_WINDOW_COVERING_DEVICE_TYPE_ID 0x0202 +#define ESP_MATTER_WINDOW_COVERING_DEVICE_TYPE_VERSION 2 static const char *TAG = "esp_matter_endpoint"; @@ -55,6 +75,11 @@ uint32_t get_device_type_id() return ESP_MATTER_ROOT_NODE_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_ROOT_NODE_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -62,7 +87,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); access_control::create(endpoint, CLUSTER_FLAG_SERVER); @@ -91,6 +116,11 @@ uint32_t get_device_type_id() return ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -98,7 +128,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -116,6 +146,11 @@ uint32_t get_device_type_id() return ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -123,7 +158,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -143,6 +178,11 @@ uint32_t get_device_type_id() return ESP_MATTER_COLOR_TEMPERATURE_LIGHT_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_COLOR_TEMPERATURE_LIGHT_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -150,7 +190,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -172,6 +212,11 @@ uint32_t get_device_type_id() return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -179,7 +224,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -201,6 +246,11 @@ uint32_t get_device_type_id() return ESP_MATTER_ON_OFF_SWITCH_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_ON_OFF_SWITCH_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -208,7 +258,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); @@ -225,6 +275,11 @@ uint32_t get_device_type_id() return ESP_MATTER_DIMMER_SWITCH_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_DIMMER_SWITCH_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -232,7 +287,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); @@ -250,6 +305,11 @@ uint32_t get_device_type_id() return ESP_MATTER_COLOR_DIMMER_SWITCH_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_COLOR_DIMMER_SWITCH_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -257,7 +317,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); @@ -276,6 +336,11 @@ uint32_t get_device_type_id() return ESP_MATTER_GENERIC_SWITCH_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_GENERIC_SWITCH_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -283,7 +348,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -299,6 +364,11 @@ uint32_t get_device_type_id() return ESP_MATTER_ON_OFF_PLUGIN_UNIT_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_ON_OFF_PLUGIN_UNIT_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -306,7 +376,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -324,6 +394,11 @@ uint32_t get_device_type_id() return ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -331,7 +406,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -351,6 +426,11 @@ uint32_t get_device_type_id() return ESP_MATTER_FAN_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_FAN_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -358,7 +438,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -375,6 +455,11 @@ uint32_t get_device_type_id() return ESP_MATTER_THERMOSTAT_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_THERMOSTAT_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -382,7 +467,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -398,6 +483,11 @@ uint32_t get_device_type_id() return ESP_MATTER_AGGREGATOR_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_AGGREGATOR_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -405,7 +495,7 @@ endpoint_t *create(node_t *node, uint8_t flags, void *priv_data) ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint,CLUSTER_FLAG_SERVER); @@ -419,6 +509,11 @@ uint32_t get_device_type_id() return ESP_MATTER_BRIDGED_NODE_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_BRIDGED_NODE_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { // bridged node endpoints are always deletable @@ -428,7 +523,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); bridged_device_basic::create(endpoint, &(config->bridged_device_basic), CLUSTER_FLAG_SERVER); @@ -443,6 +538,11 @@ uint32_t get_device_type_id() return ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -451,7 +551,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -467,6 +567,11 @@ uint32_t get_device_type_id() return ESP_MATTER_WINDOW_COVERING_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_WINDOW_COVERING_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void * priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -475,7 +580,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void * priv_da return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); @@ -491,6 +596,11 @@ uint32_t get_device_type_id() return ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -498,7 +608,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); temperature_measurement::create(endpoint, &(config->temperature_measurement), CLUSTER_FLAG_SERVER); @@ -513,6 +623,11 @@ uint32_t get_device_type_id() return ESP_MATTER_OCCUPANCY_SENSOR_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_OCCUPANCY_SENSOR_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -520,7 +635,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); occupancy_sensing::create(endpoint, &(config->occupancy_sensing), CLUSTER_FLAG_SERVER); @@ -535,6 +650,11 @@ uint32_t get_device_type_id() return ESP_MATTER_CONTACT_SENSOR_DEVICE_TYPE_ID; } +uint8_t get_device_type_version() +{ + return ESP_MATTER_CONTACT_SENSOR_DEVICE_TYPE_VERSION; +} + endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) { endpoint_t *endpoint = endpoint::create(node, flags, priv_data); @@ -542,7 +662,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat ESP_LOGE(TAG, "Could not create endpoint"); return NULL; } - add_device_type_id(endpoint, get_device_type_id()); + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); boolean_state::create(endpoint, &(config->boolean_state), CLUSTER_FLAG_SERVER); diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index 469cf8c5c..32370689e 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -43,6 +43,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* root_node */ @@ -55,6 +56,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* on_off_light */ @@ -68,6 +70,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* dimmable_light */ @@ -82,6 +85,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* color_temperature_light */ @@ -96,6 +100,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* extended_color_light */ @@ -106,6 +111,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* on_off_switch */ @@ -116,6 +122,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* dimmer_switch */ @@ -126,6 +133,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* color_dimmer_switch */ @@ -136,6 +144,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* generic_switch */ @@ -148,6 +157,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* on_off_plugin_unit */ @@ -161,6 +171,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* dimmable_plugin_unit */ @@ -172,6 +183,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* fan */ @@ -183,11 +195,13 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* thermostat */ namespace aggregator { uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, uint8_t flags, void *priv_data); } /* bridge */ @@ -197,6 +211,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* bridged_node */ @@ -207,6 +222,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* door_lock */ @@ -219,6 +235,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* window_covering */ @@ -229,6 +246,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* temperature_sensor */ @@ -239,6 +257,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* occupancy_sensor */ @@ -249,6 +268,7 @@ typedef struct config { } config_t; uint32_t get_device_type_id(); +uint8_t get_device_type_version(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); } /* contact_sensor */ diff --git a/examples/blemesh_bridge/main/blemesh_bridge.cpp b/examples/blemesh_bridge/main/blemesh_bridge.cpp index 643f645bd..cf971dd61 100644 --- a/examples/blemesh_bridge/main/blemesh_bridge.cpp +++ b/examples/blemesh_bridge/main/blemesh_bridge.cpp @@ -51,7 +51,8 @@ static esp_err_t blemesh_bridge_init_bridged_onoff_light(esp_matter_bridge_devic } on_off::config_t config; on_off::create(dev->endpoint, &config, CLUSTER_MASK_SERVER, ESP_MATTER_NONE_FEATURE_ID); - endpoint::add_device_type_id(dev->endpoint, endpoint::on_off_light::get_device_type_id()); + endpoint::add_device_type(dev->endpoint, endpoint::on_off_light::get_device_type_id(), + endpoint::on_off_light::get_device_type_version()); if (endpoint::enable(dev->endpoint, dev->parent_endpoint_id) != ESP_OK) { ESP_LOGE(TAG, "ESP Matter enable dynamic endpoint failed"); endpoint::destroy(dev->node, dev->endpoint); diff --git a/examples/zigbee_bridge/main/zigbee_bridge.cpp b/examples/zigbee_bridge/main/zigbee_bridge.cpp index 8f4532fd2..4f943e5db 100644 --- a/examples/zigbee_bridge/main/zigbee_bridge.cpp +++ b/examples/zigbee_bridge/main/zigbee_bridge.cpp @@ -31,7 +31,8 @@ static esp_err_t zigbee_bridge_init_bridged_onoff_light(esp_matter_bridge_device on_off::config_t config; on_off::create(dev->endpoint, &config, CLUSTER_MASK_SERVER, ESP_MATTER_NONE_FEATURE_ID); - endpoint::add_device_type_id(dev->endpoint, endpoint::on_off_light::get_device_type_id()); + endpoint::add_device_type(dev->endpoint, endpoint::on_off_light::get_device_type_id(), + endpoint::on_off_light::get_device_type_version()); if (endpoint::enable(dev->endpoint, dev->parent_endpoint_id) != ESP_OK) { ESP_LOGE(TAG, "ESP Matter enable dynamic endpoint failed"); endpoint::destroy(dev->node, dev->endpoint);