From fa793efda02b626181df3a325f31daf976930a8e Mon Sep 17 00:00:00 2001 From: "xieqinan@espressif.com" Date: Thu, 18 Sep 2025 21:05:02 +0800 Subject: [PATCH] feat(zigbee): move the zcl_utility into the examples_utils of zb_common_components --- .../HA_on_off_light/main/CMakeLists.txt | 4 ++-- .../HA_on_off_light/main/esp_zb_light.c | 1 + .../HA_on_off_light/main/esp_zb_light.h | 1 - .../HA_on_off_light/main/idf_component.yml | 2 ++ .../HA_on_off_switch/main/CMakeLists.txt | 4 ++-- .../HA_on_off_switch/main/esp_zb_switch.c | 1 + .../HA_on_off_switch/main/esp_zb_switch.h | 1 - .../HA_on_off_switch/main/idf_component.yml | 2 ++ .../examples_utils/CMakeLists.txt | 3 +++ .../examples_utils}/include/zcl_utility.h | 19 +++++++++---------- .../examples_utils}/zcl_utility.c | 17 ++++++++++------- 11 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 examples/zigbee/zb_common_components/examples_utils/CMakeLists.txt rename examples/zigbee/{common/zcl_utility => zb_common_components/examples_utils}/include/zcl_utility.h (76%) rename examples/zigbee/{common/zcl_utility/src => zb_common_components/examples_utils}/zcl_utility.c (91%) diff --git a/examples/zigbee/light_sample/HA_on_off_light/main/CMakeLists.txt b/examples/zigbee/light_sample/HA_on_off_light/main/CMakeLists.txt index a627f872e1..8c00feb33a 100644 --- a/examples/zigbee/light_sample/HA_on_off_light/main/CMakeLists.txt +++ b/examples/zigbee/light_sample/HA_on_off_light/main/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register( - SRC_DIRS "." "$ENV{IDF_PATH}/examples/zigbee/common/zcl_utility/src" - INCLUDE_DIRS "." "$ENV{IDF_PATH}/examples/zigbee/common/zcl_utility/include" + SRC_DIRS "." + INCLUDE_DIRS "." PRIV_REQUIRES nvs_flash esp_driver_uart ieee802154 ) diff --git a/examples/zigbee/light_sample/HA_on_off_light/main/esp_zb_light.c b/examples/zigbee/light_sample/HA_on_off_light/main/esp_zb_light.c index 4f3256c557..916baa2fc5 100644 --- a/examples/zigbee/light_sample/HA_on_off_light/main/esp_zb_light.c +++ b/examples/zigbee/light_sample/HA_on_off_light/main/esp_zb_light.c @@ -17,6 +17,7 @@ #include "esp_log.h" #include "nvs_flash.h" #include "ha/esp_zigbee_ha_standard.h" +#include "zcl_utility.h" #include "esp_zb_light.h" #if !defined ZB_ED_ROLE diff --git a/examples/zigbee/light_sample/HA_on_off_light/main/esp_zb_light.h b/examples/zigbee/light_sample/HA_on_off_light/main/esp_zb_light.h index 3f4a751c67..ed2da9d632 100644 --- a/examples/zigbee/light_sample/HA_on_off_light/main/esp_zb_light.h +++ b/examples/zigbee/light_sample/HA_on_off_light/main/esp_zb_light.h @@ -14,7 +14,6 @@ #include "esp_zigbee_core.h" #include "light_driver.h" -#include "zcl_utility.h" /* Zigbee configuration */ #define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ diff --git a/examples/zigbee/light_sample/HA_on_off_light/main/idf_component.yml b/examples/zigbee/light_sample/HA_on_off_light/main/idf_component.yml index 198da019c3..bfdc772840 100644 --- a/examples/zigbee/light_sample/HA_on_off_light/main/idf_component.yml +++ b/examples/zigbee/light_sample/HA_on_off_light/main/idf_component.yml @@ -6,3 +6,5 @@ dependencies: ## Required IDF version idf: version: ">=5.0.0" + examples_utils: + path: ${IDF_PATH}/examples/zigbee/zb_common_components/examples_utils diff --git a/examples/zigbee/light_sample/HA_on_off_switch/main/CMakeLists.txt b/examples/zigbee/light_sample/HA_on_off_switch/main/CMakeLists.txt index 7e11fe59f8..79e119440f 100644 --- a/examples/zigbee/light_sample/HA_on_off_switch/main/CMakeLists.txt +++ b/examples/zigbee/light_sample/HA_on_off_switch/main/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register( - SRC_DIRS "." "$ENV{IDF_PATH}/examples/zigbee/common/zcl_utility/src" - INCLUDE_DIRS "." "$ENV{IDF_PATH}/examples/zigbee/common/zcl_utility/include" + SRC_DIRS "." + INCLUDE_DIRS "." PRIV_REQUIRES nvs_flash esp_driver_gpio esp_driver_uart ieee802154 ) diff --git a/examples/zigbee/light_sample/HA_on_off_switch/main/esp_zb_switch.c b/examples/zigbee/light_sample/HA_on_off_switch/main/esp_zb_switch.c index 64459f04b3..fbf140207c 100644 --- a/examples/zigbee/light_sample/HA_on_off_switch/main/esp_zb_switch.c +++ b/examples/zigbee/light_sample/HA_on_off_switch/main/esp_zb_switch.c @@ -20,6 +20,7 @@ #include "esp_log.h" #include "nvs_flash.h" #include "ha/esp_zigbee_ha_standard.h" +#include "zcl_utility.h" #include "esp_zb_switch.h" #if defined ZB_ED_ROLE diff --git a/examples/zigbee/light_sample/HA_on_off_switch/main/esp_zb_switch.h b/examples/zigbee/light_sample/HA_on_off_switch/main/esp_zb_switch.h index 32a6dc9edf..8993eb969e 100644 --- a/examples/zigbee/light_sample/HA_on_off_switch/main/esp_zb_switch.h +++ b/examples/zigbee/light_sample/HA_on_off_switch/main/esp_zb_switch.h @@ -13,7 +13,6 @@ */ #include "esp_zigbee_core.h" #include "switch_driver.h" -#include "zcl_utility.h" /* Zigbee configuration */ #define MAX_CHILDREN 10 /* the max amount of connected devices */ diff --git a/examples/zigbee/light_sample/HA_on_off_switch/main/idf_component.yml b/examples/zigbee/light_sample/HA_on_off_switch/main/idf_component.yml index ad32c63b48..bfb3027106 100644 --- a/examples/zigbee/light_sample/HA_on_off_switch/main/idf_component.yml +++ b/examples/zigbee/light_sample/HA_on_off_switch/main/idf_component.yml @@ -5,3 +5,5 @@ dependencies: ## Required IDF version idf: version: ">=5.0.0" + examples_utils: + path: ${IDF_PATH}/examples/zigbee/zb_common_components/examples_utils diff --git a/examples/zigbee/zb_common_components/examples_utils/CMakeLists.txt b/examples/zigbee/zb_common_components/examples_utils/CMakeLists.txt new file mode 100644 index 0000000000..7eafd7b4d2 --- /dev/null +++ b/examples/zigbee/zb_common_components/examples_utils/CMakeLists.txt @@ -0,0 +1,3 @@ +idf_component_register(SRCS "zcl_utility.c" + INCLUDE_DIRS "include" + PRIV_REQUIRES espressif__esp-zigbee-lib) diff --git a/examples/zigbee/common/zcl_utility/include/zcl_utility.h b/examples/zigbee/zb_common_components/examples_utils/include/zcl_utility.h similarity index 76% rename from examples/zigbee/common/zcl_utility/include/zcl_utility.h rename to examples/zigbee/zb_common_components/examples_utils/include/zcl_utility.h index 760bf7e10b..afd1293a86 100644 --- a/examples/zigbee/common/zcl_utility/include/zcl_utility.h +++ b/examples/zigbee/zb_common_components/examples_utils/include/zcl_utility.h @@ -1,27 +1,26 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: LicenseRef-Included * - * Zigbee Common + * ZCL utility functions for Zigbee examples * * 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. - */ +*/ #pragma once +#include "esp_err.h" +#include "esp_zigbee_core.h" + #ifdef __cplusplus extern "C" { #endif -#include "esp_err.h" -#include "esp_check.h" -#include "esp_zigbee_core.h" - /*! Maximum length of ManufacturerName string field */ #define ESP_ZB_ZCL_CLUSTER_ID_BASIC_MANUFACTURER_NAME_MAX_LEN 32 @@ -37,9 +36,9 @@ typedef struct zcl_basic_manufacturer_info_s { /** * @brief Adds manufacturer information to the ZCL basic cluster of endpoint * - * @param[in] ep_list The pointer to the endpoint list with @p endpoint_id - * @param[in] endpoint_id The endpoint identifier indicating where the ZCL basic cluster resides - * @param[in] info The pointer to the basic manufacturer information + * @param ep_list The pointer to the endpoint list with @p endpoint_id + * @param endpoint_id The endpoint identifier indicating where the ZCL basic cluster resides + * @param info The pointer to the basic manufacturer information, @see zcl_basic_manufacturer_info_t * @return * - ESP_OK: On success * - ESP_ERR_INVALID_ARG: Invalid argument diff --git a/examples/zigbee/common/zcl_utility/src/zcl_utility.c b/examples/zigbee/zb_common_components/examples_utils/zcl_utility.c similarity index 91% rename from examples/zigbee/common/zcl_utility/src/zcl_utility.c rename to examples/zigbee/zb_common_components/examples_utils/zcl_utility.c index c88d6cd8bc..65c6fdec9d 100644 --- a/examples/zigbee/common/zcl_utility/src/zcl_utility.c +++ b/examples/zigbee/zb_common_components/examples_utils/zcl_utility.c @@ -1,21 +1,24 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: LicenseRef-Included * - * Zigbee Common + * ZCL utility functions for Zigbee examples * * 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_check.h" -#include "stdio.h" -#include "string.h" -#include "zcl_utility.h" +*/ + #include +#include + +#include "esp_check.h" +#include "esp_zigbee_core.h" + +#include "zcl_utility.h" static const char *TAG = "ZCL_UTILITY";