I.MX6 wpa_cli 使用
阅读原文时间:2023年07月10日阅读:3

/***********************************************************************
* I.MX6 wpa_cli 使用
* 说明:
* 在调试Android wifi功能之前,先要保证wpa_supplicant调试是正常才行,
* 否者都很难确定到底那一层的软件出了问题。
*
* 2016-6-28 深圳 南山平山村 曾剑锋
**********************************************************************/

一、参考文档:
. 用wpa_cli 连接无线网络
http://blog.163.com/qk_zhu/blog/static/195076154201132081536347/
. wpa_cli 连接 wifi
http://www.cnblogs.com/lidabo/p/4660206.html

二、shell command:
. wpa_supplicant -iwlan0 -Dnl80211 -c/etc/wifi/wpa_supplicant.conf &
. wpa_cli -i wlan0 -p /data/misc/wifi/sockets

三、wpa_cli command:
. scan
. scan_results
. add_network
. set_network ssid "androidap"
. set_network key_mgmt NONE
. select_network
. enable_network

四、示例:
root@android:/ # wpa_cli -i wlan0 -p /data/misc/wifi/sockets
wpa_cli v2.-devel-4.2.2_rtw_r8680.
Copyright (c) -, 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  
<>CTRL-EVENT-STATE-CHANGE id=- state= BSSID=::::: SSID=  
<>CTRL-EVENT-SCAN-RESULTS  
<>WPS-AP-AVAILABLE  
<>CTRL-EVENT-STATE-CHANGE id=- state= BSSID=::::: SSID=  
> scan\_results  
bssid / frequency / signal level / flags / ssid  
ec::ca:e1:6b:           -     \[WPA-PSK-CCMP\]\[WPA2-PSK-CCMP\]\[ESS\]      Aplex-AP  
:b0:c6:0f::b0           -     \[WPA2-PSK-CCMP\]\[ESS\]    Aplex-AP3  
8c:be:be:::d2           -     \[WPA2-PSK-CCMP\]\[ESS\]    Aplex\_C  
d0:fa:1d:::7b           -     \[WPA-PSK-CCMP\]\[WPA2-PSK-CCMP\]\[ESS\]      SZSD  
:b0:c6:4f::           -     \[WPA-PSK-CCMP\]\[WPA2-PSK-CCMP\]\[ESS\]      DXYP-  
:fb:b2::bb:           -     \[WPA-PSK-CCMP\]\[WPA2-PSK-CCMP\]\[ESS\]      TP-LINK-  
c0:::fc::a1           -     \[WPA-PSK-CCMP\]\[WPA2-PSK-CCMP\]\[ESS\]      ZLY-TECH  
::::e8:e1           -     \[WPA-PSK-TKIP+CCMP\]\[WPA2-PSK-TKIP+CCMP\]\[ESS\]SZSD  
:::ce::           -     \[WPA2-PSK-CCMP\]\[WPS\]\[ESS\]       sjb  
f0:b4:::1d:f1           -     \[WPA2-PSK-CCMP\]\[ESS\]    Xiaomi\_888  
a0:f3:c1:::           -     \[WPA2-PSK-TKIP+CCMP\]\[ESS\]       TP-LINK\_952236  
b0:d5:9d:::           -     \[WPA2-PSK-CCMP\]\[ESS\]    huo  
f8:e9::b7::8a           -     \[WPA-PSK-CCMP\]\[WPA2-PSK-CCMP\]\[WPS\]\[ESS\] laser309  
::::8b:           -     \[WPA-PSK-CCMP\]\[WPA2-PSK-CCMP\]\[ESS\]      \\xe5\\x85\\x8d\\xe8\\xb4\\xb9WiFi-  
ec::ca::d1:f6           -     \[ESS\]   TP-LINK\_D1F6  
::::7d:           -     \[ESS\]   androidap  
> add\_network

> set\_network  ssid "androidap"  
OK  
> set\_network  key\_mgmt NONE  
OK  
> select\_network  
OK  
<>CTRL-EVENT-STATE-CHANGE id= state= BSSID=::::: SSID=androidap  
> RTL871X: rtw\_set\_802\_11\_connect(wlan0)  fw\_state=0x00000008  
<>CTRL-EVENT-SCAN-RESULTS  
<>WPS-AP-AVAILABLE  
<>Trying to associate with ::::7d: (SSID='androidap' freq= MHz)  
<>CTRL-EVENT-STATE-CHANGE id= state= BSSID=::::: SSID=androidap  
> RTL871X: start auth  
RTL871X: auth success, start assoc  
RTL871X: assoc success  
<>CTRL-EVENT-STATE-CHANGE idADDRCONF(NETDEV\_CHANGE): wlan0: link becomes ready  
= state= BSSID=::::: SSID=androidap  
<>Associated with ::::7d:  
<>CTRL-EVENT-CONNECTED - Connection to ::::7d: completed (auth) \[id= id\_str=\]  
<>CTRL-EVENT-STATE-CHANGE id= state= BSSID=::::7d: SSID=androidap  
> enable\_entwork  
Unknown command 'enable\_entwork'  
> enable\_entworwlan0: no IPv6 routers present  
> enable\_network  
OK  
> q  
root@android:/ # dhcpcd wlan0  
dhcpcd\[\]: version 5.5. starting  
dhcpcd\[\]: wlan0: rebinding lease of 192.168.43.34  
dhcpcd\[\]: wlan0: acknowledged 192.168.43.34 from 192.168.43.1  
dhcpcd\[\]: wlan0: checking for 192.168.43.34  
dhcpcd\[\]: wlan0: leased 192.168.43.34 for  seconds  
dhcpcd\[\]: forked to background, child pid  
root@android:/ # ping 14.215.177.37  
PING 14.215.177.37 (14.215.177.37) () bytes of data.  
 bytes from 14.215.177.37: icmp\_seq= ttl= time= ms  
 bytes from 14.215.177.37: icmp\_seq= ttl= time=47.8 ms  
 bytes from 14.215.177.37: icmp\_seq= ttl= time=91.4 ms  
 bytes from 14.215.177.37: icmp\_seq= ttl= time=63.5 ms  
^C  
--- 14.215.177.37 ping statistics ---  
 packets transmitted,  received, % packet loss, time 4007ms  
rtt min/avg/max/mdev = 47.865/106.898/224.694/69.780 ms  
root@android:/ #

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章