Merge branch 'bridge_app' into 'main'

examples: move all the bridge apps to one directory and add a bridge_cli example for test

Closes CON-1379

See merge request app-frameworks/esp-matter!913
This commit is contained in:
Shu Chen
2024-11-05 12:29:39 +08:00
55 changed files with 270 additions and 11 deletions
+1 -1
View File
@@ -328,7 +328,7 @@ build_esp_matter_examples:
- openssl genrsa -out secure_boot_signing_key.pem 3072
# steps for external platform build for blemesh_bridge app
- cd ${ESP_MATTER_PATH}/examples/blemesh_bridge
- cd ${ESP_MATTER_PATH}/examples/bridge_apps/blemesh_bridge
- cp sdkconfig.defaults sdkconfig.defaults.backup
- cp sdkconfig.defaults.ext_plat_ci sdkconfig.defaults
@@ -955,7 +955,12 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
endpoint_t *resume(node_t *node, config_t *config, uint8_t flags, uint16_t endpoint_id, void *priv_data)
{
endpoint_t *endpoint = endpoint::resume(node, flags | ENDPOINT_FLAG_DESTROYABLE, endpoint_id, priv_data);
add(endpoint, config);
VerifyOrReturnValue(endpoint != nullptr, NULL, ESP_LOGE(TAG, "Failed to create endpoint"));
cluster_t *descriptor_cluster = descriptor::create(endpoint, &(config->descriptor), CLUSTER_FLAG_SERVER);
VerifyOrReturnValue(descriptor_cluster != nullptr, NULL, ESP_LOGE(TAG, "Failed to create descriptor cluster"));
VerifyOrReturnValue(ESP_OK == add(endpoint, config), NULL, ESP_LOGE(TAG, "Failed to add cluster"));
return endpoint;
}
} /* bridged_node */
+4 -4
View File
@@ -218,8 +218,8 @@ An example with esp_matter component is offered:
- :project_file:`Light <examples/light/README.md>`
- :project_file:`Light Switch <examples/light_switch/README.md>`
- :project_file:`Zap Light <examples/zap_light/README.md>`
- :project_file:`Zigbee Bridge <examples/zigbee_bridge/README.md>`
- :project_file:`BLE Mesh Bridge <examples/blemesh_bridge/README.md>`
- :project_file:`Zigbee Bridge <examples/bridge_apps/zigbee_bridge/README.md>`
- :project_file:`BLE Mesh Bridge <examples/bridge_apps/blemesh_bridge/README.md>`
2.2.4 Flashing the Firmware
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -440,8 +440,8 @@ for it to work. Check the "Post Commissioning Setup" section in examples for mor
- :project_file:`Light <examples/light/README.md>`
- :project_file:`Light Switch <examples/light_switch/README.md>`
- :project_file:`Zap Light <examples/zap_light/README.md>`
- :project_file:`Zigbee Bridge <examples/zigbee_bridge/README.md>`
- :project_file:`BLE Mesh Bridge <examples/blemesh_bridge/README.md>`
- :project_file:`Zigbee Bridge <examples/bridge_apps/zigbee_bridge/README.md>`
- :project_file:`BLE Mesh Bridge <examples/bridge_apps/blemesh_bridge/README.md>`
2.3.1.3 Cluster Control
^^^^^^^^^^^^^^^^^^^^^^^
+2 -2
View File
@@ -186,8 +186,8 @@ Difference between Rotating ID Unique ID and Unique ID
- :project_file:`Light <examples/light/README.md>`
- :project_file:`Light Switch <examples/light_switch/README.md>`
- :project_file:`Zap Light <examples/zap_light/README.md>`
- :project_file:`Zigbee Bridge <examples/zigbee_bridge/README.md>`
- :project_file:`BLE Mesh Bridge <examples/blemesh_bridge/README.md>`
- :project_file:`Zigbee Bridge <examples/bridge_apps/zigbee_bridge/README.md>`
- :project_file:`BLE Mesh Bridge <examples/bridge_apps/blemesh_bridge/README.md>`
A1.8 ModuleNotFoundError: No module named 'lark'
------------------------------------------------
+9 -3
View File
@@ -3,7 +3,7 @@
# Disabling the external platform builds till we fix the build problem
# due to https://github.com/project-chip/connectedhomeip/pull/30531
# JIRA tracker: CON-942
examples/blemesh_bridge:
examples/bridge_apps/blemesh_bridge:
enable:
- if: IDF_TARGET in ["esp32", "esp32c3"]
temporary: true
@@ -39,7 +39,7 @@ examples/multiple_on_off_plugin_units:
temporary: true
reason: the other targets are not tested yet
examples/esp-now_bridge_light:
examples/bridge_apps/esp-now_bridge_light:
enable:
- if: IDF_TARGET in ["esp32c3"]
temporary: true
@@ -51,7 +51,7 @@ examples/controller:
temporary: true
reason: the other targets are not tested yet
examples/zigbee_bridge:
examples/bridge_apps/zigbee_bridge:
enable:
- if: IDF_TARGET in ["esp32s3"]
temporary: true
@@ -122,3 +122,9 @@ examples/thread_border_router:
- if: IDF_TARGET in ["esp32s3"]
temporary: true
reason: the other targets are not tested yet
examples/bridge_apps/bridge_cli:
enable:
- if: IDF_TARGET in ["esp32", "esp32c3"]
temporary: true
reason: the other targets are not tested yet
@@ -0,0 +1,43 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
if(NOT DEFINED ENV{ESP_MATTER_PATH})
message(FATAL_ERROR "Please set ESP_MATTER_PATH to the path of esp-matter repo")
endif(NOT DEFINED ENV{ESP_MATTER_PATH})
if(NOT DEFINED ENV{ESP_MATTER_DEVICE_PATH})
if("${IDF_TARGET}" STREQUAL "" OR "${IDF_TARGET}" STREQUAL "esp32" OR "${IDF_TARGET}" STREQUAL "esp32c3" OR "${IDF_TARGET}" STREQUAL "esp32s3")
# use hollow device type because the iot button has a require of 'esp_adc_cal'
# which is renamed to 'esp_adc' in IDF v5.0
# TODO: set the ESP_MATTER_DEVICE_PATH to a certain target.
set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/hollow)
else()
message(FATAL_ERROR "Unsupported IDF_TARGET")
endif()
endif(NOT DEFINED ENV{ESP_MATTER_DEVICE_PATH})
set(PROJECT_VER "1.0")
set(PROJECT_VER_NUMBER 1)
set(ESP_MATTER_PATH $ENV{ESP_MATTER_PATH})
set(MATTER_SDK_PATH ${ESP_MATTER_PATH}/connectedhomeip/connectedhomeip)
# This should be done before using the IDF_TARGET variable.
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake)
set(EXTRA_COMPONENT_DIRS
"${ESP_MATTER_PATH}/examples/common"
"${MATTER_SDK_PATH}/config/esp32/components"
"${ESP_MATTER_PATH}/components"
"${ESP_MATTER_PATH}/device_hal/device"
${extra_components_dirs_append})
project(bridge_cli)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H;-fpermissive;-Wno-overloaded-virtual" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND)
# For RISCV chips, project_include.cmake sets -Wno-format, but does not clear various
# flags that depend on -Wformat
idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security;-Wno-error=cpp" APPEND)
+44
View File
@@ -0,0 +1,44 @@
# Bridge Command Line
This example demonstrates a Bridge Command Line example that can manage virtual bridged devices with device console for bridge tests.
See the [docs](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html) for more information about building and flashing the firmware.
## 1. Additional Environment Setup
No additional setup is required.
## 2. Post Commissioning Setup
Here are some console command to manage the virtual bridged devices.
- List supported bridged device types
```
matter esp bridge support
```
- Add bridged device with specific device type
```
matter esp bridge add <parent_endpoint_id> <device_type_id>
```
- Remove bridged device on an endpoint
```
matter esp bridge remove <endpoint>
```
- List all the bridged devices
```
matter esp bridge list
```
- Reset the Bridge, clear all the bridged endpoints and factory-reset
```
matter esp bridge reset
```
@@ -0,0 +1,102 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <esp_err.h>
#include <esp_log.h>
#include <nvs_flash.h>
#include <esp_matter.h>
#include <esp_matter_console.h>
#include <esp_matter_ota.h>
#include <esp_matter_console_bridge.h>
#include <common_macros.h>
static const char *TAG = "app_main";
using namespace esp_matter;
using namespace esp_matter::attribute;
using namespace esp_matter::endpoint;
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
{
switch (event->Type) {
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
ESP_LOGI(TAG, "Interface IP Address Changed");
break;
case chip::DeviceLayer::DeviceEventType::kCommissioningComplete:
ESP_LOGI(TAG, "Commissioning complete");
break;
case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired:
ESP_LOGI(TAG, "Commissioning failed, fail safe timer expired");
break;
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted:
ESP_LOGI(TAG, "Commissioning session started");
break;
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped:
ESP_LOGI(TAG, "Commissioning session stopped");
break;
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened:
ESP_LOGI(TAG, "Commissioning window opened");
break;
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed:
ESP_LOGI(TAG, "Commissioning window closed");
break;
default:
break;
}
}
// This callback is called for every attribute update. The callback implementation shall
// handle the desired attributes and return an appropriate error code. If the attribute
// is not of your interest, please do not return an error code and strictly return ESP_OK.
static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id,
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
{
esp_err_t err = ESP_OK;
if (type == PRE_UPDATE) {
ESP_LOGI(TAG, "Pre update of Endpoint 0x%x Cluster 0x%lx attribute_id 0x%lx", endpoint_id, cluster_id, attribute_id);
}
return err;
}
extern "C" void app_main()
{
esp_err_t err = ESP_OK;
/* Initialize the ESP NVS layer */
nvs_flash_init();
/* 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);
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);
ABORT_APP_ON_FAILURE(aggregator != nullptr, ESP_LOGE(TAG, "Failed to create aggregator endpoint"));
/* Matter start */
err = esp_matter::start(app_event_cb);
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();
esp_matter::console::wifi_register_commands();
esp_matter::console::bridge_register_commands();
esp_matter::console::init();
#endif
}
@@ -0,0 +1,42 @@
# Default to 921600 baud when flashing and monitoring device
CONFIG_ESPTOOLPY_BAUD_921600B=y
CONFIG_ESPTOOLPY_BAUD=921600
CONFIG_ESPTOOLPY_COMPRESSED=y
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
#enable BT
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
#disable BT connection reattempt
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n
#enable lwip ipv6 autoconfig
CONFIG_LWIP_IPV6_AUTOCONFIG=y
# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_OFFSET=0xC000
# Enable chip shell
CONFIG_ENABLE_CHIP_SHELL=y
#enable lwIP route hooks
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
# disable softap by default
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
# Disable DS Peripheral
CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n
# Enable HKDF in mbedtls
CONFIG_MBEDTLS_HKDF_C=y
# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1)
# unique local addresses for fabrics(MAX_FABRIC), a link local address(1)
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

