1 /*
2  * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #include <stdint.h>
10 #include <stdbool.h>
11 #include "esp_err.h"
12 #include "esp_wifi_types.h"
13 #include "esp_netif_types.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /**
20  * @brief Number of WiFi interfaces used by wifi-netif abstraction
21  */
22 #define MAX_WIFI_IFS WIFI_IF_MAX
23 
24 /**
25  * @brief Forward declaration of WiFi interface handle
26  */
27 typedef struct wifi_netif_driver* wifi_netif_driver_t;
28 
29 /**
30  * @brief Creates wifi driver instance to be used with esp-netif
31  *
32  * @param wifi_if wifi interface type (station, softAP)
33  *
34  * @return
35  *  - pointer to wifi interface handle on success
36  *  - NULL otherwise
37  */
38 wifi_netif_driver_t esp_wifi_create_if_driver(wifi_interface_t wifi_if);
39 
40 /**
41  * @brief Destroys wifi driver instance
42  *
43  * @param h pointer to wifi interface handle
44  *
45  */
46 void esp_wifi_destroy_if_driver(wifi_netif_driver_t h);
47 
48 /**
49  * @brief Return mac of specified wifi driver instance
50  *
51  * @param[in] ifx pointer to wifi interface handle
52  * @param[out] mac output mac address
53  *
54  * @return ESP_OK on success
55  *
56  */
57 esp_err_t esp_wifi_get_if_mac(wifi_netif_driver_t ifx, uint8_t mac[6]);
58 
59 /**
60  * @brief Return true if the supplied interface instance is ready after start.
61  * Typically used when registering on receive callback, which ought to be
62  * installed as soon as AP started, but once STA gets connected.
63  *
64  * @param[in] ifx pointer to wifi interface handle
65  *
66  * @return
67  *      - true if ready after interface started (typically Access Point type)
68  *      - false if ready once interface connected (typically for Station type)
69  */
70 bool esp_wifi_is_if_ready_when_started(wifi_netif_driver_t ifx);
71 
72 /**
73  * @brief Register interface receive callback function with argument
74  *
75  * @param[in] ifx pointer to wifi interface handle
76  * @param[in] fn  function to be registered (typically esp_netif_receive)
77  * @param[in] arg argument to be supplied to registered function (typically esp_netif ptr)
78  *
79  * @return ESP_OK on success
80  *
81  */
82 esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t fn, void * arg);
83 
84 #ifdef __cplusplus
85 }
86 #endif
87