Background: Today want to play a game wpa_cli, wpa_supplicant to understand some of the processes, the result has been not connected. . . Record how to use wpa_cli wifi debugging.
1, start the WLAN
(1) load drivers
Generally, android system which, when open wifi driver is loaded, it will unload closed wifi drive. Manual debugging time, first call the insmod command to load the specified wifi drive.
Then call iwconfig can see the driver is loaded successfully, as you can see wlan0 already have, then drive loaded successfully.
eth0 no wireless extensions.
wlan0 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=12 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
sit0 no wireless extensions.
lo no wireless extensions.
wlan1 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=12 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
tunl0 no wireless extensions.
(2) Open wlan0
say nothing of this, ifconfig wlan0 up
2, start wpa_supplicant
Command is as follows: how can refer themselves init.xxx.rc is configured parameters may be different.
wpa_supplicant –iwlan0 –Dnl80211 –c 配置文件 &
-i: Specifies the network port;
-D: Specifies the type of drive;
-C: wpa_supplicant specified configuration file.
E.g:
wpa_supplicant -d –iwlan0 –Dnl80211 –c/etc/wifi/wpa_supplicant.conf &
/Etc/wifi/wpa_supplicant.conf,-d parameter configuration file to open the print wpa_supplicant.
Configuration files are as follows:
update_config=1
ctrl_interface=/data/misc/wifi/sockets
eapol_version=1
ap_scan=1
fast_reauth=1
ps: the beginning is always not up and running, in the case of already loaded driver, has also been up wlan0, is likely to be / data / misc / wifi / sockets of insufficient permissions, can not be created wlan0 socket.
Ensure wpa_supplicant already up and running, you can look ps.
3, start wpa_cli
wpa_cli -i网口 -p socket所在路径
For example, as I just call it, then start with the following command:
wpa_cli -iwlan0 -p /data/misc/wifi/sockets/
Enter the following interface, it has been normal debugging.
wpa_cli v2.0-devel-4.4.2_rtw_r12456.20141113_beta
Copyright (c) 2004-2013, Jouni Malinen <[email protected]> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
Interactive mode
>
If you have been displayed if there is "Could not connect to wpa_supplicant - re-trying", it means wpa_cli wpa_supplicant can not establish a socket connection, this time to check whether the process is still wpa_supplicant, as well as the path wlan0 socket if there is (in my case is / data / misc / wifi / sockets / wlan0).
4, scanning ap
Enter the scan command
> scan
OK
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=3 BSSID=00:00:00:00:00:00 SSID=
<3>CTRL-EVENT-SCAN-RESULTS
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=0 BSSID=00:00:00:00:00:00 SSID=
>
There wpa_supplicant "CTRL-EVENT-SCAN-RESULTS" response, you can enter scan_results can see the scan results, as shown below.
scan_results
bssid / frequency / signal level / flags / ssid
0c:72:2c:44:10:9e 2437 -70 [WPS][ESS] SS
d4:61:2e:a2:b9:e5 2437 -57 [WPA2-PSK-CCMP][ESS] HUAWEI G9 Youth
9c:21:6a:d3:9e:a2 2437 -72 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] helezu
5c:63:bf:5f:9c:be 2462 -82 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] TOPVISION
5, the connection
See HUAWEI G9 Youth scan results from the hot spot is the strongest signal. We chose this connection ap.
> add_network
1
> set_network 1 ssid "HUAWEI G9 Youth"
OK
> set_network 1 key_mgmt WPA-PSK
OK
> set_network 1 psk "xx123456"
OK
> set_network 1 pairwise CCMP
OK
> set_network 1 group CCMP
OK
> set_network 1 proto WPA2
OK
> enable_network 1
OK
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=3 BSSID=00:00:00:00:00:00 SSID=
<3>CTRL-EVENT-SCAN-RESULTS
<3>WPS-AP-AVAILABLE
<3>Trying to associate with d4:61:2e:a2:b9:e5 (SSID='HUAWEI G9 Youth' freq=2437 MHz)
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=5 BSSID=00:00:00:00:00:00 SSID=
<3>CTRL-EVENT-STATE-CHANGE id=1 state=6 BSSID=00:00:00:00:00:00 SSID=HUAWEI G9 Youth
<3>Associated with d4:61:2e:a2:b9:e5
<3>CTRL-EVENT-STATE-CHANGE id=1 state=7 BSSID=d4:61:2e:a2:b9:e5 SSID=HUAWEI G9 Youth
<3>CTRL-EVENT-STATE-CHANGE id=1 state=8 BSSID=d4:61:2e:a2:b9:e5 SSID=HUAWEI G9 Youth
<3>WPA: Key negotiation completed with d4:61:2e:a2:b9:e5 [PTK=CCMP GTK=CCMP]
<3>CTRL-EVENT-CONNECTED - Connection to d4:61:2e:a2:b9:e5 completed (auth) [id=1 id_str=]
<3>CTRL-EVENT-STATE-CHANGE id=1 state=9 BSSID=d4:61:2e:a2:b9:e5 SSID=HUAWEI G9 Youth
The following steps:
(1) "add_network", where 1 is returned to the network ID.
SSID (2) configuration of the network, performing the SSID set_network 1 ssid AP.
Encryption and passwords (3) network configuration.
(4) to start the network, the implementation of "enable_network 0".
(5) receive "CTRL-EVENT-CONNECTED" connection is successful.
6, assign IP
At this point it has been connected ap, dhcp assigned to one IP.
Enter q to quit wpa_cli, execute the command: dhcpcd wlan0
now ready to ping, and the Android system, also need to set the DNS in Android, these processes have netd to complete, can not say here.