@@ -0,0 +1,5 @@
idf_component_register(SRC_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")
@@ -0,0 +1,12 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: Firmware partition offset needs to be 64K aligned, initial 36K (9 sectors) are reserved for bootloader and partition table
esp_secure_cert, 0x3F, ,0xd000, 0x2000, encrypted
nvs, data, nvs, 0x10000, 0xE000,
nvs_keys, data, nvs_keys,, 0x1000, encrypted
otadata, data, ota, , 0x2000
phy_init, data, phy, , 0x1000,
ota_0, app, ota_0, , 0x1D0000,
ota_1, app, ota_1, , 0x1D0000,
fctry, data, nvs, , 0x6000,
zb_storage, data, fat, , 0x20000
zb_fct, data, fat, , 1K,
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: Firmware partition offset needs to be 64K aligned, initial 36K (9 sectors) are reserved for bootloader and partition table
3 esp_secure_cert, 0x3F, ,0xd000, 0x2000, encrypted
4 nvs, data, nvs, 0x10000, 0xE000,
5 nvs_keys, data, nvs_keys,, 0x1000, encrypted
6 otadata, data, ota, , 0x2000
7 phy_init, data, phy, , 0x1000,
8 ota_0, app, ota_0, , 0x1D0000,
9 ota_1, app, ota_1, , 0x1D0000,
10 fctry, data, nvs, , 0x6000,
11 zb_storage, data, fat, , 0x20000
12 zb_fct, data, fat, , 1K,