NIC
Ameba SDK » WLAN

NIC functions. More...

## Data Structures

struct | scan_buf_arg
struct | internal_scan_handler
struct | internal_join_result_t
struct | event_list_elem_t
struct | rtw_ssid
| The structure is used to describe the SSID. More...
struct | rtw_mac
| The structure is used to describe the unique 6-byte MAC address. More...
struct | rtw_ap_info
| The structure is used to describe the setting about SSID, security type, password and default channel, used to start AP mode. More...
struct | rtw_network_info
| The structure is used to describe the station mode setting about SSID, security type and password, used when connecting to an AP. More...
struct | rtw_scan_result
| The structure is used to describe the scan result of the AP. More...
struct | rtw_scan_handler_result
| The structure is used to describe the data needed by scan result handler function. More...
struct | rtw_wifi_setting
| The structure is used to store the WIFI setting gotten from WIFI driver. More...
struct | rtw_wifi_config
| The structure is used to describe the setting when configure the network. More...
struct | rtw_maclist_t
| The structure is used to describe the maclist. More...
struct | rtw_bss_info_t
| The structure is used to describe the bss info of the network. It include the version, BSSID, beacon_period, capability, SSID, channel, atm_window, dtim_period, RSSI e.g. More...
struct | rtw_packet_filter_pattern_t
| The structure is used to set WIFI packet filter pattern. More...
struct | ieee80211_frame_info
struct | rtw_packet_filter_info_t
struct | rtw_mac_filter_list

## Macros

#define | RTW_ENABLE_API_INFO
#define | RTW_API_INFO(args) do {printf args;} while(0)
#define | MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
#define | CMP_MAC(a, b)
#define | SCAN_LONGEST_WAIT_TIME (4500)
#define | MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
#define | PSCAN_ENABLE 0x01
#define | PSCAN_FAST_SURVEY 0x02
#define | PSCAN_SIMPLE_CONFIG 0x04
#define | WLAN0_NAME "wlan0"
#define | WLAN1_NAME "wlan1"
#define | WEP_ENABLED 0x0001
#define | TKIP_ENABLED 0x0002
#define | AES_ENABLED 0x0004
#define | WSEC_SWFLAG 0x0008
#define | SHARED_ENABLED 0x00008000
#define | WPA_SECURITY 0x00200000
#define | WPA2_SECURITY 0x00400000
#define | WPS_ENABLED 0x10000000
#define | RTW_MAX_PSK_LEN (64)
#define | RTW_MIN_PSK_LEN (8)
#define | MCSSET_LEN 16

## Typedefs

typedef void(* | rtw_scan_result_callback_t) (rtw_scan_result_t **result_ptr, void *user_data)
typedef rtw_result_t(* | rtw_scan_result_handler_t) (rtw_scan_handler_result_t *malloced_scan_result)
typedef struct internal_scan_handler | internal_scan_handler_t
typedef void(* | rtw_event_handler_t) (char *buf, int buf_len, int flags, void *handler_user_data)
typedef enum _WIFI_EVENT_INDICATE | rtw_event_indicate_t
| The enumeration is event type indicated from wlan driver.
typedef struct rtw_ssid | rtw_ssid_t
| The structure is used to describe the SSID.
typedef struct rtw_mac | rtw_mac_t
| The structure is used to describe the unique 6-byte MAC address.
typedef struct rtw_ap_info | rtw_ap_info_t
| The structure is used to describe the setting about SSID, security type, password and default channel, used to start AP mode. More...
typedef struct rtw_network_info | rtw_network_info_t
| The structure is used to describe the station mode setting about SSID, security type and password, used when connecting to an AP. More...
typedef struct rtw_scan_result | rtw_scan_result_t
| The structure is used to describe the scan result of the AP.
typedef struct rtw_scan_handler_result | rtw_scan_handler_result_t
| The structure is used to describe the data needed by scan result handler function.
typedef struct rtw_wifi_setting | rtw_wifi_setting_t
| The structure is used to store the WIFI setting gotten from WIFI driver.
typedef struct rtw_wifi_config | rtw_wifi_config_t
| The structure is used to describe the setting when configure the network.
typedef struct ieee80211_frame_info | ieee80211_frame_info_t
typedef struct rtw_mac_filter_list | rtw_mac_filter_list_t

## Enumerations

enum

rtw_result_t {
RTW_SUCCESS = 0, RTW_PENDING = 1, RTW_TIMEOUT = 2, RTW_PARTIAL_RESULTS = 3,
RTW_INVALID_KEY = 4, RTW_DOES_NOT_EXIST = 5, RTW_NOT_AUTHENTICATED = 6, RTW_NOT_KEYED = 7,
RTW_IOCTL_FAIL = 8, RTW_BUFFER_UNAVAILABLE_TEMPORARY = 9, RTW_BUFFER_UNAVAILABLE_PERMANENT = 10, RTW_WPS_PBC_OVERLAP = 11,
RTW_CONNECTION_LOST = 12, RTW_ERROR = -1, RTW_BADARG = -2, RTW_BADOPTION = -3,
RTW_NOTUP = -4, RTW_NOTDOWN = -5, RTW_NOTAP = -6, RTW_NOTSTA = -7,
RTW_BADKEYIDX = -8, RTW_RADIOOFF = -9, RTW_NOTBANDLOCKED = -10, RTW_NOCLK = -11,
RTW_BADRATESET = -12, RTW_BADBAND = -13, RTW_BUFTOOSHORT = -14, RTW_BUFTOOLONG = -15,
RTW_BUSY = -16, RTW_NOTASSOCIATED = -17, RTW_BADSSIDLEN = -18, RTW_OUTOFRANGECHAN = -19,
RTW_BADCHAN = -20, RTW_BADADDR = -21, RTW_NORESOURCE = -22, RTW_UNSUPPORTED = -23,
RTW_BADLEN = -24, RTW_NOTREADY = -25, RTW_EPERM = -26, RTW_NOMEM = -27,
RTW_ASSOCIATED = -28, RTW_RANGE = -29, RTW_NOTFOUND = -30, RTW_WME_NOT_ENABLED = -31,
RTW_TSPEC_NOTFOUND = -32, RTW_ACM_NOTSUPPORTED = -33, RTW_NOT_WME_ASSOCIATION = -34, RTW_SDIO_ERROR = -35,
RTW_WLAN_DOWN = -36, RTW_BAD_VERSION = -37, RTW_TXFAIL = -38, RTW_RXFAIL = -39,
RTW_NODEVICE = -40, RTW_UNFINISHED = -41, RTW_NONRESIDENT = -42, RTW_DISABLED = -43
}

| The enumeration lists the results of the function. More...

enum

rtw_security_t {
RTW_SECURITY_OPEN = 0, RTW_SECURITY_WEP_PSK = WEP_ENABLED, RTW_SECURITY_WEP_SHARED = ( WEP_ENABLED | SHARED_ENABLED ), RTW_SECURITY_WPA_TKIP_PSK = ( WPA_SECURITY | TKIP_ENABLED ),
RTW_SECURITY_WPA_AES_PSK = ( WPA_SECURITY | AES_ENABLED ), RTW_SECURITY_WPA2_AES_PSK = ( WPA2_SECURITY | AES_ENABLED ), RTW_SECURITY_WPA2_TKIP_PSK = ( WPA2_SECURITY | TKIP_ENABLED ), RTW_SECURITY_WPA2_MIXED_PSK = ( WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED ),
RTW_SECURITY_WPA_WPA2_MIXED = ( WPA_SECURITY | WPA2_SECURITY ), RTW_SECURITY_WPS_OPEN = WPS_ENABLED, RTW_SECURITY_WPS_SECURE = (WPS_ENABLED | AES_ENABLED), RTW_SECURITY_UNKNOWN = -1,
RTW_SECURITY_FORCE_32_BIT = 0x7fffffff
}

