1: Run wpa_supplicant first
Use the following command:
Wpa_supplicant-dwext-iwlan0-C/data/system/wpa_supplicant-C/data/MISC/WiFi/wpa_supplicant.conf
2: run the command line tool wpa_cli to connect WiFi
Wpa_cli-P/data/system/wpa_supplicant-iwlan0
Then, it will let you set network interactively
Some common command:
> Scan = to scan the neighboring AP
> Scan_results = show the scan results
> Status = check out the current connection information
> Terminate = terminate wpa_supplicant
> Quit = exit wpa_cli
> Add_network = it will return a network ID to you
> Set_network <network ID> <variable> <value> = set network variables (shows list of variables when run without arguments), success will return OK, or will return fail
> Select_network <network ID> = select a network (disable others)
> Disable_network <network ID> = Disable a network
> Enable_network <network ID> = enable a network
> Set_network 0 priority 0
> List_network
> Save_config
3: Example
For AP That doesn' t have encryption
> Add_network (it will display a network ID for you, assume it returns 0)
> Set_network 0 SSID "666"
> Set_network 0 key_mgmt none
> Enable_network 0
> Quit
If normal, we have connectted to the AP "666", now you need a IP to access Internet, for example:
Dhcpcd wlan0
If everything is OK, it will get an IP & can access Internet
For AP that has WEP
> Add_network (assume returns 1)
> Set_network 1 SSID "666"
> Set_network 1 key_mgmt none
> Set_network 1 wep_key0 "Your AP passwork" (if Usting ASCII, it need double quotation marks, if using hex, then don't need the double quotation marks)
> Set_network 1 wep_tx_keyidx 0
> Select_network 1 (optional, remember, if you are connecting with another AP, you should select it to disable the another)
> Enable_network 1
And then, get an IP to access Internet
For AP that has WPA-PSK/WPA2-PSK
> Add_network (assume returns 2)
> Set_network 2 SSID "666"
> Set_network 2 PSK "your pre-shared key"
> Select_network 2 (optional, remember, if you are connecting with another AP, you should select it to disable the another)
> Enable_network 2
There is still some others options to be set, but wpa_supplicant will choose the default for you, the default will include all we need to set and then, get an IP to access the Internet
After the command is executed, wpa_cli outputs the connection process information. If everything is correct, the final output is as follows:
<2> CTRL-EVENT-CONNECTED-connection to XX: XX completed (Reauth) [ID = 0 id_str =]
Get IP Address
Use quit
Command to exit wpa_cli. Then use
Dhclient wlan0
Command to obtain the IP address.