diff --git a/examples/zigbee/.build-test-rules.yml b/examples/zigbee/.build-test-rules.yml index b50f84619b..5d3554df06 100644 --- a/examples/zigbee/.build-test-rules.yml +++ b/examples/zigbee/.build-test-rules.yml @@ -2,7 +2,7 @@ examples/zigbee/esp_zigbee_gateway: disable: - - if: IDF_TARGET in ["esp32c2", "esp32c6", "esp32h2"] + - if: IDF_TARGET in ["esp32c2", "esp32h2"] temporary: true reason: target(s) not supported yet diff --git a/examples/zigbee/esp_zigbee_gateway/CMakeLists.txt b/examples/zigbee/esp_zigbee_gateway/CMakeLists.txt index 4d57970926..eac8c5c438 100644 --- a/examples/zigbee/esp_zigbee_gateway/CMakeLists.txt +++ b/examples/zigbee/esp_zigbee_gateway/CMakeLists.txt @@ -3,5 +3,6 @@ # The following five 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.16) +set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(esp_zigbee_gateway) diff --git a/examples/zigbee/esp_zigbee_gateway/README.md b/examples/zigbee/esp_zigbee_gateway/README.md index 9f15b9d28e..d2c2e17f2b 100644 --- a/examples/zigbee/esp_zigbee_gateway/README.md +++ b/examples/zigbee/esp_zigbee_gateway/README.md @@ -1,21 +1,23 @@ -| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | # Gateway Example -This example demonstrates how to build a Zigbee Gateway device. It runs on a Wi-Fi SoC such as ESP32, ESP32-C3 and ESP32-S3, with an 802.15.4 SoC like ESP32-H4 running [esp_zigbee_rcp](../esp_zigbee_rcp) to provide 802.15.4 radio. +This example demonstrates how to build a Zigbee Gateway device. It runs on a Wi-Fi SoC such as ESP32, ESP32-C3 and ESP32-S3, with an 802.15.4 SoC like ESP32-H2 running [esp_zigbee_rcp](../esp_zigbee_rcp) to provide 802.15.4 radio. + +The example could also run on a single SoC which supports both Wi-Fi and Zigbee (e.g., ESP32-C6), but since there is only one RF path in ESP32-C6, which means Wi-Fi and Zigbee can't receive simultaneously, it has a significant impact on performance. Hence the two SoCs solution is recommended. ## Hardware Required * One development board with ESP32 or ESP32-S3 SoC acting as Zigbee gateway (loaded with esp_zigbee_gateway example) * A USB cable for power supply and programming * Three jumper wires for UART (TX, RX and GND) -* Gateway doesn't function alone. Choose ESP32-H4 as Zigbee rcp (see [esp_zigbee_rcp example](../esp_zigbee_rcp)) -* **Flash** Zigbee rcp on the ESP32-H4 DevKitC first **before** connecting to Zigbee gateway -* Connect the two SoCs via UART, below is an example setup with ESP32-DevKitC and ESP32-H4-DevKitC: +* Gateway doesn't function alone. Choose ESP32-H2 as Zigbee rcp (see [esp_zigbee_rcp example](../esp_zigbee_rcp)) +* **Flash** Zigbee rcp on the ESP32-H2 DevKitC first **before** connecting to Zigbee gateway +* Connect the two SoCs via UART, below is an example setup with ESP32-DevKitC and ESP32-H2-DevKitC: ![Zigbee_gateway](../../openthread/ot_br/image/thread-border-router-esp32-esp32h4.jpg) -ESP32 pin | ESP32-H4 pin +ESP32 pin | ESP32-H2 pin ------------- |------------- GND | G GPIO4 (RX) | TX diff --git a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c index 4f757ffcb2..7e79318bd9 100644 --- a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c +++ b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c @@ -38,6 +38,12 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_netif.h" +#include "esp_vfs_eventfd.h" +#include "esp_wifi.h" +#include "nvs_flash.h" +#include "protocol_examples_common.h" +#include "esp_coexist_internal.h" #include "esp_zigbee_gateway.h" #if (!defined ZB_MACSPLIT_HOST && defined ZB_MACSPLIT_DEVICE) @@ -127,5 +133,18 @@ void app_main(void) }; /* load Zigbee gateway platform config to initialization */ ESP_ERROR_CHECK(esp_zb_platform_config(&config)); + ESP_ERROR_CHECK(nvs_flash_init()); + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); +#if CONFIG_EXAMPLE_CONNECT_WIFI + ESP_ERROR_CHECK(example_connect()); +#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE + ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM)); + coex_enable(); + coex_schm_status_bit_set(1, 1); +#else + ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); +#endif +#endif xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL); } diff --git a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.h b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.h index 46e4188a8c..d73745035a 100644 --- a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.h +++ b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.h @@ -51,6 +51,13 @@ .max_children = MAX_CHILDREN, \ }, \ } + +#if CONFIG_ZB_RADIO_NATIVE +#define ESP_ZB_DEFAULT_RADIO_CONFIG() \ + { \ + .radio_mode = RADIO_MODE_NATIVE, \ + } +#else #define ESP_ZB_DEFAULT_RADIO_CONFIG() \ { \ .radio_mode = RADIO_MODE_UART_RCP, \ @@ -70,6 +77,7 @@ .tx_pin = 5, \ }, \ } +#endif #define ESP_ZB_DEFAULT_HOST_CONFIG() \ { \ diff --git a/examples/zigbee/esp_zigbee_gateway/partitions.csv b/examples/zigbee/esp_zigbee_gateway/partitions.csv index d8dcfcdf6b..c6e1d03bfa 100644 --- a/examples/zigbee/esp_zigbee_gateway/partitions.csv +++ b/examples/zigbee/esp_zigbee_gateway/partitions.csv @@ -2,6 +2,6 @@ # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap nvs, data, nvs, 0x9000, 0x6000, phy_init, data, phy, 0xf000, 0x1000, -factory, app, factory, 0x10000, 550K, -zb_storage, data, fat, 0x9a000, 16K, -zb_fct, data, fat, 0x9e000, 1K, +factory, app, factory, 0x10000, 1150K, +zb_storage, data, fat, , 16K, +zb_fct, data, fat, , 1K, diff --git a/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults b/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults index 781db6e5c8..6e62dede3e 100644 --- a/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults +++ b/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults @@ -30,6 +30,5 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n # CONFIG_ZB_ENABLED=y CONFIG_ZB_ZCZR=y -CONFIG_ZB_RADIO_MACSPLIT_UART=y # end of Zboss # end of Component config