| The enumeration lists the possible security types to set when connection. Station mode supports OPEN, WEP, and WPA2. AP mode support OPEN and WPA2. More...
enum | rtw_encryption_t { RTW_ENCRYPTION_UNKNOWN = 0, RTW_ENCRYPTION_OPEN = 1, RTW_ENCRYPTION_WEP40 = 2, RTW_ENCRYPTION_WPA_TKIP = 3, RTW_ENCRYPTION_WPA_AES = 4, RTW_ENCRYPTION_WPA2_TKIP = 5, RTW_ENCRYPTION_WPA2_AES = 6, RTW_ENCRYPTION_WPA2_MIXED = 7, RTW_ENCRYPTION_WEP104 = 9, RTW_ENCRYPTION_UNDEF = 0xFF }
enum | rtw_bool_t { RTW_FALSE = 0, RTW_TRUE = 1 }
enum | rtw_802_11_band_t { RTW_802_11_BAND_5GHZ = 0, RTW_802_11_BAND_2_4GHZ = 1 }
| The enumeration lists the band types. More...

enum

rtw_country_code_t {
RTW_COUNTRY_WORLD1, RTW_COUNTRY_ETSI1, RTW_COUNTRY_FCC1, RTW_COUNTRY_MKK1,
RTW_COUNTRY_ETSI2, RTW_COUNTRY_FCC2, RTW_COUNTRY_WORLD2, RTW_COUNTRY_MKK2,
RTW_COUNTRY_GLOBAL, RTW_COUNTRY_WORLD, RTW_COUNTRY_EU, RTW_COUNTRY_JP,
RTW_COUNTRY_AS, RTW_COUNTRY_BM, RTW_COUNTRY_CA, RTW_COUNTRY_DM,
RTW_COUNTRY_DO, RTW_COUNTRY_FM, RTW_COUNTRY_GD, RTW_COUNTRY_GT,
RTW_COUNTRY_GU, RTW_COUNTRY_HT, RTW_COUNTRY_MH, RTW_COUNTRY_MP,
RTW_COUNTRY_NI, RTW_COUNTRY_PA, RTW_COUNTRY_PR, RTW_COUNTRY_PW,
RTW_COUNTRY_TW, RTW_COUNTRY_US, RTW_COUNTRY_VI, RTW_COUNTRY_AD,
RTW_COUNTRY_AE, RTW_COUNTRY_AF, RTW_COUNTRY_AI, RTW_COUNTRY_AL,
RTW_COUNTRY_AM, RTW_COUNTRY_AN, RTW_COUNTRY_AR, RTW_COUNTRY_AT,
RTW_COUNTRY_AU, RTW_COUNTRY_AW, RTW_COUNTRY_AZ, RTW_COUNTRY_BA,
RTW_COUNTRY_BB, RTW_COUNTRY_BD, RTW_COUNTRY_BE, RTW_COUNTRY_BF,
RTW_COUNTRY_BG, RTW_COUNTRY_BH, RTW_COUNTRY_BL, RTW_COUNTRY_BN,
RTW_COUNTRY_BO, RTW_COUNTRY_BR, RTW_COUNTRY_BS, RTW_COUNTRY_BT,
RTW_COUNTRY_BY, RTW_COUNTRY_BZ, RTW_COUNTRY_CF, RTW_COUNTRY_CH,
RTW_COUNTRY_CI, RTW_COUNTRY_CL, RTW_COUNTRY_CN, RTW_COUNTRY_CO,
RTW_COUNTRY_CR, RTW_COUNTRY_CX, RTW_COUNTRY_CY, RTW_COUNTRY_CZ,
RTW_COUNTRY_DE, RTW_COUNTRY_DK, RTW_COUNTRY_DZ, RTW_COUNTRY_EC,
RTW_COUNTRY_EE, RTW_COUNTRY_EG, RTW_COUNTRY_ES, RTW_COUNTRY_ET,
RTW_COUNTRY_FI, RTW_COUNTRY_FR, RTW_COUNTRY_GB, RTW_COUNTRY_GE,
RTW_COUNTRY_GF, RTW_COUNTRY_GH, RTW_COUNTRY_GL, RTW_COUNTRY_GP,
RTW_COUNTRY_GR, RTW_COUNTRY_GY, RTW_COUNTRY_HK, RTW_COUNTRY_HN,
RTW_COUNTRY_HR, RTW_COUNTRY_HU, RTW_COUNTRY_ID, RTW_COUNTRY_IE,
RTW_COUNTRY_IL, RTW_COUNTRY_IN, RTW_COUNTRY_IQ, RTW_COUNTRY_IR,
RTW_COUNTRY_IS, RTW_COUNTRY_IT, RTW_COUNTRY_JM, RTW_COUNTRY_JO,
RTW_COUNTRY_KE, RTW_COUNTRY_KH, RTW_COUNTRY_KN, RTW_COUNTRY_KP,
RTW_COUNTRY_KR, RTW_COUNTRY_KW, RTW_COUNTRY_KY, RTW_COUNTRY_KZ,
RTW_COUNTRY_LA, RTW_COUNTRY_LB, RTW_COUNTRY_LC, RTW_COUNTRY_LI,
RTW_COUNTRY_LK, RTW_COUNTRY_LR, RTW_COUNTRY_LS, RTW_COUNTRY_LT,
RTW_COUNTRY_LU, RTW_COUNTRY_LV, RTW_COUNTRY_MA, RTW_COUNTRY_MC,
RTW_COUNTRY_MD, RTW_COUNTRY_ME, RTW_COUNTRY_MF, RTW_COUNTRY_MK,
RTW_COUNTRY_MN, RTW_COUNTRY_MO, RTW_COUNTRY_MQ, RTW_COUNTRY_MR,
RTW_COUNTRY_MT, RTW_COUNTRY_MU, RTW_COUNTRY_MV, RTW_COUNTRY_MW,
RTW_COUNTRY_MX, RTW_COUNTRY_MY, RTW_COUNTRY_NG, RTW_COUNTRY_NL,
RTW_COUNTRY_NO, RTW_COUNTRY_NP, RTW_COUNTRY_NZ, RTW_COUNTRY_OM,
RTW_COUNTRY_PE, RTW_COUNTRY_PF, RTW_COUNTRY_PG, RTW_COUNTRY_PH,
RTW_COUNTRY_PK, RTW_COUNTRY_PL, RTW_COUNTRY_PM, RTW_COUNTRY_PT,
RTW_COUNTRY_PY, RTW_COUNTRY_QA, RTW_COUNTRY_RS, RTW_COUNTRY_RU,
RTW_COUNTRY_RW, RTW_COUNTRY_SA, RTW_COUNTRY_SE, RTW_COUNTRY_SG,
RTW_COUNTRY_SI, RTW_COUNTRY_SK, RTW_COUNTRY_SN, RTW_COUNTRY_SR,
RTW_COUNTRY_SV, RTW_COUNTRY_SY, RTW_COUNTRY_TC, RTW_COUNTRY_TD,
RTW_COUNTRY_TG, RTW_COUNTRY_TH, RTW_COUNTRY_TN, RTW_COUNTRY_TR,
RTW_COUNTRY_TT, RTW_COUNTRY_TZ, RTW_COUNTRY_UA, RTW_COUNTRY_UG,
RTW_COUNTRY_UY, RTW_COUNTRY_UZ, RTW_COUNTRY_VC, RTW_COUNTRY_VE,
RTW_COUNTRY_VN, RTW_COUNTRY_VU, RTW_COUNTRY_WF, RTW_COUNTRY_WS,
RTW_COUNTRY_YE, RTW_COUNTRY_YT, RTW_COUNTRY_ZA, RTW_COUNTRY_ZW,
RTW_COUNTRY_MAX
}

