wpa_cli 连接 wifi

转自: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

    转自:http://hi.baidu.com/yyangjjun/item/9dfe8e175439fc7a1009b5ba   1: run wpa_supplicant first use the ...

  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. (转)Sql Server 快速查看表结构(表描述及字段说明)

    --表描述 SELECT tbs.name 表名,ds.value 描述 FROM sys.extended_properties ds LEFT JOIN sysobjects tbs ON ds. ...

  2. api的mock开源工具;api文档生成器;api的mock工具;阿里系;其他开源

    django-rest-framework,即drf的api文档,包括自带的文档和其他三方文档,比如swagger.DRF Docs等 https://www.django-rest-framewor ...

  3. Python任务调度模块 – APScheduler。动态修改调度时间间隔

    APScheduler可以把调度任务放到内存里,也可以把任务放到数据库里,那么如何交互式修改定时任务的执行时间间隔或者下次执行时间呢? 方案一:把定时任务放到数据库里,修改数据库里任务的调度时间 方案 ...

  4. iOS:搜索栏控件UISearchBar and SearchDisplayController的使用

    UISearchBar and SearchDisplayController控件: 这是一个带搜索栏和搜索显示控制器的控件,前面的SearchBar是一个搜索栏,它提供一个输入搜索条件的类似于文本框 ...

  5. PHP判断{函数/类/方法/属性}是否存在

    1.php判断系统函数或自己写的函数是否存在 bool function_exists ( string $function_name ) 判断函数是否已经定义,例如: if(function_exi ...

  6. Transform数据权限浅析2之利用Java完成权限设置

    一:项目背景 1.1:cognos的两种建模工具 为了更好的满足客户的需求,提升报表展现的效率,一种建模工具已经不能满足报表开发和展现的需要.Cognos除了给我们提供了一种基于关系型数据库的建模工具 ...

  7. weblogic 内存 及 内存溢出

    . 区分JVM虚拟机选项:Xms Xmx PermSize MaxPermSize JVM限制:相关操作系统的数据模型(32-bt还是64-bit)限制:系统的可用虚拟内存限制:系统的可用物理内存限制 ...

  8. iphone系统更新 3002错误

    一:错误原因 与苹果服务器通信连接错误 二:解决 windows下:c:/windows/system32/drivers/etc 修改里面的hosts文件 去掉和apple.com相关的 三:ios ...

  9. AA MME设备内部错误

    adobe audition 找不到所支持的音频设备 这是3.0的错误!     上面是cs6的错误的图   主要原因是以前安装过,没有注册表没有清理干净     解决方案: https://jing ...

  10. 〖Android〗/system/etc/media_codecs.xml

    其中的原文件中包含的注释如下: <?xml version="1.0" encoding="utf-8" ?> <!-- Copyright ...