Skip to content

Commit

Permalink
Merge branch 'fix_zap_light' into 'main'
Browse files Browse the repository at this point in the history
Do not use minimum unused endpoint id if server instance is disabled or ESP-Matter data model is disabled

Closes CON-1120

See merge request app-frameworks/esp-matter!702
  • Loading branch information
chshu committed Apr 15, 2024
2 parents 89f47b6 + 958c7e9 commit 431c6a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions components/esp_matter/esp_matter_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ namespace node {

static _node_t *node = NULL;

#if defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTE_ENABLE_DATA_MODEL)
// If Matter server or ESP-Matter data model is not enabled. we will never use minimum unused endpoint id.
static esp_err_t store_min_unused_endpoint_id()
{
if (!node || !esp_matter_started) {
Expand Down Expand Up @@ -287,7 +289,7 @@ static esp_err_t read_min_unused_endpoint_id()
}
return err;
}

#endif // defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTE_ENABLE_DATA_MODEL)
} /* node */

namespace cluster {
Expand Down Expand Up @@ -1083,14 +1085,13 @@ esp_err_t start(event_callback_t callback, intptr_t callback_arg)
return err;
}
esp_matter_started = true;
#ifdef CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER
// If Matter server is not enabled. we will never use minimum unused endpoint id.
#if defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTE_ENABLE_DATA_MODEL)
err = node::read_min_unused_endpoint_id();
// If the min_unused_endpoint_id is not found, we will write the current min_unused_endpoint_id in nvs.
if (err == ESP_ERR_NVS_NOT_FOUND) {
err = node::store_min_unused_endpoint_id();
}
#endif
#endif // defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTE_ENABLE_DATA_MODEL)
return err;
}

Expand Down Expand Up @@ -1930,11 +1931,12 @@ endpoint_t *create(node_t *node, uint8_t flags, void *priv_data)
endpoint->parent_endpoint_id = chip::kInvalidEndpointId;
endpoint->flags = flags;
endpoint->priv_data = priv_data;

#if defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTE_ENABLE_DATA_MODEL)
/* Store */
if (esp_matter_started) {
node::store_min_unused_endpoint_id();
}
#endif // defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTE_ENABLE_DATA_MODEL)

/* Add */
_endpoint_t *previous_endpoint = NULL;
Expand Down

0 comments on commit 431c6a5

Please sign in to comment.