| The enumeration lists all the country codes able to set to Wi-Fi driver.
enum | rtw_adaptivity_mode_t { RTW_ADAPTIVITY_DISABLE = 0, RTW_ADAPTIVITY_NORMAL, RTW_ADAPTIVITY_CARRIER_SENSE }
| The enumeration lists the adaptivity types.
enum | rtw_mode_t { RTW_MODE_NONE = 0, RTW_MODE_STA, RTW_MODE_AP, RTW_MODE_STA_AP, RTW_MODE_PROMISC, RTW_MODE_P2P }
| The enumeration lists the supported operation mode by WIFI driver, including station and AP mode.
enum | rtw_scan_mode_t { RTW_SCAN_FULL = 0, RTW_SCAN_SOCIAL, RTW_SCAN_ONE }
enum | rtw_link_status_t { RTW_LINK_DISCONNECTED = 0, RTW_LINK_CONNECTED }
| The enumeration lists the status to describe the connection link.
enum | rtw_scan_type_t { RTW_SCAN_TYPE_ACTIVE = 0x00, RTW_SCAN_TYPE_PASSIVE = 0x01, RTW_SCAN_TYPE_PROHIBITED_CHANNELS = 0x04 }
| The enumeration lists the scan types. More...
enum | rtw_bss_type_t { RTW_BSS_TYPE_INFRASTRUCTURE = 0, RTW_BSS_TYPE_ADHOC = 1, RTW_BSS_TYPE_ANY = 2, RTW_BSS_TYPE_UNKNOWN = -1 }
| The enumeration lists the bss types. More...
enum | rtw_scan_command_t { RTW_SCAN_COMMAMD = 0x01 }
enum | rtw_command_type { COMMAND1 = 0x01 }
enum | rtw_wps_type_t { RTW_WPS_TYPE_DEFAULT = 0x0000, RTW_WPS_TYPE_USER_SPECIFIED = 0x0001, RTW_WPS_TYPE_MACHINE_SPECIFIED = 0x0002, RTW_WPS_TYPE_REKEY = 0x0003, RTW_WPS_TYPE_PUSHBUTTON = 0x0004, RTW_WPS_TYPE_REGISTRAR_SPECIFIED = 0x0005, RTW_WPS_TYPE_NONE = 0x0006, RTW_WPS_TYPE_WSC = 0x0007 }
enum | rtw_network_mode_t { RTW_NETWORK_B = 1, RTW_NETWORK_BG = 3, RTW_NETWORK_BGN = 11 }
| The enumeration lists all the network bgn mode.
enum | rtw_interface_t { RTW_STA_INTERFACE = 0, RTW_AP_INTERFACE = 1 }
| The enumeration lists the interfaces. More...
enum | rtw_packet_filter_rule_t { RTW_POSITIVE_MATCHING = 0, RTW_NEGATIVE_MATCHING = 1 }
| The enumeration lists the packet filter rules. More...
enum | rtw_rcr_level_t { RTW_PROMISC_DISABLE = 0, RTW_PROMISC_ENABLE = 1, RTW_PROMISC_ENABLE_1 = 2, RTW_PROMISC_ENABLE_2 = 3, RTW_PROMISC_ENABLE_3 = 4 }
| The enumeration lists the promisc levels. More...
enum | rtw_connect_error_flag_t { RTW_NO_ERROR = 0, RTW_NONE_NETWORK = 1, RTW_CONNECT_FAIL = 2, RTW_WRONG_PASSWORD = 3, RTW_DHCP_FAIL = 4, RTW_UNKNOWN }
| The enumeration lists the disconnect reasons.
enum | rtw_tx_pwr_percentage_t { RTW_TX_PWR_PERCENTAGE_100 = 0, RTW_TX_PWR_PERCENTAGE_75 = 1, RTW_TX_PWR_PERCENTAGE_50 = 2, RTW_TX_PWR_PERCENTAGE_25 = 3, RTW_TX_PWR_PERCENTAGE_12_5 = 4 }

enum

_WIFI_EVENT_INDICATE {
WIFI_EVENT_CONNECT = 0, WIFI_EVENT_DISCONNECT = 1, WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2, WIFI_EVENT_SCAN_RESULT_REPORT = 3,
WIFI_EVENT_SCAN_DONE = 4, WIFI_EVENT_RECONNECTION_FAIL = 5, WIFI_EVENT_SEND_ACTION_DONE = 6, WIFI_EVENT_RX_MGNT = 7,
WIFI_EVENT_STA_ASSOC = 8, WIFI_EVENT_STA_DISASSOC = 9, WIFI_EVENT_STA_WPS_START = 10, WIFI_EVENT_WPS_FINISH = 11,
WIFI_EVENT_EAPOL_START = 12, WIFI_EVENT_EAPOL_RECVD = 13, WIFI_EVENT_NO_NETWORK = 14, WIFI_EVENT_BEACON_AFTER_DHCP = 15,
WIFI_EVENT_MAX
}

| The enumeration is event type indicated from wlan driver.

## Functions

int | wifi_manager_init (void)
| Initialize Realtek WiFi API System. More...
int | wifi_connect (char *ssid, rtw_security_t security_type, char *password, int ssid_len, int password_len, int key_id, void *semaphore)
| Join a Wi-Fi network. Scan for, associate and authenticate with a Wi-Fi network. On successful return, the system is ready to send data packets. More...
int | wifi_connect_bssid (unsigned char bssid[ETH_ALEN], char *ssid, rtw_security_t security_type, char *password, int bssid_len, int ssid_len, int password_len, int key_id, void *semaphore)
| Join a Wi-Fi network with specified BSSID. Scan for, associate and authenticate with a Wi-Fi network. On successful return, the system is ready to send data packets. More...
int | wifi_disconnect (void)
| Disassociates from current Wi-Fi network. More...
int | wifi_is_connected_to_ap (void)
| Check if Wi-Fi has connected to AP before dhcp. More...
int | wifi_is_up (rtw_interface_t interface)
| Check if the specified interface is up. More...
int | wifi_is_ready_to_transceive (rtw_interface_t interface)
int | wifi_set_mac_address (char *mac)
| This function sets the current Media Access Control (MAC) address of the 802.11 device. More...
int | wifi_get_mac_address (char *mac)
| Retrieves the current Media Access Control (MAC) address (or Ethernet hardware address) of the 802.11 device. More...
int | wifi_enable_powersave (void)
| Enable Wi-Fi powersave mode. More...
int | wifi_disable_powersave (void)
| Disable Wi-Fi powersave mode. More...
int | wifi_get_txpower (int *poweridx)
int | wifi_set_txpower (int poweridx)
| Set the tx power in index units. More...
int | wifi_get_associated_client_list (void *client_list_buffer, unsigned short buffer_length)
| Get the associated clients with SoftAP. More...
int | wifi_get_ap_info (rtw_bss_info_t *ap_info, rtw_security_t *security)
| Get the SoftAP information. More...
int | wifi_set_country (rtw_country_code_t country_code)
| Set the country code to driver to determine the channel set. More...
int | wifi_get_rssi (int *pRSSI)
| Retrieve the latest RSSI value. More...
int | wifi_set_channel (int channel)
| Set the listening channel for promiscuous mode. More...
int | wifi_get_channel (int *channel)
| Get the current channel on STA interface. More...
int | wifi_register_multicast_address (rtw_mac_t *mac)
| Register interest in a multicast address. Once a multicast address has been registered, all packets detected on the medium destined for that address are forwarded to the host. Otherwise they are ignored. More...
int | wifi_unregister_multicast_address (rtw_mac_t *mac)
| Unregister interest in a multicast address. Once a multicast address has been unregistered, all packets detected on the medium destined for that address are ignored. More...
_WEAK void | wifi_set_mib (void)
| Setup the adaptivity mode. You can replace this weak function by the same name funcation to setup adaptivity mode you want. More...
_WEAK void | wifi_set_country_code (void)
| Setup country code. You can replace this weak function by the same name funcation to setup country code you want. More...
int | wifi_rf_on (void)
| Enable Wi-Fi RF. More...
int | wifi_rf_off (void)
| Disable Wi-Fi RF. More...
int | wifi_on (rtw_mode_t mode)
| Enable Wi-Fi. More...
int | wifi_off (void)
| Disable Wi-Fi. More...
int | wifi_off_fastly (void)
int | wifi_set_power_mode (unsigned char ips_mode, unsigned char lps_mode)
| Set IPS/LPS mode. More...
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)
int | wifi_set_lps_dtim (unsigned char dtim)
| Set LPS DTIM. More...
int | wifi_get_lps_dtim (unsigned char *dtim)
| Get LPS DTIM. More...
int | wifi_start_ap (char *ssid, rtw_security_t security_type, char *password, int ssid_len, int password_len, int channel)
| Trigger Wi-Fi driver to start an infrastructure Wi-Fi network. More...
int | wifi_start_ap_with_hidden_ssid (char *ssid, rtw_security_t security_type, char *password, int ssid_len, int password_len, int channel)
| Start an infrastructure Wi-Fi network with hidden SSID. More...
int | wifi_scan (rtw_scan_type_t scan_type, rtw_bss_type_t bss_type, void *result_ptr)
| Initiate a scan to search for 802.11 networks. More...
int | wifi_scan_networks (rtw_scan_result_handler_t results_handler, void *user_data)
| Initiate a scan to search for 802.11 networks, a higher level API based on wifi_scan to simplify the scan operation. More...
int | wifi_scan_networks_with_ssid (int(results_handler)(char *, int, char *, void *), void *user_data, int scan_buflen, char *ssid, int ssid_len)
| Initiate a scan to search for 802.11 networks with specified SSID. More...
int | wifi_set_pscan_chan (__u8 *channel_list, __u8 *pscan_config, __u8 length)
| Set the channel used to be partial scanned. More...
int | wifi_get_setting (const char *ifname, rtw_wifi_setting_t *pSetting)
| Get current Wi-Fi setting from driver. More...
int | wifi_show_setting (const char *ifname, rtw_wifi_setting_t *pSetting)
| Show the network information stored in a rtw_wifi_setting_t structure. More...
int | wifi_set_network_mode (rtw_network_mode_t mode)
| Set the network mode according to the data rate its supported. Driver works in BGN mode in default after driver initialization. This function is used to change wireless network mode for station mode before connecting to AP. More...
int | wifi_set_promisc (rtw_rcr_level_t enabled, void(*callback)(unsigned char *, unsigned int, void *), unsigned char len_used)
| Set the chip to start or stop the promiscuous mode. More...
void | wifi_enter_promisc_mode (void)
| Let Wi-Fi enter promiscuous mode. More...
int | wifi_set_wps_phase (unsigned char is_trigger_wps)
int | wifi_restart_ap (unsigned char *ssid, rtw_security_t security_type, unsigned char *password, int ssid_len, int password_len, int channel)
| Trigger Wi-Fi driver to restart an infrastructure Wi-Fi network. More...
int | wifi_config_autoreconnect (__u8 mode, __u8 retry_times, __u16 timeout)
| Set reconnection mode with configuration. More...
int | wifi_set_autoreconnect (__u8 mode)
| Set reconnection mode with 3 retry limit and 5 seconds timeout as default. More...
int | wifi_get_autoreconnect (__u8 *mode)
| Get the result of setting reconnection mode. More...
int | wifi_get_last_error (void)
| Present the device disconnect reason while connecting. More...
void | wifi_set_indicate_mgnt (int enable)
| Get antenna infomation. More...
void | init_event_callback_list (void)
| Initialize the event callback list. More...
void | wifi_indication (rtw_event_indicate_t event, char *buf, int buf_len, int flags)
| Wlan driver indicate event to upper layer through wifi_indication. More...
void | wifi_reg_event_handler (unsigned int event_cmds, rtw_event_handler_t handler_func, void *handler_user_data)
| Register the event listener. More...
void | wifi_unreg_event_handler (unsigned int event_cmds, rtw_event_handler_t handler_func)
| Un-register the event listener. More...

