esp_openthread.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2021 Espressif Systems (Shanghai) CO LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License
  13. #pragma once
  14. #include "esp_err.h"
  15. #include "esp_openthread_types.h"
  16. #include "openthread/error.h"
  17. #include "openthread/instance.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * @brief Initializes the full OpenThread stack.
  23. *
  24. * @note The OpenThread instance will also be initialized in this function.
  25. *
  26. * @param[in] init_config The initialization configuration.
  27. *
  28. * @return
  29. * - ESP_OK on success
  30. * - ESP_ERR_NO_MEM if allocation has failed
  31. * - ESP_ERR_INVALID_ARG if radio or host connection mode not supported
  32. * - ESP_ERR_INVALID_STATE if already initialized
  33. *
  34. */
  35. esp_err_t esp_openthread_init(const esp_openthread_platform_config_t *init_config);
  36. /**
  37. * @brief Launches the OpenThread main loop.
  38. *
  39. * @note Thie function will not return unless error happens when running the OpenThread stack.
  40. *
  41. * @return
  42. * - ESP_OK on success
  43. * - ESP_ERR_NO_MEM if allocation has failed
  44. * - ESP_FAIL on other failures
  45. *
  46. */
  47. esp_err_t esp_openthread_launch_mainloop(void);
  48. /**
  49. * @brief This function performs OpenThread stack and platform driver deinitialization.
  50. *
  51. * @return
  52. * - ESP_OK on success
  53. * - ESP_ERR_INVALID_STATE if not initialized
  54. *
  55. */
  56. esp_err_t esp_openthread_deinit(void);
  57. /**
  58. * @brief This function acquires the underlying OpenThread instance.
  59. *
  60. * @note This function can be called on other tasks without lock.
  61. *
  62. * @return The OpenThread instance pointer
  63. *
  64. */
  65. otInstance *esp_openthread_get_instance(void);
  66. #ifdef __cplusplus
  67. } // end of extern "C"
  68. #endif