Android wpa_supplicant连接ap

1,adb shell 
2, insmod /system/lib/modules/wlan.ko 
failed (File exists)表示已经加载忽略错误 
3,ip link set wlan0 up 
4, setprop ctl.start wpa_supplicant 
5, wpa_cli -p/data/misc/wifi/sockets 
6,scan 
7,scan_results 
02:1a:11:f8:a1:2b 2437 -58 [WPA2-PSK-CCMP][ESS] qian 
8, add_network 假设返回0 
9,set_network 0 ssid "qian" 
10,set_network 0 psk "Aa123456" 
11,select_network 0 
12,enable_network 0 
<3>Trying to associate with SSID 'qian' 
<3>CTRL-EVENT-STATE-CHANGE id=0 state=5 BSSID=00:00:00:00:00:00 SSID=qian 
<3>CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=US 
<3>CTRL-EVENT-STATE-CHANGE id=0 state=6 BSSID=00:00:00:00:00:00 SSID=qian 
<3>Associated with 02:1a:11:f8:a1:2b 
<3>CTRL-EVENT-STATE-CHANGE id=0 state=7 BSSID=02:1a:11:f8:a1:2b SSID=qian 
<3>CTRL-EVENT-STATE-CHANGE id=0 state=8 BSSID=02:1a:11:f8:a1:2b SSID=qian 
<3>WPA: Key negotiation completed with 02:1a:11:f8:a1:2b [PTK=CCMP GTK=CCMP] 
<3>CTRL-EVENT-CONNECTED - Connection to 02:1a:11:f8:a1:2b completed [id=0 id_str=]
<3>CTRL-EVENT-STATE-CHANGE id=0 state=9 BSSID=02:1a:11:f8:a1:2b SSID=qian 
13,q退出 
14,ip a show wlan0 
13: wlan0: mtu 1500 qdisc mq state UP qlen 1000 
link/ether 00:0a:f5:89:89:ff brd ff:ff:ff:ff:ff:ff 
inet 192.168.43.74/24 brd 192.168.43.255 scope global wlan0 
valid_lft forever preferred_lft forever 
inet6 fe80::20a:f5ff:fe89:89ff/64 scope link 
valid_lft forever preferred_lft forever 
14,ping 网关 
ping 192.168.43.1 
PING 192.168.43.1 (192.168.43.1) 56(84) bytes of data. 
64 bytes from 192.168.43.1: icmp_seq=1 ttl=64 time=17.7 ms 
64 bytes from 192.168.43.1: icmp_seq=2 ttl=64 time=16.5 ms 
连接成功,获取地址成功,ping网关成功

你可能感兴趣的:(Android wpa_supplicant连接ap)