转自:http://hi.baidu.com/yyangjjun/item/9dfe8e175439fc7a1009b5ba

 
1: run wpa_supplicant first

use the following command:
wpa_supplicant -Dwext -iwlan0 -C/data/system/wpa_supplicant -c/data/misc/wifi/wpa_supplicant.conf

2: Run the command line tool wpa_cli to connect wifi

wpa_cli -p/data/system/wpa_supplicant -iwlan0
Then , it will let you set network interactively

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

3: example
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

if normal, we have connectted to the AP “666”, now you need a IP to access internet, for example:
dhcpcd wlan0
if everything is ok, it will get an IP & can access internet

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
and then ,get an IP to access internet

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

there is still some others options to be set, but wpa_supplicant will choose the default for you, the default will include all we need to set and then ,get an IP to access internet

命令执行后,wpa_cli 会输出连接的过程信息。如果一切正确,则最后后输出:
<2>CTRL-EVENT-CONNECTED - Connection to xx:xx:xx:xx:xx:xx completed (reauth) [id=0 id_str=]

获取IP地址
用 quit
命令退出wpa_cli 。然后用
dhclient wlan0
命令获取IP地址。

wpa_cli 连接 wifi的更多相关文章

  1. wpa_cli 连接 wifi(转)

    wpa_cli 连接 wifi 转自:http://hi.baidu.com/yyangjjun/item/9dfe8e175439fc7a1009b5ba   1: run wpa_supplica ...

  2. linux下使用shell命令通过wpa_cli控制wpa_supplicant连接wifi

    最近在调试wifi,已经把wpa_supplicant 工具编译打包好了,为了测试wif驱动及wifi模块是否ok,需要用shell命令临时启动wifi服务连接wifi热点测试. 首先板子启动用ifc ...

  3. Hi3516如何连接Wifi(二)

    目录: 一.总体思路 二.启动Daemon 三.作者文章合集 书承上回(Hi3516如何连接Wifi(一)),上一篇聊了一下怎样在Hi3516中用wpa_supplicant连接到Wifi热点,本文讲 ...

  4. Linux 使用wpa_supplicant手动配置连接wifi

    Linux 使用wpa_supplicant手动配置连接wifi wpa_supplicant 简介 wpa_supplicant是Linux BSD, Mac OSX和Windows的WPA的服务, ...

  5. 树莓派 连接wifi与路由器ip绑定

    先推荐几个手机软件 在酷安网里应该能找到 1.JuiceSSH  橘子ssh软件  手机连上路由器 就可以控制局域网内的树莓派 2.VNC Viewer  远程桌面软件VNC 也是连接局域网的树莓派 ...

  6. 树莓派连接wifi

    使用树莓派,通过无线网卡连接wifi,再通过远程桌面或者ssh的连接树莓派比较方便,本文记录树莓派wifi如何设置. 参考链接: http://www.jianshu.com/p/b42e8d3df4 ...

  7. 手机连接wifi自动弹窗的原理及其实现方案

    一.手机连上wifi后会自动弹窗的原理 生活中,有很多需要认证的路由器,手机连接wifi热点后会自动弹出一个网页,让用户输入账号和密码,比如星巴克,肯地基,麦当劳,甚至是火车站和机场的候车室.其实这是 ...

  8. android开发连接wifi addNetwork 返回-1

    如下代码:(注释掉的是会返回-1的代码,未注释的是能够正常连接wifi的代码) // public WifiConfiguration CreateWifiInfo(String SSID, Stri ...

  9. 为什么手机连接wifi会显示已停用?

    1.通常导致手机连接WiFi显示“已停用”故障的原因是由于无线路由器“安全模式”设置不当造成的,对此我们可以通过以下方法来解决: 2.根据无线路由器背面的信息(包括路由器IP地址,登陆用户名和密码), ...

随机推荐

  1. Android 开发实践 ViewGroup 实现左右滑出窗口(一)

    利用假期把以前做的东西总结整理一下,先从简单的开始吧.实现的效果是这样的:   做了个截屏动画,比例有点不对了,凑合着看吧. 整个窗口有3部分组成,中间的主界面是个列表,左边的滑出界面是个菜单,右边的 ...

  2. poj 3565 ants

    /* poj 3565 递归分治 还有用KM的做法 这里写的分治 按紫书上的方法 不过那里说的有点冗杂了 可以简化一下 首先为啥可以分治 也就是分成子问题解决 只要有一个集合 黑白的个数相等 就一定能 ...

  3. jQuery作用

    jquery是前端里面比较总要的,是很强大的一个选择器. 表单: 1.$(":input") 查找所有的input元素 2.$("text")    匹配所有的 ...

  4. 解决dispaly:inline-block 遗留间隙的问题

    今天做一个项目 .本来我打算是作成表格的 ,后来觉得太费事直接搞成一个div 里面直接放四个a ,然后我将a 设置成inline-block.刚开始还没发现任何间隙问题,(对了说到这里 博主给新手介绍 ...

  5. 禁用windows 10自动更新

    按Win键+R键调出运行,输入“gpedit.msc”点击“确定”,调出“本地组策略编辑器”.顺序依次展开计算机配置,管理模板 ,windows组件 ,windows更新 点击右边“配置自动更新”,选 ...

  6. 制作SSL证书

    上一节介绍了OpenSSL的目录结构,本节介绍一下SSL证书的制作. OpenSSL安装后建议把其中的bin目录添加到系统环境变量中,方便以后操作. 建立一个新的目录SSL专门用来制作证书. 建立证书 ...

  7. iOS如何准确获取通知

    iOS获取通知需要注意以下三个地方iOS 设备收到一条推送(APNs),用户点击推送通知打开应用时,应用程序根据状态不同进行处理需在 AppDelegate 中的以下两个方法中添加代码以获取apn内容 ...

  8. X3850 Linux 下DSA日志收集办法

    收集工具下载 RHEL 6: 32bit-- [IBM 下载]http://delivery04.dhe.ibm.com/sar/CMA/XSA/03tza/1/ibm_utl_dsa_dsytb7x ...

  9. Visual Studio 2013 在使用 MVC5 无智能提示

    关于 Visual Studio 2013 在使用 MVC5 无智能提示的问题,类库无法正常识别,连最基本的关键字提示都没有了,类变色也没有了,所有的关键字代码,类名,方法成员名都要全部手动敲 原因: ...

  10. gulp Tips

    npm配置相关属性用于寻找全局安装的module npm install  --save-dev 本地安装   在gulp.src()里指定取用文件的语法是,在[ ]中以字符串形式填写文件名,用&qu ...