如何通过adb 启动WIFI连接网络

[DESCRIPTION]
有时会遇到这样的问题:在没有屏的时候怎么验证wifi的功能?或者,如何绕开framework层直
接对wifi driver时么操控?本文给出了一个方案。
[SOLUTION]
主要分为3步:1)启动wifi driver;2)启动supplicant;3)启动wpa_cli.
1. 启动wifi driver
echo 1 > /dev/wmtWifi
2. 启动supplicant
cd /system/bin
./wpa_supplicant -iwlan0 -Dnl80211 -
c/system/etc/wifi/wpa_supplicant.conf
3. 启动wpa_cli
cd /system/bin
wpa_cli -p /data/misc/wpa_supplicant
启动以后可以通过help获得帮助信息。
4. 常用命令
关于wpa_cli的使用网上有很多文档(搜索wpa_cli即可获得)。
some common command:
>scan = to scan the neighboring AP
>scan_results = show the scan results
>status = check out the current connection information
>terminate = terminate wpa_supplicant
>quit = exit wpa_cli
>add_network = it will return a network id to you
>set_network <network id> <variable> <value> = set network variables
(shows list of variables when run without arguments), success will return
OK, or will return Fail
>select_network <network id> = select a network (disable others)
>disable_network <network id> = disable a network
>enable_network <network id> = enable a network
> set_network 0 priority 0
> list_network
> save_config
5. 运用举例
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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值