From 2c7f9500840a32aae0c49cd22dfa96c3160c7e4c Mon Sep 17 00:00:00 2001 From: likunqiao Date: Tue, 11 Jan 2022 15:52:34 +0800 Subject: [PATCH] Zigbee: Zigbee example update * minor update for the zigbee example --- .../main/esp_zigbee_gateway.c | 25 +++++++++++++------ .../esp_zigbee_gateway/main/idf_component.yml | 13 +--------- .../esp_zigbee_gateway/sdkconfig.defaults | 6 ----- .../esp_zigbee_rcp/main/esp_zigbee_rcp.c | 18 ++++++------- .../esp_zigbee_rcp/main/idf_component.yml | 13 +--------- .../light_bulb/main/esp_zb_light.c | 4 +-- .../light_bulb/main/idf_component.yml | 13 +--------- .../light_bulb/sdkconfig.defaults | 6 ----- .../main/esp_zb_coordinator.c | 11 ++++---- .../light_coordinator/main/idf_component.yml | 13 +--------- .../light_coordinator/sdkconfig.defaults | 6 ----- .../light_switch/main/esp_zb_switch.c | 4 +-- .../light_switch/main/idf_component.yml | 13 +--------- .../light_switch/sdkconfig.defaults | 6 ----- 14 files changed, 41 insertions(+), 110 deletions(-) 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 1359869aae..5538025f7c 100644 --- a/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c +++ b/examples/zigbee/esp_zigbee_gateway/main/esp_zigbee_gateway.c @@ -59,6 +59,9 @@ void zboss_signal_handler(zb_bufid_t bufid) zb_zdo_app_signal_hdr_t *p_sg_p = NULL; 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 *dev_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: @@ -68,6 +71,13 @@ void zboss_signal_handler(zb_bufid_t bufid) case ZB_MACSPLIT_DEVICE_BOOT: ESP_LOGI(TAG, "Zigbee rcp device booted"); + gateway_version = zb_esp_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: @@ -100,11 +110,11 @@ void zboss_signal_handler(zb_bufid_t bufid) } break; - case ZB_ZDO_SIGNAL_DEVICE_ANNCE: { - 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); + case ZB_ZDO_SIGNAL_DEVICE_ANNCE: + dev_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)", dev_annce_params->device_short_addr); - } - break; + break; + default: ESP_LOGI(TAG, "status: %d", status); break; @@ -115,7 +125,7 @@ void zboss_signal_handler(zb_bufid_t bufid) } } -void zboss_task() +static void zboss_task(void *pvParameters) { ZB_INIT("zigbee gateway"); zb_set_network_coordinator_role(IEEE_CHANNEL_MASK); @@ -125,11 +135,10 @@ void zboss_task() ESP_ERROR_CHECK(zboss_start_no_autostart()); while (1) { zboss_main_loop_iteration(); - vTaskDelay(10 / portTICK_PERIOD_MS); } } -void app_main() +void app_main(void) { zb_esp_platform_config_t config = { .radio_config = ZB_ESP_DEFAULT_RADIO_CONFIG(), @@ -137,5 +146,5 @@ void app_main() }; /* load Zigbee gateway platform config to initialization */ ESP_ERROR_CHECK(zb_esp_platform_config(&config)); - xTaskCreate(zboss_task, "zboss_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL); + xTaskCreate(zboss_task, "zboss_main", 4096, NULL, 5, NULL); } diff --git a/examples/zigbee/esp_zigbee_gateway/main/idf_component.yml b/examples/zigbee/esp_zigbee_gateway/main/idf_component.yml index de3935b811..9825e1cd1c 100644 --- a/examples/zigbee/esp_zigbee_gateway/main/idf_component.yml +++ b/examples/zigbee/esp_zigbee_gateway/main/idf_component.yml @@ -3,15 +3,4 @@ dependencies: espressif/esp-zboss-lib: "~=0.0.4" ## Required IDF version idf: - version: ">=4.1.0" - # # Put list of dependencies here - # # For components maintained by Espressif: - # component: "~1.0.0" - # # For 3rd party components: - # username/component: ">=1.0.0,<2.0.0" - # username2/component2: - # version: "~1.0.0" - # # For transient dependencies `public` flag can be set. - # # `public` flag doesn't have an effect dependencies of the `main` component. - # # All dependencies of `main` are public by default. - # public: true + version: ">=5.0.0" diff --git a/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults b/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults index cbbde23a9a..781db6e5c8 100644 --- a/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults +++ b/examples/zigbee/esp_zigbee_gateway/sdkconfig.defaults @@ -1,9 +1,3 @@ -# -# libsodium -# -CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y -# end of libsodium - # # Partition Table # 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 4c6b983a55..533b17c317 100644 --- a/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.c +++ b/examples/zigbee/esp_zigbee_rcp/main/esp_zigbee_rcp.c @@ -46,13 +46,13 @@ #endif static const char *TAG = "ESP_ZB_RCP"; -void zboss_signal_handler(zb_uint8_t param) +void zboss_signal_handler(zb_bufid_t bufid) { zb_zdo_app_signal_hdr_t *sg_p = NULL; /* get application signal from the buffer */ - zb_zdo_app_signal_type_t sig = zb_get_app_signal(param, &sg_p); + zb_zdo_app_signal_type_t sig = zb_get_app_signal(bufid, &sg_p); - if (ZB_GET_APP_SIGNAL_STATUS(param) == 0) { + if (ZB_GET_APP_SIGNAL_STATUS(bufid) == 0) { switch (sig) { case ZB_COMMON_SIGNAL_CAN_SLEEP: #if defined(ZB_USE_SLEEP) @@ -64,15 +64,15 @@ void zboss_signal_handler(zb_uint8_t param) } else if (sig == ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY) { ESP_LOGI(TAG, "Production config is not present or invalid"); } else { - ESP_LOGI(TAG, "Device started FAILED status %d", ZB_GET_APP_SIGNAL_STATUS(param)); + ESP_LOGI(TAG, "Device started FAILED status %d", ZB_GET_APP_SIGNAL_STATUS(bufid)); } - if (param) { - zb_buf_free(param); + if (bufid) { + zb_buf_free(bufid); } } -void zboss_task() +static void zboss_task(void * pvParameters) { ZB_INIT("esp_zigbee_rcp"); while (1) { @@ -80,7 +80,7 @@ void zboss_task() } } -void app_main() +void app_main(void) { zb_esp_platform_config_t config = { .radio_config = ZB_ESP_DEFAULT_RADIO_CONFIG(), @@ -88,5 +88,5 @@ void app_main() }; /* load Zigbee rcp platform config to initialization */ ESP_ERROR_CHECK(zb_esp_platform_config(&config)); - xTaskCreate(zboss_task, "zboss_main", 4096, xTaskGetCurrentTaskHandle(), 5, NULL); + xTaskCreate(zboss_task, "zboss_main", 4096, NULL, 5, NULL); } diff --git a/examples/zigbee/esp_zigbee_rcp/main/idf_component.yml b/examples/zigbee/esp_zigbee_rcp/main/idf_component.yml index de3935b811..9825e1cd1c 100644 --- a/examples/zigbee/esp_zigbee_rcp/main/idf_component.yml +++ b/examples/zigbee/esp_zigbee_rcp/main/idf_component.yml @@ -3,15 +3,4 @@ dependencies: espressif/esp-zboss-lib: "~=0.0.4" ## Required IDF version idf: - version: ">=4.1.0" - # # Put list of dependencies here - # # For components maintained by Espressif: - # component: "~1.0.0" - # # For 3rd party components: - # username/component: ">=1.0.0,<2.0.0" - # username2/component2: - # version: "~1.0.0" - # # For transient dependencies `public` flag can be set. - # # `public` flag doesn't have an effect dependencies of the `main` component. - # # All dependencies of `main` are public by default. - # public: true + version: ">=5.0.0" diff --git a/examples/zigbee/light_sample/light_bulb/main/esp_zb_light.c b/examples/zigbee/light_sample/light_bulb/main/esp_zb_light.c index c245be3282..387b43af61 100644 --- a/examples/zigbee/light_sample/light_bulb/main/esp_zb_light.c +++ b/examples/zigbee/light_sample/light_bulb/main/esp_zb_light.c @@ -106,7 +106,7 @@ static void bdb_start_top_level_commissioning_cb(zb_uint8_t mode_mask) * * @param bufid Zigbee zboss stack buffer id used to pass signal. */ -void zboss_signal_handler(zb_uint8_t bufid) +void zboss_signal_handler(zb_bufid_t bufid) { zb_uint8_t status = ZB_GET_APP_SIGNAL_STATUS(bufid); zb_zdo_app_signal_type_t sig = zb_get_app_signal(bufid, NULL); @@ -212,7 +212,7 @@ static void esp_zb_light_cb(zb_bufid_t bufid) } } -void app_main() +void app_main(void) { zb_ret_t zb_err_code; zb_esp_platform_config_t config = { diff --git a/examples/zigbee/light_sample/light_bulb/main/idf_component.yml b/examples/zigbee/light_sample/light_bulb/main/idf_component.yml index de3935b811..9825e1cd1c 100644 --- a/examples/zigbee/light_sample/light_bulb/main/idf_component.yml +++ b/examples/zigbee/light_sample/light_bulb/main/idf_component.yml @@ -3,15 +3,4 @@ dependencies: espressif/esp-zboss-lib: "~=0.0.4" ## Required IDF version idf: - version: ">=4.1.0" - # # Put list of dependencies here - # # For components maintained by Espressif: - # component: "~1.0.0" - # # For 3rd party components: - # username/component: ">=1.0.0,<2.0.0" - # username2/component2: - # version: "~1.0.0" - # # For transient dependencies `public` flag can be set. - # # `public` flag doesn't have an effect dependencies of the `main` component. - # # All dependencies of `main` are public by default. - # public: true + version: ">=5.0.0" diff --git a/examples/zigbee/light_sample/light_bulb/sdkconfig.defaults b/examples/zigbee/light_sample/light_bulb/sdkconfig.defaults index 1fa4e7a917..974931a889 100644 --- a/examples/zigbee/light_sample/light_bulb/sdkconfig.defaults +++ b/examples/zigbee/light_sample/light_bulb/sdkconfig.defaults @@ -1,11 +1,5 @@ CONFIG_IDF_TARGET="esp32h2" -# -# libsodium -# -CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y -# end of libsodium - # # Partition Table # diff --git a/examples/zigbee/light_sample/light_coordinator/main/esp_zb_coordinator.c b/examples/zigbee/light_sample/light_coordinator/main/esp_zb_coordinator.c index d6b39998df..dcc6a80fd0 100644 --- a/examples/zigbee/light_sample/light_coordinator/main/esp_zb_coordinator.c +++ b/examples/zigbee/light_sample/light_coordinator/main/esp_zb_coordinator.c @@ -60,6 +60,7 @@ void zboss_signal_handler(zb_bufid_t bufid) zb_zdo_app_signal_hdr_t *p_sg_p = NULL; 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 *dev_annce_params = NULL; switch (sig) { case ZB_ZDO_SIGNAL_SKIP_STARTUP: @@ -97,11 +98,11 @@ void zboss_signal_handler(zb_bufid_t bufid) } break; - case ZB_ZDO_SIGNAL_DEVICE_ANNCE: { - 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); + case ZB_ZDO_SIGNAL_DEVICE_ANNCE: + dev_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)", dev_annce_params->device_short_addr); - } - break; + break; + default: ESP_LOGI(TAG, "status: %d", status); break; @@ -112,7 +113,7 @@ void zboss_signal_handler(zb_bufid_t bufid) } } -void app_main() +void app_main(void) { zb_ret_t zb_err_code; zb_esp_platform_config_t config = { diff --git a/examples/zigbee/light_sample/light_coordinator/main/idf_component.yml b/examples/zigbee/light_sample/light_coordinator/main/idf_component.yml index de3935b811..9825e1cd1c 100644 --- a/examples/zigbee/light_sample/light_coordinator/main/idf_component.yml +++ b/examples/zigbee/light_sample/light_coordinator/main/idf_component.yml @@ -3,15 +3,4 @@ dependencies: espressif/esp-zboss-lib: "~=0.0.4" ## Required IDF version idf: - version: ">=4.1.0" - # # Put list of dependencies here - # # For components maintained by Espressif: - # component: "~1.0.0" - # # For 3rd party components: - # username/component: ">=1.0.0,<2.0.0" - # username2/component2: - # version: "~1.0.0" - # # For transient dependencies `public` flag can be set. - # # `public` flag doesn't have an effect dependencies of the `main` component. - # # All dependencies of `main` are public by default. - # public: true + version: ">=5.0.0" diff --git a/examples/zigbee/light_sample/light_coordinator/sdkconfig.defaults b/examples/zigbee/light_sample/light_coordinator/sdkconfig.defaults index 1fa4e7a917..974931a889 100644 --- a/examples/zigbee/light_sample/light_coordinator/sdkconfig.defaults +++ b/examples/zigbee/light_sample/light_coordinator/sdkconfig.defaults @@ -1,11 +1,5 @@ CONFIG_IDF_TARGET="esp32h2" -# -# libsodium -# -CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y -# end of libsodium - # # Partition Table # diff --git a/examples/zigbee/light_sample/light_switch/main/esp_zb_switch.c b/examples/zigbee/light_sample/light_switch/main/esp_zb_switch.c index 402145933c..90140ff46b 100644 --- a/examples/zigbee/light_sample/light_switch/main/esp_zb_switch.c +++ b/examples/zigbee/light_sample/light_switch/main/esp_zb_switch.c @@ -231,7 +231,7 @@ static void bdb_start_top_level_commissioning_cb(zb_uint8_t mode_mask) * * @param bufid Zigbee zboss stack buffer id used to pass signal. */ -void zboss_signal_handler(zb_uint8_t bufid) +void zboss_signal_handler(zb_bufid_t bufid) { zb_zdo_app_signal_hdr_t *p_sg_p = NULL; zb_zdo_app_signal_type_t sig = zb_get_app_signal(bufid, &p_sg_p); @@ -281,7 +281,7 @@ void zboss_signal_handler(zb_uint8_t bufid) } } -void app_main() +void app_main(void) { zb_ret_t zb_err_code; zb_esp_platform_config_t config = { diff --git a/examples/zigbee/light_sample/light_switch/main/idf_component.yml b/examples/zigbee/light_sample/light_switch/main/idf_component.yml index de3935b811..9825e1cd1c 100644 --- a/examples/zigbee/light_sample/light_switch/main/idf_component.yml +++ b/examples/zigbee/light_sample/light_switch/main/idf_component.yml @@ -3,15 +3,4 @@ dependencies: espressif/esp-zboss-lib: "~=0.0.4" ## Required IDF version idf: - version: ">=4.1.0" - # # Put list of dependencies here - # # For components maintained by Espressif: - # component: "~1.0.0" - # # For 3rd party components: - # username/component: ">=1.0.0,<2.0.0" - # username2/component2: - # version: "~1.0.0" - # # For transient dependencies `public` flag can be set. - # # `public` flag doesn't have an effect dependencies of the `main` component. - # # All dependencies of `main` are public by default. - # public: true + version: ">=5.0.0" diff --git a/examples/zigbee/light_sample/light_switch/sdkconfig.defaults b/examples/zigbee/light_sample/light_switch/sdkconfig.defaults index ae34b12a3d..4f82c3f28f 100644 --- a/examples/zigbee/light_sample/light_switch/sdkconfig.defaults +++ b/examples/zigbee/light_sample/light_switch/sdkconfig.defaults @@ -1,11 +1,5 @@ CONFIG_IDF_TARGET="esp32h2" -# -# libsodium -# -CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y -# end of libsodium - # # Partition Table #