]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/include/drv_wifi.h
Introduce a port for T-HEAD CK802. A simple demo for T-HEAD CB2201 is also included.
[freertos] / FreeRTOS / Demo / T-HEAD_CB2201_CDK / csi / csi_driver / include / drv_wifi.h
1 /**
2  * Copyright (C) 2016 CSI Project. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __CSI_WIFI_H__
18 #define __CSI_WIFI_H__
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #ifndef bool
25 #define bool        int8_t
26 #define false       0        ///< XOS definition of 'false'
27 #define true        1        ///< XOS definition of 'true'
28 #endif
29
30 typedef enum {
31     WIFI_EVENT_WIFI_READY = 0,           /**< WiFi ready */
32     WIFI_EVENT_SCAN_DONE,                /**< finish scanning AP */
33     WIFI_EVENT_STA_START,                /**< station start */
34     WIFI_EVENT_STA_STOP,                 /**< station stop */
35     WIFI_EVENT_STA_CONNECTED,            /**< station connected to AP */
36     WIFI_EVENT_STA_DISCONNECTED,         /**< station disconnected from AP */
37     WIFI_EVENT_STA_AUTHMODE_CHANGE,      /**< the auth mode of AP connected by station changed */
38     WIFI_EVENT_STA_GOT_IP,               /**< station got IP from connected AP */
39     WIFI_EVENT_STA_WPS_ER_SUCCESS,       /**< station wps succeeds in enrollee mode */
40     WIFI_EVENT_STA_WPS_ER_FAILED,        /**< station wps fails in enrollee mode */
41     WIFI_EVENT_STA_WPS_ER_TIMEOUT,       /**< station wps timeout in enrollee mode */
42     WIFI_EVENT_STA_WPS_ER_PIN,           /**< station wps pin code in enrollee mode */
43     WIFI_EVENT_AP_START,                 /**< soft-AP start */
44     WIFI_EVENT_AP_STOP,                  /**< soft-AP stop */
45     WIFI_EVENT_AP_STACONNECTED,          /**< a station connected to soft-AP */
46     WIFI_EVENT_AP_STADISCONNECTED,       /**< a station disconnected from soft-AP */
47     WIFI_EVENT_AP_PROBEREQRECVED,        /**< Receive probe request packet in soft-AP interface */
48     WIFI_EVENT_AP_STA_GOT_IP6,           /**< station or ap interface v6IP addr is preferred */
49     WIFI_EVENT_ETH_START,                /**< ethernet start */
50     WIFI_EVENT_ETH_STOP,                 /**< ethernet stop */
51     WIFI_EVENT_ETH_CONNECTED,            /**< ethernet phy link up */
52     WIFI_EVENT_ETH_DISCONNECTED,         /**< ethernet phy link down */
53     WIFI_EVENT_ETH_GOT_IP,               /**< ethernet got IP from connected AP */
54     WIFI_EVENT_MAX
55 } wifi_event_id_t;
56
57
58 typedef enum {
59     CSI_IF_WIFI_STA = 0,     /**< CSI station interface */
60     CSI_IF_WIFI_AP,          /**< CSI soft-AP interface */
61     CSI_IF_ETH,              /**< CSI ethernet interface */
62     CSI_IF_MAX
63 } csi_interface_t;
64
65 typedef enum {
66     WIFI_MODE_NULL = 0,  /**< null mode */
67     WIFI_MODE_STA,       /**< WiFi station mode */
68     WIFI_MODE_AP,        /**< WiFi soft-AP mode */
69     WIFI_MODE_APSTA,     /**< WiFi station + soft-AP mode */
70     WIFI_MODE_MAX
71 } wifi_mode_t;
72
73 typedef csi_interface_t wifi_interface_t;
74
75 #define WIFI_IF_STA CSI_IF_WIFI_STA
76 #define WIFI_IF_AP  CSI_IF_WIFI_AP
77
78 typedef enum {
79     WIFI_COUNTRY_CN = 0, /**< country China, channel range [1, 14] */
80     WIFI_COUNTRY_JP,     /**< country Japan, channel range [1, 14] */
81     WIFI_COUNTRY_US,     /**< country USA, channel range [1, 11] */
82     WIFI_COUNTRY_EU,     /**< country Europe, channel range [1, 13] */
83     WIFI_COUNTRY_MAX
84 } wifi_country_t;
85
86 typedef enum {
87     WIFI_AUTH_OPEN = 0,         /**< authenticate mode : open */
88     WIFI_AUTH_WEP,              /**< authenticate mode : WEP */
89     WIFI_AUTH_WPA_PSK,          /**< authenticate mode : WPA_PSK */
90     WIFI_AUTH_WPA2_PSK,         /**< authenticate mode : WPA2_PSK */
91     WIFI_AUTH_WPA_WPA2_PSK,     /**< authenticate mode : WPA_WPA2_PSK */
92     WIFI_AUTH_WPA2_ENTERPRISE,  /**< authenticate mode : WPA2_ENTERPRISE */
93     WIFI_AUTH_MAX
94 } wifi_auth_mode_t;
95
96 enum {
97     WIFI_REASON_UNSPECIFIED              = 1,
98     WIFI_REASON_AUTH_EXPIRE              = 2,
99     WIFI_REASON_AUTH_LEAVE               = 3,
100     WIFI_REASON_ASSOC_EXPIRE             = 4,
101     WIFI_REASON_ASSOC_TOOMANY            = 5,
102     WIFI_REASON_NOT_AUTHED               = 6,
103     WIFI_REASON_NOT_ASSOCED              = 7,
104     WIFI_REASON_ASSOC_LEAVE              = 8,
105     WIFI_REASON_ASSOC_NOT_AUTHED         = 9,
106     WIFI_REASON_DISASSOC_PWRCAP_BAD      = 10,
107     WIFI_REASON_DISASSOC_SUPCHAN_BAD     = 11,
108     WIFI_REASON_IE_INVALID               = 13,
109     WIFI_REASON_MIC_FAILURE              = 14,
110     WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT   = 15,
111     WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
112     WIFI_REASON_IE_IN_4WAY_DIFFERS       = 17,
113     WIFI_REASON_GROUP_CIPHER_INVALID     = 18,
114     WIFI_REASON_PAIRWISE_CIPHER_INVALID  = 19,
115     WIFI_REASON_AKMP_INVALID             = 20,
116     WIFI_REASON_UNSUPP_RSN_IE_VERSION    = 21,
117     WIFI_REASON_INVALID_RSN_IE_CAP       = 22,
118     WIFI_REASON_802_1X_AUTH_FAILED       = 23,
119     WIFI_REASON_CIPHER_SUITE_REJECTED    = 24,
120
121     WIFI_REASON_BEACON_TIMEOUT           = 200,
122     WIFI_REASON_NO_AP_FOUND              = 201,
123     WIFI_REASON_AUTH_FAIL                = 202,
124     WIFI_REASON_ASSOC_FAIL               = 203,
125     WIFI_REASON_HANDSHAKE_TIMEOUT        = 204,
126 };
127
128 typedef enum {
129     WIFI_SECOND_CHAN_NONE = 0,  /**< the channel width is HT20 */
130     WIFI_SECOND_CHAN_ABOVE,     /**< the channel width is HT40 and the second channel is above the primary channel */
131     WIFI_SECOND_CHAN_BELOW,     /**< the channel width is HT40 and the second channel is below the primary channel */
132 } wifi_second_chan_t;
133
134 typedef enum {
135     WIFI_SCAN_TYPE_ACTIVE = 0,  /**< active scan */
136     WIFI_SCAN_TYPE_PASSIVE,     /**< passive scan */
137 } wifi_scan_type_t;
138
139 typedef struct {
140     uint32_t min;  /**< minimum active scan time per channel, units: millisecond */
141     uint32_t max;  /**< maximum active scan time per channel, units: millisecond, values above 1500ms may
142                                           cause station to disconnect from AP and are not recommended.  */
143 } wifi_active_scan_time_t;
144
145 typedef union {
146     wifi_active_scan_time_t active;  /**< active scan time per channel */
147     uint32_t passive;                /**< passive scan time per channel, units: millisecond, values above 1500ms may
148                                           cause station to disconnect from AP and are not recommended. */
149 } wifi_scan_time_t;
150
151 typedef struct {
152     uint8_t *ssid;               /**< SSID of AP */
153     uint8_t *bssid;              /**< MAC address of AP */
154     uint8_t channel;             /**< channel, scan the specific channel */
155     bool show_hidden;            /**< enable to scan AP whose SSID is hidden */
156     wifi_scan_type_t scan_type;  /**< scan type, active or passive */
157     wifi_scan_time_t scan_time;  /**< scan time per channel */
158 } wifi_scan_config_t;
159
160 typedef struct {
161     uint8_t bssid[6];                     /**< MAC address of AP */
162     uint8_t ssid[32];                     /**< SSID of AP */
163     uint8_t primary;                      /**< channel of AP */
164     wifi_second_chan_t second;            /**< second channel of AP */
165     int8_t  rssi;                         /**< signal strength of AP */
166     wifi_auth_mode_t authmode;            /**< authmode of AP */
167     uint32_t low_rate_enable:1;           /**< bit: 0 flag to identify if low rate is enabled or not */
168     uint32_t reserved:31;                 /**< bit: 1..31 reserved */
169 } wifi_ap_record_t;
170
171 typedef enum {
172     WIFI_PS_NONE,    /**< No power save */
173     WIFI_PS_MODEM,   /**< Modem power save */
174 } wifi_ps_type_t;
175
176 #define WIFI_PROTOCOL_11B         1
177 #define WIFI_PROTOCOL_11G         2
178 #define WIFI_PROTOCOL_11N         4
179 #define WIFI_PROTOCOL_LR          8
180
181 typedef enum {
182     WIFI_BW_HT20 = 1, /* Bandwidth is HT20 */
183     WIFI_BW_HT40,     /* Bandwidth is HT40 */
184     WIFI_BW_HT20_HT40,
185 } wifi_bandwidth_t;
186
187 typedef struct {
188     uint8_t ssid[32];           /**< SSID of soft-AP */
189     uint8_t password[64];       /**< Password of soft-AP */
190     uint8_t ssid_len;           /**< Length of SSID. If softap_config.ssid_len==0, check the SSID until there is a termination character; otherwise, set the SSID length according to softap_config.ssid_len. */
191     uint8_t channel;            /**< Channel of soft-AP */
192     wifi_auth_mode_t authmode;  /**< Auth mode of soft-AP. Do not support AUTH_WEP in soft-AP mode */
193     uint8_t ssid_hidden;        /**< Broadcast SSID or not, default 0, broadcast the SSID */
194     uint8_t max_connection;     /**< Max number of stations allowed to connect in, default 4, max 4 */
195     uint16_t beacon_interval;   /**< Beacon interval, 100 ~ 60000 ms, default 100 ms */
196 } wifi_ap_config_t;
197
198 typedef struct {
199     uint8_t ssid[32];      /**< SSID of target AP*/
200     uint8_t password[64];  /**< password of target AP*/
201     bool bssid_set;        /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
202     uint8_t bssid[6];     /**< MAC address of target AP*/
203 } wifi_sta_config_t;
204
205 typedef union {
206     wifi_ap_config_t  ap;  /**< configuration of AP */
207     wifi_sta_config_t sta; /**< configuration of STA */
208 } wifi_config_t;
209
210 typedef struct {
211     uint8_t mac[6];  /**< mac address of sta that associated with soft-AP */
212 } wifi_sta_info_t;
213
214 #define CSI_WIFI_MAX_CONN_NUM  (10)       /**< max number of stations which can connect to soft-AP */
215
216 typedef struct {
217     wifi_sta_info_t sta[CSI_WIFI_MAX_CONN_NUM]; /**< station list */
218     int       num; /**< number of station that associated with soft-AP */
219 } wifi_sta_list_t;
220
221 typedef enum {
222     WIFI_STORAGE_FLASH,  /**< all configuration will strore in both memory and flash */
223     WIFI_STORAGE_RAM,    /**< all configuration will only store in the memory */
224 } wifi_storage_t;
225
226 /**
227   * @brief     Vendor IE type
228   *
229   */
230 typedef enum {
231     WIFI_VND_IE_TYPE_BEACON,
232     WIFI_VND_IE_TYPE_PROBE_REQ,
233     WIFI_VND_IE_TYPE_PROBE_RCSI,
234     WIFI_VND_IE_TYPE_ASSOC_REQ,
235     WIFI_VND_IE_TYPE_ASSOC_RCSI,
236 } wifi_vendor_ie_type_t;
237
238 /**
239   * @brief     Vendor IE index
240   *
241   */
242 typedef enum {
243     WIFI_VND_IE_ID_0,
244     WIFI_VND_IE_ID_1,
245 } wifi_vendor_ie_id_t;
246
247 typedef struct {
248     signed rssi:8;            /**< signal intensity of packet */
249     unsigned rate:5;          /**< data rate */
250     unsigned :1;              /**< reserve */
251     unsigned sig_mode:2;      /**< 0:is not 11n packet; 1:is 11n packet */
252     unsigned :16;             /**< reserve */
253     unsigned mcs:7;           /**< if is 11n packet, shows the modulation(range from 0 to 76) */
254     unsigned cwb:1;           /**< if is 11n packet, shows if is HT40 packet or not */
255     unsigned :16;             /**< reserve */
256     unsigned smoothing:1;     /**< reserve */
257     unsigned not_sounding:1;  /**< reserve */
258     unsigned :1;              /**< reserve */
259     unsigned aggregation:1;   /**< Aggregation */
260     unsigned stbc:2;          /**< STBC */
261     unsigned fec_coding:1;    /**< if is 11n packet, shows if is LDPC packet or not */
262     unsigned sgi:1;           /**< SGI */
263     unsigned noise_floor:8;   /**< noise floor */
264     unsigned ampdu_cnt:8;     /**< ampdu cnt */
265     unsigned channel:4;       /**< which channel this packet in */
266     unsigned :12;             /**< reserve */
267     unsigned timestamp:32;    /**< timestamp */
268     unsigned :32;             /**< reserve */
269     unsigned :32;             /**< reserve */
270     unsigned sig_len:12;      /**< It is really lenth of packet */
271     unsigned :12;             /**< reserve */
272     unsigned rx_state:8;      /**< rx state */
273 } wifi_pkt_rx_ctrl_t;
274
275 typedef struct {
276     wifi_pkt_rx_ctrl_t rx_ctrl;
277     uint8_t payload[0];       /**< ieee80211 packet buff, The length of payload is described by sig_len */
278 } wifi_promiscuous_pkt_t;
279
280 /**
281   * @brief     Promiscuous frame type
282   *
283   */
284 typedef enum {
285     WIFI_PKT_CTRL,  /**< control type, receive packet buf is wifi_pkt_rx_ctrl_t */
286     WIFI_PKT_MGMT,  /**< management type, receive packet buf is wifi_promiscuous_pkt_t */
287     WIFI_PKT_DATA,  /**< data type, receive packet buf is wifi_promiscuous_pkt_t */
288     WIFI_PKT_MISC,  /**< other type, receive packet buf is wifi_promiscuous_pkt_t */
289 } wifi_promiscuous_pkt_type_t;
290
291 #define CSI_OK          0
292 #define CSI_FAIL        -1
293
294 #define CSI_ERR_NO_MEM          0x101
295 #define CSI_ERR_INVALID_ARG     0x102
296 #define CSI_ERR_INVALID_STATE   0x103
297 #define CSI_ERR_INVALID_SIZE    0x104
298 #define CSI_ERR_NOT_FOUND       0x105
299 #define CSI_ERR_NOT_SUPPORTED   0x106
300 #define CSI_ERR_TIMEOUT         0x107
301 #define CSI_ERR_INVALID_RCSIONSE    0x108
302 #define CSI_ERR_INVALID_CRC     0x109
303
304 //#define CSI_ERR_WIFI_BASE       0x3000 /*!< Starting number of WiFi error codes */
305
306 #define CSI_ERR_WIFI_OK          CSI_OK                    /*!< No error */
307 #define CSI_ERR_WIFI_FAIL        CSI_FAIL                  /*!< General fail code */
308 #define CSI_ERR_WIFI_NO_MEM      CSI_ERR_NO_MEM            /*!< Out of memory */
309 #define CSI_ERR_WIFI_ARG         CSI_ERR_INVALID_ARG       /*!< Invalid argument */
310 #define CSI_ERR_WIFI_NOT_SUPPORT CSI_ERR_NOT_SUPPORTED     /*!< Indicates that API is not supported yet */
311
312 #define CSI_ERR_WIFI_NOT_INIT    (CSI_DRV_ERRNO_WIFI_BASE + 1)   /*!< WiFi driver was not installed by csi_wifi_init */
313 #define CSI_ERR_WIFI_NOT_STARTED (CSI_DRV_ERRNO_WIFI_BASE + 2)   /*!< WiFi driver was not started by csi_wifi_start */
314 #define CSI_ERR_WIFI_IF          (CSI_DRV_ERRNO_WIFI_BASE + 3)   /*!< WiFi interface error */
315 #define CSI_ERR_WIFI_MODE        (CSI_DRV_ERRNO_WIFI_BASE + 4)   /*!< WiFi mode error */
316 #define CSI_ERR_WIFI_STATE       (CSI_DRV_ERRNO_WIFI_BASE + 5)   /*!< WiFi internal state error */
317 #define CSI_ERR_WIFI_CONN        (CSI_DRV_ERRNO_WIFI_BASE + 6)   /*!< WiFi internal control block of station or soft-AP error */
318 #define CSI_ERR_WIFI_NVS         (CSI_DRV_ERRNO_WIFI_BASE + 7)   /*!< WiFi internal NVS module error */
319 #define CSI_ERR_WIFI_MAC         (CSI_DRV_ERRNO_WIFI_BASE + 8)   /*!< MAC address is invalid */
320 #define CSI_ERR_WIFI_SSID        (CSI_DRV_ERRNO_WIFI_BASE + 9)   /*!< SSID is invalid */
321 #define CSI_ERR_WIFI_PASSWORD    (CSI_DRV_ERRNO_WIFI_BASE + 10)  /*!< Password is invalid */
322 #define CSI_ERR_WIFI_TIMEOUT     (CSI_DRV_ERRNO_WIFI_BASE + 11)  /*!< Timeout error */
323 #define CSI_ERR_WIFI_WAKE_FAIL   (CSI_DRV_ERRNO_WIFI_BASE + 12)  /*!< WiFi is in sleep state(RF closed) and wakeup fail */
324
325 typedef enum
326 {
327     FRAME_FILTER_MODE_FORWARD = 1,                  /*!< Packet filter engine forwards matching packets, discards non-matching packets */
328     FRAME_FILTER_MODE_DISCARD = 0,                  /*!< Packet filter engine discards matching packets, forwards non-matching packets */
329 } frame_filter_mode_t;
330
331 typedef enum
332 {
333     FRAME_FILTER_RULE_POSITIVE_MATCHING  = 0,       /*!< Specifies that a filter should match a given pattern     */
334     FRAME_FILTER_RULE_NEGATIVE_MATCHING  = 1,       /*!< Specifies that a filter should NOT match a given pattern */
335 } frame_filter_rule_t;
336
337 /**
338  * Structure describing a frame filter list item
339  */
340 typedef struct
341 {
342     uint32_t                       id;             /*!< Unique identifier for a packet filter item */
343     frame_filter_rule_t            rule;           /*!< Filter matches are either POSITIVE or NEGATIVE matching */
344     uint16_t                       offset;         /*!< Offset in bytes to start filtering (referenced to the start of the ethernet packet) */
345     uint16_t                       mask_size;      /*!< Size of the mask in bytes */
346     uint8_t*                       mask;           /*!< Pattern mask bytes to be ANDed with the pattern eg. "\xff00" (must be in network byte order) */
347     uint8_t*                       pattern;        /*!< Pattern bytes used to filter eg. "\x0800"  (must be in network byte order) */
348     bool                           enabled_status; /*!< When returned from mhd_get_packet_filters, indicates if the filter is enabled */
349 } wifi_frame_filter_t;
350
351 struct wifi_frame_filter_list
352 {
353     struct wifi_frame_filter_list*  next;
354 };
355 typedef struct wifi_frame_filter_list wifi_frame_filter_list_t;
356
357 typedef void (*wifi_event_cb_t)(uint32_t event);  ///< Signal WiFi Event. Events refer to wifi_event_id_t
358
359 /**
360   * @brief  Init WiFi
361   *         Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
362   *         WiFi NVS structure etc, this WiFi also start WiFi task
363   *
364   * @attention 1. This API must be called before all other WiFi API can be called
365   *
366   * @param  cb callback to handle WiFi event
367   *
368   * @return
369   *    - CSI_OK: succeed
370   *    - CSI_ERR_WIFI_NO_MEM: out of memory
371   *    - others: refer to error code csi_err.h
372   */
373 int32_t csi_wifi_init(wifi_event_cb_t *cb);
374
375 /**
376   * @brief  Deinit WiFi
377   *         Free all resource allocated in csi_wifi_init and stop WiFi task
378   *
379   * @attention 1. This API should be called if you want to remove WiFi driver from the system
380   *
381   * @return CSI_OK: succeed
382   */
383 int32_t csi_wifi_deinit(void);
384
385 /**
386   * @brief     Set the WiFi operating mode
387   *
388   *            Set the WiFi operating mode as station, soft-AP or station+soft-AP,
389   *            The default mode is soft-AP mode.
390   *
391   * @param     mode  WiFi operating mode
392   *
393   * @return
394   *    - CSI_OK: succeed
395   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
396   *    - CSI_ERR_WIFI_ARG: invalid argument
397   *    - others: refer to error code in csi_err.h
398   */
399 int32_t csi_wifi_set_mode(wifi_mode_t mode);
400
401 /**
402   * @brief  Get current operating mode of WiFi
403   *
404   * @param[out]  mode  store current WiFi mode
405   *
406   * @return
407   *    - CSI_OK: succeed
408   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
409   *    - CSI_ERR_WIFI_ARG: invalid argument
410   */
411 int32_t csi_wifi_get_mode(wifi_mode_t *mode);
412
413 /**
414   * @brief  Start WiFi according to current configuration
415   *         If mode is WIFI_MODE_STA, it create station control block and start station
416   *         If mode is WIFI_MODE_AP, it create soft-AP control block and start soft-AP
417   *         If mode is WIFI_MODE_APSTA, it create soft-AP and station control block and start soft-AP and station
418   *
419   * @return
420   *    - CSI_OK: succeed
421   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
422   *    - CSI_ERR_WIFI_ARG: invalid argument
423   *    - CSI_ERR_WIFI_NO_MEM: out of memory
424   *    - CSI_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
425   *    - CSI_ERR_WIFI_FAIL: other WiFi internal errors
426   */
427 int32_t csi_wifi_start(void);
428
429 /**
430   * @brief  Stop WiFi
431   *         If mode is WIFI_MODE_STA, it stop station and free station control block
432   *         If mode is WIFI_MODE_AP, it stop soft-AP and free soft-AP control block
433   *         If mode is WIFI_MODE_APSTA, it stop station/soft-AP and free station/soft-AP control block
434   *
435   * @return
436   *    - CSI_OK: succeed
437   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
438   */
439 int32_t csi_wifi_stop(void);
440
441 /**
442  * @brief  Restore WiFi stack persistent settings to default values
443  *
444  * This function will reset settings made using the following APIs:
445  * - csi_wifi_get_auto_connect,
446  * - csi_wifi_set_protocol,
447  * - csi_wifi_set_config related
448  * - csi_wifi_set_mode
449  *
450  * @return
451  *    - CSI_OK: succeed
452  *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
453  */
454 int32_t csi_wifi_restore(void);
455
456 /**
457   * @brief     Connect the WiFi station to the AP.
458   *
459   * @attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode
460   * @attention 2. If connecting to an AP, call csi_wifi_disconnect to disconnect.
461   *
462   * @return 
463   *    - CSI_OK: succeed
464   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
465   *    - CSI_ERR_WIFI_NOT_START: WiFi is not started by csi_wifi_start
466   *    - CSI_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
467   *    - CSI_ERR_WIFI_SSID: SSID of AP which station connects is invalid
468   */
469 int32_t csi_wifi_connect(void);
470
471 /**
472   * @brief     Disconnect the WiFi station from the AP.
473   *
474   * @return
475   *    - CSI_OK: succeed
476   *    - CSI_ERR_WIFI_NOT_INIT: WiFi was not initialized by csi_wifi_init
477   *    - CSI_ERR_WIFI_NOT_STARTED: WiFi was not started by csi_wifi_start
478   *    - CSI_ERR_WIFI_FAIL: other WiFi internal errors
479   */
480 int32_t csi_wifi_disconnect(void);
481
482 /**
483   * @brief     deauthenticate all stations or associated id equals to aid
484   *
485   * @param     aid  when aid is 0, deauthenticate all stations, otherwise deauthenticate station whose associated id is aid
486   *
487   * @return
488   *    - CSI_OK: succeed
489   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
490   *    - CSI_ERR_WIFI_NOT_STARTED: WiFi was not started by csi_wifi_start
491   *    - CSI_ERR_WIFI_ARG: invalid argument
492   *    - CSI_ERR_WIFI_MODE: WiFi mode is wrong
493   */
494 int32_t csi_wifi_deauth_sta(uint16_t aid);
495
496 /**
497   * @brief     Scan all available APs.
498   *
499   * @attention If this API is called, the found APs are stored in WiFi driver dynamic allocated memory and that
500   *            will be freed in csi_wifi_get_ap_list, so generally, call csi_wifi_get_ap_list to cause
501   *            the memory to be freed once the scan is done
502   * @attention The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds.
503   *            Values above 1500ms may cause station to disconnect from AP and are not recommended.
504   *
505   * @param     config  configuration of scanning
506   * @param     block if block is true, this API will block the caller until the scan is done, otherwise
507   *                         it will return immediately
508   *
509   * @return
510   *    - CSI_OK: succeed
511   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
512   *    - CSI_ERR_WIFI_NOT_STARTED: WiFi was not started by csi_wifi_start
513   *    - CSI_ERR_WIFI_TIMEOUT: blocking scan is timeout
514   *    - others: refer to error code in csi_err.h
515   */
516 int32_t csi_wifi_scan_start(wifi_scan_config_t *config, bool block);
517
518 /**
519   * @brief     Stop the scan in process
520   *
521   * @return
522   *    - CSI_OK: succeed
523   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
524   *    - CSI_ERR_WIFI_NOT_STARTED: WiFi is not started by csi_wifi_start
525   */
526 int32_t csi_wifi_scan_stop(void);
527
528 /**
529   * @brief     Get AP list found in last scan
530   *
531   * @param[inout]  number As input param, it stores max AP number ap_records can hold. 
532   *                As output param, it receives the actual AP number this API returns.
533   * @param         ap_records  wifi_ap_record_t array to hold the found APs
534   *
535   * @return
536   *    - CSI_OK: succeed
537   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
538   *    - CSI_ERR_WIFI_NOT_STARTED: WiFi is not started by csi_wifi_start
539   *    - CSI_ERR_WIFI_ARG: invalid argument
540   *    - CSI_ERR_WIFI_NO_MEM: out of memory
541   */
542 int32_t csi_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records);
543
544
545 /**
546   * @brief     Get information of AP which station is associated with
547   *
548   * @param     ap_info  the wifi_ap_record_t to hold AP information
549   *
550   * @return
551   *    - CSI_OK: succeed
552   *    - others: fail
553   */
554 int32_t csi_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info);
555
556 /**
557   * @brief     Set current power save type
558   *
559   * @attention Default power save type is WIFI_PS_NONE.
560   *
561   * @param     type  power save type
562   *
563   * @return    CSI_ERR_WIFI_NOT_SUPPORT: not supported yet
564   */
565 int32_t csi_wifi_set_ps(wifi_ps_type_t type);
566
567 /**
568   * @brief     Get current power save type
569   *
570   * @attention Default power save type is WIFI_PS_NONE.
571   *
572   * @param[out]  type: store current power save type
573   *
574   * @return    CSI_ERR_WIFI_NOT_SUPPORT: not supported yet
575   */
576 int32_t csi_wifi_get_ps(wifi_ps_type_t *type);
577
578 /**
579   * @brief     Set protocol type of specified interface
580   *            The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N)
581   *
582   * @attention Currently we only support 802.11b or 802.11bg or 802.11bgn mode
583   *
584   * @param     ifx  interfaces
585   * @param     protocol_bitmap  WiFi protocol bitmap
586   *
587   * @return
588   *    - CSI_OK: succeed
589   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
590   *    - CSI_ERR_WIFI_IF: invalid interface
591   *    - others: refer to error codes in csi_err.h
592   */
593 int32_t csi_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap);
594
595 /**
596   * @brief     Get the current protocol bitmap of the specified interface
597   *
598   * @param     ifx  interface
599   * @param[out] protocol_bitmap  store current WiFi protocol bitmap of interface ifx
600   *
601   * @return
602   *    - CSI_OK: succeed
603   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
604   *    - CSI_ERR_WIFI_IF: invalid interface
605   *    - CSI_ERR_WIFI_ARG: invalid argument
606   *    - others: refer to error codes in csi_err.h
607   */
608 int32_t csi_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap);
609
610 /**
611   * @brief     Set the bandwidth of specified interface
612   *
613   * @attention 1. API return false if try to configure an interface that is not enabled
614   * @attention 2. WIFI_BW_HT40 is supported only when the interface support 11N
615   *
616   * @param     ifx  interface to be configured
617   * @param     bw  bandwidth
618   *
619   * @return
620   *    - CSI_OK: succeed
621   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
622   *    - CSI_ERR_WIFI_IF: invalid interface
623   *    - CSI_ERR_WIFI_ARG: invalid argument
624   *    - others: refer to error codes in csi_err.h
625   */
626 int32_t csi_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw);
627
628 /**
629   * @brief     Get the bandwidth of specified interface
630   *
631   * @attention 1. API return false if try to get a interface that is not enable
632   *
633   * @param     ifx interface to be configured
634   * @param[out] bw  store bandwidth of interface ifx
635   *
636   * @return
637   *    - CSI_OK: succeed
638   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
639   *    - CSI_ERR_WIFI_IF: invalid interface
640   *    - CSI_ERR_WIFI_ARG: invalid argument
641   */
642 int32_t csi_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
643
644 /**
645   * @brief     Set primary/secondary channel
646   *
647   * @attention 1. This is a special API for sniffer
648   * @attention 2. This API should be called after csi_wifi_start() or csi_wifi_set_promiscuous()
649   *
650   * @param     primary  for HT20, primary is the channel number, for HT40, primary is the primary channel
651   * @param     second   for HT20, second is ignored, for HT40, second is the second channel
652   *
653   * @return
654   *    - CSI_OK: succeed
655   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
656   *    - CSI_ERR_WIFI_IF: invalid interface
657   *    - CSI_ERR_WIFI_ARG: invalid argument
658   */
659 int32_t csi_wifi_set_channel(uint8_t primary, wifi_second_chan_t second);
660
661 /**
662   * @brief     Get the primary/secondary channel
663   *
664   * @attention 1. API return false if try to get a interface that is not enable
665   *
666   * @param[out]  primary   store current primary channel
667   * @param[out]  second  store current second channel
668   *
669   * @return
670   *    - CSI_OK: succeed
671   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
672   *    - CSI_ERR_WIFI_ARG: invalid argument
673   */
674 int32_t csi_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
675
676 /**
677   * @brief     Set country code
678   *            The default value is WIFI_COUNTRY_CN
679   *
680   * @param     country  country type
681   *
682   * @return
683   *    - CSI_OK: succeed
684   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
685   *    - CSI_ERR_WIFI_ARG: invalid argument
686   *    - others: refer to error code in csi_err.h
687   */
688 int32_t csi_wifi_set_country(wifi_country_t country);
689
690 /**
691   * @brief     Get country code
692   *
693   * @param     country  store current country
694   *
695   * @return
696   *    - CSI_OK: succeed
697   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
698   *    - CSI_ERR_WIFI_ARG: invalid argument
699   */
700 int32_t csi_wifi_get_country(wifi_country_t *country);
701
702 /**
703   * @brief     Set MAC address of the WiFi station or the soft-AP interface.
704   *
705   * @attention 1. This API can only be called when the interface is disabled
706   * @attention 2. soft-AP and station have different MAC addresses, do not set them to be the same.
707   * @attention 3. The bit 0 of the first byte of MAC address can not be 1. For example, the MAC address
708   *      can set to be "1a:XX:XX:XX:XX:XX", but can not be "15:XX:XX:XX:XX:XX".
709   *
710   * @param     ifx  interface
711   * @param     mac  the MAC address
712   *
713   * @return
714   *    - CSI_OK: succeed
715   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
716   *    - CSI_ERR_WIFI_ARG: invalid argument
717   *    - CSI_ERR_WIFI_IF: invalid interface
718   *    - CSI_ERR_WIFI_MAC: invalid mac address
719   *    - CSI_ERR_WIFI_MODE: WiFi mode is wrong
720   *    - others: refer to error codes in csi_err.h
721   */
722 int32_t csi_wifi_set_mac(wifi_interface_t ifx, uint8_t mac[6]);
723
724 /**
725   * @brief     Get mac of specified interface
726   *
727   * @param      ifx  interface
728   * @param[out] mac  store mac of the interface ifx
729   *
730   * @return
731   *    - CSI_OK: succeed
732   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
733   *    - CSI_ERR_WIFI_ARG: invalid argument
734   *    - CSI_ERR_WIFI_IF: invalid interface
735   */
736 int32_t csi_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]);
737
738 /**
739   * @brief The RX callback function in the promiscuous mode. 
740   *        Each time a packet is received, the callback function will be called.
741   *
742   * @param buf  Data received. Type of data in buffer (wifi_promiscuous_pkt_t or wifi_pkt_rx_ctrl_t) indicated by 'type' parameter.
743   * @param type  promiscuous packet type.
744   *
745   */
746 typedef void (* wifi_promiscuous_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type);
747
748 /**
749   * @brief Register the RX callback function in the promiscuous mode.
750   *
751   * Each time a packet is received, the registered callback function will be called.
752   *
753   * @param cb  callback
754   *
755   * @return
756   *    - CSI_OK: succeed
757   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
758   */
759 int32_t csi_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
760
761 /**
762   * @brief     Enable the promiscuous mode.
763   *
764   * @param     en  false - disable, true - enable
765   *
766   * @return
767   *    - CSI_OK: succeed
768   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
769   */
770 int32_t csi_wifi_set_promiscuous(bool en);
771
772 /**
773   * @brief     Get the promiscuous mode.
774   *
775   * @param[out] en  store the current status of promiscuous mode
776   *
777   * @return
778   *    - CSI_OK: succeed
779   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
780   *    - CSI_ERR_WIFI_ARG: invalid argument
781   */
782 int32_t csi_wifi_get_promiscuous(bool *en);
783
784 /**
785   * @brief     Set the configuration of STA or AP
786   *
787   * @attention 1. This API can be called only when specified interface is enabled, otherwise, API fail
788   * @attention 2. For station configuration, bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.
789   * @attention 3. Limited to only one channel, so when in the soft-AP+station mode, the soft-AP will adjust its channel automatically to be the same as
790   *               the channel of the station.
791   *
792   * @param     ifx  interface
793   * @param     conf  station or soft-AP configuration
794   *
795   * @return
796   *    - CSI_OK: succeed
797   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
798   *    - CSI_ERR_WIFI_ARG: invalid argument
799   *    - CSI_ERR_WIFI_IF: invalid interface
800   *    - CSI_ERR_WIFI_MODE: invalid mode
801   *    - CSI_ERR_WIFI_PASSWORD: invalid password
802   *    - CSI_ERR_WIFI_NVS: WiFi internal NVS error
803   *    - others: refer to the erro code in csi_err.h
804   */
805 int32_t csi_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf);
806
807 /**
808   * @brief     Get configuration of specified interface
809   *
810   * @param     ifx  interface
811   * @param[out]  conf  station or soft-AP configuration
812   *
813   * @return
814   *    - CSI_OK: succeed
815   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
816   *    - CSI_ERR_WIFI_ARG: invalid argument
817   *    - CSI_ERR_WIFI_IF: invalid interface
818   */
819 int32_t csi_wifi_get_config(wifi_interface_t ifx, wifi_config_t *conf);
820
821 /**
822   * @brief     Get STAs associated with soft-AP
823   *
824   * @attention SSC only API
825   *
826   * @param[out] sta  station list
827   *
828   * @return
829   *    - CSI_OK: succeed
830   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
831   *    - CSI_ERR_WIFI_ARG: invalid argument
832   *    - CSI_ERR_WIFI_MODE: WiFi mode is wrong
833   *    - CSI_ERR_WIFI_CONN: WiFi internal error, the station/soft-AP control block is invalid
834   */
835 int32_t csi_wifi_ap_get_sta_list(wifi_sta_list_t *sta);
836
837
838 /**
839   * @brief     Set the WiFi API configuration storage type
840   *
841   * @attention 1. The default value is WIFI_STORAGE_FLASH
842   *
843   * @param     storage : storage type
844   *
845   * @return
846   *   - CSI_OK: succeed
847   *   - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
848   *   - CSI_ERR_WIFI_ARG: invalid argument
849   */
850 int32_t csi_wifi_set_storage(wifi_storage_t storage);
851
852 /**
853   * @brief     Set auto connect
854   *            The default value is true
855   *
856   * @param     en : true - enable auto connect / false - disable auto connect
857   *
858   * @return
859   *    - CSI_OK: succeed
860   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
861   *    - CSI_ERR_WIFI_MODE: WiFi internal error, the station/soft-AP control block is invalid
862   *    - others: refer to error code in csi_err.h
863   */
864 int32_t csi_wifi_set_auto_connect(bool en);
865
866 /**
867   * @brief     Get the auto connect flag
868   *
869   * @param[out] en  store current auto connect configuration
870   *
871   * @return
872   *    - CSI_OK: succeed
873   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
874   *    - CSI_ERR_WIFI_ARG: invalid argument
875   */
876 int32_t csi_wifi_get_auto_connect(bool *en);
877
878 /**
879   * @brief     Set vendor specific element
880   *
881   * @param     enable  enable or not
882   * @param     type  information element type
883   * @param     idx  information element index
884   * @param     vnd_ie  pointer to a vendor specific element
885   *
886   * @return
887   *    - CSI_OK: succeed
888   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
889   *    - CSI_ERR_WIFI_ARG: invalid argument
890   *    - CSI_ERR_WIFI_NO_MEM: out of memory
891   */
892 int32_t csi_wifi_set_vendor_ie(bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, uint8_t *vnd_ie);
893
894 /**
895   * @brief     Define function pointer for vendor specific element callback
896   * @param     ctx  reserved
897   * @param     type  information element type 
898   * @param     sa  source address
899   * @param     vnd_ie  pointer to a vendor specific element
900   * @param     rssi  received signal strength indication
901   */
902 typedef void (*csi_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const uint8_t *vnd_ie, int rssi);
903
904 /**
905   * @brief     Set vendor specific element callback
906   *
907   * @param     cb   callback function
908   * @param     ctx  reserved
909   *
910   * @return
911   *    - CSI_OK: succeed
912   *    - CSI_ERR_WIFI_NOT_INIT: WiFi is not initialized by csi_wifi_init
913   */
914 int32_t csi_wifi_set_vendor_ie_cb(csi_vendor_ie_cb_t cb, void *ctx);
915
916 /**
917   * @brief  get whether the wifi driver is allowed to transmit data or not
918   *
919   * @return
920   *     - true  : upper layer should stop to transmit data to wifi driver
921   *     - false : upper layer can transmit data to wifi driver
922   */
923 bool csi_wifi_tx_is_stop(void);
924
925 /**
926   * @brief  free the rx buffer which allocated by wifi driver
927   *
928   * @param  buffer: rx buffer pointer
929   */
930 void csi_wifi_free_rx_buffer(void *buffer);
931
932 /**
933   * @brief  transmit the buffer via wifi driver
934   *
935   * @param  wifi_if : wifi interface id
936   * @param  buffer : the buffer to be tansmit
937   * @param  len : the length of buffer
938   *
939   * @return
940   *    - ERR_OK  : Successfully transmit the buffer to wifi driver
941   *    - ERR_MEM : Out of memory
942   *    - ERR_IF : WiFi driver error
943   *    - ERR_ARG : Invalid argument
944   */
945 int csi_wifi_tx(wifi_interface_t wifi_if, void *buffer, uint16_t len);
946
947 /**
948   * @brief     The WiFi RX callback function
949   *
950   *            Each time the WiFi need to forward the packets to high layer, the callback function will be called.
951   *            ebuf is rx buffer allocated by wifi driver
952   */
953 typedef int32_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *ebuf);
954
955 /**
956   * @brief     Set the WiFi RX callback
957   *
958   * @attention 1. Currently we support only one RX callback for each interface
959   *
960   * @param     ifx : interface
961   * @param     fn : WiFi RX callback
962   *
963   * @return
964   *     - CSI_OK : succeed
965   *     - others : fail
966   */
967 int32_t csi_wifi_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn);
968
969 /**
970   \brief       Add Frame Filter Setting with Filter ID.
971   \param[in]   filter  Pointer to filter setting
972   \return      
973 */
974 int32_t csi_wifi_add_framefilter(const wifi_frame_filter_t *filter);
975
976 /**
977   \brief       Remove Frame Filter Setting.
978   \param[in]   filter_id  Frame Filter ID
979   \return      
980 */
981 int32_t csi_wifi_remove_framefilter(uint32_t filter_id);
982
983 /**
984   \brief       Enable/Disable Specified Frame Filter ID.
985   \param[in]   filter_id  Frame Filter ID
986   \param[in]   en  Enable or disable
987   \return      
988 */
989 int32_t csi_wifi_en_framefilter(uint32_t filter_id, bool en);
990
991 /**
992   \brief       Get frame filter table list.
993   \param[in]   list  frame filter table list
994   \param[in]   count_out  the count of filter setting added
995   \param[in]   max_count  max filter setting can be supported
996   \return      
997 */
998 int32_t csi_wifi_get_framefilter(wifi_frame_filter_list_t* list, uint32_t* count_out, uint32_t max_count);
999
1000 /**
1001 * @brief This function gets the radio status of the Wi-Fi driver.
1002 *
1003 * @param[out]  on_off indicates the Wi-Fi radio is on or off.
1004 *
1005 * Value                         |Definition                                                              |
1006 * ------------------------------|------------------------------------------------------------------------|
1007 * \b 0                          | OFF, the Wi-Fi radio is turned off, and Wi-Fi TX/RX is disabled.|
1008 * \b 1                          | ON, the Wi-Fi radio is turned on, and Wi-Fi TX/RX is enabled.|
1009 *
1010 *
1011 * @return  >=0 the operation completed successfully, <0 the operation failed.
1012 *
1013 * @note In repeater mode, both Wi-Fi interface and Wi-Fi radio are turned on/off at the same time.
1014 */
1015 int32_t wifi_config_get_radio(uint8_t *on_off);
1016
1017 /**
1018 * @brief This function sets the radio status of the Wi-Fi driver. This operation takes effect immediately.
1019 *
1020 * @param[in] on_off indicates the Wi-Fi radio is on or off.
1021 *
1022 * Value                         |Definition                                                              |
1023 * ------------------------------|------------------------------------------------------------------------|
1024 * \b 0                          | OFF, the Wi-Fi radio is turned off, and Wi-Fi TX/RX is disabled|
1025 * \b 1                          | ON, the Wi-Fi radio is turned on, and Wi-Fi TX/RX is enabled|
1026 *
1027 * @return  >=0 the operation completed successfully, <0 the operation failed.
1028 *
1029 * @note In repeater mode, both Wi-Fi interface and Wi-Fi radio are turned on/off at the same time.
1030 */
1031 int32_t wifi_config_set_radio(uint8_t on_off);
1032
1033 /**
1034 * @brief This function gets the RSSI of the connected AP. It's only used for the STA mode and while the station is connected to the AP.
1035 *
1036 * @param[out]  rssi returns the RSSI of the connected AP.
1037 *
1038 * @return  >=0 the operation completed successfully, <0 the operation failed.
1039 *
1040 *
1041 */
1042 int32_t csi_wifi_connection_get_rssi(int8_t *rssi);
1043
1044
1045 #ifdef __cplusplus
1046 }
1047 #endif
1048
1049 #endif /* __CSI_WIFI_H__ */
1050
1051