esp_wifi_netif.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_NETIF_H
  14. #define _ESP_WIFI_NETIF_H
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /**
  19. * @brief Number of WiFi interfaces used by wifi-netif abstraction
  20. */
  21. #define MAX_WIFI_IFS (2)
  22. /**
  23. * @brief Forward declaration of WiFi interface handle
  24. */
  25. typedef struct wifi_netif_driver* wifi_netif_driver_t;
  26. /**
  27. * @brief Creates wifi driver instance to be used with esp-netif
  28. *
  29. * @param wifi_if wifi interface type (station, softAP)
  30. *
  31. * @return
  32. * - pointer to wifi interface handle on success
  33. * - NULL otherwise
  34. */
  35. wifi_netif_driver_t esp_wifi_create_if_driver(wifi_interface_t wifi_if);
  36. /**
  37. * @brief Destroys wifi driver instance
  38. *
  39. * @param h pointer to wifi interface handle
  40. *
  41. */
  42. void esp_wifi_destroy_if_driver(wifi_netif_driver_t h);
  43. /**
  44. * @brief Return mac of specified wifi driver instance
  45. *
  46. * @param[in] ifx pointer to wifi interface handle
  47. * @param[out] mac output mac address
  48. *
  49. * @return ESP_OK on success
  50. *
  51. */
  52. esp_err_t esp_wifi_get_if_mac(wifi_netif_driver_t ifx, uint8_t mac[6]);
  53. /**
  54. * @brief Return true if the supplied interface instance is ready after start.
  55. * Typically used when registering on receive callback, which ought to be
  56. * installed as soon as AP started, but once STA gets connected.
  57. *
  58. * @param[in] ifx pointer to wifi interface handle
  59. *
  60. * @return
  61. * - true if ready after intertace started (typically Access Point type)
  62. * - false if ready once intertace connected (typically for Station type)
  63. */
  64. bool esp_wifi_is_if_ready_when_started(wifi_netif_driver_t ifx);
  65. /**
  66. * @brief Register interface receive callback function with argument
  67. *
  68. * @param[in] ifx pointer to wifi interface handle
  69. * @param[in] fn funtion to be registered (typically esp_netif_receive)
  70. * @param[in] arg argument to be supplied to registered function (typically esp_netif ptr)
  71. *
  72. * @return ESP_OK on success
  73. *
  74. */
  75. esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t fn, void * arg);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif //_ESP_WIFI_NETIF_H