Skip to content

Commit

Permalink
Added secondary network interface device type in esp-matter
Browse files Browse the repository at this point in the history
  • Loading branch information
DejinChen committed Sep 20, 2024
1 parent 8642047 commit a33ed54
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
31 changes: 31 additions & 0 deletions components/esp_matter/esp_matter_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,37 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)

} /* thread_border_router */

namespace secondary_network_interface {
uint32_t get_device_type_id()
{
return ESP_MATTER_SECONDARY_NETWORK_INTERFACE_DEVICE_TYPE_ID;
}

uint8_t get_device_type_version()
{
return ESP_MATTER_SECONDARY_NETWORK_INTERFACE_DEVICE_TYPE_VERSION;
}

endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
{
return common::create<config_t>(node, config, flags, priv_data, add);
}

esp_err_t add(endpoint_t *endpoint, config_t *config)
{
VerifyOrReturnError(endpoint != nullptr, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Endpoint cannot be NULL"));
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err);
return err;
}

network_commissioning::create(endpoint, &(config->network_commissioning), CLUSTER_FLAG_SERVER);

return ESP_OK;
}
} /* secondary_network_interface */

} /* endpoint */

namespace node {
Expand Down
14 changes: 14 additions & 0 deletions components/esp_matter/esp_matter_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
#define ESP_MATTER_WATER_VALVE_DEVICE_TYPE_VERSION 1
#define ESP_MATTER_DEVICE_ENERGY_MANAGEMENT_DEVICE_TYPE_ID 0x050D
#define ESP_MATTER_DEVICE_ENERGY_MANAGEMENT_DEVICE_TYPE_VERSION 1
#define ESP_MATTER_SECONDARY_NETWORK_INTERFACE_DEVICE_TYPE_ID 0x0019
#define ESP_MATTER_SECONDARY_NETWORK_INTERFACE_DEVICE_TYPE_VERSION 1

#define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_ID 0x0091
#define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_VERSION 1
Expand Down Expand Up @@ -869,6 +871,18 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat
esp_err_t add(endpoint_t *endpoint, config_t *config);
} /* thread_border_router */

namespace secondary_network_interface {
typedef struct config {
cluster::descriptor::config_t descriptor;
cluster::network_commissioning::config_t network_commissioning;
} config_t;

uint32_t get_device_type_id();
uint8_t get_device_type_version();
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data);
esp_err_t add(endpoint_t *endpoint, config_t *config);
} /* secondary_network_interface */

} /* endpoint */

namespace node {
Expand Down

0 comments on commit a33ed54

Please sign in to comment.