diff --git a/examples/zigbee/esp_zigbee_gateway/README.md b/examples/zigbee/esp_zigbee_gateway/README.md index 40aa4be56b..1a6fadfe8f 100644 --- a/examples/zigbee/esp_zigbee_gateway/README.md +++ b/examples/zigbee/esp_zigbee_gateway/README.md @@ -54,7 +54,7 @@ I (660) ESP_ZB_GATEWAY: status: -1 I (670) ESP_ZB_GATEWAY: Zigbee stack initialized I (680) ESP_ZB_GATEWAY: Zigbee rcp device booted I (1280) ESP_ZB_GATEWAY: Start network formation -I (3060) ESP_ZB_GATEWAY: Formed network successfully (ieee extended address: f9:54:2d:01:a0:03:f7:84, PAN ID: 0x8651) +I (3060) ESP_ZB_GATEWAY: Formed network successfully (Extended PAN ID: f9:54:2d:01:a0:03:f7:84, PAN ID: 0x8651, Channel:13, Short Address: 0x0000) I (4060) ESP_ZB_GATEWAY: status: 0 I (4400) ESP_ZB_GATEWAY: Network steering started ``` 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 ef89143963..1bba39313d 100644 --- a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c +++ b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c @@ -1,38 +1,15 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: LicenseRef-Included + * SPDX-License-Identifier: CC0-1.0 * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Zigbee Gateway Example * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * This example code is in the Public Domain (or CC0 licensed, at your option.) * - * 2. Redistributions in binary form, except as embedded into a Espressif Systems - * integrated circuit in a product or a software update for such product, - * must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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 #include @@ -42,16 +19,16 @@ #include "esp_coexist.h" #include "esp_log.h" #include "esp_netif.h" -#include "esp_spiffs.h" #include "esp_vfs_eventfd.h" -#include "esp_vfs_dev.h" -#include "driver/usb_serial_jtag_vfs.h" -#include "driver/uart_vfs.h" #include "esp_wifi.h" #include "nvs_flash.h" #include "protocol_examples_common.h" #include "esp_zigbee_gateway.h" +#include "esp_vfs_dev.h" +#include "esp_vfs_usb_serial_jtag.h" +#include "driver/usb_serial_jtag.h" + #if (!defined ZB_MACSPLIT_HOST && defined ZB_MACSPLIT_DEVICE) #error Only Zigbee gateway host device should be defined #endif @@ -67,9 +44,9 @@ esp_err_t esp_zb_gateway_console_init(void) setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - usb_serial_jtag_vfs_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_usb_serial_jtag_set_rx_line_endings(ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - usb_serial_jtag_vfs_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_usb_serial_jtag_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); /* Enable non-blocking mode on stdin and stdout */ fcntl(fileno(stdout), F_SETFL, O_NONBLOCK); @@ -77,8 +54,8 @@ esp_err_t esp_zb_gateway_console_init(void) usb_serial_jtag_driver_config_t usb_serial_jtag_config = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT(); ret = usb_serial_jtag_driver_install(&usb_serial_jtag_config); - usb_serial_jtag_vfs_use_driver(); - uart_vfs_dev_register(); + esp_vfs_usb_serial_jtag_use_driver(); + esp_vfs_dev_uart_register(); return ret; } #endif @@ -109,8 +86,13 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START: case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT: if (err_status == ESP_OK) { - ESP_LOGI(TAG, "Start network formation"); - esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION); + ESP_LOGI(TAG, "Device started up in %s factory-reset mode", esp_zb_bdb_is_factory_new() ? "" : "non"); + if (esp_zb_bdb_is_factory_new()) { + ESP_LOGI(TAG, "Start network formation"); + esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION); + } else { + ESP_LOGI(TAG, "Device rebooted"); + } } else { ESP_LOGE(TAG, "Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status)); } @@ -119,10 +101,10 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) if (err_status == ESP_OK) { esp_zb_ieee_addr_t ieee_address; esp_zb_get_long_address(ieee_address); - ESP_LOGI(TAG, "Formed network successfully (ieee_address: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d)", + ESP_LOGI(TAG, "Formed network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d, Short Address: 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], - esp_zb_get_pan_id(), esp_zb_get_current_channel()); + esp_zb_get_pan_id(), esp_zb_get_current_channel(), esp_zb_get_short_address()); esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING); } else { ESP_LOGI(TAG, "Restart network formation (status: %s)", esp_err_to_name(err_status)); @@ -138,6 +120,15 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) dev_annce_params = (esp_zb_zdo_signal_device_annce_params_t *)esp_zb_app_signal_get_params(p_sg_p); ESP_LOGI(TAG, "New device commissioned or rejoined (short: 0x%04hx)", dev_annce_params->device_short_addr); break; + case ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS: + if (err_status == ESP_OK) { + if (*(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)) { + ESP_LOGI(TAG, "Network(0x%04hx) is open for %d seconds", esp_zb_get_pan_id(), *(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)); + } else { + ESP_LOGW(TAG, "Network(0x%04hx) closed, devices joining not allowed.", esp_zb_get_pan_id()); + } + } + break; default: ESP_LOGI(TAG, "ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type, esp_err_to_name(err_status)); @@ -147,10 +138,9 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) static void esp_zb_task(void *pvParameters) { - /* initialize Zigbee stack with Zigbee coordinator config */ + /* initialize Zigbee stack */ 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_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK); ESP_ERROR_CHECK(esp_zb_start(false)); esp_zb_main_loop_iteration(); @@ -162,7 +152,7 @@ void app_main(void) .radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(), .host_config = ESP_ZB_DEFAULT_HOST_CONFIG(), }; - /* 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()); 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 d73745035a..2bc61f0e2b 100644 --- a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.h +++ b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.h @@ -1,38 +1,15 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: LicenseRef-Included + * SPDX-License-Identifier: CC0-1.0 * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Zigbee Gateway Example * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * This example code is in the Public Domain (or CC0 licensed, at your option.) * - * 2. Redistributions in binary form, except as embedded into a Espressif Systems - * integrated circuit in a product or a software update for such product, - * must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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" diff --git a/examples/zigbee/esp_zigbee_gateway/main/idf_component.yml b/examples/zigbee/esp_zigbee_gateway/main/idf_component.yml index aa8c8ed77d..5346a089ab 100644 --- a/examples/zigbee/esp_zigbee_gateway/main/idf_component.yml +++ b/examples/zigbee/esp_zigbee_gateway/main/idf_component.yml @@ -1,7 +1,7 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp-zboss-lib: "~0.7.0" - espressif/esp-zigbee-lib: "~0.9.0" + espressif/esp-zboss-lib: "1.0.9" + espressif/esp-zigbee-lib: "1.0.9" ## Required IDF version idf: version: ">=5.0.0" diff --git a/examples/zigbee/esp_zigbee_gateway/partitions.csv b/examples/zigbee/esp_zigbee_gateway/partitions.csv index b7bdb05faa..055152f11a 100644 --- a/examples/zigbee/esp_zigbee_gateway/partitions.csv +++ b/examples/zigbee/esp_zigbee_gateway/partitions.csv @@ -2,6 +2,7 @@ # 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, 1148K, -zb_storage, data, fat, , 16K, -zb_fct, data, fat, , 1K, +factory, app, factory, 0x10000, 1400K, +zb_storage, data, fat, 0x16e000,16K, +zb_fct, data, fat, 0x172000,1K, +rcp_fw, data, spiffs, 0x173000,500k, diff --git a/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults b/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults index 6e62dede3e..0d42a949ae 100644 --- a/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults +++ b/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults @@ -22,8 +22,7 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y CONFIG_MBEDTLS_ECJPAKE_C=y # end of mbedTLS -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=4096 # # Zboss @@ -32,3 +31,9 @@ CONFIG_ZB_ENABLED=y CONFIG_ZB_ZCZR=y # end of Zboss # end of Component config + +# +# IEEE802154 +# +CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y +# end of IEEE802154 diff --git a/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.c b/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.c index d264f25e43..2c419ab68d 100644 --- a/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.c +++ b/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.c @@ -1,38 +1,15 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: LicenseRef-Included + * SPDX-License-Identifier: CC0-1.0 * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Zigbee RCP Example * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * This example code is in the Public Domain (or CC0 licensed, at your option.) * - * 2. Redistributions in binary form, except as embedded into a Espressif Systems - * integrated circuit in a product or a software update for such product, - * must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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 "freertos/FreeRTOS.h" diff --git a/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.h b/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.h index 50f708a541..c8f59a51a3 100644 --- a/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.h +++ b/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.h @@ -1,38 +1,15 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: LicenseRef-Included + * SPDX-License-Identifier: CC0-1.0 * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Zigbee RCP Example * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * This example code is in the Public Domain (or CC0 licensed, at your option.) * - * 2. Redistributions in binary form, except as embedded into a Espressif Systems - * integrated circuit in a product or a software update for such product, - * must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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_zigbee_core.h" diff --git a/examples/zigbee/esp_zigbee_rcp/main/idf_component.yml b/examples/zigbee/esp_zigbee_rcp/main/idf_component.yml index aa99452a45..72f9982b83 100644 --- a/examples/zigbee/esp_zigbee_rcp/main/idf_component.yml +++ b/examples/zigbee/esp_zigbee_rcp/main/idf_component.yml @@ -1,7 +1,7 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp-zboss-lib: "~0.7.0" - espressif/esp-zigbee-lib: "~0.9.0" + espressif/esp-zboss-lib: "~1.0.9" + espressif/esp-zigbee-lib: "~1.0.9" ## Required IDF version idf: version: ">=5.0.0" diff --git a/examples/zigbee/esp_zigbee_rcp/partitions.csv b/examples/zigbee/esp_zigbee_rcp/partitions.csv index 43c1fae4b5..e72a9f10a2 100644 --- a/examples/zigbee/esp_zigbee_rcp/partitions.csv +++ b/examples/zigbee/esp_zigbee_rcp/partitions.csv @@ -2,5 +2,5 @@ # 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, +factory, app, factory, 0x10000, 548K, zb_storage, data, fat, 0x9a000, 16K, diff --git a/examples/zigbee/esp_zigbee_rcp/sdkconfig.defaults b/examples/zigbee/esp_zigbee_rcp/sdkconfig.defaults index 693d709e85..ff652ad98b 100644 --- a/examples/zigbee/esp_zigbee_rcp/sdkconfig.defaults +++ b/examples/zigbee/esp_zigbee_rcp/sdkconfig.defaults @@ -1,7 +1,7 @@ # # Partition Table # -CONFIG_PARTITION_TABLE_SINGLE_APP=y +CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 @@ -14,4 +14,10 @@ CONFIG_PARTITION_TABLE_MD5=y CONFIG_ZB_ENABLED=y CONFIG_ZB_RCP=y # end of ZBOSS Source + +# +# IEEE802154 +# +CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y +# end of IEEE802154 # end of Component config diff --git a/examples/zigbee/light_sample/HA_on_off_light/README.md b/examples/zigbee/light_sample/HA_on_off_light/README.md index 28eaf8d327..a22052d608 100644 --- a/examples/zigbee/light_sample/HA_on_off_light/README.md +++ b/examples/zigbee/light_sample/HA_on_off_light/README.md @@ -11,7 +11,7 @@ The ESP Zigbee SDK provides more examples and tools for productization: ## Hardware Required -* One development board with ESP32-H2 SoC acting as Zigbee end device (loaded with HA_on_off_light example) +* One development board with ESP32-H2 SoC acting as Zigbee end-device (loaded with HA_on_off_light example) * A USB cable for power supply and programming * Choose another ESP32-H2 as Zigbee coordinator (see [HA_on_off_switch example](../HA_on_off_switch)) @@ -33,18 +33,25 @@ Build the project, flash it to the board, and start the monitor tool to view the As you run the example, you will see the following log: -light bulb: ``` -I (918) ESP_ZB_LIGHT: status: 255 -I (901) ESP_ZB_LIGHT: Zigbee stack initialized -I (901) ESP_ZB_LIGHT: Start network steering -I (2611) ESP_ZB_LIGHT: Joined network successfully (Extended PAN ID: aa:98:48:01:a0:03:f7:84, PAN ID: 0x0e8b) -I (5651) ESP_ZB_LIGHT: on/off light set to 1 -I (6631) ESP_ZB_LIGHT: on/off light set to 0 -I (7331) ESP_ZB_LIGHT: on/off light set to 1 -I (8251) ESP_ZB_LIGHT: on/off light set to 0 -I (9111) ESP_ZB_LIGHT: on/off light set to 1 -I (9671) ESP_ZB_LIGHT: on/off light set to 0 +I (394) main_task: Calling app_main() +I (404) gpio: GPIO[8]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 +I (404) phy_init: phy_version 220,2dbbbe7,Sep 25 2023,20:39:25 +I (464) phy: libbtbb version: 90c587c, Sep 25 2023, 20:39:57 +I (474) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: ZDO Config Ready (0x17), status: ESP_FAIL +I (474) ESP_ZB_COLOR_DIMM_LIGHT: Zigbee stack initialized +I (484) ESP_ZB_COLOR_DIMM_LIGHT: Start network steering +I (484) main_task: Returned from app_main() +I (9614) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: NWK Permit Join (0x36), status: ESP_OK +I (9834) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: NWK Permit Join (0x36), status: ESP_OK +I (9834) ESP_ZB_COLOR_DIMM_LIGHT: Joined network successfully (Extended PAN ID: 60:55:f9:00:00:f6:07:b4, PAN ID: 0x2a74, Channel:13) +I (32944) ESP_ZB_COLOR_DIMM_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1) +I (32944) ESP_ZB_COLOR_DIMM_LIGHT: Light sets to On +I (33984) ESP_ZB_COLOR_DIMM_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1) +I (33984) ESP_ZB_COLOR_DIMM_LIGHT: Light sets to Off +I (35304) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: NLME Status Indication (0x32), status: ESP_OK +I (35534) ESP_ZB_COLOR_DIMM_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1) +I (35534) ESP_ZB_COLOR_DIMM_LIGHT: Light sets to On ``` ## Light Control Functions 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 e2fef6a8fa..a77ac5dc94 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 @@ -1,38 +1,15 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: LicenseRef-Included + * SPDX-License-Identifier: CC0-1.0 * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Zigbee HA_on_off_light Example * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * This example code is in the Public Domain (or CC0 licensed, at your option.) * - * 2. Redistributions in binary form, except as embedded into a Espressif Systems - * integrated circuit in a product or a software update for such product, - * must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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 "freertos/FreeRTOS.h" @@ -67,8 +44,13 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START: case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT: if (err_status == ESP_OK) { - ESP_LOGI(TAG, "Start network steering"); - esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING); + ESP_LOGI(TAG, "Device started up in %s factory-reset mode", esp_zb_bdb_is_factory_new() ? "" : "non"); + if (esp_zb_bdb_is_factory_new()) { + ESP_LOGI(TAG, "Start network steering"); + esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING); + } else { + ESP_LOGI(TAG, "Device rebooted"); + } } else { /* commissioning failed */ ESP_LOGW(TAG, "Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status)); @@ -78,10 +60,10 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) if (err_status == ESP_OK) { esp_zb_ieee_addr_t extended_pan_id; esp_zb_get_extended_pan_id(extended_pan_id); - ESP_LOGI(TAG, "Joined network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d)", + ESP_LOGI(TAG, "Joined network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d, Short Address: 0x%04hx)", extended_pan_id[7], extended_pan_id[6], extended_pan_id[5], extended_pan_id[4], extended_pan_id[3], extended_pan_id[2], extended_pan_id[1], extended_pan_id[0], - esp_zb_get_pan_id(), esp_zb_get_current_channel()); + esp_zb_get_pan_id(), esp_zb_get_current_channel(), esp_zb_get_short_address()); } else { ESP_LOGI(TAG, "Network steering was not successful (status: %s)", esp_err_to_name(err_status)); esp_zb_scheduler_alarm((esp_zb_callback_t)bdb_start_top_level_commissioning_cb, ESP_ZB_BDB_MODE_NETWORK_STEERING, 1000); @@ -100,14 +82,13 @@ static esp_err_t zb_attribute_handler(const esp_zb_zcl_set_attr_value_message_t bool light_state = 0; ESP_RETURN_ON_FALSE(message, ESP_FAIL, TAG, "Empty message"); - ESP_RETURN_ON_FALSE(message->info.status == ESP_ZB_ZCL_STATUS_SUCCESS, ESP_ERR_INVALID_ARG, TAG, - "Received message: error status(%d)", message->info.status); - ESP_LOGI(TAG, "Received message: endpoint(%d), cluster(0x%x), attribute(0x%x), data size(%d)", - message->info.dst_endpoint, message->info.cluster, message->attribute.id, message->attribute.data.size); + ESP_RETURN_ON_FALSE(message->info.status == ESP_ZB_ZCL_STATUS_SUCCESS, ESP_ERR_INVALID_ARG, TAG, "Received message: error status(%d)", + message->info.status); + ESP_LOGI(TAG, "Received message: endpoint(%d), cluster(0x%x), attribute(0x%x), data size(%d)", message->info.dst_endpoint, message->info.cluster, + message->attribute.id, message->attribute.data.size); if (message->info.dst_endpoint == HA_ESP_LIGHT_ENDPOINT) { if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_ON_OFF) { - if (message->attribute.id == ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID && - message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_BOOL) { + if (message->attribute.id == ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_BOOL) { light_state = message->attribute.data.value ? *(bool *)message->attribute.data.value : light_state; ESP_LOGI(TAG, "Light sets to %s", light_state ? "On" : "Off"); light_driver_set_power(light_state); 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 7885b50009..5def811a87 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 @@ -1,49 +1,27 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: LicenseRef-Included + * SPDX-License-Identifier: CC0-1.0 * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Zigbee HA_on_off_light Example * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * This example code is in the Public Domain (or CC0 licensed, at your option.) * - * 2. Redistributions in binary form, except as embedded into a Espressif Systems - * integrated circuit in a product or a software update for such product, - * must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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_zigbee_core.h" #include "light_driver.h" /* Zigbee configuration */ -#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ +#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ #define ED_AGING_TIMEOUT ESP_ZB_ED_AGING_TIMEOUT_64MIN #define ED_KEEP_ALIVE 3000 /* 3000 millisecond */ -#define HA_ESP_LIGHT_ENDPOINT 10 /* esp light bulb device endpoint, used to process light controlling commands */ +#define HA_ESP_LIGHT_ENDPOINT 10 /* esp light bulb device endpoint, used to process light controlling commands */ #define ESP_ZB_PRIMARY_CHANNEL_MASK ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK /* Zigbee primary channel mask use in the example */ + #define ESP_ZB_ZED_CONFIG() \ { \ .esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, \ 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 0fb287d698..8578e73e67 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 @@ -1,7 +1,7 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp-zigbee-lib: "~0.9.0" - espressif/esp-zboss-lib: "~0.7.0" + espressif/esp-zboss-lib: "1.0.9" + espressif/esp-zigbee-lib: "1.0.9" espressif/led_strip: "~2.0.0" ## Required IDF version idf: diff --git a/examples/zigbee/light_sample/HA_on_off_light/partitions.csv b/examples/zigbee/light_sample/HA_on_off_light/partitions.csv index 9bf5a13c90..a56c0be780 100644 --- a/examples/zigbee/light_sample/HA_on_off_light/partitions.csv +++ b/examples/zigbee/light_sample/HA_on_off_light/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, 652K, -zb_storage, data, fat, 0xb3000, 16K, -zb_fct, data, fat, 0xb7000, 1K, +factory, app, factory, 0x10000, 900K, +zb_storage, data, fat, 0xf1000, 16K, +zb_fct, data, fat, 0xf5000, 1K, diff --git a/examples/zigbee/light_sample/HA_on_off_light/sdkconfig.defaults b/examples/zigbee/light_sample/HA_on_off_light/sdkconfig.defaults index 6099bd9436..bff542df4f 100644 --- a/examples/zigbee/light_sample/HA_on_off_light/sdkconfig.defaults +++ b/examples/zigbee/light_sample/HA_on_off_light/sdkconfig.defaults @@ -22,12 +22,16 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y CONFIG_MBEDTLS_ECJPAKE_C=y # end of mbedTLS -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n - # # Zboss # CONFIG_ZB_ENABLED=y CONFIG_ZB_ZED=y # end of Zboss + +# +# IEEE802154 +# +CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y +# end of IEEE802154 # end of Component config diff --git a/examples/zigbee/light_sample/HA_on_off_switch/README.md b/examples/zigbee/light_sample/HA_on_off_switch/README.md index 2b5ffc21e1..b02dc682ec 100644 --- a/examples/zigbee/light_sample/HA_on_off_switch/README.md +++ b/examples/zigbee/light_sample/HA_on_off_switch/README.md @@ -33,30 +33,32 @@ Build the project, flash it to the board, and start the monitor tool to view the As you run the example, you will see the following log: -light switch: ``` -I (318) gpio: GPIO[9]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2 -I (328) system_api: Base MAC address is not set -I (328) system_api: read default base MAC address from EFUSE -I (408) phy: libbtbb version: 6c47ec3, Mar 16 2022, 18:54:24 -I (408) phy: phy_version: 101, bb2a234, Mar 16 2022, 18:54:11 -I (818) ESP_ZB_ON_OFF_SWITCH: status: 255 -I (818) ESP_ZB_ON_OFF_SWITCH: Zigbee stack initialized -I (818) ESP_ZB_ON_OFF_SWITCH: Start network formation -I (1318) ESP_ZB_ON_OFF_SWITCH: Formed network successfully (Extended PAN ID: ff:fc:7c:c0:f0:bd:97:10, PAN ID: 0x88e7) -I (1778) ESP_ZB_ON_OFF_SWITCH: status: 0 -I (5528) ESP_ZB_ON_OFF_SWITCH: status: 0 -I (6038) ESP_ZB_ON_OFF_SWITCH: status: 0 -I (6068) ESP_ZB_ON_OFF_SWITCH: New device commissioned or rejoined (short: 0x2878) -I (6098) ESP_ZB_ON_OFF_SWITCH: User find cb: address:0x2878, endpoint:10 -I (6638) ESP_ZB_ON_OFF_SWITCH: status: 0 -I (6678) ESP_ZB_ON_OFF_SWITCH: status: 0 -I (8168) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command -I (8898) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command -I (9458) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command -I (10088) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command -I (10588) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command -I (11098) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command +I (388) main_task: Calling app_main() +I (398) gpio: GPIO[9]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2 +I (398) phy_init: phy_version 220,2dbbbe7,Sep 25 2023,20:39:25 +I (478) phy: libbtbb version: 90c587c, Sep 25 2023, 20:39:57 +I (488) ESP_ZB_ON_OFF_SWITCH: ZDO signal: ZDO Config Ready (0x17), status: ESP_FAIL +I (488) ESP_ZB_ON_OFF_SWITCH: Zigbee stack initialized +I (488) ESP_ZB_ON_OFF_SWITCH: Start network formation +I (498) main_task: Returned from app_main() +I (998) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NWK Permit Join (0x36), status: ESP_OK +I (998) ESP_ZB_ON_OFF_SWITCH: Formed network successfully (Extended PAN ID: 60:55:f9:00:00:f6:07:b4, PAN ID: 0x2a74, Channel:13) +I (1468) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NWK Permit Join (0x36), status: ESP_OK +I (1468) ESP_ZB_ON_OFF_SWITCH: Network steering started +I (14228) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NWK Device Associated (0x12), status: ESP_OK +I (14728) ESP_ZB_ON_OFF_SWITCH: ZDO signal: ZDO Device Update (0x30), status: ESP_OK +I (14788) ESP_ZB_ON_OFF_SWITCH: New device commissioned or rejoined (short: 0xe399) +I (14858) ESP_ZB_ON_OFF_SWITCH: Found light +I (14858) ESP_ZB_ON_OFF_SWITCH: Try to bind On/Off +I (14858) ESP_ZB_ON_OFF_SWITCH: Bound successfully! +I (14858) ESP_ZB_ON_OFF_SWITCH: The light originating from address(0xe399) on endpoint(10) +I (15338) ESP_ZB_ON_OFF_SWITCH: ZDO signal: ZDO Device Authorized (0x2f), status: ESP_OK +I (15408) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NWK Permit Join (0x36), status: ESP_OK +I (35838) ESP_ZB_ON_OFF_SWITCH: ZDO signal: NLME Status Indication (0x32), status: ESP_OK +I (38548) ESP_ZB_ON_OFF_SWITCH: Send 'on_off toggle' command +I (39598) ESP_ZB_ON_OFF_SWITCH: Send 'on_off toggle' command +I (41148) ESP_ZB_ON_OFF_SWITCH: Send 'on_off toggle' command ``` ## Light Control Functions 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 2fdaa82172..2750377202 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 @@ -1,38 +1,15 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: LicenseRef-Included + * SPDX-License-Identifier: CC0-1.0 * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Zigbee HA_on_off_switch Example * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * This example code is in the Public Domain (or CC0 licensed, at your option.) * - * 2. Redistributions in binary form, except as embedded into a Espressif Systems - * integrated circuit in a product or a software update for such product, - * must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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 "string.h" @@ -82,8 +59,7 @@ static void bind_cb(esp_zb_zdp_status_t zdo_status, void *user_ctx) ESP_LOGI(TAG, "Bound successfully!"); if (user_ctx) { light_bulb_device_params_t *light = (light_bulb_device_params_t *)user_ctx; - ESP_LOGI(TAG, "The light originating from address(0x%x) on endpoint(%d)", light->short_addr, - light->endpoint); + ESP_LOGI(TAG, "The light originating from address(0x%x) on endpoint(%d)", light->short_addr, light->endpoint); free(light); } } @@ -124,8 +100,13 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START: case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT: if (err_status == ESP_OK) { - ESP_LOGI(TAG, "Start network formation"); - esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION); + ESP_LOGI(TAG, "Device started up in %s factory-reset mode", esp_zb_bdb_is_factory_new() ? "" : "non"); + if (esp_zb_bdb_is_factory_new()) { + ESP_LOGI(TAG, "Start network formation"); + esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION); + } else { + ESP_LOGI(TAG, "Device rebooted"); + } } else { ESP_LOGE(TAG, "Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status)); } @@ -134,10 +115,10 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) if (err_status == ESP_OK) { esp_zb_ieee_addr_t extended_pan_id; esp_zb_get_extended_pan_id(extended_pan_id); - ESP_LOGI(TAG, "Formed network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d)", + ESP_LOGI(TAG, "Formed network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d, Short Address: 0x%04hx)", extended_pan_id[7], extended_pan_id[6], extended_pan_id[5], extended_pan_id[4], extended_pan_id[3], extended_pan_id[2], extended_pan_id[1], extended_pan_id[0], - esp_zb_get_pan_id(), esp_zb_get_current_channel()); + esp_zb_get_pan_id(), esp_zb_get_current_channel(), esp_zb_get_short_address()); esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING); } else { ESP_LOGI(TAG, "Restart network formation (status: %s)", esp_err_to_name(err_status)); @@ -157,6 +138,15 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) cmd_req.addr_of_interest = dev_annce_params->device_short_addr; esp_zb_zdo_find_on_off_light(&cmd_req, user_find_cb, NULL); break; + case ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS: + if (err_status == ESP_OK) { + if (*(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)) { + ESP_LOGI(TAG, "Network(0x%04hx) is open for %d seconds", esp_zb_get_pan_id(), *(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)); + } else { + ESP_LOGW(TAG, "Network(0x%04hx) closed, devices joining not allowed.", esp_zb_get_pan_id()); + } + } + break; default: ESP_LOGI(TAG, "ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type, esp_err_to_name(err_status)); 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 3a14d46637..d4d95a0a0e 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 @@ -1,47 +1,24 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: LicenseRef-Included + * SPDX-License-Identifier: CC0-1.0 * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Zigbee HA_on_off_switch Example * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * This example code is in the Public Domain (or CC0 licensed, at your option.) * - * 2. Redistributions in binary form, except as embedded into a Espressif Systems - * integrated circuit in a product or a software update for such product, - * must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. Any software provided in binary form under this license must not be reverse - * engineered, decompiled, modified and/or disassembled. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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_zigbee_core.h" #include "switch_driver.h" /* Zigbee configuration */ #define MAX_CHILDREN 10 /* the max amount of connected devices */ -#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ -#define HA_ONOFF_SWITCH_ENDPOINT 1 /* esp light switch device endpoint */ -#define ESP_ZB_PRIMARY_CHANNEL_MASK ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK /* Zigbee primary channel mask use in the example */ +#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ +#define HA_ONOFF_SWITCH_ENDPOINT 1 /* esp light switch device endpoint */ +#define ESP_ZB_PRIMARY_CHANNEL_MASK (1l << 13) /* Zigbee primary channel mask use in the example */ #define ESP_ZB_ZC_CONFIG() \ { \ 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 479a89e4fc..c186c3c8ca 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 @@ -1,7 +1,7 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp-zigbee-lib: "~0.9.0" - espressif/esp-zboss-lib: "~0.7.0" + espressif/esp-zboss-lib: "1.0.9" + espressif/esp-zigbee-lib: "1.0.9" ## Required IDF version idf: version: ">=5.0.0" diff --git a/examples/zigbee/light_sample/HA_on_off_switch/partitions.csv b/examples/zigbee/light_sample/HA_on_off_switch/partitions.csv index 9bf5a13c90..a56c0be780 100644 --- a/examples/zigbee/light_sample/HA_on_off_switch/partitions.csv +++ b/examples/zigbee/light_sample/HA_on_off_switch/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, 652K, -zb_storage, data, fat, 0xb3000, 16K, -zb_fct, data, fat, 0xb7000, 1K, +factory, app, factory, 0x10000, 900K, +zb_storage, data, fat, 0xf1000, 16K, +zb_fct, data, fat, 0xf5000, 1K, diff --git a/examples/zigbee/light_sample/HA_on_off_switch/sdkconfig.defaults b/examples/zigbee/light_sample/HA_on_off_switch/sdkconfig.defaults index 24f8636e5e..b6077ef439 100644 --- a/examples/zigbee/light_sample/HA_on_off_switch/sdkconfig.defaults +++ b/examples/zigbee/light_sample/HA_on_off_switch/sdkconfig.defaults @@ -22,12 +22,11 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y CONFIG_MBEDTLS_ECJPAKE_C=y # end of mbedTLS -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n - # # Zboss # CONFIG_ZB_ENABLED=y CONFIG_ZB_ZCZR=y +CONFIG_IEEE802154_RECEIVE_DONE_HANDLER=y # end of Zboss # end of Component config