android-wpa_cli 调试wifi

1、使用ifconfig -a指令查看网络端口

g6sh:/ # ifconfig -a
sit0      Link encap:IPv6-in-IPv4  
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 TX bytes:0

eth1      Link encap:Ethernet  HWaddr 56:4d:51:68:01:f8  Driver virtio_net
          inet addr:192.168.4.102  Bcast:192.168.4.255  Mask:255.255.255.0
          inet6 addr: fe80::d18b:a39e:120f:f415/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:167 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2482 TX bytes:12328

ip6_vti0  Link encap:UNSPEC  
          NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 TX bytes:0

eth0      Link encap:Ethernet  HWaddr aa:aa:aa:aa:aa:aa  Driver virtio_net
          inet addr:192.168.2.2  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a8aa:aaff:feaa:aaaa/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1160 TX bytes:7915

wlan0     Link encap:Ethernet  HWaddr bc:82:5d:00:18:ae  Driver brcmfmac
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 TX bytes:0

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope: Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:167 errors:0 dropped:0 overruns:0 frame:0
          TX packets:167 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15371 TX bytes:15371

ip6tnl0   Link encap:UNSPEC  
          NOARP  MTU:1452  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 TX bytes:0

ip_vti0   Link encap:UNSPEC  
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 TX bytes:0

2、 ifconfig mlan up启动mlan0

g6sh:/ # ifconfig wlan0 up

3、启动wpa_supplicant

/vendor/hw/wpa_supplicant -Dnl80211 -iwlan0 -c/vendor/etc/wifi/wpa_supplicant.conf -B

 

ps -e 查看进程 wpa_supplicant已经启动

system        3323  1565 3714644 142712 futex_wait_queue_me 0 S dsv.carstate.service
root          3330     2       0      0 worker_thread       0 I [kworker/0:0]
root          3350     2       0      0 worker_thread       0 I [kworker/u4:3]
wifi          3363     1 2128788   7148 poll_schedule_timeout 0 S wpa_supplicant
root          3364  3230   11740   7144 0                   0 R ps

 

4、启动wpa_cli

g6sh:/ # wpa_cli -iwlan0                                                       
wpa_cli v2.7-devel-9
Copyright (c) 2004-2017, Jouni Malinen 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-STARTED
<3>CTRL-EVENT-SCAN-RESULTS
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00 SSID=
<3>CTRL-EVENT-NETWORK-NOT-FOUND
> scan
OK
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=3 BSSID=00:00:00:00:00:00 SSID=
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-RESULTS
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00 SSID=
<3>CTRL-EVENT-NETWORK-NOT-FOUND
> scan_result
bssid / frequency / signal level / flags / ssid
d4:c1:9e:37:20:ad    5180    -81    [WPA2-EAP-CCMP][ESS]    office
d4:c1:9e:b7:20:ad    5180    -80    [WPA2-PSK-CCMP][ESS]    Android-auto
d4:c1:9e:37:20:ac    5180    -81    [WPA2-PSK-CCMP][ESS]    TEMS
d4:c1:9e:f7:20:ac    5180    -81    [WPA2-EAP-CCMP][ESS]    mobile
d4:c1:9e:77:20:ad    5180    -80    [WPA2-EAP-CCMP][ESS]    VIP
d4:c1:9e:37:20:a8    2462    -84    [WPA2-PSK-CCMP][ESS]    TEMS
d4:c1:9e:37:20:a9    2462    -84    [WPA2-EAP-CCMP][ESS]    office
d4:c1:9e:f7:20:a8    2462    -85    [WPA2-EAP-CCMP][ESS]    mobile
d4:c1:9e:77:20:a9    2462    -85    [WPA2-EAP-CCMP][ESS]    VIP

 

可以输入help查看wpa_cli支持的指令,比如add_network添加网络,select_network选择网络等

你可能感兴趣的:(wifi)