esp_wifi_default.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _ESP_WIFI_DEFAULT_H
  7. #define _ESP_WIFI_DEFAULT_H
  8. #include "esp_netif.h"
  9. #include "esp_wifi_types.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief Attaches wifi station interface to supplied netif
  15. *
  16. * @param esp_netif instance to attach the wifi station to
  17. *
  18. * @return
  19. * - ESP_OK on success
  20. * - ESP_FAIL if attach failed
  21. */
  22. esp_err_t esp_netif_attach_wifi_station(esp_netif_t *esp_netif);
  23. /**
  24. * @brief Attaches wifi soft AP interface to supplied netif
  25. *
  26. * @param esp_netif instance to attach the wifi AP to
  27. *
  28. * @return
  29. * - ESP_OK on success
  30. * - ESP_FAIL if attach failed
  31. */
  32. esp_err_t esp_netif_attach_wifi_ap(esp_netif_t *esp_netif);
  33. /**
  34. * @brief Sets default wifi event handlers for STA interface
  35. *
  36. * @return
  37. * - ESP_OK on success, error returned from esp_event_handler_register if failed
  38. */
  39. esp_err_t esp_wifi_set_default_wifi_sta_handlers(void);
  40. /**
  41. * @brief Sets default wifi event handlers for AP interface
  42. *
  43. * @return
  44. * - ESP_OK on success, error returned from esp_event_handler_register if failed
  45. */
  46. esp_err_t esp_wifi_set_default_wifi_ap_handlers(void);
  47. /**
  48. * @brief Sets default wifi event handlers for NAN interface
  49. *
  50. * @return
  51. * - ESP_OK on success, error returned from esp_event_handler_register if failed
  52. */
  53. esp_err_t esp_wifi_set_default_wifi_nan_handlers(void);
  54. /**
  55. * @brief Clears default wifi event handlers for supplied network interface
  56. *
  57. * @param esp_netif instance of corresponding if object
  58. *
  59. * @return
  60. * - ESP_OK on success, error returned from esp_event_handler_register if failed
  61. */
  62. esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif);
  63. /**
  64. * @brief Creates default WIFI AP. In case of any init error this API aborts.
  65. *
  66. * @note The API creates esp_netif object with default WiFi access point config,
  67. * attaches the netif to wifi and registers wifi handlers to the default event loop.
  68. * This API uses assert() to check for potential errors, so it could abort the program.
  69. * (Note that the default event loop needs to be created prior to calling this API)
  70. *
  71. * @return pointer to esp-netif instance
  72. */
  73. esp_netif_t* esp_netif_create_default_wifi_ap(void);
  74. /**
  75. * @brief Creates default WIFI STA. In case of any init error this API aborts.
  76. *
  77. * @note The API creates esp_netif object with default WiFi station config,
  78. * attaches the netif to wifi and registers wifi handlers to the default event loop.
  79. * This API uses assert() to check for potential errors, so it could abort the program.
  80. * (Note that the default event loop needs to be created prior to calling this API)
  81. *
  82. * @return pointer to esp-netif instance
  83. */
  84. esp_netif_t* esp_netif_create_default_wifi_sta(void);
  85. /**
  86. * @brief Creates default WIFI NAN. In case of any init error this API aborts.
  87. *
  88. * @note The API creates esp_netif object with default WiFi station config,
  89. * attaches the netif to wifi and registers wifi handlers to the default event loop.
  90. * (Note that the default event loop needs to be created prior to calling this API)
  91. *
  92. * @return pointer to esp-netif instance
  93. */
  94. esp_netif_t* esp_netif_create_default_wifi_nan(void);
  95. /**
  96. * @brief Destroys default WIFI netif created with esp_netif_create_default_wifi_...() API.
  97. *
  98. * @param[in] esp_netif object to detach from WiFi and destroy
  99. *
  100. * @note This API unregisters wifi handlers and detaches the created object from the wifi.
  101. * (this function is a no-operation if esp_netif is NULL)
  102. */
  103. void esp_netif_destroy_default_wifi(void *esp_netif);
  104. /**
  105. * @brief Creates esp_netif WiFi object based on the custom configuration.
  106. *
  107. * @attention This API DOES NOT register default handlers!
  108. *
  109. * @param[in] wifi_if type of wifi interface
  110. * @param[in] esp_netif_config inherent esp-netif configuration pointer
  111. *
  112. * @return pointer to esp-netif instance
  113. */
  114. esp_netif_t* esp_netif_create_wifi(wifi_interface_t wifi_if, const esp_netif_inherent_config_t *esp_netif_config);
  115. /**
  116. * @brief Creates default STA and AP network interfaces for esp-mesh.
  117. *
  118. * Both netifs are almost identical to the default station and softAP, but with
  119. * DHCP client and server disabled. Please note that the DHCP client is typically
  120. * enabled only if the device is promoted to a root node.
  121. *
  122. * Returns created interfaces which could be ignored setting parameters to NULL
  123. * if an application code does not need to save the interface instances
  124. * for further processing.
  125. *
  126. * @param[out] p_netif_sta pointer where the resultant STA interface is saved (if non NULL)
  127. * @param[out] p_netif_ap pointer where the resultant AP interface is saved (if non NULL)
  128. *
  129. * @return ESP_OK on success
  130. */
  131. esp_err_t esp_netif_create_default_wifi_mesh_netifs(esp_netif_t **p_netif_sta, esp_netif_t **p_netif_ap);
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif //_ESP_WIFI_DEFAULT_H