## Variables

char * | buf
int | buf_len
rtw_scan_result_t ** | pap_details
rtw_scan_result_t * | ap_details
int | scan_cnt
rtw_bool_t | scan_complete
unsigned char | max_ap_size
rtw_scan_result_handler_t | gscan_result_handler
int | scan_running
void * | user_data
unsigned int | scan_start_time
rtw_network_info_t | network_info
void * | join_sema
rtw_event_handler_t | handler
void * | handler_user_data
unsigned char | len
unsigned char | val [33]
unsigned char | octet [6]
rtw_ssid_t | ssid
rtw_security_t | security_type
unsigned char * | password
int | password_len
int | channel
rtw_ssid_t | ssid
rtw_mac_t | bssid
rtw_security_t | security_type
unsigned char * | password
int | password_len
int | key_id
rtw_ssid_t | SSID
rtw_mac_t | BSSID
signed short | signal_strength
rtw_bss_type_t | bss_type
rtw_security_t | security
rtw_wps_type_t | wps_type
unsigned int | channel
rtw_802_11_band_t | band
rtw_scan_result_t | ap_details
rtw_bool_t | scan_complete
void * | user_data
rtw_mode_t | mode
unsigned char | ssid [33]
unsigned char | channel
rtw_security_t | security_type
unsigned char | password [65]
unsigned char | key_idx
unsigned int | boot_mode
unsigned char | ssid [32]
unsigned char | ssid_len
unsigned char | security_type
unsigned char | password [65]
unsigned char | password_len
unsigned char | channel
unsigned int | count
rtw_mac_t | mac_list [1]
unsigned int | version
unsigned int | length
rtw_mac_t | BSSID
unsigned short | beacon_period
unsigned short | capability
unsigned char | SSID_len
unsigned char | SSID [32]
unsigned char | channel
unsigned short | atim_window
unsigned char | dtim_period
signed short | RSSI
unsigned char | n_cap
unsigned int | nbss_cap
unsigned char | basic_mcs [MCSSET_LEN]
unsigned short | ie_offset
unsigned int | ie_length
unsigned short | offset
unsigned short | mask_size
unsigned char * | mask
unsigned char * | pattern
unsigned short | i_fc
unsigned short | i_dur
unsigned char | i_addr1 [6]
unsigned char | i_addr2 [6]
unsigned char | i_addr3 [6]
unsigned short | i_seq
unsigned char | bssid [6]
unsigned char | encrypt
signed char | rssi
char | filter_id
rtw_packet_filter_pattern_t | patt
rtw_packet_filter_rule_t | rule
unsigned char | enable
struct list_head | node
unsigned char | mac_addr [6]

## Ameba1 Only

void | wifi_set_ap_polling_sta (__u8 enabled)
| enable AP sending QoS Null0 Data to poll Sta be alive More...

## Detailed Description

NIC functions.

## Macro Definition Documentation

#define CMP_MAC | ( |  | a,
|  |  | b
| ) |  |

Value:
(((a[0])==(b[0]))&& \
((a[1])==(b[1]))&& \
((a[2])==(b[2]))&& \
((a[3])==(b[3]))&& \
((a[4])==(b[4]))&& \
((a[5])==(b[5])))

## Typedef Documentation

typedef struct rtw_ap_info rtw_ap_info_t

The structure is used to describe the setting about SSID, security type, password and default channel, used to start AP mode.

Note
  The data length of string pointed by ssid and password should not exceed 32.

typedef struct rtw_network_info rtw_network_info_t

The structure is used to describe the station mode setting about SSID, security type and password, used when connecting to an AP.

Note
  The data length of string pointed by ssid and password should not exceed 32.

typedef void(* rtw_scan_result_callback_t) (rtw_scan_result_t **result_ptr, void *user_data)

Scan result callback function pointer type

Parameters

  result_ptr | : A pointer to the pointer that indicates where to put the next scan result
  user_data | : User provided data

## Enumeration Type Documentation

enum rtw_802_11_band_t

The enumeration lists the band types.

Enumerator
RTW_802_11_BAND_5GHZ | Denotes 5GHz radio band
RTW_802_11_BAND_2_4GHZ | Denotes 2.4GHz radio band

enum rtw_bss_type_t

The enumeration lists the bss types.

Enumerator
RTW_BSS_TYPE_INFRASTRUCTURE | Denotes infrastructure network
RTW_BSS_TYPE_ADHOC | Denotes an 802.11 ad-hoc IBSS network
RTW_BSS_TYPE_ANY | Denotes either infrastructure or ad-hoc network
RTW_BSS_TYPE_UNKNOWN | May be returned by scan function if BSS type is unknown. Do not pass this to the Join function

enum rtw_interface_t

The enumeration lists the interfaces.

Enumerator
RTW_STA_INTERFACE | STA or Client Interface
RTW_AP_INTERFACE | SoftAP Interface

enum rtw_packet_filter_rule_t

The enumeration lists the packet filter rules.

Enumerator
RTW_POSITIVE_MATCHING | Receive the data matching with this pattern and discard the other data
RTW_NEGATIVE_MATCHING | Discard the data matching with this pattern and receive the other data

enum rtw_rcr_level_t

The enumeration lists the promisc levels.

Enumerator
RTW_PROMISC_DISABLE | Disable the promisc
RTW_PROMISC_ENABLE | Fetch all ethernet packets
RTW_PROMISC_ENABLE_1 | Fetch only B/M packets
RTW_PROMISC_ENABLE_2 | Fetch all 802.11 packets
RTW_PROMISC_ENABLE_3 | Fetch only B/M 802.11 packets

enum rtw_result_t

The enumeration lists the results of the function.

