Merge branch 'fix_dynamic_ep_check' into 'main'

Fix dynamic endpoint check and added abort in examples

See merge request app-frameworks/esp-matter!607
This commit is contained in:
Hrishikesh Dhayagude
2024-02-15 18:07:36 +08:00
28 changed files with 127 additions and 152 deletions
@@ -1882,6 +1882,12 @@ endpoint_t *create(node_t *node, uint8_t flags, void *priv_data)
}
_node_t *current_node = (_node_t *)node;
if (get_count(node) >= CONFIG_ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT) {
ESP_LOGE(TAG, "Dynamic endpoint count cannot be greater than CONFIG_ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT:%u",
CONFIG_ESP_MATTER_MAX_DYNAMIC_ENDPOINT_COUNT);
return NULL;
}
/* Allocate */
_endpoint_t *endpoint = (_endpoint_t *)esp_matter_mem_calloc(1, sizeof(_endpoint_t));
if (!endpoint) {
@@ -1,7 +1,7 @@
set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console app_reset console fatfs hal)
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "."
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils"
PRIV_REQUIRES ${PRIV_REQUIRES_LIST})
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
@@ -14,6 +14,7 @@
#include <esp_matter_console.h>
#include <esp_matter_ota.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_reset.h>
#include "esp_console.h"
@@ -142,20 +143,14 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
// node handle can be used to add/modify other endpoints.
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node) {
ESP_LOGE(TAG, "Matter node creation failed");
}
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
uint8_t device_type_index;
if(esp_matter::nvs_helpers::get_device_type_from_nvs(&device_type_index) != ESP_OK) {
semaphoreHandle = xSemaphoreCreateBinary();
if (semaphoreHandle == NULL)
{
ESP_LOGE(TAG, "Failed to create semaphore %d");
}
ABORT_APP_ON_FAILURE(semaphoreHandle != nullptr, ESP_LOGE(TAG, "Failed to create semaphore"));
ESP_LOGI(TAG, "\r\n\r\nEnter command: create --device_type to get started");
example::console::init();
@@ -165,9 +160,7 @@ extern "C" void app_main()
semaphoreHandle = NULL;
example::console::deinit();
}
else
{
} else {
esp_matter::data_model::create(device_type_index);
}
@@ -183,10 +176,7 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
#if CONFIG_ENABLE_CHIP_SHELL
esp_matter::console::diagnostics_register_commands();
+2 -1
View File
@@ -1,6 +1,7 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "."
"${ESP_MATTER_PATH}/examples/common/blemesh_platform")
"${ESP_MATTER_PATH}/examples/common/blemesh_platform"
"${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+6 -14
View File
@@ -14,6 +14,7 @@
#include <esp_matter_console.h>
#include <esp_matter_ota.h>
#include <common_macros.h>
#include <app_bridged_device.h>
#include "blemesh_bridge.h"
@@ -123,31 +124,22 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
// node handle can be used to add/modify other endpoints.
node_t *node = node::create(&node_config, app_attribute_update_cb, NULL);
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node) {
ESP_LOGE(TAG, "Matter node creation failed");
}
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
aggregator::config_t aggregator_config;
endpoint_t *aggregator = endpoint::aggregator::create(node, &aggregator_config, ENDPOINT_FLAG_NONE, NULL);
if (!aggregator) {
ESP_LOGE(TAG, "Matter aggregator endpoint creation failed");
}
ABORT_APP_ON_FAILURE(aggregator != nullptr, ESP_LOGE(TAG, "Failed to create aggregator endpoint"));
aggregator_endpoint_id = endpoint::get_id(aggregator);
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
err = app_bridge_initialize(node, create_bridge_devices);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to resume the bridged endpoints: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to resume the bridged endpoints: %d", err));
#if CONFIG_ENABLE_CHIP_SHELL
esp_matter::console::diagnostics_register_commands();
+29
View File
@@ -0,0 +1,29 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <stdlib.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#define ABORT_APP_ON_FAILURE(x, ...) do { \
if (!(unlikely(x))) { \
__VA_ARGS__; \
vTaskDelay(5000 / portTICK_PERIOD_MS); \
abort(); \
} \
} while (0)
+2 -1
View File
@@ -1,5 +1,6 @@
idf_component_register(SRC_DIRS "."
INCLUDE_DIRS ".")
INCLUDE_DIRS "."
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
if(CONFIG_SPIFFS_ATTESTATION_TRUST_STORE)
spiffs_create_partition_image(paa_cert ${CMAKE_SOURCE_DIR}/paa_cert FLASH_IN_PROJECT)
+5 -12
View File
@@ -25,6 +25,7 @@
#include <esp_matter_thread_br_launcher.h>
#include <esp_ot_config.h>
#endif // CONFIG_OPENTHREAD_BORDER_ROUTER
#include <common_macros.h>
#include <app_reset.h>
#include <app/server/Server.h>
@@ -90,22 +91,14 @@ extern "C" void app_main()
// to a specific fabric.
node::config_t node_config;
node_t *node = node::create(&node_config, NULL, NULL);
if (!node) {
ESP_LOGE(TAG, "Failed to create esp_matter node");
return;
}
endpoint_t *root_endpoint = endpoint::get(node, 0);
if (!root_endpoint) {
ESP_LOGE(TAG, "Failed to create root_node endpoint");
return;
}
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
#endif // !CONFIG_ESP_MATTER_COMMISSIONER_ENABLE
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
#if CONFIG_ESP_MATTER_COMMISSIONER_ENABLE
esp_matter::lock::chip_stack_lock(portMAX_DELAY);
esp_matter::commissioner::init(5580);
+1 -1
View File
@@ -1,5 +1,5 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+6 -11
View File
@@ -15,6 +15,7 @@
#include <esp_matter_ota.h>
#include <esp_matter_attribute_utils.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_reset.h>
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
@@ -302,16 +303,13 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
on_off_light::config_t light_config;
light_config.on_off.on_off = DEFAULT_POWER;
light_config.on_off.lighting.start_up_on_off = nullptr;
endpoint_t *endpoint = on_off_light::create(node, &light_config, ENDPOINT_FLAG_NONE, NULL);
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node || !endpoint) {
ESP_LOGE(TAG, "Matter node creation failed");
}
ABORT_APP_ON_FAILURE(endpoint != nullptr, ESP_LOGE(TAG, "Failed to create on off light endpoint"));
light_endpoint_id = endpoint::get_id(endpoint);
ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id);
@@ -319,6 +317,7 @@ extern "C" void app_main()
/* Create custom badge cluster in basic-information endpoint */
uint32_t custom_cluster_id = BADGE_CLUSTER_ID;
cluster_t *badge_cluster = cluster::create(endpoint::get(node, 0x0), custom_cluster_id, CLUSTER_FLAG_SERVER);
ABORT_APP_ON_FAILURE(badge_cluster != nullptr, ESP_LOGE(TAG, "Failed to create badge cluster"));
/* Create custom attributes in badge cluster for retrieving the vcard properties */
attribute::create(badge_cluster, NAME_ATTRIBUTE_ID, ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_long_char_str("", MAX_ATTR_SIZE));
@@ -341,9 +340,7 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
/* Starting driver with default values */
if (chip::Server::GetInstance().GetFabricTable().FabricCount())
@@ -351,9 +348,7 @@ extern "C" void app_main()
#if CONFIG_ENABLE_ENCRYPTED_OTA
err = esp_matter_ota_requestor_encrypted_init(s_decryption_key, s_decryption_key_len);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialized the encrypted OTA, err: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to initialized the encrypted OTA, err: %d", err));
#endif // CONFIG_ENABLE_ENCRYPTED_OTA
#if CONFIG_ENABLE_CHIP_SHELL
@@ -1,5 +1,5 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+10 -18
View File
@@ -14,6 +14,7 @@
#include <esp_matter_console.h>
#include <esp_matter_ota.h>
#include <app_bridged_device.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_espnow.h>
#include <app_reset.h>
@@ -141,12 +142,9 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
// node handle can be used to add/modify other endpoints.
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
/* This node handle can be used to create/add other endpoints and clusters. */
if (!node) {
ESP_LOGE(TAG, "Matter node creation failed");
}
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
color_temperature_light::config_t light_config;
light_config.on_off.on_off = DEFAULT_POWER;
@@ -156,22 +154,20 @@ extern "C" void app_main()
light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature;
light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature;
light_config.color_control.color_temperature.startup_color_temperature_mireds = nullptr;
// endpoint handles can be used to add/modify clusters.
endpoint_t *endpoint = color_temperature_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle);
if (!endpoint) {
ESP_LOGE(TAG, "Matter color temperature light endpoint creation failed");
}
ABORT_APP_ON_FAILURE(endpoint != nullptr, ESP_LOGE(TAG, "Failed to create color temperature light endpoint"));
aggregator::config_t aggregator_config;
endpoint_t *aggregator = endpoint::aggregator::create(node, &aggregator_config, ENDPOINT_FLAG_NONE, NULL);
if (!aggregator) {
ESP_LOGE(TAG, "Matter aggregator endpoint creation failed");
}
ABORT_APP_ON_FAILURE(aggregator != nullptr, ESP_LOGE(TAG, "Failed to create aggregator endpoint"));
light_endpoint_id = endpoint::get_id(endpoint);
ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id);
aggregator_endpoint_id = endpoint::get_id(aggregator);
ESP_LOGI(TAG, "Switch created with endpoint id %d", aggregator_endpoint_id);
ESP_LOGI(TAG, "Aggregator created with endpoint id %d", aggregator_endpoint_id);
/* Add additional features to the node */
cluster_t *cluster = cluster::get(endpoint, ColorControl::Id);
@@ -182,14 +178,10 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
err = app_bridge_initialize(node, create_bridge_devices);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to resume the bridged endpoints: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to resume the bridged endpoints: %d", err));
app_espnow_init();
+1 -1
View File
@@ -1,5 +1,5 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+6 -4
View File
@@ -14,6 +14,7 @@
#include <esp_matter_console.h>
#include <esp_matter_ota.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_reset.h>
#include <app/util/attribute-storage.h>
@@ -202,9 +203,11 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
/* Call for Boot button */
err = create_button(NULL, node);
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to create generic switch button"));
/* Use the code snippet commented below to create more physical buttons. */
@@ -226,16 +229,15 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
SetTagList(0, chip::Span<const Descriptor::Structs::SemanticTagStruct::Type>(gEp0TagList));
SetTagList(1, chip::Span<const Descriptor::Structs::SemanticTagStruct::Type>(gEp1TagList));
nvs_handle_t handle;
nvs_open_from_partition(CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION_LABEL, "chip-factory", NVS_READWRITE, &handle);
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to open namespace:chip-factory from partition:"
CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION_LABEL ", err:%d", err));
int32_t out_value = 0;
if (nvs_get_i32(handle, "fl-sz/1", &out_value) == ESP_ERR_NVS_NOT_FOUND)
+1 -1
View File
@@ -1,5 +1,5 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+9 -11
View File
@@ -14,6 +14,7 @@
#include <esp_matter_console.h>
#include <esp_matter_ota.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_reset.h>
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
@@ -156,7 +157,10 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
// node handle can be used to add/modify other endpoints.
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
extended_color_light::config_t light_config;
light_config.on_off.on_off = DEFAULT_POWER;
@@ -166,12 +170,10 @@ extern "C" void app_main()
light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature;
light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature;
light_config.color_control.color_temperature.startup_color_temperature_mireds = nullptr;
endpoint_t *endpoint = extended_color_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle);
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node || !endpoint) {
ESP_LOGE(TAG, "Matter node creation failed");
}
// endpoint handles can be used to add/modify clusters.
endpoint_t *endpoint = extended_color_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle);
ABORT_APP_ON_FAILURE(endpoint != nullptr, ESP_LOGE(TAG, "Failed to create extended color light endpoint"));
light_endpoint_id = endpoint::get_id(endpoint);
ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id);
@@ -201,18 +203,14 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
/* Starting driver with default values */
app_driver_light_set_defaults(light_endpoint_id);
#if CONFIG_ENABLE_ENCRYPTED_OTA
err = esp_matter_ota_requestor_encrypted_init(s_decryption_key, s_decryption_key_len);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialized the encrypted OTA, err: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to initialized the encrypted OTA, err: %d", err));
#endif // CONFIG_ENABLE_ENCRYPTED_OTA
#if CONFIG_ENABLE_CHIP_SHELL
+1 -1
View File
@@ -5,7 +5,7 @@ if (CONFIG_DYNAMIC_PASSCODE_COMMISSIONABLE_DATA_PROVIDER)
endif()
idf_component_register(SRC_DIRS ${SRC_DIRS_LIST}
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+4 -8
View File
@@ -15,6 +15,7 @@
#include <esp_matter_ota.h>
#include <esp_matter_providers.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_reset.h>
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
@@ -107,14 +108,11 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
on_off_switch::config_t switch_config;
endpoint_t *endpoint = on_off_switch::create(node, &switch_config, ENDPOINT_FLAG_NONE, switch_handle);
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node || !endpoint) {
ESP_LOGE(TAG, "Matter node creation failed");
}
ABORT_APP_ON_FAILURE(endpoint != nullptr, ESP_LOGE(TAG, "Failed to create on off switch endpoint"));
/* Add group cluster to the switch endpoint */
cluster::groups::config_t groups_config;
@@ -140,9 +138,7 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
#if CONFIG_ENABLE_CHIP_SHELL
esp_matter::console::diagnostics_register_commands();
+1 -1
View File
@@ -18,7 +18,7 @@ set(exclude_srcs_list "${MATTER_SDK_PATH}/examples/all-clusters-app/all-cluste
idf_component_register(SRC_DIRS ${SRC_DIRS_LIST}
EXCLUDE_SRCS ${exclude_srcs_list}
INCLUDE_DIRS ${INCLUDE_DIRS_LIST}
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+7 -10
View File
@@ -13,6 +13,7 @@
#include <esp_matter.h>
#include <esp_matter_console.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_reset.h>
#include <static-supported-temperature-levels.h>
@@ -101,19 +102,18 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
// "Identify", "Groups", "Scenes", "Refrigerator Mode Select" and "Refrigerator Alarm" are optional cluster for refrigerator device type so we are not adding them by default.
refrigerator::config_t refrigerator_config;
endpoint_t *endpoint = refrigerator::create(node, &refrigerator_config, ENDPOINT_FLAG_NONE, NULL);
ABORT_APP_ON_FAILURE(endpoint != nullptr, ESP_LOGE(TAG, "Failed to create refrigerator endpoint"));
// "Temperature Measurement", "Refrigerator and Temperature Controlled Cabinet Mode Select" are optional cluster for temperature_controlled_cabinet device type so we are not adding them by default.
temperature_controlled_cabinet::config_t temperature_controlled_cabinet_config;
endpoint_t *endpoint1 = temperature_controlled_cabinet::create(node, &temperature_controlled_cabinet_config, ENDPOINT_FLAG_NONE, NULL);
ABORT_APP_ON_FAILURE(endpoint1 != nullptr, ESP_LOGE(TAG, "Failed to create temperature controlled cabinet endpoint"));
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node || !endpoint || !endpoint1) {
ESP_LOGE(TAG, "Matter node creation failed");
}
esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpoint1, chip::app::Clusters::TemperatureControl::Id);
// Atlest one of temperature_number and temperature_level feature is mandatory.
@@ -127,9 +127,7 @@ extern "C" void app_main()
ESP_LOGI(TAG, "Temperature controlled cabinet created with endpoint_id %d", temp_ctrl_endpoint_id);
err = set_parent_endpoint(endpoint1, endpoint);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to set parent %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to set parent endpoint, err:%d", err));
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
/* Set OpenThread platform config */
@@ -143,9 +141,8 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
chip::app::Clusters::TemperatureControl::SetInstance(&sAppSupportedTemperatureLevelsDelegate);
#if CONFIG_ENABLE_CHIP_SHELL
@@ -1,5 +1,5 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
@@ -14,6 +14,7 @@
#include <esp_matter_console.h>
#include <esp_matter_ota.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_reset.h>
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
@@ -144,15 +145,12 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
room_air_conditioner::config_t room_air_conditioner_config;
room_air_conditioner_config.on_off.on_off = DEFAULT_POWER;
endpoint_t *endpoint = room_air_conditioner::create(node, &room_air_conditioner_config, ENDPOINT_FLAG_NONE, room_air_conditioner_handle);
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node || !endpoint) {
ESP_LOGE(TAG, "Matter node creation failed");
}
ABORT_APP_ON_FAILURE(endpoint != nullptr, ESP_LOGE(TAG, "Failed to create room air conditioner endpoint"));
room_air_conditioner_endpoint_id = endpoint::get_id(endpoint);
ESP_LOGI(TAG, "Room Air Conditioner created with endpoint_id %d", room_air_conditioner_endpoint_id);
@@ -169,9 +167,7 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
/* Starting driver with default values */
app_driver_room_air_conditioner_set_defaults(room_air_conditioner_endpoint_id);
+1 -1
View File
@@ -1,5 +1,5 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+5 -8
View File
@@ -16,6 +16,7 @@
#include <esp_matter.h>
#include <esp_matter_ota.h>
#include <common_macros.h>
#include <app_priv.h>
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
#include <platform/ESP32/OpenthreadLauncher.h>
@@ -142,13 +143,11 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
endpoint::on_off_light::config_t endpoint_config;
endpoint_t *app_endpoint = endpoint::on_off_light::create(node, &endpoint_config, ENDPOINT_FLAG_NONE, NULL);
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node || !app_endpoint) {
ESP_LOGE(TAG, "Matter node creation failed");
}
ABORT_APP_ON_FAILURE(app_endpoint != nullptr, ESP_LOGE(TAG, "Failed to create on off light endpoint"));
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
/* Set OpenThread platform config */
@@ -162,7 +161,5 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
}
+1 -1
View File
@@ -1,5 +1,5 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
# We must set CHIP_ROOT to include esp32_codegen.cmake
get_filename_component(CHIP_ROOT "${MATTER_SDK_PATH}" REALPATH)
+2 -3
View File
@@ -13,6 +13,7 @@
#include <esp_matter.h>
#include <esp_matter_console.h>
#include <common_macros.h>
#include <app_priv.h>
#include <app_reset.h>
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
@@ -107,9 +108,7 @@ extern "C" void app_main()
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
/* Starting driver with default values */
app_driver_light_set_defaults(light_endpoint_id);
+1 -1
View File
@@ -1,5 +1,5 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS ".")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
+7 -16
View File
@@ -14,6 +14,7 @@
#include <esp_matter_console.h>
#include <esp_matter_ota.h>
#include <common_macros.h>
#include <app_bridged_device.h>
#include <app_zboss.h>
#include <zigbee_bridge.h>
@@ -124,30 +125,20 @@ extern "C" void app_main()
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
node::config_t node_config;
node_t *node = node::create(&node_config, app_attribute_update_cb, NULL);
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
if (!node) {
ESP_LOGE(TAG, "Matter node creation failed");
}
ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
aggregator::config_t aggregator_config;
endpoint_t *aggregator = endpoint::aggregator::create(node, &aggregator_config, ENDPOINT_FLAG_NONE, NULL);
if (!aggregator) {
ESP_LOGE(TAG, "Matter aggregator endpoint creation failed");
} else {
aggregator_endpoint_id = endpoint::get_id(aggregator);
}
ABORT_APP_ON_FAILURE(aggregator != nullptr, ESP_LOGE(TAG, "Failed to create aggregator endpoint"));
aggregator_endpoint_id = endpoint::get_id(aggregator);
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to start Matter, err:%d", err));
err = app_bridge_initialize(node, create_bridge_devices);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to resume the bridged endpoints: %d", err);
}
ABORT_APP_ON_FAILURE(err == ESP_OK, ESP_LOGE(TAG, "Failed to resume the bridged endpoints: %d", err));
#if CONFIG_ENABLE_CHIP_SHELL
esp_matter::console::diagnostics_register_commands();