@@ -141,6 +141,7 @@ typedef struct _endpoint {
141141 uint16_t endpoint_id;
142142 uint8_t device_type_count;
143143 uint32_t device_type_ids[ESP_MATTER_MAX_DEVICE_TYPE_COUNT];
144+ uint8_t device_type_versions[ESP_MATTER_MAX_DEVICE_TYPE_COUNT];
144145 uint16_t flags;
145146 _cluster_t *cluster_list;
146147 EmberAfEndpointType *endpoint_type;
@@ -395,7 +396,6 @@ esp_err_t enable(endpoint_t *endpoint, uint16_t parent_endpoint_id)
395396 current_endpoint->endpoint_type = endpoint_type;
396397
397398 /* Device types */
398- int default_device_version = 1 ;
399399 EmberAfDeviceType *device_types_ptr = (EmberAfDeviceType *)calloc (current_endpoint->device_type_count , sizeof (EmberAfDeviceType));
400400 if (!device_types_ptr) {
401401 ESP_LOGE (TAG, " Couldn't allocate device_types" );
@@ -406,7 +406,7 @@ esp_err_t enable(endpoint_t *endpoint, uint16_t parent_endpoint_id)
406406 }
407407 for (size_t i = 0 ; i < current_endpoint->device_type_count ; ++i) {
408408 device_types_ptr[i].deviceId = current_endpoint->device_type_ids [i];
409- device_types_ptr[i].deviceVersion = default_device_version ;
409+ device_types_ptr[i].deviceVersion = current_endpoint-> device_type_versions [i] ;
410410 }
411411 chip::Span<EmberAfDeviceType> device_types (device_types_ptr, current_endpoint->device_type_count );
412412 current_endpoint->device_types_ptr = device_types_ptr;
@@ -1670,7 +1670,7 @@ uint16_t get_id(endpoint_t *endpoint)
16701670 return current_endpoint->endpoint_id ;
16711671}
16721672
1673- esp_err_t add_device_type_id (endpoint_t *endpoint, uint32_t device_type_id)
1673+ esp_err_t add_device_type (endpoint_t *endpoint, uint32_t device_type_id, uint8_t device_type_version )
16741674{
16751675 if (!endpoint) {
16761676 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)
16821682 return ESP_FAIL;
16831683 }
16841684 current_endpoint->device_type_ids [current_endpoint->device_type_count ] = device_type_id;
1685+ current_endpoint->device_type_versions [current_endpoint->device_type_count ] = device_type_version;
16851686 current_endpoint->device_type_count ++;
16861687 return ESP_OK;
16871688}
@@ -1701,6 +1702,21 @@ uint32_t *get_device_type_ids(endpoint_t *endpoint, uint8_t *device_type_count_p
17011702 return current_endpoint->device_type_ids ;
17021703}
17031704
1705+ uint8_t *get_device_type_versions (endpoint_t *endpoint, uint8_t *device_type_count_ptr)
1706+ {
1707+ if (!endpoint) {
1708+ ESP_LOGE (TAG, " Endpoint cannot be NULL" );
1709+ return NULL ;
1710+ }
1711+ if (!device_type_count_ptr) {
1712+ ESP_LOGE (TAG, " device type count pointer cannot be NULL" );
1713+ return NULL ;
1714+ }
1715+ _endpoint_t *current_endpoint = (_endpoint_t *)endpoint;
1716+ *device_type_count_ptr = current_endpoint->device_type_count ;
1717+ return current_endpoint->device_type_versions ;
1718+ }
1719+
17041720void *get_priv_data (uint16_t endpoint_id)
17051721{
17061722 node_t *node = node::get ();
0 commit comments