esp_zigbee_rcp.c 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: LicenseRef-Included
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice,
  10. * this list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Espressif Systems
  13. * integrated circuit in a product or a software update for such product,
  14. * must reproduce the above copyright notice, this list of conditions and
  15. * the following disclaimer in the documentation and/or other materials
  16. * provided with the distribution.
  17. *
  18. * 3. Neither the name of the copyright holder nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software without
  20. * specific prior written permission.
  21. *
  22. * 4. Any software provided in binary form under this license must not be reverse
  23. * engineered, decompiled, modified and/or disassembled.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  29. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  35. * POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. #include "freertos/FreeRTOS.h"
  38. #include "freertos/task.h"
  39. #include "esp_log.h"
  40. #include "nvs_flash.h"
  41. #include "zb_scheduler.h"
  42. #include "esp_zigbee_rcp.h"
  43. #if (defined ZB_MACSPLIT_HOST && !defined ZB_MACSPLIT_DEVICE)
  44. #error Only Zigbee rcp device should be defined
  45. #endif
  46. static const char *TAG = "ESP_ZB_RCP";
  47. void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
  48. {
  49. uint32_t *p_sg_p = signal_struct->p_app_signal;
  50. esp_err_t err_status = signal_struct->esp_err_status;
  51. esp_zb_app_signal_type_t sig_type = *p_sg_p;
  52. if (err_status == ESP_OK) {
  53. } else if (sig_type == ESP_ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY) {
  54. ESP_LOGI(TAG, "Production config is not present or invalid");
  55. } else {
  56. ESP_LOGI(TAG, "Device started FAILED status %d", err_status);
  57. }
  58. }
  59. static void esp_zb_task(void *pvParameters)
  60. {
  61. esp_zb_rcp_init();
  62. esp_zb_rcp_main_loop_iteration();
  63. }
  64. void app_main(void)
  65. {
  66. esp_zb_platform_config_t config = {
  67. .radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(),
  68. .host_config = ESP_ZB_DEFAULT_HOST_CONFIG(),
  69. };
  70. ESP_ERROR_CHECK(nvs_flash_init());
  71. /* load Zigbee rcp platform config to initialization */
  72. esp_zb_macsplit_set_version(RCP_COMPILE_DEFINE);
  73. ESP_ERROR_CHECK(esp_zb_platform_config(&config));
  74. xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL);
  75. }