esp_openthread_netif_glue.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "esp_err.h"
  8. #include "esp_netif.h"
  9. #include "esp_openthread_types.h"
  10. #include "openthread/instance.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /**
  15. * @brief Default configuration reference of OT esp-netif
  16. */
  17. #define ESP_NETIF_INHERENT_DEFAULT_OPENTHREAD() \
  18. { \
  19. .flags = 0, \
  20. ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
  21. ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
  22. .get_ip_event = 0, \
  23. .lost_ip_event = 0, \
  24. .if_key = "OT_DEF", \
  25. .if_desc = "openthread", \
  26. .route_prio = 15 \
  27. };
  28. #define ESP_NETIF_DEFAULT_OPENTHREAD() \
  29. { \
  30. .base = &g_esp_netif_inherent_openthread_config, \
  31. .driver = NULL, \
  32. .stack = &g_esp_netif_netstack_default_openthread, \
  33. }
  34. extern const esp_netif_netstack_config_t g_esp_netif_netstack_default_openthread;
  35. extern const esp_netif_inherent_config_t g_esp_netif_inherent_openthread_config;
  36. /**
  37. * @brief This function initializes the OpenThread network interface glue.
  38. *
  39. * @param[in] config The platform configuration.
  40. *
  41. * @return
  42. * - glue pointer on success
  43. * - NULL on failure
  44. *
  45. */
  46. void *esp_openthread_netif_glue_init(const esp_openthread_platform_config_t *config);
  47. /**
  48. * @brief This function deinitializes the OpenThread network interface glue.
  49. *
  50. */
  51. void esp_openthread_netif_glue_deinit(void);
  52. /**
  53. * @brief This function acquires the OpenThread netif.
  54. *
  55. * @return
  56. * The OpenThread netif or NULL if not initialzied.
  57. *
  58. */
  59. esp_netif_t *esp_openthread_get_netif(void);
  60. #ifdef __cplusplus
  61. }
  62. #endif