Enumerator
RTW_SUCCESS | Success
RTW_PENDING | Pending
RTW_TIMEOUT | Timeout
RTW_PARTIAL_RESULTS | Partial results
RTW_INVALID_KEY | Invalid key
RTW_DOES_NOT_EXIST | Does not exist
RTW_NOT_AUTHENTICATED | Not authenticated
RTW_NOT_KEYED | Not keyed
RTW_IOCTL_FAIL | IOCTL fail
RTW_BUFFER_UNAVAILABLE_TEMPORARY | Buffer unavailable temporarily
RTW_BUFFER_UNAVAILABLE_PERMANENT | Buffer unavailable permanently
RTW_WPS_PBC_OVERLAP | WPS PBC overlap
RTW_CONNECTION_LOST | Connection lost
RTW_ERROR | Generic Error
RTW_BADARG | Bad Argument
RTW_BADOPTION | Bad option
RTW_NOTUP | Not up
RTW_NOTDOWN | Not down
RTW_NOTAP | Not AP
RTW_NOTSTA | Not STA
RTW_BADKEYIDX | BAD Key Index
RTW_RADIOOFF | Radio Off
RTW_NOTBANDLOCKED | Not band locked
RTW_NOCLK | No Clock
RTW_BADRATESET | BAD Rate valueset
RTW_BADBAND | BAD Band
RTW_BUFTOOSHORT | Buffer too short
RTW_BUFTOOLONG | Buffer too long
RTW_BUSY | Busy
RTW_NOTASSOCIATED | Not Associated
RTW_BADSSIDLEN | Bad SSID len
RTW_OUTOFRANGECHAN | Out of Range Channel
RTW_BADCHAN | Bad Channel
RTW_BADADDR | Bad Address
RTW_NORESOURCE | Not Enough Resources
RTW_UNSUPPORTED | Unsupported
RTW_BADLEN | Bad length
RTW_NOTREADY | Not Ready
RTW_EPERM | Not Permitted
RTW_NOMEM | No Memory
RTW_ASSOCIATED | Associated
RTW_RANGE | Not In Range
RTW_NOTFOUND | Not Found
RTW_WME_NOT_ENABLED | WME Not Enabled
RTW_TSPEC_NOTFOUND | TSPEC Not Found
RTW_ACM_NOTSUPPORTED | ACM Not Supported
RTW_NOT_WME_ASSOCIATION | Not WME Association
RTW_SDIO_ERROR | SDIO Bus Error
RTW_WLAN_DOWN | WLAN Not Accessible
RTW_BAD_VERSION | Incorrect version
RTW_TXFAIL | TX failure
RTW_RXFAIL | RX failure
RTW_NODEVICE | Device not present
RTW_UNFINISHED | To be finished
RTW_NONRESIDENT | access to nonresident overlay
RTW_DISABLED | Disabled in this build

enum rtw_scan_type_t

The enumeration lists the scan types.

Enumerator
RTW_SCAN_TYPE_ACTIVE | Actively scan a network by sending 802.11 probe(s)
RTW_SCAN_TYPE_PASSIVE | Passively scan a network by listening for beacons from APs
RTW_SCAN_TYPE_PROHIBITED_CHANNELS | Passively scan on channels not enabled by the country code

enum rtw_security_t

The enumeration lists the possible security types to set when connection.
Station mode supports OPEN, WEP, and WPA2.
AP mode support OPEN and WPA2.

Enumerator
RTW_SECURITY_OPEN | Open security
RTW_SECURITY_WEP_PSK | WEP Security with open authentication
RTW_SECURITY_WEP_SHARED | WEP Security with shared authentication
RTW_SECURITY_WPA_TKIP_PSK | WPA Security with TKIP
RTW_SECURITY_WPA_AES_PSK | WPA Security with AES
RTW_SECURITY_WPA2_AES_PSK | WPA2 Security with AES
RTW_SECURITY_WPA2_TKIP_PSK | WPA2 Security with TKIP
RTW_SECURITY_WPA2_MIXED_PSK | WPA2 Security with AES & TKIP
RTW_SECURITY_WPA_WPA2_MIXED | WPA/WPA2 Security
RTW_SECURITY_WPS_OPEN | WPS with open security
RTW_SECURITY_WPS_SECURE | WPS with AES security
RTW_SECURITY_UNKNOWN | May be returned by scan function if security is unknown. Do not pass this to the join function!
RTW_SECURITY_FORCE_32_BIT | Exists only to force rtw_security_t type to 32 bits

## Function Documentation

void init_event_callback_list | ( | void |  | ) |

Initialize the event callback list.

Warning
  Please make sure this function has been invoked before using the event handler related mechanism.

Parameters

  None |

Returns
  None

int wifi_config_autoreconnect | ( | __u8 | mode,
|  | __u8 | retry_times,
|  | __u16 | timeout
| ) |  |

Set reconnection mode with configuration.

Parameters

  [in] | mode | Set 1/0 to enalbe/disable the reconnection mode.
  [in] | retry_times | The number of retry limit.
  [in] | timeout | The timeout value (in seconds).

Returns
  0 if success, otherwise return -1.

Note
  Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling, or this API won't be effective.
  The difference between wifi_config_autoreconnect() and wifi_set_autoreconnect() is that user can specify the retry times and timeout value in wifi_config_autoreconnect(). But in wifi_set_autoreconnect() these values are set with 3 retry limit and 5 seconds timeout as default.

int wifi_connect | ( | char * | ssid,
|  | rtw_security_t | security_type,
|  | char * | password,
|  | int | ssid_len,
|  | int | password_len,
|  | int | key_id,
|  | void * | semaphore
| ) |  |

Join a Wi-Fi network. Scan for, associate and authenticate with a Wi-Fi network. On successful return, the system is ready to send data packets.

Parameters

  [in] | ssid | A null terminated string containing the SSID name of the network to join.

  [in]

  security_type

  Authentication type:
  - RTW_SECURITY_OPEN - Open Security
  - RTW_SECURITY_WEP_PSK - WEP Security with open authentication
  - RTW_SECURITY_WEP_SHARED - WEP Security with shared authentication
  - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
  - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
  - RTW_SECURITY_WPA2_TKIP_PSK - WPA2 Security using TKIP cipher
  - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers

  [in] | password | A byte array containing either the cleartext security key for WPA/WPA2 secured networks, or a pointer to an array of rtw_wep_key_t structures for WEP secured networks.
  [in] | ssid_len | The length of the SSID in bytes.
  [in] | password_len | The length of the security_key in bytes.
  [in] | key_id | The index of the wep key (0, 1, 2, or 3). If not using it, leave it with value -1.
  [in] | semaphore | A user provided semaphore that is flagged when the join is complete. If not using it, leave it with NULL value.

Returns
  RTW_SUCCESS: when the system is joined and ready to send data packets.
  RTW_ERROR: if an error occurred.

Note
  Please make sure the Wi-Fi is enabled before invoking this function. (wifi_on())

int wifi_connect_bssid | ( | unsigned char | bssid[ETH_ALEN],
|  | char * | ssid,
|  | rtw_security_t | security_type,
|  | char * | password,
|  | int | bssid_len,
|  | int | ssid_len,
|  | int | password_len,
|  | int | key_id,
|  | void * | semaphore
| ) |  |

Join a Wi-Fi network with specified BSSID. Scan for, associate and authenticate with a Wi-Fi network. On successful return, the system is ready to send data packets.

Parameters

  [in] | bssid | The specified BSSID to connect.
  [in] | ssid | A null terminated string containing the SSID name of the network to join.

  [in]

  security_type

  Authentication type:
  - RTW_SECURITY_OPEN - Open Security
  - RTW_SECURITY_WEP_PSK - WEP Security with open authentication
  - RTW_SECURITY_WEP_SHARED - WEP Security with shared authentication
  - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
  - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
  - RTW_SECURITY_WPA2_TKIP_PSK - WPA2 Security using TKIP cipher
  - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers

  [in] | password | A byte array containing either the cleartext security key for WPA/WPA2 secured networks, or a pointer to an array of rtw_wep_key_t structures for WEP secured networks.
  [in] | ssid_len | The length of the SSID in bytes.
  [in] | password_len | The length of the security_key in bytes.
  [in] | key_id | The index of the wep key.
  [in] | semaphore | A user provided semaphore that is flagged when the join is complete.

Returns
  RTW_SUCCESS: when the system is joined and ready to send data packets.
  RTW_ERROR: if an error occurred.

