esp_openthread_task_queue.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * @brief OpenThread task declaration
  21. *
  22. */
  23. typedef void (*esp_openthread_task_t)(void *);
  24. /**
  25. * @brief This function allocs and initializes the OpenThread task queue.
  26. *
  27. * @return
  28. * - ESP_OK on success
  29. * - ESP_ERR_NO_MEM on queue allocation failure
  30. * - ESP_FAIL on other failures
  31. *
  32. */
  33. esp_err_t esp_openthread_task_queue_init(void);
  34. /**
  35. * @brief This function posts a task to the OpenThread task queue.
  36. *
  37. * @param[in] task The task to execute.
  38. * @param[in] arg The context argument to be passed to the task.
  39. *
  40. * @return
  41. * - ESP_OK
  42. * - ESP_FAIL
  43. *
  44. */
  45. esp_err_t esp_openthread_task_queue_post(esp_openthread_task_t task, void *arg);
  46. /**
  47. * @brief This function updates the task queue inner fd to the main loop.
  48. *
  49. * @param[inout] mainloop The main loop context.
  50. *
  51. */
  52. void esp_openthread_task_queue_update(esp_openthread_mainloop_context_t *mainloop);
  53. /**
  54. * @brief This function drives the execution of the task queue.
  55. *
  56. * @param[in] instance The OpenThread instance.
  57. * @param[in] mainloop The main loop context.
  58. *
  59. * @return
  60. * - ESP_OK
  61. * - ESP_FAIL
  62. *
  63. */
  64. esp_err_t esp_openthread_task_queue_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop);
  65. /**
  66. * @brief This function deinitializes the task queue.
  67. *
  68. * @return
  69. * - ESP_OK
  70. * - ESP_FAIL
  71. *
  72. */
  73. esp_err_t esp_openthread_task_queue_deinit(void);
  74. #ifdef __cplusplus
  75. }
  76. #endif