wpa_supplicant is a connection, WIFI configuration's tool. It mainly includes two programs: wpa_supplicant and wpa_cli. teh relationship between the two is server and client. Usually, we can process the WIFI's configuration and connection through wpa_cli, if there is special need you can write applications directly. We can directly use wpa_supplicant interface in order to write applications.
This article mainly discribes how to use wpa_cli in order to access WIFI's configuration and connection.
$ wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B
Notes:add the following codes to this file /etc/wpa_supplicant.conf.
ctrl_interface=/var/run/wpa_supplicant
update_config=1
$ wpa_cli -i wlan0 scan Search for wifi network
$ wpa_cli -i wlan0 scan_result Display the search result.
$ wpa_cli -i wlan0 add_network Add a network connection.
If you want to connect(WPA encryption mode):[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] (wpa encrypted)
wifi name:wifi_name
wifi password:wifi_psk
$ wpa_cli -i wlan0 set_network 0 ssid '"wifi_name"'
$ wpa_cli -i wlan0 set_network 0 psk '"wifi_psk"'
$ wpa_cli -i wlan0 enable_network 0
If you want to connect(WEP encryption mode):[WEP][ESS] (wep encrypted)
wifi name:wifi_name
wifi password:wifi_psk
$ wpa_cli -i wlan0 set_network 0 ssid '"wpa_name"'
$ wpa_cli -i wlan0 set_network 0 key_mgmt NONE
$ wpa_cli -i wlan0 set_network 0 wep_key0 '"wap_psk"'
$ wpa_cli -i wlan0 enable_network 0
If you want to connect(No encryption mode):[ESS] (No encryption)
wifi name:wifi_name
$ wpa_cli -i wlan0 set_network 0 ssid '"wifi_name"'
$ wpa_cli -i wlan0 set_network 0 key_mgmt NONE
$ wpa_cli -i wlan0 enable_network 0
$ udhcpc -i wlan0 -s /etc/udhcpc.script -q
Once the execution is complete, you can connect to the network.
$ wpa_cli -i wlan0 save_config
$ wpa_cli -i wlan0 disable_network 0
$ wpa_cli -i wlan0 list_network List all saved connections
$ wpa_cli -i wlan0 select_network 0 Connect to the first saved connection.
$ wpa_cli -i wlan0 enable_network 0 Enable the first saved connection.
$ ifconfig wlan0 down
$ killall udhcpc
$ killall wpa_supplicant
wpa_wifi_tool is based on wpa_supplicant and wpa_cli's tool for wifi quick setup. It is used during debugging for easy connection to wifi. Users do not need to run step2's complex commands, they are used to achieve wifi settings and connections and other functions.
Notes:This tool is only used as a debugging tool, It is recommended to use wpa_cli or directly use wpa_supplicant to achieve actual wifi function's development.
Method:
For other methods, please refer to help.