mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Merge branch 'update_submodule_support_esp32h2' into 'main'
Submodule: Update the connectedhomeip submodule to the lastest master commit 069b09b5f3 See merge request app-frameworks/esp-matter!180
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ variables:
|
||||
# idf_v5_0 is used for zigbee_bridge example and examples of ESP32-H2
|
||||
- git clone --recursive --shallow-submodules --reference-if-able /local_references/github/ https://github.com/espressif/esp-idf.git
|
||||
- cd esp-idf
|
||||
- git checkout 047903c612e2c7212693c0861966bf7c83430ebf
|
||||
- git checkout ccdeb43cc7274a49e8dfa331de95ab06dea25183
|
||||
- git submodule update --init --recursive --depth 1
|
||||
- export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets"
|
||||
- ./install.sh
|
||||
|
||||
@@ -18,9 +18,9 @@ git clone --recursive https://github.com/espressif/esp-matter.git
|
||||
|
||||
## Supported ESP-IDF and connectedhomeip versions
|
||||
|
||||
- ESP Matter currently works with [commit 06457ae](https://github.com/project-chip/connectedhomeip/tree/06457ae) of connectedhomeip.
|
||||
- ESP Matter currently works with [commit 68dbb8f](https://github.com/project-chip/connectedhomeip/tree/68dbb8f) of connectedhomeip.
|
||||
- For Wi-Fi devices (ESP32, ESP32-C3, ESP32-S3), ESP-IDF [v4.4.2 release](https://github.com/espressif/esp-idf/releases/tag/v4.4.2) is required.
|
||||
- For Thread devices (ESP32-H2), ESP-IDF master branch at [commit 047903c](https://github.com/espressif/esp-idf/commit/047903c) should be used.
|
||||
- For Thread devices (ESP32-H2) and Zigbee Bridge example, ESP-IDF release/v5.0 branch at [commit ccdeb43](https://github.com/espressif/esp-idf/tree/ccdeb43) should be used.
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
@@ -71,7 +71,7 @@ set(INCLUDE_DIRS_LIST "."
|
||||
"${MATTER_SDK_PATH}/src"
|
||||
"${ZAP_GENERATED_PATH}/../")
|
||||
|
||||
set(REQUIRES_LIST chip bt esp_matter_console)
|
||||
set(REQUIRES_LIST chip bt esp_matter_console nvs_flash)
|
||||
|
||||
if ("${IDF_TARGET}" STREQUAL "esp32h2")
|
||||
list(APPEND REQUIRES_LIST openthread esp_matter_openthread)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS esp_matter_console.cpp esp_matter_console_diagnostics.cpp
|
||||
INCLUDE_DIRS .
|
||||
PRIV_REQUIRES chip esp32_mbedtls)
|
||||
PRIV_REQUIRES chip esp32_mbedtls esp_timer)
|
||||
|
||||
@@ -4,4 +4,4 @@ endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS .
|
||||
PRIV_REQUIRES openthread)
|
||||
PRIV_REQUIRES openthread esp_netif driver)
|
||||
|
||||
@@ -5,4 +5,4 @@ endif()
|
||||
idf_component_register(SRC_DIRS ${src_dirs}
|
||||
INCLUDE_DIRS include
|
||||
PRIV_INCLUDE_DIRS private_include
|
||||
REQUIRES lwip)
|
||||
REQUIRES lwip esp_netif)
|
||||
|
||||
Submodule connectedhomeip/connectedhomeip updated: 06457aea2d...069b09b5f3
@@ -0,0 +1,43 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) CO 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
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <iot_button.h>
|
||||
#include <led_driver.h>
|
||||
|
||||
#define LED_GPIO_PIN GPIO_NUM_8
|
||||
#define LED_CHANNEL 0 /* RMT_CHANNEL_0 */
|
||||
#define BUTTON_GPIO_PIN GPIO_NUM_9
|
||||
|
||||
static const char *TAG = "device";
|
||||
|
||||
led_driver_config_t led_driver_get_config()
|
||||
{
|
||||
led_driver_config_t config = {
|
||||
.gpio = LED_GPIO_PIN,
|
||||
.channel = LED_CHANNEL,
|
||||
};
|
||||
return config;
|
||||
}
|
||||
|
||||
button_config_t button_driver_get_config()
|
||||
{
|
||||
button_config_t config = {
|
||||
.type = BUTTON_TYPE_GPIO,
|
||||
.gpio_button_config = {
|
||||
.gpio_num = BUTTON_GPIO_PIN,
|
||||
.active_level = 0,
|
||||
}
|
||||
};
|
||||
return config;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
SET(device_type hollow)
|
||||
SET(led_type hollow_led)
|
||||
SET(button_type hollow_button)
|
||||
|
||||
SET(extra_components_dirs_append "$ENV{ESP_MATTER_DEVICE_PATH}/../../led_driver"
|
||||
"$ENV{ESP_MATTER_DEVICE_PATH}/../../button_driver/button")
|
||||
@@ -28,23 +28,37 @@ led_driver_handle_t led_driver_init(led_driver_config_t *config)
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing light driver");
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
rmt_config_t rmt_cfg = RMT_DEFAULT_CONFIG_TX(config->gpio, config->channel);
|
||||
rmt_cfg.clk_div = 2;
|
||||
err = rmt_config(&rmt_cfg);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "rmt_cfg failed");
|
||||
return NULL;
|
||||
}
|
||||
err = rmt_driver_install(rmt_cfg.channel, 0, 0);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "rmt_driver_install failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(1, (led_strip_dev_t)rmt_cfg.channel);
|
||||
led_strip_t *strip = led_strip_new_rmt_ws2812(&strip_config);
|
||||
#else
|
||||
led_strip_config_t strip_config = {
|
||||
.strip_gpio_num = config->gpio,
|
||||
.max_leds = 1,
|
||||
};
|
||||
led_strip_handle_t strip;
|
||||
err = led_strip_new_rmt_device(&strip_config, &strip);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "led_strip initializing failed");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
if (!strip) {
|
||||
ESP_LOGE(TAG, "W2812 driver install failed");
|
||||
err = ESP_FAIL;
|
||||
return NULL;
|
||||
}
|
||||
return (led_driver_handle_t)strip;
|
||||
}
|
||||
@@ -62,6 +76,7 @@ esp_err_t led_driver_set_RGB(led_driver_handle_t handle)
|
||||
ESP_LOGE(TAG, "led driver handle cannot be NULL");
|
||||
err = ESP_FAIL;
|
||||
} else {
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
led_strip_t *strip = (led_strip_t *)handle;
|
||||
err = strip->set_pixel(strip, 0, mRGB.red, mRGB.green, mRGB.blue);
|
||||
if (err != ESP_OK) {
|
||||
@@ -70,6 +85,11 @@ esp_err_t led_driver_set_RGB(led_driver_handle_t handle)
|
||||
}
|
||||
ESP_LOGI(TAG, "led set r:%d, g:%d, b:%d", mRGB.red, mRGB.green, mRGB.blue);
|
||||
err = strip->refresh(strip, 100);
|
||||
#else
|
||||
led_strip_handle_t strip = (led_strip_handle_t)handle;
|
||||
err = led_strip_set_pixel(strip, 0, mRGB.red, mRGB.green, mRGB.blue);
|
||||
err |= led_strip_refresh(strip);
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "strip_refresh failed");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ The Prerequisites for ESP-IDF and Matter:
|
||||
::
|
||||
|
||||
git clone --recursive https://github.com/espressif/esp-idf.git
|
||||
cd esp-idf; git checkout 047903c; git submodule update --init --recursive;
|
||||
cd esp-idf; git checkout ccdeb43cc7; git submodule update --init --recursive;
|
||||
./install.sh
|
||||
cd ..
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
"../common"
|
||||
"${IDF_PATH}/examples/common_components/qrcode"
|
||||
"${MATTER_SDK_PATH}/config/esp32/components"
|
||||
"${ESP_MATTER_PATH}/components"
|
||||
"${ESP_MATTER_PATH}/device_hal/device"
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <esp_bt.h>
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
#include <esp_nimble_hci.h>
|
||||
#endif
|
||||
#include <host/ble_hs.h>
|
||||
#include <nimble/nimble_port.h>
|
||||
|
||||
@@ -33,7 +35,10 @@ esp_err_t app_ble_disable()
|
||||
return ESP_FAIL;
|
||||
}
|
||||
nimble_port_deinit();
|
||||
esp_err_t err = esp_nimble_hci_and_controller_deinit();
|
||||
esp_err_t err = ESP_OK;
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
err = esp_nimble_hci_and_controller_deinit();
|
||||
#endif
|
||||
err |= esp_bt_mem_release(ESP_BT_MODE_BLE);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "BLE deinit failed");
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
qrcode: "^0.1.0"
|
||||
@@ -30,7 +30,6 @@ include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
"../common"
|
||||
"${IDF_PATH}/examples/common_components/qrcode"
|
||||
"${MATTER_SDK_PATH}/config/esp32/components"
|
||||
"${ESP_MATTER_PATH}/components"
|
||||
"${ESP_MATTER_PATH}/device_hal/device"
|
||||
@@ -38,8 +37,8 @@ set(EXTRA_COMPONENT_DIRS
|
||||
|
||||
project(light)
|
||||
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND)
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND)
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DCHIP_HAVE_CONFIG_H" 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" APPEND)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security;-Wformat=0" APPEND)
|
||||
|
||||
@@ -5,4 +5,4 @@ idf_component_register(SRC_DIRS "."
|
||||
PRIV_REQUIRES ${PRIV_REQUIRES_LIST})
|
||||
|
||||
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 14)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CONFIG_IDF_TARGET="esp32h2"
|
||||
CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2=y
|
||||
|
||||
# Default to 921600 baud when flashing and monitoring device
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
@@ -12,17 +13,12 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
|
||||
# libsodium
|
||||
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
|
||||
|
||||
|
||||
# Enable NIMBLE which is mynewt_nimble component out of bt component
|
||||
# It will be merge to bt component soon
|
||||
# NIMBLE
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=y
|
||||
CONFIG_BT_NIMBLE_EXT_ADV=n
|
||||
CONFIG_BT_NIMBLE_USE_ESP_TIMER=n
|
||||
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
|
||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
|
||||
CONFIG_BTDM_CTRL_MODE_BTDM=n
|
||||
CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70
|
||||
CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE=n
|
||||
|
||||
# FreeRTOS should use legacy API
|
||||
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
|
||||
@@ -46,6 +42,7 @@ CONFIG_LWIP_MULTICAST_PING=y
|
||||
CONFIG_MBEDTLS_HARDWARE_AES=n
|
||||
CONFIG_MBEDTLS_HARDWARE_MPI=n
|
||||
CONFIG_MBEDTLS_HARDWARE_SHA=n
|
||||
CONFIG_MBEDTLS_HARDWARE_ECC=y
|
||||
CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN=n
|
||||
CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY=n
|
||||
CONFIG_MBEDTLS_CMAC_C=y
|
||||
@@ -54,22 +51,18 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
|
||||
|
||||
# MDNS platform
|
||||
CONFIG_USE_MINIMAL_MDNS=n
|
||||
|
||||
# Increase stacks size
|
||||
CONFIG_NIMBLE_CONTROLLER_TASK_STACK_SIZE=5120
|
||||
CONFIG_NIMBLE_HOST_TASK_STACK_SIZE=5120
|
||||
|
||||
# ESP32H2 BLE using a ext 32k crystal
|
||||
CONFIG_ESP32H2_RTC_CLK_SRC_EXT_CRYS=y
|
||||
CONFIG_ENABLE_EXTENDED_DISCOVERY=y
|
||||
|
||||
# Enable OTA Requestor
|
||||
CONFIG_ENABLE_OTA_REQUESTOR=y
|
||||
|
||||
# Disable STA and AP for ESP32H2
|
||||
CONFIG_ENABLE_WIFI_STATION=n
|
||||
CONFIG_ENABLE_WIFI_AP=n
|
||||
|
||||
# Button
|
||||
CONFIG_BUTTON_PERIOD_TIME_MS=20
|
||||
CONFIG_BUTTON_LONG_PRESS_TIME_MS=5000
|
||||
|
||||
# disable chip-shell
|
||||
# chip shell includes wifi commands which will cause a compiling error of RegisterWiFicommands
|
||||
# It should be fixed on upstream repo
|
||||
CONFIG_ENABLE_CHIP_SHELL=n
|
||||
# Enable chip shell
|
||||
CONFIG_ENABLE_CHIP_SHELL=y
|
||||
|
||||
@@ -28,7 +28,6 @@ include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
"../common"
|
||||
"${IDF_PATH}/examples/common_components/qrcode"
|
||||
"${MATTER_SDK_PATH}/config/esp32/components"
|
||||
"${ESP_MATTER_PATH}/components"
|
||||
"${ESP_MATTER_PATH}/device_hal/device"
|
||||
@@ -36,8 +35,8 @@ set(EXTRA_COMPONENT_DIRS
|
||||
|
||||
project(light_switch)
|
||||
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND)
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND)
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DCHIP_HAVE_CONFIG_H" 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" APPEND)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security;;-Wformat=0" APPEND)
|
||||
|
||||
@@ -5,4 +5,4 @@ idf_component_register(SRC_DIRS "."
|
||||
PRIV_REQUIRES ${PRIV_REQUIRES_LIST})
|
||||
|
||||
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 14)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CONFIG_IDF_TARGET="esp32h2"
|
||||
CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2=y
|
||||
|
||||
# Default to 921600 baud when flashing and monitoring device
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
@@ -12,17 +13,12 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
|
||||
# libsodium
|
||||
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
|
||||
|
||||
|
||||
# Enable NIMBLE which is mynewt_nimble component out of bt component
|
||||
# It will be merge to bt component soon
|
||||
# NIMBLE
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=y
|
||||
CONFIG_BT_NIMBLE_EXT_ADV=n
|
||||
CONFIG_BT_NIMBLE_USE_ESP_TIMER=n
|
||||
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
|
||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
|
||||
CONFIG_BTDM_CTRL_MODE_BTDM=n
|
||||
CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70
|
||||
CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE=n
|
||||
|
||||
# FreeRTOS should use legacy API
|
||||
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
|
||||
@@ -46,6 +42,7 @@ CONFIG_LWIP_MULTICAST_PING=y
|
||||
CONFIG_MBEDTLS_HARDWARE_AES=n
|
||||
CONFIG_MBEDTLS_HARDWARE_MPI=n
|
||||
CONFIG_MBEDTLS_HARDWARE_SHA=n
|
||||
CONFIG_MBEDTLS_HARDWARE_ECC=y
|
||||
CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN=n
|
||||
CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY=n
|
||||
CONFIG_MBEDTLS_CMAC_C=y
|
||||
@@ -54,22 +51,18 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
|
||||
|
||||
# MDNS platform
|
||||
CONFIG_USE_MINIMAL_MDNS=n
|
||||
|
||||
# Increase stacks size
|
||||
CONFIG_NIMBLE_CONTROLLER_TASK_STACK_SIZE=5120
|
||||
CONFIG_NIMBLE_HOST_TASK_STACK_SIZE=5120
|
||||
|
||||
# ESP32H2 BLE using a ext 32k crystal
|
||||
CONFIG_ESP32H2_RTC_CLK_SRC_EXT_CRYS=y
|
||||
CONFIG_ENABLE_EXTENDED_DISCOVERY=y
|
||||
|
||||
# Enable OTA Requestor
|
||||
CONFIG_ENABLE_OTA_REQUESTOR=y
|
||||
|
||||
# Disable STA and AP for ESP32H2
|
||||
CONFIG_ENABLE_WIFI_STATION=n
|
||||
CONFIG_ENABLE_WIFI_AP=n
|
||||
|
||||
# Button
|
||||
CONFIG_BUTTON_PERIOD_TIME_MS=20
|
||||
CONFIG_BUTTON_LONG_PRESS_TIME_MS=5000
|
||||
|
||||
# disable chip-shell
|
||||
# chip shell includes wifi commands which will cause a compiling error of RegisterWiFicommands
|
||||
# It should be fixed on upstream repo
|
||||
CONFIG_ENABLE_CHIP_SHELL=n
|
||||
# Enable chip shell
|
||||
CONFIG_ENABLE_CHIP_SHELL=y
|
||||
|
||||
@@ -30,7 +30,6 @@ include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
"../common"
|
||||
"${IDF_PATH}/examples/common_components/qrcode"
|
||||
"${MATTER_SDK_PATH}/config/esp32/components"
|
||||
"${ESP_MATTER_PATH}/components"
|
||||
"${ESP_MATTER_PATH}/device_hal/device"
|
||||
@@ -38,8 +37,8 @@ set(EXTRA_COMPONENT_DIRS
|
||||
|
||||
project(zap_light)
|
||||
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND)
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND)
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DCHIP_HAVE_CONFIG_H" 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" APPEND)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security;-Wformat=0" APPEND)
|
||||
|
||||
@@ -5,4 +5,4 @@ idf_component_register(SRC_DIRS "."
|
||||
PRIV_REQUIRES ${PRIV_REQUIRES_LIST})
|
||||
|
||||
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 14)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CONFIG_IDF_TARGET="esp32h2"
|
||||
CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2=y
|
||||
|
||||
# Default to 921600 baud when flashing and monitoring device
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
@@ -12,17 +13,12 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
|
||||
# libsodium
|
||||
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
|
||||
|
||||
|
||||
# Enable NIMBLE which is mynewt_nimble component out of bt component
|
||||
# It will be merge to bt component soon
|
||||
# NIMBLE
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=y
|
||||
CONFIG_BT_NIMBLE_EXT_ADV=n
|
||||
CONFIG_BT_NIMBLE_USE_ESP_TIMER=n
|
||||
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
|
||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
|
||||
CONFIG_BTDM_CTRL_MODE_BTDM=n
|
||||
CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70
|
||||
CONFIG_DEINIT_BLE_ON_COMMISSIONING_COMPLETE=n
|
||||
|
||||
# FreeRTOS should use legacy API
|
||||
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
|
||||
@@ -46,6 +42,7 @@ CONFIG_LWIP_MULTICAST_PING=y
|
||||
CONFIG_MBEDTLS_HARDWARE_AES=n
|
||||
CONFIG_MBEDTLS_HARDWARE_MPI=n
|
||||
CONFIG_MBEDTLS_HARDWARE_SHA=n
|
||||
CONFIG_MBEDTLS_HARDWARE_ECC=y
|
||||
CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN=n
|
||||
CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY=n
|
||||
CONFIG_MBEDTLS_CMAC_C=y
|
||||
@@ -54,19 +51,18 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
|
||||
|
||||
# MDNS platform
|
||||
CONFIG_USE_MINIMAL_MDNS=n
|
||||
CONFIG_ENABLE_EXTENDED_DISCOVERY=y
|
||||
|
||||
# Increase stacks size
|
||||
CONFIG_NIMBLE_CONTROLLER_TASK_STACK_SIZE=5120
|
||||
CONFIG_NIMBLE_HOST_TASK_STACK_SIZE=5120
|
||||
# Enable OTA Requestor
|
||||
CONFIG_ENABLE_OTA_REQUESTOR=y
|
||||
|
||||
# ESP32H2 BLE using a ext 32k crystal
|
||||
CONFIG_ESP32H2_RTC_CLK_SRC_EXT_CRYS=y
|
||||
# Disable STA and AP for ESP32H2
|
||||
CONFIG_ENABLE_WIFI_STATION=n
|
||||
CONFIG_ENABLE_WIFI_AP=n
|
||||
|
||||
# Button
|
||||
CONFIG_BUTTON_PERIOD_TIME_MS=20
|
||||
CONFIG_BUTTON_LONG_PRESS_TIME_MS=5000
|
||||
|
||||
# disable chip-shell
|
||||
# chip shell includes wifi commands which will cause a compiling error of RegisterWiFicommands
|
||||
# It should be fixed on upstream repo
|
||||
CONFIG_ENABLE_CHIP_SHELL=n
|
||||
# Enable chip shell
|
||||
CONFIG_ENABLE_CHIP_SHELL=y
|
||||
|
||||
@@ -7,12 +7,11 @@ if(NOT DEFINED ENV{ESP_MATTER_PATH})
|
||||
endif(NOT DEFINED ENV{ESP_MATTER_PATH})
|
||||
|
||||
if(NOT DEFINED ENV{ESP_MATTER_DEVICE_PATH})
|
||||
if("${IDF_TARGET}" STREQUAL "esp32" OR "${IDF_TARGET}" STREQUAL "")
|
||||
set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32_devkit_c)
|
||||
elseif("${IDF_TARGET}" STREQUAL "esp32c3")
|
||||
set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32c3_devkit_m)
|
||||
elseif("${IDF_TARGET}" STREQUAL "esp32s3")
|
||||
set(ENV{ESP_MATTER_DEVICE_PATH} $ENV{ESP_MATTER_PATH}/device_hal/device/esp32s3_devkit_c)
|
||||
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()
|
||||
@@ -28,7 +27,6 @@ include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
"../common"
|
||||
"${IDF_PATH}/examples/common_components/qrcode"
|
||||
"${MATTER_SDK_PATH}/config/esp32/components"
|
||||
"${ESP_MATTER_PATH}/components"
|
||||
"${ESP_MATTER_PATH}/device_hal/device"
|
||||
@@ -40,4 +38,4 @@ idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" 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" APPEND)
|
||||
idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security;-Wformat=0;-Wno-error=cpp" APPEND)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode esp_matter_ota app_bridge
|
||||
esp-zboss-lib)
|
||||
set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode esp_matter_ota app_bridge esp-zigbee-lib)
|
||||
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
#include <esp_matter_ota.h>
|
||||
#include <esp_route_hook.h>
|
||||
|
||||
#include <app_bridged_device.h>
|
||||
#include <app_qrcode.h>
|
||||
#include <app_zboss.h>
|
||||
#include <app_bridged_device.h>
|
||||
#include <zigbee_bridge.h>
|
||||
|
||||
static const char *TAG = "app_main";
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "zigbee_bridge.h"
|
||||
#include <app_zboss.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_zigbee_api_core.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <zboss_api.h>
|
||||
#include <zigbee_bridge.h>
|
||||
|
||||
#if (!defined ZB_MACSPLIT_HOST)
|
||||
#if (!defined(ZB_MACSPLIT_HOST) && defined(ZB_MACSPLIT_DEVICE))
|
||||
#error "Zigbee host option should be enabled to use this example"
|
||||
#endif
|
||||
|
||||
@@ -22,9 +22,7 @@ static const char *TAG = "esp_zboss";
|
||||
|
||||
static void bdb_start_top_level_commissioning_cb(zb_uint8_t mode_mask)
|
||||
{
|
||||
if (!bdb_start_top_level_commissioning(mode_mask)) {
|
||||
ESP_LOGE(TAG, "In BDB commissioning, an error occurred (for example: the device has already been running)");
|
||||
}
|
||||
ESP_ERROR_CHECK(esp_zb_bdb_start_top_level_commissioning(mode_mask));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,21 +38,35 @@ void zboss_signal_handler(zb_bufid_t bufid)
|
||||
zb_zdo_app_signal_type_t sig = zb_get_app_signal(bufid, &p_sg_p);
|
||||
zb_ret_t status = ZB_GET_APP_SIGNAL_STATUS(bufid);
|
||||
zb_zdo_signal_device_annce_params_t *device_annce_params = NULL;
|
||||
zb_zdo_signal_macsplit_dev_boot_params_t *rcp_version = NULL;
|
||||
zb_uint32_t gateway_version;
|
||||
|
||||
switch (sig) {
|
||||
case ZB_ZDO_SIGNAL_SKIP_STARTUP:
|
||||
ESP_LOGI(TAG, "Zigbee stack initialized");
|
||||
bdb_start_top_level_commissioning(ZB_BDB_INITIALIZATION);
|
||||
esp_zb_bdb_start_top_level_commissioning(ZB_BDB_INITIALIZATION);
|
||||
break;
|
||||
|
||||
case ZB_MACSPLIT_DEVICE_BOOT:
|
||||
ESP_LOGI(TAG, "Zigbee rcp device booted");
|
||||
gateway_version = esp_zb_macsplit_get_version();
|
||||
rcp_version = ZB_ZDO_SIGNAL_GET_PARAMS(p_sg_p, zb_zdo_signal_macsplit_dev_boot_params_t);
|
||||
ESP_LOGI(TAG, "Zigbee rcp device version: %d.%d.%d", (rcp_version->dev_version >> 24 & 0x000000FF),
|
||||
(rcp_version->dev_version >> 16 & 0x000000FF), (rcp_version->dev_version & 0x000000FF));
|
||||
ESP_LOGI(TAG, "Zigbee gateway version: %d.%d.%d", (gateway_version >> 24 & 0x000000FF),
|
||||
(gateway_version >> 16 & 0x000000FF), (gateway_version & 0x000000FF));
|
||||
if (gateway_version != rcp_version->dev_version) {
|
||||
ESP_LOGE(TAG,
|
||||
"rcp has different Zigbee stack version with Zigbee gateway! Please check the rcp software or "
|
||||
"other issues");
|
||||
}
|
||||
break;
|
||||
|
||||
case ZB_BDB_SIGNAL_DEVICE_FIRST_START:
|
||||
case ZB_BDB_SIGNAL_DEVICE_REBOOT:
|
||||
if (status == RET_OK) {
|
||||
ESP_LOGI(TAG, "Start network formation");
|
||||
bdb_start_top_level_commissioning(ZB_BDB_NETWORK_FORMATION);
|
||||
esp_zb_bdb_start_top_level_commissioning(ZB_BDB_NETWORK_FORMATION);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to initialize Zigbee stack (status: %d)", status);
|
||||
}
|
||||
@@ -68,7 +80,7 @@ void zboss_signal_handler(zb_bufid_t bufid)
|
||||
ESP_LOGI(TAG, "ieee extended address: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx)",
|
||||
ieee_address[7], ieee_address[6], ieee_address[5], ieee_address[4], ieee_address[3],
|
||||
ieee_address[2], ieee_address[1], ieee_address[0], ZB_PIBCACHE_PAN_ID());
|
||||
bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING);
|
||||
esp_zb_bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Restart network formation (status: %d)", status);
|
||||
ZB_SCHEDULE_APP_ALARM((zb_callback_t)bdb_start_top_level_commissioning_cb, ZB_BDB_NETWORK_FORMATION,
|
||||
@@ -85,18 +97,10 @@ void zboss_signal_handler(zb_bufid_t bufid)
|
||||
case ZB_ZDO_SIGNAL_DEVICE_ANNCE:
|
||||
device_annce_params = ZB_ZDO_SIGNAL_GET_PARAMS(p_sg_p, zb_zdo_signal_device_annce_params_t);
|
||||
ESP_LOGI(TAG, "New device commissioned or rejoined (short: 0x%04hx)", device_annce_params->device_short_addr);
|
||||
status =
|
||||
ZB_SCHEDULE_APP_ALARM(zigbee_bridge_match_bridged_onoff_light, bufid, MATCH_BRIDGED_DEVICE_START_DELAY);
|
||||
if (status != RET_OK) {
|
||||
ESP_LOGD(TAG, "Could not start schedule alarm for matching bridged device");
|
||||
}
|
||||
status =
|
||||
ZB_SCHEDULE_APP_ALARM(zigbee_bridge_match_bridged_onoff_light_timeout, bufid, MATCH_BRIDGED_DEVICE_TIMEOUT);
|
||||
if (status != RET_OK) {
|
||||
ESP_LOGD(TAG, "Could not start schedule alarm for matching bridged device timeout");
|
||||
}
|
||||
// this buf will be free in zboss_match_bridged_device_callback/zboss_match_bridged_device_timeout later
|
||||
bufid = 0;
|
||||
esp_zb_zdo_match_desc_req_param_t cmd_req;
|
||||
cmd_req.dst_nwk_addr = device_annce_params->device_short_addr;
|
||||
cmd_req.addr_of_interest = device_annce_params->device_short_addr;
|
||||
esp_zb_zdo_find_on_off_light(&cmd_req, zigbee_bridge_find_bridged_on_off_light_cb);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -109,27 +113,23 @@ void zboss_signal_handler(zb_bufid_t bufid)
|
||||
}
|
||||
}
|
||||
|
||||
void zboss_task()
|
||||
static void zboss_task(void *pvParameters)
|
||||
{
|
||||
ZB_INIT("zigbee bridge");
|
||||
zb_set_network_coordinator_role(IEEE_CHANNEL_MASK);
|
||||
zb_set_nvram_erase_at_start(ERASE_PERSISTENT_CONFIG);
|
||||
zb_set_max_children(MAX_CHILDREN);
|
||||
/* initialize Zigbee stack with Zigbee coordinator config */
|
||||
esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZC_CONFIG();
|
||||
esp_zb_init(&zb_nwk_cfg);
|
||||
/* initiate Zigbee Stack start without zb_send_no_autostart_signal auto-start */
|
||||
ESP_ERROR_CHECK(zboss_start_no_autostart());
|
||||
while (1) {
|
||||
zboss_main_loop_iteration();
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
}
|
||||
ESP_ERROR_CHECK(esp_zb_start(false));
|
||||
esp_zb_main_loop_iteration();
|
||||
}
|
||||
|
||||
void launch_app_zboss(void)
|
||||
{
|
||||
zb_esp_platform_config_t config = {
|
||||
.radio_config = ZB_ESP_DEFAULT_RADIO_CONFIG(),
|
||||
.host_config = ZB_ESP_DEFAULT_HOST_CONFIG(),
|
||||
esp_zb_platform_config_t config = {
|
||||
.radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(),
|
||||
.host_config = ESP_ZB_DEFAULT_HOST_CONFIG(),
|
||||
};
|
||||
/* load Zigbee gateway platform config to initialization */
|
||||
ESP_ERROR_CHECK(zb_esp_platform_config(&config));
|
||||
ESP_ERROR_CHECK(esp_zb_platform_config(&config));
|
||||
xTaskCreate(zboss_task, "zboss_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL);
|
||||
}
|
||||
|
||||
@@ -8,22 +8,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "esp_err.h"
|
||||
#include <stdint.h>
|
||||
#include <zigbee_bridge.h>
|
||||
|
||||
/*Zigbee Configuration*/
|
||||
#define IEEE_CHANNEL_MASK (1l << 22) /**< Zigbee default channel */
|
||||
#define ERASE_PERSISTENT_CONFIG ZB_TRUE /**< Full device erase for all network devices before running example. */
|
||||
#define MAX_CHILDREN 10 /**< The maximum amount of connected devices */
|
||||
#define MAX_CHILDREN 10 /* < The maximum amount of connected devices */
|
||||
#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */
|
||||
|
||||
#define MATCH_DESC_REQ_ROLE ZB_NWK_BROADCAST_RX_ON_WHEN_IDLE
|
||||
#define MATCH_BRIDGED_DEVICE_START_DELAY (2 * ZB_TIME_ONE_SECOND)
|
||||
#define MATCH_BRIDGED_DEVICE_TIMEOUT (5 * ZB_TIME_ONE_SECOND)
|
||||
#define ESP_ZB_ZC_CONFIG() \
|
||||
{ \
|
||||
.esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR, \
|
||||
.install_code_policy = INSTALLCODE_POLICY_ENABLE, \
|
||||
.nwk_cfg = { \
|
||||
.zczr_cfg = \
|
||||
{ \
|
||||
.max_children = MAX_CHILDREN, \
|
||||
}, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define ZB_ESP_DEFAULT_RADIO_CONFIG() \
|
||||
#define ESP_ZB_DEFAULT_RADIO_CONFIG() \
|
||||
{ \
|
||||
.radio_mode = RADIO_MODE_UART_RCP, \
|
||||
.radio_uart_config = { \
|
||||
@@ -43,12 +47,9 @@ extern "C" {
|
||||
}, \
|
||||
}
|
||||
|
||||
#define ZB_ESP_DEFAULT_HOST_CONFIG() \
|
||||
#define ESP_ZB_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_NONE, \
|
||||
}
|
||||
|
||||
void launch_app_zboss(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp-zboss-lib: "~=0.0.4"
|
||||
espressif/esp-zboss-lib: "~0.1.0"
|
||||
espressif/esp-zigbee-lib: "~0.1.1"
|
||||
qrcode: "^0.1.0"
|
||||
espressif/mdns: "^1.0.3"
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: ">=5.0.0"
|
||||
|
||||
@@ -6,16 +6,12 @@
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_matter_bridge.h"
|
||||
#include <app_bridged_device.h>
|
||||
#include <esp_check.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_matter.h>
|
||||
|
||||
#include <app_bridged_device.h>
|
||||
#include <app_zboss.h>
|
||||
#include <esp_matter_core.h>
|
||||
#include <zboss_api_buf.h>
|
||||
#include <esp_matter_bridge.h>
|
||||
#include <zigbee_bridge.h>
|
||||
|
||||
static const char *TAG = "zigbee_bridge";
|
||||
@@ -30,6 +26,7 @@ static esp_err_t zigbee_bridge_init_bridged_onoff_light(esp_matter_bridge_device
|
||||
ESP_LOGE(TAG, "Invalid bridge device to be initialized");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
on_off::config_t config;
|
||||
on_off::create(dev->endpoint, &config, CLUSTER_MASK_SERVER, ESP_MATTER_NONE_FEATURE_ID);
|
||||
endpoint::set_device_type_id(dev->endpoint, endpoint::on_off_light::get_device_type_id());
|
||||
@@ -40,85 +37,33 @@ static esp_err_t zigbee_bridge_init_bridged_onoff_light(esp_matter_bridge_device
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void zigbee_bridge_match_bridged_onoff_light_cb(zb_bufid_t bufid)
|
||||
void zigbee_bridge_find_bridged_on_off_light_cb(zb_uint8_t zdo_status, zb_uint16_t addr, zb_uint8_t endpoint)
|
||||
{
|
||||
zb_zdo_match_desc_resp_t *p_resp = (zb_zdo_match_desc_resp_t *)zb_buf_begin(bufid);
|
||||
zb_apsde_data_indication_t *p_ind = ZB_BUF_GET_PARAM(bufid, zb_apsde_data_indication_t);
|
||||
zb_uint8_t *p_match_ep;
|
||||
zb_ret_t zb_err_code;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if ((p_resp->status == ZB_ZDP_STATUS_SUCCESS) && (p_resp->match_len > 0)) {
|
||||
p_match_ep = (zb_uint8_t *)(p_resp + 1);
|
||||
ESP_LOGI(TAG, "on_off_light found: address:0x%x, endpoint:%d, response_status:%d", addr, endpoint, zdo_status);
|
||||
if (zdo_status == ZB_ZDP_STATUS_SUCCESS) {
|
||||
node_t *node = node::get();
|
||||
ESP_GOTO_ON_FALSE(node, ESP_ERR_INVALID_STATE, exit, TAG, "Could not find esp_matter node");
|
||||
if (app_bridge_get_device_by_zigbee_shortaddr(p_ind->src_addr)) {
|
||||
ESP_LOGI(TAG, "Bridged node for 0x%04x zigbee device on endpoint %d has been created", p_ind->src_addr,
|
||||
app_bridge_get_matter_endpointid_by_zigbee_shortaddr(p_ind->src_addr));
|
||||
if (!node) {
|
||||
ESP_LOGE(TAG, "Could not find esp_matter node");
|
||||
return;
|
||||
}
|
||||
if (app_bridge_get_device_by_zigbee_shortaddr(addr)) {
|
||||
ESP_LOGI(TAG, "Bridged node for 0x%04x zigbee device on endpoint %d has been created", addr,
|
||||
app_bridge_get_matter_endpointid_by_zigbee_shortaddr(addr));
|
||||
} else {
|
||||
app_bridged_device_t *bridged_device = app_bridge_create_bridged_device(node, ESP_MATTER_BRIDGED_DEVICE_TYPE_ZIGBEE, app_bridge_zigbee_address(*p_match_ep, p_ind->src_addr));
|
||||
ESP_GOTO_ON_FALSE(bridged_device, ESP_FAIL, exit, TAG, "Failed to create zigbee bridged device (on_off light)");
|
||||
ESP_GOTO_ON_ERROR(zigbee_bridge_init_bridged_onoff_light(bridged_device->dev), exit, TAG, "Failed to initialize the bridged node");
|
||||
ESP_LOGI(TAG, "Create/Update bridged node for 0x%04x zigbee device on endpoint %d", p_ind->src_addr,
|
||||
app_bridge_get_matter_endpointid_by_zigbee_shortaddr(p_ind->src_addr));
|
||||
}
|
||||
zb_err_code = ZB_SCHEDULE_APP_ALARM_CANCEL(zigbee_bridge_match_bridged_onoff_light_timeout, ZB_ALARM_ANY_PARAM);
|
||||
if (zb_err_code != RET_OK) {
|
||||
ESP_LOGE(TAG, "Failed to cancel alarm for match_bridged_device_timeout");
|
||||
app_bridged_device_t *bridged_device = app_bridge_create_bridged_device(
|
||||
node, ESP_MATTER_BRIDGED_DEVICE_TYPE_ZIGBEE, app_bridge_zigbee_address(endpoint, addr));
|
||||
if (!bridged_device) {
|
||||
ESP_LOGE(TAG, "Failed to create zigbee bridged device (on_off light)");
|
||||
return;
|
||||
}
|
||||
if (zigbee_bridge_init_bridged_onoff_light(bridged_device->dev) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize the bridged node");
|
||||
return;
|
||||
}
|
||||
ESP_LOGI(TAG, "Create/Update bridged node for 0x%04x zigbee device on endpoint %d", addr,
|
||||
app_bridge_get_matter_endpointid_by_zigbee_shortaddr(addr));
|
||||
}
|
||||
}
|
||||
exit:
|
||||
if (bufid) {
|
||||
zb_buf_free(bufid);
|
||||
}
|
||||
}
|
||||
|
||||
void zigbee_bridge_match_bridged_onoff_light(zb_bufid_t bufid)
|
||||
{
|
||||
zb_zdo_match_desc_param_t *p_req;
|
||||
|
||||
zb_zdo_app_signal_hdr_t *p_sg_p = NULL;
|
||||
zb_get_app_signal(bufid, &p_sg_p);
|
||||
zb_zdo_signal_device_annce_params_t *dev_annce_params =
|
||||
ZB_ZDO_SIGNAL_GET_PARAMS(p_sg_p, zb_zdo_signal_device_annce_params_t);
|
||||
|
||||
zb_uint16_t shortaddr = dev_annce_params->device_short_addr;
|
||||
p_req = (zb_zdo_match_desc_param_t *)zb_buf_initial_alloc(
|
||||
bufid, sizeof(zb_zdo_match_desc_param_t) + (1) * sizeof(zb_uint16_t));
|
||||
p_req->nwk_addr = shortaddr;
|
||||
p_req->addr_of_interest = shortaddr;
|
||||
p_req->profile_id = ZB_AF_HA_PROFILE_ID;
|
||||
|
||||
p_req->num_in_clusters = 1;
|
||||
p_req->num_out_clusters = 0;
|
||||
p_req->cluster_list[0] = ZB_ZCL_CLUSTER_ID_ON_OFF;
|
||||
|
||||
zb_zdo_match_desc_req(bufid, zigbee_bridge_match_bridged_onoff_light_cb);
|
||||
}
|
||||
|
||||
void zigbee_bridge_match_bridged_onoff_light_timeout(zb_bufid_t bufid)
|
||||
{
|
||||
ESP_LOGE(TAG, "The device is not an onoff light");
|
||||
if (bufid) {
|
||||
zb_buf_free(bufid);
|
||||
}
|
||||
}
|
||||
|
||||
void zigbee_bridge_send_on(zb_uint8_t buf, zb_uint16_t zigbee_shortaddr)
|
||||
{
|
||||
app_bridged_device_t *zigbee_device = app_bridge_get_device_by_zigbee_shortaddr(zigbee_shortaddr);
|
||||
ZB_ZCL_ON_OFF_SEND_REQ(buf, zigbee_shortaddr, ZB_APS_ADDR_MODE_16_ENDP_PRESENT, zigbee_device->dev_addr.zigbee_endpointid,
|
||||
zigbee_device->dev->endpoint_id, ZB_AF_HA_PROFILE_ID, ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
|
||||
ZB_ZCL_CMD_ON_OFF_ON_ID, NULL);
|
||||
}
|
||||
|
||||
void zigbee_bridge_send_off(zb_uint8_t buf, zb_uint16_t zigbee_shortaddr)
|
||||
{
|
||||
app_bridged_device_t *zigbee_device = app_bridge_get_device_by_zigbee_shortaddr(zigbee_shortaddr);
|
||||
ZB_ZCL_ON_OFF_SEND_REQ(buf, zigbee_shortaddr, ZB_APS_ADDR_MODE_16_ENDP_PRESENT, zigbee_device->dev_addr.zigbee_endpointid,
|
||||
zigbee_device->dev->endpoint_id, ZB_AF_HA_PROFILE_ID, ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
|
||||
ZB_ZCL_CMD_ON_OFF_OFF_ID, NULL);
|
||||
}
|
||||
|
||||
esp_err_t zigbee_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
|
||||
@@ -128,9 +73,15 @@ esp_err_t zigbee_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster_
|
||||
if (zigbee_device && zigbee_device->dev && zigbee_device->dev->endpoint) {
|
||||
if (cluster_id == OnOff::Id) {
|
||||
if (attribute_id == OnOff::Attributes::OnOff::Id) {
|
||||
ESP_LOGD(TAG, "Update Bridged Device, ep: %d, cluster: %d, att: %d", endpoint_id, cluster_id, attribute_id);
|
||||
zb_buf_get_out_delayed_ext((val->val.b ? zigbee_bridge_send_on : zigbee_bridge_send_off),
|
||||
zigbee_device->dev_addr.zigbee_shortaddr, 0);
|
||||
ESP_LOGD(TAG, "Update Bridged Device, ep: %d, cluster: %d, att: %d", endpoint_id, cluster_id,
|
||||
attribute_id);
|
||||
esp_zb_zcl_on_off_cmd_t cmd_req;
|
||||
cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = zigbee_device->dev_addr.zigbee_shortaddr;
|
||||
cmd_req.zcl_basic_cmd.dst_endpoint = zigbee_device->dev_addr.zigbee_endpointid;
|
||||
cmd_req.zcl_basic_cmd.src_endpoint = zigbee_device->dev->endpoint_id;
|
||||
cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT;
|
||||
cmd_req.on_off_cmd_id = val->val.b ? ZB_ZCL_CMD_ON_OFF_ON_ID : ZB_ZCL_CMD_ON_OFF_OFF_ID;
|
||||
esp_zb_zcl_on_off_cmd_req(&cmd_req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,25 +7,13 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <esp_matter_attribute_utils.h>
|
||||
#include <zboss_api.h>
|
||||
#include <zboss_api_zcl.h>
|
||||
#include <esp_zigbee_api_HA_standard.h>
|
||||
#include <esp_zigbee_api_core.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <zb_ha.h>
|
||||
|
||||
void zigbee_bridge_match_bridged_onoff_light(zb_bufid_t bufid);
|
||||
|
||||
void zigbee_bridge_match_bridged_onoff_light_timeout(zb_bufid_t bufid);
|
||||
void zigbee_bridge_find_bridged_on_off_light_cb(zb_uint8_t zdo_status, zb_uint16_t addr, zb_uint8_t endpoint);
|
||||
|
||||
esp_err_t zigbee_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
|
||||
esp_matter_attr_val_t *val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,3 +8,4 @@ ota_0, app, ota_0, 0x20000, 0x1D0000,
|
||||
ota_1, app, ota_1, , 0x1D0000,
|
||||
fctry, data, nvs, , 0x6000,
|
||||
zb_storage, data, fat, , 0x20000
|
||||
zb_fct, data, fat, , 1K,
|
||||
|
||||
|
@@ -36,4 +36,4 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n
|
||||
# Zboss
|
||||
CONFIG_ZB_ENABLED=y
|
||||
CONFIG_ZB_ZCZR=y
|
||||
CONFIG_ZB_HOST=y
|
||||
CONFIG_ZB_RADIO_MACSPLIT_UART=y
|
||||
|
||||
Reference in New Issue
Block a user