esp_wifi_default.h 3.8 KB

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