/*********************************************************************** * I.MX6 wpa_cli 使用 * 说明: * 在调试Android wifi功能之前,先要保证wpa_supplicant调试是正常才行, * 否者都很难确定到底那一层的软件出了问题。 * * 2016-6-28 深圳 南山平山村 曾剑锋 **********************************************************************/ 一、参考文档: 1. 用wpa_cli 连接无线网络 http://blog.163.com/qk_zhu/blog/static/195076154201132081536347/ 2. wpa_cli 连接 wifi http://www.cnblogs.com/lidabo/p/4660206.html 二、shell command: 1. wpa_supplicant -iwlan0 -Dnl80211 -c/etc/wifi/wpa_supplicant.conf & 2. wpa_cli -i wlan0 -p /data/misc/wifi/sockets 三、wpa_cli command: 1. scan 2. scan_results 3. add_network 4. set_network 0 ssid "androidap" 5. set_network 0 key_mgmt NONE 6. select_network 0 7. enable_network 0 四、示例: root@android:/ # wpa_cli -i wlan0 -p /data/misc/wifi/sockets wpa_cli v2.0-devel-4.2.2_rtw_r8680.20130821 Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi> and contributors This software may be distributed under the terms of the BSD license. See README for more details. Interactive mode > 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>WPS-AP-AVAILABLE <3>CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00 SSID= > scan_results bssid / frequency / signal level / flags / ssid ec:26:ca:e1:6b:17 2462 -49 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] Aplex-AP 00:b0:c6:0f:24:b0 2412 -63 [WPA2-PSK-CCMP][ESS] Aplex-AP3 8c:be:be:01:54:d2 2412 -63 [WPA2-PSK-CCMP][ESS] Aplex_C d0:fa:1d:76:01:7b 2462 -66 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] SZSD 00:b0:c6:4f:98:27 2417 -66 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] DXYP-2015 94:fb:b2:40:bb:98 2462 -66 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] TP-LINK-2016 c0:61:18:fc:73:a1 2437 -67 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] ZLY-TECH 88:25:93:77:e8:e1 2462 -67 [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][ESS]SZSD 14:75:90:ce:35:87 2412 -69 [WPA2-PSK-CCMP][WPS][ESS] sjb f0:b4:29:31:1d:f1 2412 -69 [WPA2-PSK-CCMP][ESS] Xiaomi_888 a0:f3:c1:95:22:36 2462 -70 [WPA2-PSK-TKIP+CCMP][ESS] TP-LINK_952236 b0:d5:9d:58:45:14 2437 -71 [WPA2-PSK-CCMP][ESS] huo f8:e9:03:b7:15:8a 2412 -71 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] laser309 00:36:76:57:8b:86 2437 -73 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] 360\xe5\x85\x8d\xe8\xb4\xb9WiFi-86 ec:26:ca:47:d1:f6 2437 -45 [ESS] TP-LINK_D1F6 18:59:36:89:7d:47 2437 -57 [ESS] androidap > add_network 0 > set_network 0 ssid "androidap" OK > set_network 0 key_mgmt NONE OK > select_network 0 OK <3>CTRL-EVENT-STATE-CHANGE id=0 state=3 BSSID=00:00:00:00:00:00 SSID=androidap > RTL871X: rtw_set_802_11_connect(wlan0) fw_state=0x00000008 <3>CTRL-EVENT-SCAN-RESULTS <3>WPS-AP-AVAILABLE <3>Trying to associate with 18:59:36:89:7d:47 (SSID='androidap' freq=2437 MHz) <3>CTRL-EVENT-STATE-CHANGE id=0 state=5 BSSID=00:00:00:00:00:00 SSID=androidap > RTL871X: start auth RTL871X: auth success, start assoc RTL871X: assoc success <3>CTRL-EVENT-STATE-CHANGE idADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready =0 state=6 BSSID=00:00:00:00:00:00 SSID=androidap <3>Associated with 18:59:36:89:7d:47 <3>CTRL-EVENT-CONNECTED - Connection to 18:59:36:89:7d:47 completed (auth) [id=0 id_str=] <3>CTRL-EVENT-STATE-CHANGE id=0 state=9 BSSID=18:59:36:89:7d:47 SSID=androidap > enable_entwork 0 Unknown command 'enable_entwork' > enable_entworwlan0: no IPv6 routers present > enable_network 0 OK > q root@android:/ # dhcpcd wlan0 dhcpcd[3653]: version 5.5.6 starting dhcpcd[3653]: wlan0: rebinding lease of 192.168.43.34 dhcpcd[3653]: wlan0: acknowledged 192.168.43.34 from 192.168.43.1 dhcpcd[3653]: wlan0: checking for 192.168.43.34 dhcpcd[3653]: wlan0: leased 192.168.43.34 for 3600 seconds dhcpcd[3653]: forked to background, child pid 3685 root@android:/ # ping 14.215.177.37 PING 14.215.177.37 (14.215.177.37) 56(84) bytes of data. 64 bytes from 14.215.177.37: icmp_seq=1 ttl=49 time=224 ms 64 bytes from 14.215.177.37: icmp_seq=2 ttl=49 time=47.8 ms 64 bytes from 14.215.177.37: icmp_seq=4 ttl=49 time=91.4 ms 64 bytes from 14.215.177.37: icmp_seq=5 ttl=49 time=63.5 ms ^C --- 14.215.177.37 ping statistics --- 5 packets transmitted, 4 received, 20% packet loss, time 4007ms rtt min/avg/max/mdev = 47.865/106.898/224.694/69.780 ms root@android:/ #