wpa_cli与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 |
Description |
|
status |
stat |
displays the current connection status |
|
disconnect |
disc |
prevents wpa_supplicant from connecting to any access point |
|
quit |
q |
exits wpa_cli |
|
terminate |
term |
kills wpa_supplicant |
|
reconfigure |
recon |
reloads wpa_supplicant with the configuration file supplied (-c parameter) |
|
scan |
scan |
scans for available access points (only scans it, doesn‘t display anything) |
|
scan_result |
scan_r |
displays the results of the last scan |
|
list_networks |
list_n |
displays a list of configured networks and their status (active or not, enabled or disabled) |
|
select_network |
select_n |
select a network among those defined to initiate a connection (ie select_network 0) |
|
enable_network |
enable_n |
makes a configured network available for selection (ie enable_network 0) |
|
disable_network |
disable_n |
makes a configured network unavailable for selection (ie disable_network 0) |
|
remove_network |
remove_n |
removes a network and its configuration from the list (ie remove_network 0) |
|
add_network |
add_n |
adds a new network to the list. Its id will be created automatically |
|
set_network |
set_n |
shows a very short list of available options to configure a 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 |
get_n |
displays the required parameter for the specified network. See nextsection for a list of parameters |
|
save_config |
save_c |
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=9f65cb4a8c8507ed4fece7631046893b4c4380146d96864968d4e414c42246100024b8ed7a66471980853a3c50f11e41bca770216c5d61aa9bc98b4addb9922b3bcd7a742613d51742c419de8a1c729f7e875a98ea42b3e1&p=8b2a975bcd8711a052eedb2f4a4c&newp=8b2a971f81822dec08e29e7d495d92695c02dc3051dcd14f2895ff0b&user=baidu&fm=sc&query=adb+shell+wifi&qid=&p1=4
参考原文:http://blog.sina.com.cn/s/blog_55465b470100l73l.html
wpa_cli与wpa_supplicant的交互命令的更多相关文章
- wpa_cli和wpa_supplicant使用,配置无线AP名和密码,静态ip地址
配置静态ip方法分享:通过串口命令行输入如下命令: 1. 添加无线网络接入点(AP) 及其 密码:# wpa_cli -p /data/misc/wpa_supplicantwpa_cli v0.5. ...
- Linux常用命令学习4---(挂载命令mount umount、用户登陆查看和用户交互命令 w who last lastlog)
紧接着上一篇Linux的命令行的学习:Linux学习3---(文件的压缩和解压缩命令zip unzip tar.关机和重启命令shutdown reboot……) 1.挂载命令 简介 ...
- Linux TOP 交互命令
今天总结一点top命令的一些交互命令,比较实用! h或者? 显示帮助画面,给出一些简短的命令总结说明 k 终止一个进程. 系统将提示用户输 ...
- php 的交互命令行
php 的交互命令行 使用过 python 都知道 python 可以使用交互命令. 如下图: 但是 执行 php 显示这个是什么鬼? 按回车和加分号都没用,这是什么原因? 其实是因为使用 php 交 ...
- 设置 PyCharm 软件中 Terminal 窗口 中启动的 python 交互命令的版本
设置 PyCharm 软件中 Terminal 窗口 中启动的 python 交互命令的版本 python2 和 python3 有很大的不同,使用python2 编写的程序,如果使用python3 ...
- Kettle——shell交互命令
Kettle--shell交互命令 在kettle上开发了job或transform可以以单独的文件存在,也可以存放在资源库中.调用这些程序可以通过shell脚本调用,记录下: 资源库中的job: . ...
- linux下使用shell命令通过wpa_cli控制wpa_supplicant连接wifi
最近在调试wifi,已经把wpa_supplicant 工具编译打包好了,为了测试wif驱动及wifi模块是否ok,需要用shell命令临时启动wifi服务连接wifi热点测试. 首先板子启动用ifc ...
- RTSP交互命令简介及过程参数描述
目录 [hide] 1 RTSP消息格式 2 简单的rtsp交互过程 3 rtsp中常用方法 3.1 OPTION 3.2 DESCRIBE 3.3 SETUP 3.4 PLAY 3.5 PAUSE ...
- Go语言远程执行ssh命令简单封装(支持带交互命令)
使用包:golang.org/x/crypto/ssh 以下封装一个发送命令的Cli结构体 type Cli struct { IP string //IP地址 Username string //用 ...
随机推荐
- 设置ViewController 数据源无法改变view
病情描述: viewController创建的时候勾选了xib,然后在显示的时候调用了如下语句: MTDetailDealViewController *detailController = [[MT ...
- java构造函数也可以用private开头
private 构造函数一般用于Singleton模式,指的是整个应用只有本类的一个对象,一般这种类都有一个类似getInstance()的方法!下面是一个Singleton的例子:public cl ...
- HBase0.98.1 通过协调器进行表的行数统计
1. 启用表aggregation,只对特定的表生效.通过HBase Shell 来实现 (1)disable指定表.hbase> disable 'student' (2)添加aggregat ...
- c# 访问修饰符的访问权限
1. 访问修饰符. 指定声明的类型和类型成员的可访问性. (1) public:是类型和类型成员的访问修饰符.公共访问是允许的最高访问级别.对访问公共成员没有限制. (2) private:是一个成员 ...
- ssh框架配置事务管理器
http://blog.163.com/zsq303288862@126/blog/static/9374596120111182446727/
- 拦截器getmodel方法什么时候被调用(没搞懂有什么鸟用,自己搭的项目中用到了这个)
拦截器是Struts2最强大的特性之一,它是一种可以让用户在Action执行之前和Result执行之后进行一些功能处理的机制.Struts2 的预定义拦截器 modelDriven 如果action实 ...
- IIViewDeckController的使用,左右拖拉菜单效果实现
博客园 IIViewDeckController的使用,左右拖拉菜单效果实现 很多应用里面都实现了对应的侧拉 显示隐藏的效果,看起来很符合用户体验的类似于这种 看起来很好看,今天去晚上搜下 ...
- 【svn】server建立以及svn使用
安装好VisualSVN Server后[安装过程看这里],运行VisualSVN Server Manger,下面是启动界面: 好的,下面我来添加一个代码库[Repository],如下图: 按上图 ...
- javascript基础学习(九)
javascript之基本包装类型 学习要点: 基本包装类型概述 Boolean类型 Number类型 String类型 一.基本包装类型概述 为了便于操作基本类型值,提供了3种特殊的引用类型:Boo ...
- Android 新版NDK环境搭建(免Cygwin)
使用最新ndk,直接抛弃cygwin,以前做Android的项目要用到NDK就必须要下载NDK,下载安装Cygwin(模拟Linux环境用的),下载CDT(Eclipse C/C++开发插件),还要配 ...