esp_openthread.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_openthread_types.h"
  9. #include "openthread/error.h"
  10. #include "openthread/instance.h"
  11. #include "lwip/ip_addr.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /**
  16. * @brief Initializes the full OpenThread stack.
  17. *
  18. * @note The OpenThread instance will also be initialized in this function.
  19. *
  20. * @param[in] init_config The initialization configuration.
  21. *
  22. * @return
  23. * - ESP_OK on success
  24. * - ESP_ERR_NO_MEM if allocation has failed
  25. * - ESP_ERR_INVALID_ARG if radio or host connection mode not supported
  26. * - ESP_ERR_INVALID_STATE if already initialized
  27. *
  28. */
  29. esp_err_t esp_openthread_init(const esp_openthread_platform_config_t *init_config);
  30. /**
  31. * @brief Launches the OpenThread main loop.
  32. *
  33. * @note Thie function will not return unless error happens when running the OpenThread stack.
  34. *
  35. * @return
  36. * - ESP_OK on success
  37. * - ESP_ERR_NO_MEM if allocation has failed
  38. * - ESP_FAIL on other failures
  39. *
  40. */
  41. esp_err_t esp_openthread_launch_mainloop(void);
  42. /**
  43. * @brief This function performs OpenThread stack and platform driver deinitialization.
  44. *
  45. * @return
  46. * - ESP_OK on success
  47. * - ESP_ERR_INVALID_STATE if not initialized
  48. *
  49. */
  50. esp_err_t esp_openthread_deinit(void);
  51. /**
  52. * @brief This function acquires the underlying OpenThread instance.
  53. *
  54. * @note This function can be called on other tasks without lock.
  55. *
  56. * @return The OpenThread instance pointer
  57. *
  58. */
  59. otInstance *esp_openthread_get_instance(void);
  60. #ifdef __cplusplus
  61. } // end of extern "C"
  62. #endif