在Android的shell中连接无线网络

通过使用wpa_cli工具连接无线网络。


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 next section for a list of parameters

save_config

save_c

saves the configuration



设置网络的基本格式:set_network <network id> <key> <parameter> [<parameter>]
显示网络信息的基本格式:get_network <network id> <key>
相应的参数如下表:

Key

Description

Parameters

ssid

Access point name

string

id_str

String identifying the network

string

priority

Connection priority over other APs

number (0 being the default low priority)

bssid

Mac address of the access point

mac address

scan_ssid

Enable/disbale ssid scan

0, 1, 2

key_mgmt

Type of key management

WPA-PSK, WPA_EAP, None

pairwise

Pairwise ciphers for WPA

CCMP, TKIP

group=TKIP

Group ciphers for WPA

CCMP, TKIP, WEP104, WEP40

psk

Pre-Shared Key (clear or encrypted)

string

wep_key0

WEP key (up to 4: wep_key[0123])

string

eap

Extensible Authentication Protocol

MD5, MSCHAPV2, OTP, GTC, TLS, PEAP, TTLS

identity

EAP identity string

string

password

EAP password

string

ca_cert

Pathname to CA certificate file

/full/path/to/certificate

client_cert

Pathname to client certificate

/full/path/to/certificate (PEM/DER)

private_key

Pathname to a client private key file

/full/path/to/private_key (PEM/DER/PFX)



1、连接无加密的AP
>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
2、连接WEP加密AP
>add_network   (assume return 1)
>set_network 1 ssid "666"
>set_network 1 key_mgmt NONE
>set_network 1 wep_key0 "your ap password"
>enable_network 1
3、连接WPA-PSK/WPA2-PSK加密的AP
>add_network   (assume return 2)
>set_network 2 ssid "666"
>set_network 2 psk "your pre-shared key"
>enable_network 2

参考文章:http://blog.sina.com.cn/s/blog_55465b470100l73l.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ADB(Android Debug Bridge)是Android开发工具包(SDK)的一部分,它用于在计算机和安卓设备之间建立调试连接。ADB通常需要通过USB电缆来连接计算机与设备,但是如果设备支持无线连接,我们也可以使用无线方式连接。 要使用ADB进行无线连接,首先需要通过USB将安卓设备连接到电脑,并在计算机上安装好ADB驱动程序。接下来,打开CMD或终端窗口,并输入adb devices命令来确认设备已被正常连接。 接下来,通过输入adb tcpip <port>命令,将ADB连接端口更改为指定的端口号。通常情况下,我们可以选择5555作为端口号。若成功更改端口号,CMD或终端窗口将显示"restarting in TCP mode port: <port>"等信息。 然后,我们需要找到设备的IP地址。可以在设备的设置,找到关于手机(或者类似的)选项,里面应该有设备的IP地址。或者,我们也可以在CMD或终端窗口输入adb shell ifconfig命令来获取设备的IP地址。 最后,我们可以通过输入adb connect <device IP address>:<port>命令来与安卓设备进行无线连接。例如,如果设备的IP地址是192.168.0.100,并且端口号是5555,我们可以输入adb connect 192.168.0.100:5555来建立连接。 如果一切顺利,我们将在CMD或终端窗口看到"connected to <device IP address>:<port>"的提示信息,表示已经成功连接到设备。 通过以上步骤,我们可以在无需使用USB电缆的情况下,使用ADB与安卓设备进行调试和数据传输。需要注意的是,无线连接速度可能相对较慢,并且连接可能不太稳定,请确保设备和计算机在同一网络环境下,以保证良好的无线连接体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值