您好,欢迎来到意榕旅游网。
搜索
您的当前位置:首页wpa_supplicant的用法

wpa_supplicant的用法

来源:意榕旅游网
wpa_supplicant的用法

(1)通过adb命令行,可以直接打开supplicant,从而运行wpa_cli,可以解决客户没有显示屏而无法操作WIFI的问题,还可以避免UI的问题带到driver。进一步来说,可以用在很多没有键盘输入和LCD输出的安卓终端产品的操作上。

wpa_supplicant包含两个主要的可执行工具:wpa_supplicant和wpa_cli。wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。 (2)在wpa_cli交互模式下可以执行很多命令,列表如下: Full command Short command status disconnect quit terminate reconfigure scan scan_result list_networks stat disc q term recon scan scan_r list_n Description displays the current connection status prevents wpa_supplicant from connecting to any access point exits wpa_cli kills wpa_supplicant reloads wpa_supplicant with the configuration file supplied (-c parameter) scans for available access points (only scans it, doesn't display anything) displays the results of the last scan displays a list of configured networks and their status (active or not, enabled or disabled) select a network among those defined to initiate a connection (ie select_network 0) makes a configured network available for selection (ie enable_network 0) makes a configured network unavailable for selection (ie disable_network 0) removes a network and its configuration from the list (ie remove_network 0) adds a new network to the list. Its id will be created automatically shows a very short list of available options to configure a select_network select_n enable_network enable_n disable_network disable_n remove_network remove_n add_network set_network add_n set_n network when supplied with no parameters. See next section for a list of extremely useful parameters to be used with set_network and get_network. get_network save_config get_n save_c displays the required parameter for the specified network. See next section for a list of parameters saves the configuration (3)平台操作实例(仅限于MTK平台 且具ROOT权限) A,首先保证ADB连入,且能运行adb remount,这样避免系统文件只读。然后设置wpa_cli和wpa_supplicant有较强权限。

B,运行echo 1 > /dev/wmtWifi,启动WIFI驱动。但是这个使能不会表现在安卓界面上层,默认是要在启动安卓时开启WIFI模块的,也即设置中的WIFI要默认ON。 C,进入/system/bin目录,首先运行服务端wpa_supplicant。 ./wpa_supplicant -iwlan0 -Dnl80211 -c/system/etc/wifi/wpa_supplicant.conf 正常启动后的回显如下:

不可收入态表明该服务端已经在运行了(也可能是可输入状态,只要后面的wpa_cali可连接就行)。-i -D -c的参数意义可直接在Help中查询,具体有些参数可能因平台不同而有差异。

D,另开启一个ADB SHELL,作客户端运行wpa_cali。如下: cd /system/bin

wpa_cli -p /data/misc/wpa_supplicant 回显如下说明正常并处于交互模式:

E,执行一系列命令看看 scan

scan_results

F,连WIFI的命令行,有以下几种:

for AP that doesn`t have encryption

>add_network (It will display a network id for you, assume it returns 0) >set_network 0 ssid “666” >set_network 0 key_mgmt NONE >enable_network 0 >quit

for AP that has WEP

>add_network (assume returns 1) >set_network 1 ssid “666” >set_network 1 key_mgmt NONE

>set_network 1 wep_key0 “your ap passwork”(if usting ASCII, it need double quotation marks, if using hex, then don`t need the double quotation marks)

>set_network 1 wep_tx_keyidx 0

>select_network 1 (optional, remember, if you are connecting with another AP, you should select it to disable the another) >enable_network 1

for AP that has WPA-PSK/WPA2-PSK >add_network (assume returns 2) >set_network 2 ssid “666”

>set_network 2 psk “your pre-shared key”

>select_network 2 (optional, remember, if you are connecting with another AP, you should select it to disable the another) >enable_network 2 我自己的实验图如下:

以上过程就说明联网OK,可以上网了。

参考原文:

http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece76310463b4c4380146d9668d4e414c42246100024b8ed7a671980853a3c50f11e41bca770216c5d61aa9bc98b4addb9922b3bcd7a742613d51742c419de8a1c729f7e875a98ea42b3e1&p=8b2a975bcd8711a052eedb2f4a4c&newp=8b2a971f81822dec08e29e7d495d92695c02dc3051dcd14f25ff0b&user=baidu&fm=sc&query=adb+shell+wifi&qid=&p1=4 参考原文:http://blog.sina.com.cn/s/blog_565b470100l73l.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- yrrf.cn 版权所有 赣ICP备2024042794号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务