Note
  Please make sure the Wi-Fi is enabled before invoking this function. (wifi_on())
  The difference between wifi_connect_bssid() and wifi_connect() is that BSSID has higher priority as the basis of connection in wifi_connect_bssid.

int wifi_disable_powersave | ( | void |  | ) |

Disable Wi-Fi powersave mode.

Parameters

  None |

Returns
  RTW_SUCCESS or RTW_ERROR.

int wifi_disconnect | ( | void |  | ) |

Disassociates from current Wi-Fi network.

Parameters

  None |

Returns
  RTW_SUCCESS: On successful disassociation from the AP.
  RTW_ERROR: If an error occurred.

int wifi_enable_powersave | ( | void |  | ) |

Enable Wi-Fi powersave mode.

Parameters

  None |

Returns
  RTW_SUCCESS or RTW_ERROR.

void wifi_enter_promisc_mode | ( | void |  | ) |

Let Wi-Fi enter promiscuous mode.

Parameters

  [in] | None |

Returns
  None

int wifi_get_ap_info | ( | rtw_bss_info_t * | ap_info,
|  | rtw_security_t * | security
| ) |  |

Get the SoftAP information.

Parameters

  [out] | ap_info | The location where the AP info will be stored.
  [out] | security | The security type.

Returns
  RTW_SUCCESS: The result is successfully got.
  RTW_ERROR: The result is not successfully got.

int wifi_get_associated_client_list | ( | void * | client_list_buffer,
|  | unsigned short | buffer_length
| ) |  |

Get the associated clients with SoftAP.

Parameters

  [out] | client_list_buffer | The location where the client list will be stored.
  [in] | buffer_length | The buffer length.

Returns
  RTW_SUCCESS: The result is successfully got.
  RTW_ERROR: The result is not successfully got.

int wifi_get_autoreconnect | ( | __u8 * | mode | ) |

Get the result of setting reconnection mode.

Parameters

  [out] | mode | Point to the result of setting reconnection mode.

Returns
  0 if success, otherwise return -1.

Note
  Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling, or this API won't be effective.

int wifi_get_channel | ( | int * | channel | ) |

Get the current channel on STA interface.

Parameters

  [out] | channel | A pointer to the variable where the channel value will be written

Returns
  RTW_SUCCESS: If the channel is successfully read.
  RTW_ERROR: If the channel is not successfully read.

int wifi_get_last_error | ( | void |  | ) |

Present the device disconnect reason while connecting.

Parameters

  None |

Returns
  rtw_connect_error_flag_t
  - 0: RTW_NO_ERROR
  - 1: RTW_NONE_NETWORK
  - 2: RTW_CONNECT_FAIL
  - 3: RTW_WRONG_PASSWORD
  - 4: RTW_DHCP_FAIL
  - 5: RTW_UNKNOWN (initial status)

int wifi_get_lps_dtim | ( | unsigned char * | dtim | ) |

Get LPS DTIM.

Parameters

  [out] | dtim | In LPS, the package can be buffered at AP side. STA leave LPS until dtim count of packages buffered at AP side.

Returns
  RTW_SUCCESS if getting LPS dtim successful.
  RTW_ERROR otherwise.

int wifi_get_mac_address | ( | char * | mac | ) |

Retrieves the current Media Access Control (MAC) address (or Ethernet hardware address) of the 802.11 device.

Parameters

  [in] | mac | Point to the result of the mac address will be get.

Returns
  RTW_SUCCESS or RTW_ERROR

int wifi_get_rssi | ( | int * | pRSSI | ) |

Retrieve the latest RSSI value.

Parameters

  [out] | pRSSI | Points to the integer to store the RSSI value gotten from driver.

Returns
  RTW_SUCCESS: If the RSSI is succesfully retrieved.
  RTW_ERROR: If the RSSI is not retrieved.

int wifi_get_setting | ( | const char * | ifname,
|  | rtw_wifi_setting_t * | pSetting
| ) |  |

Get current Wi-Fi setting from driver.

Parameters

  [in] | ifname | the wlan interface name, can be WLAN0_NAME or WLAN1_NAME.
  [out] | pSetting | Points to the rtw_wifi_setting_t structure to store the WIFI setting gotten from driver.

Returns
  RTW_SUCCESS or RTW_ERROR.

int wifi_get_txpower | ( | int * | poweridx | ) |

Gets the tx power in index units

Parameters

  dbm | : The variable to receive the tx power in index.

Returns
  RTW_SUCCESS : if successful RTW_ERROR : if not successful

void wifi_indication | ( | rtw_event_indicate_t | event,
|  | char * | buf,
|  | int | buf_len,
|  | int | flags
| ) |  |

Wlan driver indicate event to upper layer through wifi_indication.

Parameters

  [in] | event | An event reported from driver to upper layer application. Please refer to rtw_event_indicate_t enum.
  [in] | buf | If it is not NUL, buf is a pointer to the buffer for message string.
  [in] | buf_len | The length of the buffer.
  [in] | flags | Indicate some extra information, sometimes it is 0.

Return values

  None |

Note
  If upper layer application triggers additional operations on receiving of wext_wlan_indicate, please strictly check current stack size usage (by using uxTaskGetStackHighWaterMark() ), and tries not to share the same stack with wlan driver if remaining stack space is not available for the following operations. ex: using semaphore to notice another thread instead of handing event directly in wifi_indication().

int wifi_is_connected_to_ap | ( | void |  | ) |

Check if Wi-Fi has connected to AP before dhcp.

Parameters

  None |

Returns
  RTW_SUCCESS: If conneced.
  RTW_ERROR: If not connect.

int wifi_is_ready_to_transceive | ( | rtw_interface_t | interface | ) |

Determines if a particular interface is ready to transceive ethernet packets

Parameters

  Radio | interface to check, options are RTW_STA_INTERFACE, RTW_AP_INTERFACE

Returns
  RTW_SUCCESS : if the interface is ready to transceive ethernet packets
  RTW_NOTFOUND : no AP with a matching SSID was found
  RTW_NOT_AUTHENTICATED: a matching AP was found but it won't let you authenticate. This can occur if this device is in the block list on the AP.
  RTW_NOT_KEYED: the device has authenticated and associated but has not completed the key exchange. This can occur if the passphrase is incorrect.
  RTW_ERROR : if the interface is not ready to transceive ethernet packets

int wifi_is_up | ( | rtw_interface_t | interface | ) |

Check if the specified interface is up.

Parameters

  [in] | interface | The interface can be set as RTW_STA_INTERFACE or RTW_AP_INTERFACE. (rtw_interface_t)

Returns
  If the function succeeds, the return value is 1. Otherwise, return 0.

int wifi_manager_init | ( | void |  | ) |

Initialize Realtek WiFi API System.

- Initialize the required parts of the software platform. i.e. worker, event registering, semaphore, etc.
- Initialize the RTW API thread which handles the asynchronous event.
  Returns
    RTW_SUCCESS if initialization is successful, RTW_ERROR otherwise

int wifi_off | ( | void |  | ) |

Disable Wi-Fi.

Parameters

  None |

Returns
  RTW_SUCCESS: if deinitialization is successful.
  RTW_ERROR: otherwise.

int wifi_off_fastly | ( | void |  | ) |

Turn off the Wi-Fi device

- Bring the Wireless interface "Down"
- De-Initialises the driver thread which arbitrates access to the SDIO/SPI bus

Returns
  RTW_SUCCESS if deinitialization is successful, RTW_ERROR otherwise

int wifi_on | ( | rtw_mode_t | mode | ) |

Enable Wi-Fi.

- Bring the Wireless interface "Up"
- Initialize the driver thread which arbitrates access to the SDIO/SPI bus

Parameters

  [in] | mode | Decide to enable WiFi in which mode. The optional modes are enumerated in rtw_mode_t.

Returns
  RTW_SUCCESS: if the WiFi chip was initialized successfully.
  RTW_ERROR: if the WiFi chip was not initialized successfully.

void wifi_reg_event_handler | ( | unsigned int | event_cmds,
|  | rtw_event_handler_t | handler_func,
|  | void * | handler_user_data
| ) |  |

Register the event listener.

Parameters

  [in] | event_cmds | : The event command number indicated.
  [in] | handler_func | : the callback function which will receive and process the event.
  [in] | handler_user_data | : user specific data that will be passed directly to the callback function.

Returns
  RTW_SUCCESS : if successfully registers the event.
  RTW_ERROR : if an error occurred.

