连接AP的命令


使用iwpriv命令连接AP

连接AP的命令(无加密状态)

iwpriv wlan0 set NetworkType=Infra
iwpriv wlan0 set AuthMode=OPEN
iwpriv wlan0 set EncrypType=NONE
iwpriv wlan0 set SSID=”SWP_Android

连接加密的AP的命令

iwpriv wlan0 set NetworkType=Infra
iwpriv wlan0 show NetworkType
iwpriv wlan0 set AuthMode=WPA2PSK
iwpriv wlan0 set EncrypType=AES
iwpriv wlan0 set SSID=”Test_5G”
iwpriv wlan0 set WPAPSK=”12345678”

查看AP连接状态

iwpriv wlan0 connStatus

通过DHCP申请IP地址

adb shell busybox udhcpc -i wlan0
adb shell busybox ifconfig wlan0 ~192.168.31.159~

查看扫描结果

iwlist wlan0 sc
iwpriv wlan0 get_site_survey

使用wpa_cli命令连接AP

查看当前网络

wpa_cli -iwlan0 list_networks

扫描AP

wpa_cli -iwlan0 scan
wpa_cli -iwlan0 scan_results

添加网络

wpa_cli -iwlan0 add_network

配置网络参数

wpa_cli -iwlan0 set_network 0 ssid “TEST”
wpa_cli -iwlan0 set_network 0 key_mgmt WPA2_PSK
wpa_cli -iwlan0 set_network 0 psk “12345678”

连接AP

wpa_cli -iwlan0 enable_network 0

查看网络状态

wpa_cli -iwlan0 status

请求IP地址

dhclient wlan0