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 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef _ESP_WIFI_NETIF_H
16 #define _ESP_WIFI_NETIF_H
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /**
23  * @brief Number of WiFi interfaces used by wifi-netif abstraction
24  */
25 #define MAX_WIFI_IFS (2)
26 
27 /**
28  * @brief Forward declaration of WiFi interface handle
29  */
30 typedef struct wifi_netif_driver* wifi_netif_driver_t;
31 
32 /**
33  * @brief Creates wifi driver instance to be used with esp-netif
34  *
35  * @param wifi_if wifi interface type (station, softAP)
36  *
37  * @return
38  *  - pointer to wifi interface handle on success
39  *  - NULL otherwise
40  */
41 wifi_netif_driver_t esp_wifi_create_if_driver(wifi_interface_t wifi_if);
42 
43 /**
44  * @brief Destroys wifi driver instance
45  *
46  * @param h pointer to wifi interface handle
47  *
48  */
49 void esp_wifi_destroy_if_driver(wifi_netif_driver_t h);
50 
51 /**
52  * @brief Return mac of specified wifi driver instance
53  *
54  * @param[in] ifx pointer to wifi interface handle
55  * @param[out] mac output mac address
56  *
57  * @return ESP_OK on success
58  *
59  */
60 esp_err_t esp_wifi_get_if_mac(wifi_netif_driver_t ifx, uint8_t mac[6]);
61 
62 /**
63  * @brief Return true if the supplied interface instance is ready after start.
64  * Typically used when registering on receive callback, which ought to be
65  * installed as soon as AP started, but once STA gets connected.
66  *
67  * @param[in] ifx pointer to wifi interface handle
68  *
69  * @return
70  *      - true if ready after intertace started (typically Access Point type)
71  *      - false if ready once intertace connected (typically for Station type)
72  */
73 bool esp_wifi_is_if_ready_when_started(wifi_netif_driver_t ifx);
74 
75 /**
76  * @brief Register interface receive callback function with argument
77  *
78  * @param[in] ifx pointer to wifi interface handle
79  * @param[in] fn  funtion to be registered (typically esp_netif_receive)
80  * @param[in] arg argument to be supplied to registered function (typically esp_netif ptr)
81  *
82  * @return ESP_OK on success
83  *
84  */
85 esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t fn, void * arg);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif //_ESP_WIFI_NETIF_H
92