Note
  Set the same event_cmds with empty handler_func will unregister the event_cmds.

int wifi_register_multicast_address | ( | rtw_mac_t * | mac | ) |

Register interest in a multicast address.
Once a multicast address has been registered, all packets detected on the medium destined for that address are forwarded to the host. Otherwise they are ignored.

Parameters

  [in] | mac | Ethernet MAC address

Returns
  RTW_SUCCESS: If the address is registered successfully.
  RTW_ERROR: If the address is not registered.

int wifi_restart_ap | ( | unsigned char * | ssid,
|  | rtw_security_t | security_type,
|  | unsigned char * | password,
|  | int | ssid_len,
|  | int | password_len,
|  | int | channel
| ) |  |

Trigger Wi-Fi driver to restart an infrastructure Wi-Fi network.

Warning
  If a STA interface is active when this function is called, the softAP will start on the same channel as the STA. It will NOT use the channel provided!

Parameters

  [in] | ssid | A null terminated string containing the SSID name of the network.

  [in]

  security_type

  - RTW_SECURITY_OPEN - Open Security
  - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
  - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
  - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
  - WEP security is NOT IMPLEMENTED. It is NOT SECURE!

  [in] | password | A byte array containing the cleartext security key for the network.
  [in] | ssid_len | The length of the SSID in bytes.
  [in] | password_len | The length of the security_key in bytes.
  [in] | channel | 802.11 channel number.

Returns
  RTW_SUCCESS: If successfully creates an AP.
  RTW_ERROR: If an error occurred.

Note
  Please make sure the Wi-Fi is enabled before invoking this function. (wifi_on())

int wifi_rf_off | ( | void |  | ) |

Disable Wi-Fi RF.

Parameters

  None |

Returns
  If the function succeeds, the return value is 0.

Note
  The difference between wifi_rf_off() and wifi_off() is that wifi_rf_off() simply disable RF HAL, the driver and used heap memory will NOT be released.

int wifi_rf_on | ( | void |  | ) |

Enable Wi-Fi RF.

Parameters

  None |

Returns
  If the function succeeds, the return value is 0.

Note
  The difference between wifi_rf_on() and wifi_on() is that wifi_rf_on() simply enable RF HAL, it does not enable the driver or allocate memory.

int wifi_scan | ( | rtw_scan_type_t | scan_type,
|  | rtw_bss_type_t | bss_type,
|  | void * | result_ptr
| ) |  |

Initiate a scan to search for 802.11 networks.

Parameters

  [in] | scan_type | Specifies whether the scan should be Active, Passive or scan Prohibited channels
  [in] | bss_type | Specifies whether the scan should search for Infrastructure networks (those using an Access Point), Ad-hoc networks, or both types.
  [in] | result_ptr | Scan specific ssid. The first 4 bytes is ssid lenth, and ssid name append after it. If no specific ssid need to scan, PLEASE CLEAN result_ptr before pass it into parameter.
  [out] | result_ptr | a pointer to a pointer to a result storage structure.

Returns
  RTW_SUCCESS or RTW_ERROR

Note
  The scan progressively accumulates results over time, and may take between 1 and 3 seconds to complete. The results of the scan will be individually provided to the callback function. Note: The callback function will be executed in the context of the RTW thread.
  When scanning specific channels, devices with a strong signal strength on nearby channels may be detected

int wifi_scan_networks | ( | rtw_scan_result_handler_t | results_handler,
|  | void * | user_data
| ) |  |

Initiate a scan to search for 802.11 networks, a higher level API based on wifi_scan to simplify the scan operation.

Parameters

  [in] | results_handler | The callback function which will receive and process the result data.
  [in] | user_data | User specified data that will be passed directly to the callback function.

Returns
  RTW_SUCCESS or RTW_ERROR

Note
  Callback must not use blocking functions, since it is called from the context of the RTW thread. The callback, user_data variables will be referenced after the function returns. Those variables must remain valid until the scan is completed. The usage of this api can reference ATWS in atcmd_wifi.c.

int wifi_scan_networks_with_ssid | ( | int(results_handler)(char *, int, char *, void *) | ,
|  | void * | user_data,
|  | int | scan_buflen,
|  | char * | ssid,
|  | int | ssid_len
| ) |  |

Initiate a scan to search for 802.11 networks with specified SSID.

Parameters

  [in] | results_handler | The callback function which will receive and process the result data.
  [in] | user_data | User specified data that will be passed directly to the callback function.
  [in] | scan_buflen | The length of the result storage structure.
  [in] | ssid | The SSID of target network.
  [in] | ssid_len | The length of the target network SSID.

Returns
  RTW_SUCCESS or RTW_ERROR

Note
  Callback must not use blocking functions, since it is called from the context of the RTW thread. The callback, user_data variables will be referenced after the function returns. Those variables must remain valid until the scan is completed.

void wifi_set_ap_polling_sta | ( | __u8 | enabled | ) |

enable AP sending QoS Null0 Data to poll Sta be alive

Parameters

  [in]

  enabled

  enabled can be set to 0,1.
  - 0 means enable.
  - 1 means disable.

Returns
  None

int wifi_set_autoreconnect | ( | __u8 | mode | ) |

Set reconnection mode with 3 retry limit and 5 seconds timeout as default.

Parameters

  [in] | mode | Set 1/0 to enalbe/disable the reconnection mode.

Returns
  0 if success, otherwise return -1.

Note
  Defining CONFIG_AUTO_RECONNECT in "autoconf.h" needs to be done before compiling, or this API won't be effective.
  The difference between wifi_config_autoreconnect() and wifi_set_autoreconnect() is that user can specify the retry times and timeout value in wifi_config_autoreconnect(). But in wifi_set_autoreconnect() these values are set with 3 retry limit and 5 seconds timeout as default.

int wifi_set_channel | ( | int | channel | ) |

Set the listening channel for promiscuous mode.

Parameters

  [in] | channel | The desired channel.

Returns
  RTW_SUCCESS: If the channel is successfully set.
  RTW_ERROR: If the channel is not successfully set.

Note
  Do NOT need to call this function for STA mode wifi driver, since it will determine the channel from received beacon.

int wifi_set_country | ( | rtw_country_code_t | country_code | ) |

Set the country code to driver to determine the channel set.

Parameters

  [in] | country_code | Specify the country code.

Returns
  RTW_SUCCESS: If result is successfully set.
  RTW_ERROR: If result is not successfully set.

_WEAK void wifi_set_country_code | ( | void |  | ) |

Setup country code. You can replace this weak function by the same name funcation to setup country code you want.

Parameters

  None |

Returns
  If the function succeeds, the return value is 0.

void wifi_set_indicate_mgnt | ( | int | enable | ) |

Get antenna infomation.

Parameters

  [in] | antenna | Points to store the antenna value gotten from driver, 0: main, 1: aux.

Returns
  0 if success, otherwise return -1.

int wifi_set_lps_dtim | ( | unsigned char | dtim | ) |

Set LPS DTIM.

Parameters

  [in] | dtim | In LPS, the package can be buffered at AP side. STA leave LPS until dtim count of packages buffered at AP side.

Returns
  RTW_SUCCESS if setting LPS dtim successful.
  RTW_ERROR otherwise

int wifi_set_mac_address | ( | char * | mac | ) |

This function sets the current Media Access Control (MAC) address of the 802.11 device.

Parameters

  [in] | mac | Wi-Fi MAC address.

Returns
  RTW_SUCCESS or RTW_ERROR

_WEAK void wifi_set_mib | ( | void |  | ) |

Setup the adaptivity mode. You can replace this weak function by the same name funcation to setup adaptivity mode you want.

Parameters

  None |

Returns
  If the function succeeds, the return value is 0.

int wifi_set_network_mode | ( | rtw_network_mode_t | mode | ) |

Set the network mode according to the data rate its supported. Driver works in BGN mode in default after driver initialization. This function is used to change wireless network mode for station mode before connecting to AP.

Parameters

  [in] | mode | Network mode to set. The value can be RTW_NETWORK_B/RTW_NETWORK_BG/RTW_NETWORK_BGN.

Returns
  RTW_SUCCESS or RTW_ERROR.

int wifi_set_power_mode | ( | unsigned char | ips_mode,
|  | unsigned char | lps_mode
| ) |  |

Set IPS/LPS mode.

