1 /******************************************************************************
2  * Copyright (c) 2013-2016 Realtek Semiconductor Corp.
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 /**
18   ******************************************************************************
19   * @file    wifi_conf.h
20   * @author
21   * @version
22   * @brief   This file provides user interface for Wi-Fi station and AP mode configuration
23   *             base on the functionalities provided by Realtek Wi-Fi driver.
24   ******************************************************************************
25   */
26 #ifndef __WIFI_API_H
27 #define __WIFI_API_H
28 
29 /** @addtogroup nic NIC
30  *  @ingroup    wlan
31  *  @brief      NIC functions
32  *  @{
33  */
34 
35 #include "wifi_constants.h"
36 #include "wifi_structures.h"
37 #include "wifi_util.h"
38 #include "wifi_ind.h"
39 #include <platform/platform_stdlib.h>
40 
41 #ifdef __cplusplus
42   extern "C" {
43 #endif
44 
45 /******************************************************
46  *                    Macros
47  ******************************************************/
48 
49 #define RTW_ENABLE_API_INFO
50 
51 #ifdef RTW_ENABLE_API_INFO
52 #if defined(CONFIG_MBED_ENABLED)
53     extern __u32 GlobalDebugEnable;
54     #define RTW_API_INFO(...)     do {\
55         if (GlobalDebugEnable) \
56             printf(__VA_ARGS__);\
57     }while(0)
58 #else
59     #define RTW_API_INFO printf
60 #endif
61 #else
62     #define RTW_API_INFO(args)
63 #endif
64 
65 #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
66 #define CMP_MAC( a, b )  (((a[0])==(b[0]))&& \
67                           ((a[1])==(b[1]))&& \
68                           ((a[2])==(b[2]))&& \
69                           ((a[3])==(b[3]))&& \
70                           ((a[4])==(b[4]))&& \
71                           ((a[5])==(b[5])))
72 
73 /******************************************************
74  *                    Constants
75  ******************************************************/
76 #define SCAN_LONGEST_WAIT_TIME  (4500)
77 
78 
79 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
80 
81 #define PSCAN_ENABLE 0x01      //enable for partial channel scan
82 #define PSCAN_FAST_SURVEY 0x02 //set to select scan time to FAST_SURVEY_TO, otherwise SURVEY_TO
83 #define PSCAN_SIMPLE_CONFIG   0x04 //set to select scan time to FAST_SURVEY_TO and resend probe request
84 
85 typedef enum _WL_BAND_TYPE{
86 	WL_BAND_2_4G = 0,
87 	WL_BAND_5G,
88 	WL_BAND_2_4G_5G_BOTH,
89 	WL_BANDMAX
90 }WL_BAND_TYPE,*PWL_BAND_TYPE;
91 
92 /******************************************************
93  *                 Type Definitions
94  ******************************************************/
95 
96 /** Scan result callback function pointer type
97  *
98  * @param result_ptr  : A pointer to the pointer that indicates where to put the next scan result
99  * @param user_data   : User provided data
100  */
101 typedef void (*rtw_scan_result_callback_t)( rtw_scan_result_t** result_ptr, void* user_data );
102 typedef rtw_result_t (*rtw_scan_result_handler_t)( rtw_scan_handler_result_t* malloced_scan_result );
103 
104 /******************************************************
105  *                    Structures
106  ******************************************************/
107 typedef struct {
108 	char *buf;
109 	int buf_len;
110 } scan_buf_arg;
111 
112 /******************************************************
113  *                    Structures
114  ******************************************************/
115 typedef struct internal_scan_handler{
116 	rtw_scan_result_t** pap_details;
117 	rtw_scan_result_t * ap_details;
118 	int	scan_cnt;
119 	rtw_bool_t	scan_complete;
120 	unsigned char	max_ap_size;
121 	rtw_scan_result_handler_t gscan_result_handler;
122 #if defined(SCAN_USE_SEMAPHORE) && SCAN_USE_SEMAPHORE
123 	void *scan_semaphore;
124 #else
125 	int 	scan_running;
126 #endif
127 	void*	user_data;
128 	unsigned int	scan_start_time;
129 } internal_scan_handler_t;
130 
131 typedef struct {
132     rtw_network_info_t	network_info;
133     void *join_sema;
134 } internal_join_result_t;
135 
136 /******************************************************
137  *               Function Declarations
138  ******************************************************/
139 /**
140  * @brief  Initialize Realtek WiFi API System.
141  * 			- Initialize the required parts of the software platform.
142  *   			i.e. worker, event registering, semaphore, etc.
143  * 			- Initialize the RTW API thread which handles the asynchronous event.
144  * @return RTW_SUCCESS if initialization is successful, RTW_ERROR otherwise
145  */
146 int wifi_manager_init(void);
147 
148 /**
149  * @brief  Join a Wi-Fi network.
150  * 		Scan for, associate and authenticate with a Wi-Fi network.
151  *		On successful return, the system is ready to send data packets.
152  *
153  * @param[in]  ssid: A null terminated string containing the SSID name of the network to join.
154  * @param[in]  security_type: Authentication type:
155  *                         - RTW_SECURITY_OPEN           - Open Security
156  *                         - RTW_SECURITY_WEP_PSK        - WEP Security with open authentication
157  *                         - RTW_SECURITY_WEP_SHARED     - WEP Security with shared authentication
158  *                         - RTW_SECURITY_WPA_TKIP_PSK   - WPA Security
159  *                         - RTW_SECURITY_WPA2_AES_PSK   - WPA2 Security using AES cipher
160  *                         - RTW_SECURITY_WPA2_TKIP_PSK  - WPA2 Security using TKIP cipher
161  *                         - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
162  * @param[in]  password: A byte array containing either the cleartext security key for WPA/WPA2
163  *  						 secured networks, or a pointer to an array of rtw_wep_key_t
164  *  						 structures for WEP secured networks.
165  * @param[in]  ssid_len: The length of the SSID in bytes.
166  * @param[in]  password_len: The length of the security_key in bytes.
167  * @param[in]  key_id: The index of the wep key (0, 1, 2, or 3). If not using it, leave it with value -1.
168  * @param[in]  semaphore: A user provided semaphore that is flagged when the join is complete. If not using it, leave it with NULL value.
169  * @return  RTW_SUCCESS: when the system is joined and ready to send data packets.
170  * @return  RTW_ERROR: if an error occurred.
171  * @note  Please make sure the Wi-Fi is enabled before invoking this function. (@ref wifi_on())
172  */
173 int wifi_connect(
174 	char 				*ssid,
175 	rtw_security_t	security_type,
176 	char 				*password,
177 	int 				ssid_len,
178 	int 				password_len,
179 	int 				key_id,
180 	void 				*semaphore);
181 
182 /**
183  * @brief  Join a Wi-Fi network with specified BSSID.
184  * 		Scan for, associate and authenticate with a Wi-Fi network.
185  *		On successful return, the system is ready to send data packets.
186  * @param[in]  bssid: The specified BSSID to connect.
187  * @param[in]  ssid: A null terminated string containing the SSID name of the network to join.
188  * @param[in]  security_type: Authentication type:
189  *                         - RTW_SECURITY_OPEN           - Open Security
190  *                         - RTW_SECURITY_WEP_PSK        - WEP Security with open authentication
191  *                         - RTW_SECURITY_WEP_SHARED     - WEP Security with shared authentication
192  *                         - RTW_SECURITY_WPA_TKIP_PSK   - WPA Security
193  *                         - RTW_SECURITY_WPA2_AES_PSK   - WPA2 Security using AES cipher
194  *                         - RTW_SECURITY_WPA2_TKIP_PSK  - WPA2 Security using TKIP cipher
195  *                         - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
196  * @param[in]  password: A byte array containing either the cleartext security key for WPA/WPA2
197  *  						 secured networks, or a pointer to an array of rtw_wep_key_t
198  *  						 structures for WEP secured networks.
199  * @param[in]  ssid_len: The length of the SSID in bytes.
200  * @param[in]  password_len: The length of the security_key in bytes.
201  * @param[in]  key_id: The index of the wep key.
202  * @param[in]  semaphore: A user provided semaphore that is flagged when the join is complete.
203  * @return  RTW_SUCCESS: when the system is joined and ready to send data packets.
204  * @return  RTW_ERROR: if an error occurred.
205  * @note  Please make sure the Wi-Fi is enabled before invoking this function. (@ref wifi_on())
206  * @note  The difference between @ref wifi_connect_bssid() and @ref wifi_connect() is that BSSID has higher priority as the basis of connection in @ref wifi_connect_bssid.
207  */
208 int wifi_connect_bssid(
209 	unsigned char 		bssid[ETH_ALEN],
210 	char 				*ssid,
211 	rtw_security_t	security_type,
212 	char 				*password,
213 	int 				bssid_len,
214 	int 				ssid_len,
215 	int 				password_len,
216 	int 				key_id,
217 	void 				*semaphore);
218 
219 /**
220   * @brief  Disassociates from current Wi-Fi network.
221   * @param  None
222   * @return  RTW_SUCCESS: On successful disassociation from the AP.
223   * @return  RTW_ERROR: If an error occurred.
224   */
225 int wifi_disconnect(void);
226 
227 /**
228 * @brief  Check if Wi-Fi has connected to AP before dhcp.
229 * @param  None
230 * @return  RTW_SUCCESS: If conneced.
231 * @return  RTW_ERROR: If not connect.
232 */
233 int wifi_is_connected_to_ap(void);
234 
235 /**
236   * @brief  Check if the specified interface is up.
237   * @param[in]  interface: The interface can be set as RTW_STA_INTERFACE or RTW_AP_INTERFACE. (@ref rtw_interface_t)
238   * @return  If the function succeeds, the return value is 1. Otherwise, return 0.
239   */
240 int wifi_is_up(rtw_interface_t interface);
241 
242 /** Determines if a particular interface is ready to transceive ethernet packets
243  *
244  * @param     Radio interface to check, options are
245  *  				RTW_STA_INTERFACE, RTW_AP_INTERFACE
246  * @return    RTW_SUCCESS  : if the interface is ready to
247  *  		  transceive ethernet packets
248  * @return    RTW_ERROR    : if the interface is not ready to
249  *  		  transceive ethernet packets
250  */
251 int wifi_is_ready_to_transceive(rtw_interface_t interface);
252 
253 /**
254  * @brief  This function sets the current Media Access Control (MAC) address of the 802.11 device.
255  * @param[in] mac: Wi-Fi MAC address.
256  * @return    RTW_SUCCESS or RTW_ERROR
257  */
258 int wifi_set_mac_address(char * mac);
259 
260 /**
261  * @brief  Retrieves the current Media Access Control (MAC) address
262  *			(or Ethernet hardware address) of the 802.11 device.
263  * @param[in]  mac: Point to the result of the mac address will be get.
264  * @return    RTW_SUCCESS or RTW_ERROR
265  */
266 int wifi_get_mac_address(char * mac);
267 
268 /**
269  * @brief Enable Wi-Fi powersave mode.
270  * @param  None
271  * @return RTW_SUCCESS or RTW_ERROR.
272  */
273 int wifi_enable_powersave(void);
274 
275 /**
276  * @brief Resume Wi-Fi powersave mode.
277  * @param  None
278  * @return RTW_SUCCESS or RTW_ERROR.
279  */
280 int wifi_resume_powersave(void);
281 
282 /**
283  * @brief Disable Wi-Fi powersave mode.
284  * @param  None
285  * @return RTW_SUCCESS or RTW_ERROR.
286  */
287 int wifi_disable_powersave(void);
288 
289 /** Gets the tx power in index units
290  *
291  * @param dbm : The variable to receive the tx power in index.
292  *
293  * @return  RTW_SUCCESS : if successful
294  *          RTW_ERROR   : if not successful
295  */
296 
297 void wifi_btcoex_set_bt_on(void);
298 
299 void wifi_btcoex_set_bt_off(void);
300 
301 int wifi_get_txpower(int *poweridx);
302 
303 /**
304  * @brief  Set the tx power in index units.
305  * @param[in] poweridx: The desired tx power in index.
306  * @return  RTW_SUCCESS: if tx power is successfully set
307  * @return  RTW_ERROR: if tx power is not successfully set
308  */
309 int wifi_set_txpower(int poweridx);
310 
311 /**
312  * @brief  Get the associated clients with SoftAP.
313  * @param[out]  client_list_buffer: The location where the client list will be stored.
314  * @param[in]  buffer_length: The buffer length.
315  * @return  RTW_SUCCESS: The result is successfully got.
316  * @return  RTW_ERROR: The result is not successfully got.
317  */
318 int wifi_get_associated_client_list(void * client_list_buffer, unsigned short buffer_length);
319 
320 /**
321  * @brief Get connected AP's BSSID
322  * @param[out] bssid : the location where the AP BSSID will be stored
323  * @return RTW_SUCCESS : if result was successfully get
324  * @return RTW_ERROR : if result was not successfully get
325  */
326 int wifi_get_ap_bssid(unsigned char *bssid);
327 
328 /**
329  * @brief  Get the SoftAP information.
330  * @param[out]  ap_info: The location where the AP info will be stored.
331  * @param[out]  security: The security type.
332  * @return  RTW_SUCCESS: The result is successfully got.
333  * @return  RTW_ERROR: The result is not successfully got.
334  */
335 int wifi_get_ap_info(rtw_bss_info_t * ap_info, rtw_security_t* security);
336 
337 /**
338  * @brief  Set the country code to driver to determine the channel set.
339  * @param[in]  country_code: Specify the country code.
340  * @return  RTW_SUCCESS: If result is successfully set.
341  * @return  RTW_ERROR: If result is not successfully set.
342  */
343 int wifi_set_country(rtw_country_code_t country_code);
344 
345 /**
346  * @brief  retrieved sta mode MAX data rate.
347  * @param[out]  inidata_rate: MAX data rate.
348  * @return  RTW_SUCCESS: If the INIDATA_RATE is successfully retrieved.
349  * @return  RTW_ERROR: If the INIDATA_RATE is not retrieved.
350  * note: inidata_rate = 2 * (data rate), you need inidata_rate/2.0 to get the real rate
351  */
352 int wifi_get_sta_max_data_rate(__u8 * inidata_rate);
353 
354 /**
355  * @brief  Retrieve the latest RSSI value.
356  * @param[out]  pRSSI: Points to the integer to store the RSSI value gotten from driver.
357  * @return  RTW_SUCCESS: If the RSSI is succesfully retrieved.
358  * @return  RTW_ERROR: If the RSSI is not retrieved.
359  */
360 int wifi_get_rssi(int *pRSSI);
361 
362 /**
363  * @brief  Retrieve the latest average beacon RSSI value.
364  * @param[out]  pRSSI: Points to the integer to store the RSSI value gotten from driver.
365  * @return  RTW_SUCCESS: If the RSSI is succesfully retrieved.
366  * @return  RTW_ERROR: If the RSSI is not retrieved.
367  */
368 int wifi_get_bcn_rssi(int *pRSSI);
369 
370 /**
371  * @brief  Set the listening channel for promiscuous mode.
372  * @param[in]  channel: The desired channel.
373  * @return  RTW_SUCCESS: If the channel is successfully set.
374  * @return  RTW_ERROR: If the channel is not successfully set.
375  * @note  Do NOT need to call this function for STA mode wifi driver, since it will determine the channel from received beacon.
376  */
377 int wifi_set_channel(int channel);
378 
379 /**
380  * @brief  Get the current channel on STA interface.
381  * @param[out] channel: A pointer to the variable where the
382  *  				channel value will be written
383  * @return  RTW_SUCCESS: If the channel is successfully read.
384  * @return  RTW_ERROR: If the channel is not successfully read.
385  */
386 int wifi_get_channel(int *channel);
387 
388 /**
389  * @brief  switch the current channelPlan on STA or AP interface.
390  * @param[in] channel_plan: the available channelPlan Map index
391  *  				        from 0x20 to 0x79
392  * @return  RTW_SUCCESS: If the channel is successfully read.
393  * @return  RTW_ERROR: If the channel is not successfully read.
394  */
395 int wifi_change_channel_plan(uint8_t channel_plan);
396 
397 /**
398  * @brief  Register interest in a multicast address.\n
399  * 		Once a multicast address has been registered, all packets detected on the
400  * 		medium destined for that address are forwarded to the host.
401  * 		Otherwise they are ignored.
402  * @param[in] mac: Ethernet MAC address
403  * @return  RTW_SUCCESS: If the address is registered successfully.
404  * @return  RTW_ERROR: If the address is not registered.
405  */
406 int wifi_register_multicast_address(rtw_mac_t *mac);
407 
408 /**
409  * @brief  Unregister interest in a multicast address.\n
410  * 		Once a multicast address has been unregistered, all packets detected on the
411  * 		medium destined for that address are ignored.
412  * @param[in] mac: Ethernet MAC address
413  * @return  RTW_SUCCESS: If the address is unregistered successfully.
414  * @return  RTW_ERROR: If the address is not unregistered.
415  */
416 int wifi_unregister_multicast_address(rtw_mac_t *mac);
417 
418 /**
419  * @brief  Setup the adaptivity mode.
420  * 		You can replace this weak function by the same name funcation to setup adaptivity mode you want.
421  * @param  None
422  * @return  If the function succeeds, the return value is 0.
423  */
424 _WEAK void wifi_set_mib(void);
425 
426 /**
427  * @brief  Setup country code.
428   * 		You can replace this weak function by the same name funcation to setup country code you want.
429  * @param  None
430  * @return  If the function succeeds, the return value is 0.
431  */
432 //----------------------------------------------------------------------------//
433 _WEAK void wifi_set_country_code(void);
434 
435 /**
436  * @brief  Enable Wi-Fi RF.
437  * @param  None
438  * @return  If the function succeeds, the return value is 0.
439  * @note  The difference between @ref wifi_rf_on() and @ref wifi_on() is that @ref wifi_rf_on() simply enable RF HAL, it does not enable the driver or allocate memory.
440  */
441 int wifi_rf_on(void);
442 
443 /**
444  * @brief  Disable Wi-Fi RF.
445  * @param  None
446  * @return  If the function succeeds, the return value is 0.
447  * @note  The difference between @ref wifi_rf_off() and @ref wifi_off() is that @ref wifi_rf_off() simply disable RF HAL, the driver and used heap memory will NOT be released.
448  */
449 int wifi_rf_off(void);
450 
451 /**
452  * @brief  Enable Wi-Fi.
453  * - Bring the Wireless interface "Up"
454  * - Initialize the driver thread which arbitrates access
455  *   to the SDIO/SPI bus
456  *
457  * @param[in]  mode: Decide to enable WiFi in which mode. The optional modes are enumerated in @ref rtw_mode_t.
458  * @return  RTW_SUCCESS: if the WiFi chip was initialized successfully.
459  * @return  RTW_ERROR: if the WiFi chip was not initialized successfully.
460  */
461 int wifi_on(rtw_mode_t mode);
462 
463 /**
464  * @brief  Disable Wi-Fi.
465  *
466  * @param  None
467  * @return  RTW_SUCCESS: if deinitialization is successful.
468  * @return  RTW_ERROR: otherwise.
469  */
470 int wifi_off(void);
471 
472 /**
473  * @brief  Switch Wifi Mode
474  *
475  * - Switch Wifi Mode to @param[in]
476  *
477  * @param[in]  mode: Decide to switch WiFi to which mode. The optional modes are RTW_MODE_STA or RTW_MODE_AP.
478  * @return  RTW_SUCCESS:    if the WiFi switch mode successful.
479  * @return  RTW_ERROR:      if the WiFi swithc mdoe not successful.
480  */
481 int wifi_set_mode(rtw_mode_t mode);
482 
483 /**
484  * Turn off the Wi-Fi device
485  *
486  * - Bring the Wireless interface "Down"
487  * - De-Initialises the driver thread which arbitrates access
488  *   to the SDIO/SPI bus
489  *
490  * @return RTW_SUCCESS if deinitialization is successful,
491  *  	   RTW_ERROR otherwise
492  */
493 int wifi_off_fastly(void);
494 
495 /**
496  * @brief  Set IPS/LPS mode.
497  * @param[in] ips_mode: The desired IPS mode. It becomes effective when wlan enter ips.\n
498  *		@ref ips_mode is inactive power save mode. Wi-Fi automatically turns RF off if it is not associated to AP. Set 1 to enable inactive power save mode.
499  * @param[in] lps_mode: The desired LPS mode. It becomes effective when wlan enter lps.\n
500  *		@ref lps_mode is leisure power save mode. Wi-Fi automatically turns RF off during the association to AP is traffic is not busy while it also automatically turns RF on to listen to beacon. Set 1 to enable leisure power save mode.
501  * @return  RTW_SUCCESS if setting LPS mode successful.
502  * @return  RTW_ERROR otherwise.
503  */
504 
505 int wifi_set_power_mode(unsigned char ips_mode, unsigned char lps_mode);
506 
507 /**
508  * Set TDMA parameters
509  *
510  * @param[in] slot_period  : We separate TBTT into 2 or 3 slots.
511  *                           If we separate TBTT into 2 slots, then slot_period should be larger or equal to 50ms.
512  *                           It means 2 slot period is
513  *                               slot_period, 100-slot_period
514  *                           If we separate TBTT into 3 slots, then slot_period should be less or equal to 33ms.
515  *                           It means 3 slot period is
516  *                               100 - 2 * slot_period, slot_period, slot_period
517  * @param[in] rfon_period_len_1: rf on period of slot 1
518  * @param[in] rfon_period_len_2: rf on period of slot 2
519  * @param[in] rfon_period_len_3: rf on period of slot 3
520  *
521  * @return RTW_SUCCESS if setting TDMA parameters successful
522  *         RTW_ERROR otherwise
523  */
524 int wifi_set_tdma_param(unsigned char slot_period, unsigned char rfon_period_len_1, unsigned char rfon_period_len_2, unsigned char rfon_period_len_3);
525 
526 /**
527  * @brief Set LPS DTIM.
528  * @param[in] dtim: In LPS, the package can be buffered at AP side.
529  *                    STA leave LPS until dtim count of packages buffered at AP side.
530  * @return  RTW_SUCCESS if setting LPS dtim successful.
531  * @return  RTW_ERROR otherwise
532  */
533 int wifi_set_lps_dtim(unsigned char dtim);
534 
535 /**
536  * @brief  Get LPS DTIM.
537  * @param[out] dtim: In LPS, the package can be buffered at AP side.
538  *                    STA leave LPS until dtim count of packages buffered at AP side.
539  * @return  RTW_SUCCESS if getting LPS dtim successful.
540  * @return  RTW_ERROR otherwise.
541  */
542 int wifi_get_lps_dtim(unsigned char *dtim);
543 
544 enum {
545 	LPS_THRESH_PKT_COUNT = 0,
546 	LPS_THRESH_DIRECT_ENTER,
547 	LPS_THRESH_TP,
548 };
549 typedef unsigned char rtw_lps_thresh_t;
550 
551 /**
552  * @brief  Set LPS threshold.
553  * @param[in] mode: LPS threshold mode LPS_THRESH_PKT_COUNT/LPS_THRESH_DIRECT_ENTER/LPS_THRESH_TP
554  * @return  RTW_SUCCESS if set LPS threshold successful.
555  * @return  RTW_ERROR otherwise.
556  */
557 int wifi_set_lps_thresh(rtw_lps_thresh_t mode);
558 
559 /**
560  * @brief Set LPS LEVEL
561  * @param[in] lps_level: 0 is LPS_NORMAL, 1 is LPS_LCLK, 2 is LPS_PG
562  *
563  * @return  RTW_SUCCESS if setting LPS level successful.
564  * @return  RTW_ERROR otherwise
565  */
566 int wifi_set_lps_level(unsigned char lps_level);
567 
568 #ifdef LONG_PERIOD_TICKLESS
569 /**
570  * @brief Set Smart PS
571  * @param[in] smartps: 0 is issue NULL data, 2 is issue PS-Poll
572  *
573  * @return  RTW_SUCCESS if setting Smart PS successful.
574  * @return  RTW_ERROR otherwise
575  */
576 int wifi_set_lps_smartps(unsigned char smartps);
577 #endif
578 /**
579  * @brief  Set Management Frame Protection Support.
580  * @param[in] value:
581  *				- NO_MGMT_FRAME_PROTECTION 		- not support
582  *				- MGMT_FRAME_PROTECTION_OPTIONAL 	- capable
583  *				- MGMT_FRAME_PROTECTION_REQUIRED 	- required
584  * @return  RTW_SUCCESS if setting Management Frame Protection Support successful.
585  * @return  RTW_ERROR otherwise.
586  */
587 int wifi_set_mfp_support(unsigned char value);
588 
589 /**
590  * @brief  Trigger Wi-Fi driver to start an infrastructure Wi-Fi network.
591  * @warning If a STA interface is active when this function is called, the softAP will
592  *          start on the same channel as the STA. It will NOT use the channel provided!
593  * @param[in]  ssid: A null terminated string containing the SSID name of the network.
594  * @param[in]  security_type:
595  *                         - RTW_SECURITY_OPEN           - Open Security
596  *                         - RTW_SECURITY_WPA_TKIP_PSK   - WPA Security
597  *                         - RTW_SECURITY_WPA2_AES_PSK   - WPA2 Security using AES cipher
598  *                         - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
599  *                         - WEP security is NOT IMPLEMENTED. It is NOT SECURE!
600  * @param[in]  password: A byte array containing the cleartext security key for the network.
601  * @param[in]  ssid_len: The length of the SSID in bytes.
602  * @param[in]  password_len: The length of the security_key in bytes.
603  * @param[in]  channel: 802.11 channel number.
604  * @return  RTW_SUCCESS: If successfully creates an AP.
605  * @return  RTW_ERROR: If an error occurred.
606  * @note  Please make sure the Wi-Fi is enabled before invoking this function. (@ref wifi_on())
607  */
608 int wifi_start_ap(
609 	char 				*ssid,
610 	rtw_security_t		security_type,
611 	char 				*password,
612 	int 				ssid_len,
613 	int 				password_len,
614 	int					channel);
615 
616 /**
617  * @brief  Start an infrastructure Wi-Fi network with hidden SSID.
618  * @warning If a STA interface is active when this function is called, the softAP will
619  *          start on the same channel as the STA. It will NOT use the channel provided!
620  *
621  * @param[in]  ssid: A null terminated string containing
622  *  	 the SSID name of the network to join.
623  * @param[in]  security_type: Authentication type: \n
624  *                         - RTW_SECURITY_OPEN           - Open Security
625  *                         - RTW_SECURITY_WPA_TKIP_PSK   - WPA Security
626  *                         - RTW_SECURITY_WPA2_AES_PSK   - WPA2 Security using AES cipher
627  *                         - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
628  *                         - WEP security is NOT IMPLEMENTED. It is NOT SECURE!
629  * @param[in]  password: A byte array containing the cleartext
630  *  	 security key for the network.
631  * @param[in]  ssid_len: The length of the SSID in bytes.
632  * @param[in]  password_len: The length of the security_key in bytes.
633  * @param[in]  channel: 802.11 channel number
634  *
635  * @return  RTW_SUCCESS: If successfully creates an AP.
636  * @return  RTW_ERROR: If an error occurred.
637  */
638 int wifi_start_ap_with_hidden_ssid(
639 	char 				*ssid,
640 	rtw_security_t		security_type,
641 	char 				*password,
642 	int 				ssid_len,
643 	int 				password_len,
644 	int					channel);
645 
646 /**
647  * @brief  Initiate a scan to search for 802.11 networks.
648  *
649  * @param[in]  scan_type: Specifies whether the scan should
650  *                             be Active, Passive or scan
651  *                             Prohibited channels
652  * @param[in]  bss_type: Specifies whether the scan should
653  *                             search for Infrastructure
654  *                             networks (those using an Access
655  *                             Point), Ad-hoc networks, or both
656  *                             types.
657  * @param[in]  result_ptr: Scan specific ssid. The first 4
658  *                             bytes is ssid lenth, and ssid name
659  *                             append after it.
660  *                             If no specific ssid need to scan,
661  *                             PLEASE CLEAN result_ptr before pass
662  *                             it into parameter.
663  * @param[out]  result_ptr: a pointer to a pointer to a result
664  *                             storage structure.
665  * @return  RTW_SUCCESS or RTW_ERROR
666  * @note  The scan progressively accumulates results over time, and
667  *  			may take between 1 and 3 seconds to complete. The results of
668  *  			the scan will be individually provided to the callback
669  *  			function. Note: The callback function will be executed in
670  *  			the context of the RTW thread.
671  * @note  When scanning specific channels, devices with a
672  *  	 strong signal strength on nearby channels may be
673  *  	 detected
674  */
675 int wifi_scan(rtw_scan_type_t                    scan_type,
676 				  rtw_bss_type_t                     bss_type,
677 				  void*                result_ptr);
678 
679 /**
680  * @brief  Initiate a scan to search for 802.11 networks, a higher level API based on wifi_scan
681  *			to simplify the scan operation.
682  * @param[in]  results_handler: The callback function which will receive and process the result data.
683  * @param[in]  user_data: User specified data that will be passed directly to the callback function.
684  * @return  RTW_SUCCESS or RTW_ERROR
685  * @note  Callback must not use blocking functions, since it is called from the context of the RTW thread.
686  *			The callback, user_data variables will be referenced after the function returns.
687  *			Those variables must remain valid until the scan is completed.
688  *			The usage of this api can reference ATWS in atcmd_wifi.c.
689  */
690 int wifi_scan_networks(rtw_scan_result_handler_t results_handler, void* user_data);
691 
692 /**
693  * @brief  Initiate a scan to search for 802.11 networks, a higher level API based on wifi_scan
694  *			to simplify the scan operation. This API separate full scan channel to partial scan
695  *			each channel for concurrent mode. MCC means Multi-channel concurrent.
696  * @param[in]  results_handler: The callback function which will receive and process the result data.
697  * @param[in]  user_data: User specified data that will be passed directly to the callback function.
698  * @return  RTW_SUCCESS or RTW_ERROR
699  * @note  Callback must not use blocking functions, since it is called from the context of the RTW thread.
700  *			The callback, user_data variables will be referenced after the function returns.
701  *			Those variables must remain valid until the scan is completed.
702  *			The usage of this api can reference ATWS in atcmd_wifi.c.
703  */
704 int wifi_scan_networks_mcc(rtw_scan_result_handler_t results_handler, void* user_data);
705 
706 /**
707  * @brief  Initiate a scan to search for 802.11 networks with specified SSID.
708  * @param[in]  results_handler: The callback function which will receive and process the result data.
709  * @param[in]  user_data: User specified data that will be passed directly to the callback function.
710  * @param[in]  scan_buflen: The length of the result storage structure.
711  * @param[in]  ssid: The SSID of target network.
712  * @param[in]  ssid_len: The length of the target network SSID.
713  * @return  RTW_SUCCESS or RTW_ERROR
714  * @note  Callback must not use blocking functions, since it is called from the context of the RTW thread.
715  *			The callback, user_data variables will be referenced after the function returns.
716  *			Those variables must remain valid until the scan is completed.
717  */
718 int wifi_scan_networks_with_ssid(int (results_handler)(char*, int, char *, void *), void* user_data, int scan_buflen, char* ssid, int ssid_len);
719 
720 /**
721  * @brief  Initiate a scan to search for 802.11 networks with specified SSID.
722  * @param[in]  results_handler: The callback function which will receive and process the result data.
723  * @param[in]  user_data: User specified data that will be passed directly to the callback function.
724  * @param[in]  scan_buflen: The length of the result storage structure.
725  * @param[in]  ssid: The SSID of target network.
726  * @param[in]  ssid_len: The length of the target network SSID.
727  * @return  RTW_SUCCESS or RTW_ERROR
728  * @note  Callback must not use blocking functions, since it is called from the context of the RTW thread.
729  *			The callback, user_data variables will be referenced after the function returns.
730  *			Those variables must remain valid until the scan is completed.
731  */
732 int wifi_scan_networks_with_ssid_by_extended_security(int (results_handler)(char*, int, char *, void *), void* user_data, int scan_buflen, char* ssid, int ssid_len);
733 
734 /**
735 * @brief  Set the channel used to be partial scanned.
736 * @param[in]  channel_list: An array stores the channel list.
737 * @param[in]  pscan_config: the pscan_config of the channel set.
738 * @param[in]  length: The length of the channel_list.
739 * @return  RTW_SUCCESS or RTW_ERROR.
740 * @note  This function should be used with wifi_scan function. First, use @ref wifi_set_pscan_chan to
741 *			indicate which channel will be scanned, and then use @ref wifi_scan to get scanned results.
742 */
743 int wifi_set_pscan_chan(__u8 * channel_list,__u8 * pscan_config, __u8 length);
744 
745 /**
746  * @brief  Get current Wi-Fi setting from driver.
747  * @param[in]  ifname: the wlan interface name, can be WLAN0_NAME or WLAN1_NAME.
748  * @param[out]  pSetting: Points to the rtw_wifi_setting_t structure to store the WIFI setting gotten from driver.
749  * @return  RTW_SUCCESS or RTW_ERROR.
750  */
751 int wifi_get_setting(const char *ifname,rtw_wifi_setting_t *pSetting);
752 
753 /**
754  * @brief  Show the network information stored in a rtw_wifi_setting_t structure.
755  * @param[in]  ifname: the wlan interface name, can be WLAN0_NAME or WLAN1_NAME.
756  * @param[in]  pSetting: Points to the rtw_wifi_setting_t structure which information is gotten by @ref wifi_get_setting().
757  * @return  RTW_SUCCESS or RTW_ERROR.
758  */
759 int wifi_show_setting(const char *ifname,rtw_wifi_setting_t *pSetting);
760 
761 /**
762  * @brief
763 Set the network mode according to the data rate its supported.
764  *			Driver works in BGN mode in default after driver initialization. This function is used to
765  *			change wireless network mode for station mode before connecting to AP.
766  * @param[in]  mode: Network mode to set. The value can be RTW_NETWORK_B/RTW_NETWORK_BG/RTW_NETWORK_BGN.
767  * @return  RTW_SUCCESS or RTW_ERROR.
768  */
769 int wifi_set_network_mode(rtw_network_mode_t mode);
770 
771 /**
772  * @brief	Get the network mode.
773  *			Driver works in BGN mode in default after driver initialization. This function is used to
774  *			get the current wireless network mode for station mode.
775  * @param[in]  pmode: Network mode to get.
776  * @return  RTW_SUCCESS or RTW_ERROR.
777  */
778 int wifi_get_network_mode(rtw_network_mode_t *pmode);
779 
780 /**
781  * @brief  Set the chip to start or stop the promiscuous mode.
782  * @param[in]  enabled: enabled can be set 0, 1, 2, 3 and 4. if enabled is zero, disable the promisc, else enable the promisc.
783  *                    - 0 means disable the promisc.
784  *                    - 1 means enable the promisc special for all ethernet frames.
785  *                    - 2 means enable the promisc special for Broadcast/Multicast ethernet frames.
786  *                    - 3 means enable the promisc special for all 802.11 frames.
787  *                    - 4 means enable the promisc special for Broadcast/Multicast 802.11 frames.
788  * @param[in]  callback: the callback function which will
789  *  			  receive and process the netowork data.
790  * @param[in]  len_used: specify if the the promisc data length is used.
791  *				If len_used set to 1, packet(frame data) length will be saved and transferred to callback function.
792  *
793  * @return  RTW_SUCCESS or RTW_ERROR
794  * @note  This function can be used to implement vendor specified simple configure.
795  * @note  To fetch Ethernet frames, the len_used should be set to 1
796  */
797 int wifi_set_promisc(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used);
798 
799 /**
800  * @brief  Let Wi-Fi enter promiscuous mode.
801  * @param[in]  None
802  * @return  None
803  */
804 void wifi_enter_promisc_mode(void);
805 
806 /** Set the wps phase
807  *
808  * @param is_trigger_wps[in]   : to trigger wps function or not
809  *
810  * @return    RTW_SUCCESS or RTW_ERROR
811  */
812 int wifi_set_wps_phase(unsigned char is_trigger_wps);
813 
814 /**
815  * @brief  Trigger Wi-Fi driver to restart an infrastructure Wi-Fi network.
816  * @warning If a STA interface is active when this function is called, the softAP will
817  *          start on the same channel as the STA. It will NOT use the channel provided!
818  * @param[in]  ssid: A null terminated string containing the SSID name of the network.
819  * @param[in]  security_type:
820  *                         - RTW_SECURITY_OPEN           - Open Security
821  *                         - RTW_SECURITY_WPA_TKIP_PSK   - WPA Security
822  *                         - RTW_SECURITY_WPA2_AES_PSK   - WPA2 Security using AES cipher
823  *                         - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
824  *                         - WEP security is NOT IMPLEMENTED. It is NOT SECURE!
825  * @param[in]  password: A byte array containing the cleartext security key for the network.
826  * @param[in]  ssid_len: The length of the SSID in bytes.
827  * @param[in]  password_len: The length of the security_key in bytes.
828  * @param[in]  channel: 802.11 channel number.
829  * @return  RTW_SUCCESS: If successfully creates an AP.
830  * @return  RTW_ERROR: If an error occurred.
831  * @note  Please make sure the Wi-Fi is enabled before invoking this function. (@ref wifi_on())
832  */
833 int wifi_restart_ap(
834 	unsigned char 		*ssid,
835 	rtw_security_t		security_type,
836 	unsigned char 		*password,
837 	int 				ssid_len,
838 	int 				password_len,
839 	int					channel);
840 
841 /**
842  * @brief  Set reconnection mode with configuration.
843  * @param[in]  mode: Set 1/0 to enalbe/disable the reconnection mode.
844  * @param[in]  retry_times: The number of retry limit.
845  * @param[in]  timeout: The timeout value (in seconds).
846  * @return  0 if success, otherwise return -1.
847  * @note  Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling,
848  *			or this API won't be effective.
849  * @note  The difference between @ref wifi_config_autoreconnect() and @ref wifi_set_autoreconnect() is that
850  *			user can specify the retry times and timeout value in @ref wifi_config_autoreconnect().
851  *			But in @ref wifi_set_autoreconnect() these values are set with 3 retry limit and 5 seconds timeout as default.
852  */
853 int wifi_config_autoreconnect(__u8 mode, __u8 retry_times, __u16 timeout);
854 
855 /**
856   * @brief  Set reconnection mode with 3 retry limit and 5 seconds timeout as default.
857   * @param[in]  mode: Set 1/0 to enalbe/disable the reconnection mode.
858   * @return  0 if success, otherwise return -1.
859   * @note  Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling,
860   *			or this API won't be effective.
861   * @note  The difference between @ref wifi_config_autoreconnect() and @ref wifi_set_autoreconnect() is that
862   *			user can specify the retry times and timeout value in @ref wifi_config_autoreconnect().
863   *			But in @ref wifi_set_autoreconnect() these values are set with 3 retry limit and 5 seconds timeout as default.
864   */
865 int wifi_set_autoreconnect(__u8 mode);
866 
867 /**
868   * @brief  Get the result of setting reconnection mode.
869   * @param[out]  mode: Point to the result of setting reconnection mode.
870   * @return  0 if success, otherwise return -1.
871   * @note  Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling,
872   *			or this API won't be effective.
873   */
874 int wifi_get_autoreconnect(__u8 *mode);
875 
876 /**
877   * @brief  Present the device disconnect reason while connecting.
878   * @param  None
879   * @return  @ref rtw_connect_error_flag_t
880   *			- 0: RTW_NO_ERROR
881   *			- 1: RTW_NONE_NETWORK
882   *			- 2: RTW_CONNECT_FAIL
883   *			- 3: RTW_WRONG_PASSWORD
884   *			- 4: RTW_DHCP_FAIL
885   *			- 5: RTW_UNKNOWN (initial status)
886   */
887 int wifi_get_last_error(void);
888 
889 
890 #ifdef CONFIG_CUSTOM_IE
891 #ifndef BIT
892 #define BIT(x)	((__u32)1 << (x))
893 #endif
894 
895 #ifndef _CUSTOM_IE_TYPE_
896 #define _CUSTOM_IE_TYPE_
897 /**
898   * @brief  The enumeration is transmission type for wifi custom ie.
899   */
900 enum CUSTOM_IE_TYPE{
901 	PROBE_REQ = BIT(0),
902 	PROBE_RSP = BIT(1),
903 	BEACON	  = BIT(2),
904 	ASSOC_REQ =BIT(3),
905 };
906 typedef __u32 rtw_custom_ie_type_t;
907 #endif /* _CUSTOM_IE_TYPE_ */
908 
909 /* ie format
910  * +-----------+--------+-----------------------+
911  * |element ID | length | content in length byte|
912  * +-----------+--------+-----------------------+
913  *
914  * type: refer to CUSTOM_IE_TYPE
915  */
916 #ifndef _CUS_IE_
917 #define _CUS_IE_
918 /**
919   * @brief  The structure is used to set WIFI custom ie list, and type match CUSTOM_IE_TYPE.\n
920   *			The ie will be transmitted according to the type.
921   */
922 typedef struct _cus_ie{
923 	__u8 *ie;
924 	__u8 type;
925 }rtw_custom_ie_t, *p_rtw_custom_ie_t;
926 #endif /* _CUS_IE_ */
927 
928 /**
929   * @brief  Setup custom ie list.
930   * @warning  This API can't be executed twice before deleting the previous custom ie list.
931   * @param[in]  cus_ie: Pointer to WIFI CUSTOM IE list.
932   * @param[in]  ie_num: The number of WIFI CUSTOM IE list.
933   * @return  0 if success, otherwise return -1.
934   * @note  Defininig CONFIG_CUSTOM_IE in "autoconf.h" needs to be done before compiling,
935   *			or this API won't be effective.
936   */
937 int wifi_add_custom_ie(void *cus_ie, int ie_num);
938 
939 /**
940   * @brief  Update the item in WIFI CUSTOM IE list.
941   * @param[in]  cus_ie: Pointer to WIFI CUSTOM IE address.
942   * @param[in]  ie_index: Index of WIFI CUSTOM IE list.
943   * @return  0 if success, otherwise return -1.
944   * @note  Defininig CONFIG_CUSTOM_IE in "autoconf.h" needs to be done before compiling,
945   *			or this API won't be effective.
946   */
947 int wifi_update_custom_ie(void *cus_ie, int ie_index);
948 
949 /**
950   * @brief  Delete WIFI CUSTOM IE list.
951   * @param  None
952   * @return  0 if success, otherwise return -1.
953   * @note  Defininig CONFIG_CUSTOM_IE in "autoconf.h" needs to be done before compiling,
954   *			or this API won't be effective.
955   */
956 int wifi_del_custom_ie(void);
957 #endif
958 
959 #ifdef CONFIG_PROMISC
960 
961 /**
962   * @brief  Initialize packet filter related data.
963   * @param  None
964   * @return  None
965   */
966 void wifi_init_packet_filter(void);
967 
968 /**
969   * @brief  Add packet filter.
970   * @param[in]  filter_id: The filter id.
971   * @param[in]  patt: Point to the filter pattern.
972   * @param[in]  rule: Point to the filter rule.
973   * @return  0 if success, otherwise return -1.
974   * @note  For now, the maximum number of filters is 5.
975   */
976 int wifi_add_packet_filter(unsigned char filter_id, rtw_packet_filter_pattern_t *patt, rtw_packet_filter_rule_t rule);
977 
978 /**
979   * @brief  Enable the packet filter.
980   * @param[in]  filter_id: The filter id.
981   * @return  0 if success, otherwise return -1.
982   * @note  The filter can be used only if it has been enabled.
983   */
984 int wifi_enable_packet_filter(unsigned char filter_id);
985 
986 /**
987   * @brief  Disable the packet filter.
988   * @param[in]  filter_id: The filter id.
989   * @return  0 if success, otherwise return -1.
990   */
991 int wifi_disable_packet_filter(unsigned char filter_id);
992 
993 /**
994   * @brief  Remove the packet filter.
995   * @param[in]  filter_id: The filter id.
996   * @return  0 if success, otherwise return -1.
997   */
998 int wifi_remove_packet_filter(unsigned char filter_id);
999 
1000 /**
1001   * @brief: Only receive the packets sent by the specified ap and phone in promisc mode.
1002   * @param[in]  enable: set 1 to enable filter, set 0 to disable this filter function.
1003   * @param[in]  ap_mac: if 'enable' equals 0, it's useless; if 'enable' equals 1, this value is the ap's mac address.
1004   * @param[in]  phone_mac: if 'enable' equals 0, it's useless; if 'enable' equals 1, this value is the phone's mac address.
1005   * @return  None.
1006   * @note  Please invoke this function as "wifi_filter_by_ap_and_phone_mac(0,NULL,NULL)" before exiting promisc mode if you enabled it during the promisc mode.
1007   */
1008 void wifi_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac, void *phone_mac);
1009 #endif
1010 
1011 /**
1012   * @brief  Get antenna infomation.
1013   * @param[in]  antenna: Points to store the antenna value gotten from driver, 0: main, 1: aux.
1014   * @return  0 if success, otherwise return -1.
1015   */
1016 #ifdef CONFIG_ANTENNA_DIVERSITY
1017 int wifi_get_antenna_info(unsigned char *antenna);
1018 #endif // #ifdef CONFIG_ANTENNA_DIVERSITY
1019 
1020 /**
1021   * @brief:	config mode of HW indicating packets(mgnt and data) and SW reporting packets to wifi_indication().
1022   * @param[in]
1023   *		0: disable mode(default), HW only indicate bssid-matched pkts and SW don't report.
1024   *		1: normal mode, HW only indicate bssid-matched pkts and SW report.
1025   *		2: wild mode, HW indicate all pkts and SW report.
1026   *
1027   * @return	None
1028   * @note None
1029   */
1030 void wifi_set_indicate_mgnt(int enable);
1031 
1032 
1033 /**
1034  * @brief  Get the information of MP driver
1035  * @param[out]  ability : 0x1 stand for mp driver, and 0x0 stand for normal driver
1036  * @return  RTW_SUCCESS
1037  */
1038 int wifi_get_drv_ability(uint32_t *ability);
1039 
1040 /**
1041  * @brief  Set channel plan into flash/efuse, must reboot after setting channel plan
1042  * @param[in]  channel_plan : the value of channel plan, define in wifi_constants.h
1043  * @return  RTW_SUCCESS or RTW_ERROR
1044  */
1045 int wifi_set_channel_plan(uint8_t channel_plan);
1046 
1047 /**
1048  * @brief  Get channel plan from calibration section
1049  * @param[out]  channel_plan : point to the value of channel plan, define in wifi_constants.h
1050  * @return  RTW_SUCCESS or RTW_ERROR
1051  */
1052 int wifi_get_channel_plan(uint8_t *channel_plan);
1053 
1054 #ifdef CONFIG_AP_MODE
1055 /**
1056  * @brief  Enable packets forwarding in ap mode
1057  * @return  RTW_SUCCESS
1058  */
1059 int wifi_enable_forwarding(void);
1060 
1061 /**
1062  * @brief  Disable packets forwarding in ap mode
1063  * @return  RTW_SUCCESS
1064  */
1065 int wifi_disable_forwarding(void);
1066 #endif
1067 
1068 #ifdef CONFIG_CONCURRENT_MODE
1069 /**
1070  * @brief  Set flag for concurrent mode wlan1 issue_deauth when channel switched by wlan0
1071  *          usage: wifi_set_ch_deauth(0) -> wlan0 wifi_connect -> wifi_set_ch_deauth(1)
1072  * @param[in]  enable : 0 for disable and 1 for enable
1073  * @return  RTW_SUCCESS
1074  */
1075 int wifi_set_ch_deauth(__u8 enable);
1076 #endif
1077 
1078 ///@name Ameba1 Only
1079 ///@{
1080 /**
1081  * @brief enable AP sending QoS Null0 Data to poll Sta be alive
1082  * @param[in]  enabled: enabled can be set to 0,1.
1083  *			- 0	means enable.
1084  *			- 1	means disable.
1085  * @return  None
1086  */
1087 void wifi_set_ap_polling_sta(__u8 enabled);
1088 ///@}
1089 
1090 #ifdef CONFIG_SW_MAILBOX_EN
1091 /**
1092  * @brief  interface for bt to set mailbox info to wifi, mostly for coexistence usage
1093  * @param[in]  data : pointer of mailbox data
1094  * @param[in]  len : length of mailbox data
1095  * @return  0 if success, otherwise return -1
1096  */
1097 int mailbox_to_wifi(u8 *data, u8 len);
1098 #else
1099 #define mailbox_to_wifi(data, len)
1100 #endif
1101 
1102 #ifdef CONFIG_WOWLAN_TCP_KEEP_ALIVE
1103 /**
1104  * @brief  construct a tcp packet that offload to wlan. wlan would keep sending this packet to tcp server.
1105  *
1106  * @param[in]  socket_fd : tcp socket
1107  * @param[in]  content : tcp payload
1108  * @param[in]  len : tcp payload size
1109  * @param[in]  interval_ms : send this packeter every interval_ms milliseconds
1110  * @return  RTW_SUCCESS
1111  */
1112 int wifi_set_tcp_keep_alive_offload(int socket_fd, uint8_t *content, size_t len, uint32_t interval_ms);
1113 #endif
1114 
1115 // WoWlan related
1116 //-------------------------------------------------------------//
1117 #ifdef CONFIG_WOWLAN
1118 typedef struct {
1119 	unsigned int filter_id;
1120 	unsigned int polarity;
1121 	unsigned int type;
1122 	unsigned int offset;
1123 	unsigned char *bitmask;
1124 	unsigned char *pattern;
1125 } wowlan_pattern_param_t;
1126 
1127 int wifi_wowlan_ctrl(int enable);
1128 int wifi_wowlan_set_pattern(wowlan_pattern_t pattern);
1129 #endif
1130 //-------------------------------------------------------------//
1131 #ifdef CONFIG_APP_CTRL_RF_ONOFF
1132 extern void rtw_rf_cmd(u32 Status);
1133 extern u32 rtw_get_tsf(u32 Port);
1134 #endif
1135 
1136 /*
1137  * @brief get band
1138  *@retval  the support band type.
1139  * 	WL_BAND_2_4G: only support 2.4G
1140  *	WL_BAND_5G: only support 5G
1141  *      WL_BAND_2_4G_5G_BOTH: support both 2.4G and 5G
1142  */
1143 WL_BAND_TYPE wifi_get_band_type(void);
1144 
1145 
1146 #ifdef LOW_POWER_WIFI_CONNECT
1147 int wifi_set_psk_eap_interval(uint16_t psk_interval, uint16_t eap_interval);
1148 int wifi_set_null1_param(uint8_t check_period, uint8_t pkt_num, uint8_t limit, uint8_t interval);
1149 #endif
1150 
1151 /**
1152  * @brief  Switch channel of softap and inform connected stations to keep wifi connection.
1153  * @param[in]  new_channel: The channel number that softap will switch to.
1154  * @return  RTW_SUCCESS: If switching channel is successful.
1155  * @return  RTW_ERROR: If switching channel is failed.
1156  */
1157 int wifi_ap_switch_chl_and_inform(unsigned char new_channel);
1158 
1159 #ifdef __cplusplus
1160   }
1161 #endif
1162 
1163 /*\@}*/
1164 
1165 #endif // __WIFI_API_H
1166 
1167 //----------------------------------------------------------------------------//
1168 
1169