esp_wifi_default.h 4.2 KB

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