Parameters

  [in] | ips_mode | The desired IPS mode. It becomes effective when wlan enter ips. 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.
  [in] | lps_mode | The desired LPS mode. It becomes effective when wlan enter lps. 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.

Returns
  RTW_SUCCESS if setting LPS mode successful.
  RTW_ERROR otherwise.

int wifi_set_promisc | ( | rtw_rcr_level_t | enabled,
|  | void(*)(unsigned char *, unsigned int, void *) | callback,
|  | unsigned char | len_used
| ) |  |

Set the chip to start or stop the promiscuous mode.

Parameters

  [in]

  enabled

  enabled can be set 0, 1 and 2. if enabled is zero, disable the promisc, else enable the promisc.
  - 0 means disable the promisc.
  - 1 means enable the promisc.
  - 2 means enable the promisc special for length is used.

  [in] | callback | the callback function which will receive and process the netowork data.
  [in] | len_used | specify if the the promisc length is used. If len_used set to 1, packet length will be saved and transferred to callback function.

Returns
  RTW_SUCCESS or RTW_ERROR

Note
  This function can be used to implement vendor specified simple configure.

int wifi_set_pscan_chan | ( | __u8 * | channel_list,
|  | __u8 * | pscan_config,
|  | __u8 | length
| ) |  |

Set the channel used to be partial scanned.

Parameters

  [in] | channel_list | An array stores the channel list.
  [in] | pscan_config | the pscan_config of the channel set.
  [in] | length | The length of the channel_list.

Returns
  RTW_SUCCESS or RTW_ERROR.

Note
  This function should be used with wifi_scan function. First, use wifi_set_pscan_chan to indicate which channel will be scanned, and then use wifi_scan to get scanned results.

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
| ) |  |

Set TDMA parameters

Parameters

  [in] | slot_period | : We separate TBTT into 2 or 3 slots. If we separate TBTT into 2 slots, then slot_period should be larger or equal to 50ms. It means 2 slot period is slot_period, 100-slot_period If we separate TBTT into 3 slots, then slot_period should be less or equal to 33ms. It means 3 slot period is 100 - 2 * slot_period, slot_period, slot_period
  [in] | rfon_period_len_1 | rf on period of slot 1
  [in] | rfon_period_len_2 | rf on period of slot 2
  [in] | rfon_period_len_3 | rf on period of slot 3

Returns
  RTW_SUCCESS if setting TDMA parameters successful RTW_ERROR otherwise

int wifi_set_txpower | ( | int | poweridx | ) |

Set the tx power in index units.

Parameters

  [in] | poweridx | The desired tx power in index.

Returns
  RTW_SUCCESS: if tx power is successfully set
  RTW_ERROR: if tx power is not successfully set

int wifi_set_wps_phase | ( | unsigned char | is_trigger_wps | ) |

Set the wps phase

Parameters

  is_trigger_wps[in] | : to trigger wps function or not

Returns
  RTW_SUCCESS or RTW_ERROR

int wifi_show_setting | ( | const char * | ifname,
|  | rtw_wifi_setting_t * | pSetting
| ) |  |

Show the network information stored in a rtw_wifi_setting_t structure.

Parameters

  [in] | ifname | the wlan interface name, can be WLAN0_NAME or WLAN1_NAME.
  [in] | pSetting | Points to the rtw_wifi_setting_t structure which information is gotten by wifi_get_setting().

Returns
  RTW_SUCCESS or RTW_ERROR.

int wifi_start_ap | ( | char * | ssid,
|  | rtw_security_t | security_type,
|  | char * | password,
|  | int | ssid_len,
|  | int | password_len,
|  | int | channel
| ) |  |

Trigger Wi-Fi driver to start an infrastructure Wi-Fi network.

Warning
  If a STA interface is active when this function is called, the softAP will start on the same channel as the STA. It will NOT use the channel provided!

Parameters

  [in] | ssid | A null terminated string containing the SSID name of the network.

  [in]

  security_type

  - RTW_SECURITY_OPEN - Open Security
  - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
  - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
  - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
  - WEP security is NOT IMPLEMENTED. It is NOT SECURE!

  [in] | password | A byte array containing the cleartext security key for the network.
  [in] | ssid_len | The length of the SSID in bytes.
  [in] | password_len | The length of the security_key in bytes.
  [in] | channel | 802.11 channel number.

Returns
  RTW_SUCCESS: If successfully creates an AP.
  RTW_ERROR: If an error occurred.

Note
  Please make sure the Wi-Fi is enabled before invoking this function. (wifi_on())

int wifi_start_ap_with_hidden_ssid | ( | char * | ssid,
|  | rtw_security_t | security_type,
|  | char * | password,
|  | int | ssid_len,
|  | int | password_len,
|  | int | channel
| ) |  |

Start an infrastructure Wi-Fi network with hidden SSID.

Warning
  If a STA interface is active when this function is called, the softAP will start on the same channel as the STA. It will NOT use the channel provided!

Parameters

  [in] | ssid | A null terminated string containing the SSID name of the network to join.

  [in]

  security_type

  Authentication type:
  - RTW_SECURITY_OPEN - Open Security
  - RTW_SECURITY_WPA_TKIP_PSK - WPA Security
  - RTW_SECURITY_WPA2_AES_PSK - WPA2 Security using AES cipher
  - RTW_SECURITY_WPA2_MIXED_PSK - WPA2 Security using AES and/or TKIP ciphers
  - WEP security is NOT IMPLEMENTED. It is NOT SECURE!

  [in] | password | A byte array containing the cleartext security key for the network.
  [in] | ssid_len | The length of the SSID in bytes.
  [in] | password_len | The length of the security_key in bytes.
  [in] | channel | 802.11 channel number

Returns
  RTW_SUCCESS: If successfully creates an AP.
  RTW_ERROR: If an error occurred.

void wifi_unreg_event_handler | ( | unsigned int | event_cmds,
|  | rtw_event_handler_t | handler_func
| ) |  |

Un-register the event listener.

Parameters

  [in] | event_cmds | : The event command number indicated.
  [in] | handler_func | : the callback function which will receive and process the event.

Returns
  RTW_SUCCESS : if successfully un-registers the event .
  RTW_ERROR : if an error occurred.

int wifi_unregister_multicast_address | ( | rtw_mac_t * | mac | ) |

Unregister interest in a multicast address.
Once a multicast address has been unregistered, all packets detected on the medium destined for that address are ignored.

Parameters

  [in] | mac | Ethernet MAC address

Returns
  RTW_SUCCESS: If the address is unregistered successfully.
  RTW_ERROR: If the address is not unregistered.

## Variable Documentation

unsigned short atim_window

units are Kusec

rtw_802_11_band_t band

Radio band

unsigned char basic_mcs[MCSSET_LEN]

802.11N BSS required MCS set

unsigned short beacon_period

units are Kusec

rtw_bss_type_t bss_type

Network type

rtw_mac_t BSSID

Basic Service Set Identification (i.e. MAC address of Access Point)

unsigned short capability

Capability information

unsigned int channel

Radio channel that the AP beacon was received on

unsigned int count

Number of MAC addresses in the list

unsigned char dtim_period

DTIM period

unsigned int ie_length

byte length of Information Elements

unsigned short ie_offset

offset at which IEs start, from beginning

unsigned char len

SSID length

unsigned int length

byte length of data in this record,

rtw_mac_t mac_list[1]

Variable length array of MAC addresses

unsigned char* mask

Pattern mask bytes to be ANDed with the pattern eg. "\xff00" (must be in network byte order)

unsigned short mask_size

Size of the mask in bytes

unsigned char n_cap

BSS is 802.11N Capable

unsigned int nbss_cap

802.11N BSS Capabilities (based on HT_CAP_*)

unsigned char octet[6]

Unique 6-byte MAC address

unsigned short offset

Offset in bytes to start filtering (referenced to the start of the ethernet packet)

unsigned char* pattern

Pattern bytes used to filter eg. "\x0800" (must be in network byte order)

signed short RSSI

receive signal strength (in dBm)

rtw_security_t security

Security type

signed short signal_strength

Receive Signal Strength Indication in dBm. <-90=Very poor, >-30=Excellent

rtw_ssid_t SSID

Service Set Identification (i.e. Name of Access Point)

unsigned char val[33]

SSID name (AP name)

unsigned int version

version field

rtw_wps_type_t wps_type

WPS type