手动加载WiFi驱动
加载驱动
insmod /system/8812au.v2.ko
启动wlan0
busybox ifconfig wlan0 up
禁用wlan0
busybox ifconfig wlan0 down
卸载驱动
rmmod 8812au
wifi节点加载
启动wlan0之前可以先使用ifconfig -a wlan0查看wlan0 节点是否存在,
127|rk3399_mid:/ # ifconfig -a wlan0
wlan0 Link encap:Ethernet HWaddr d4:b7:61:9f:3a:3c
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 TX bytes:0
若不存在,则需先启动p2p_supp_rtl服务创建wlan0节点
开启p2p_supp_rtl服务
setprop ctl.start p2p_supp_rtl
关闭p2p_supp_rtl服务
setprop ctl.stop p2p_supp_rtl
p2p_supp_rtl服务不支持命令开启
usbwifi开启后连接网络,需要wpa_supplicant服务支持
开启wpa_supplicant服务
setprop ctl.start wpa_supplicant
关闭wpa_supplicant服务
setprop ctl.stop wpa_supplicant
wpa_supplicant服务可以使用命令开启
查找wpa_supplicant服务
service wpa_supplicant /system/bin/wpa_supplicant
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
-I/system/etc/wifi/wpa_supplicant_overlay.conf \
-e/data/misc/wifi/entropy.bin -O/data/misc/wifi/sockets \
-g@android:wpa_wlan0
输入命令开启wpa_supplicant服务
/system/bin/wpa_supplicant -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf -I/system/etc/wifi/wpa_supplicant_overlay.conf -e/data/misc/wifi/entropy.bin -O/data/misc/wifi/sockets -g@android:wpa_wlan0 -dd
-dd 使用logcat查看时打开与wpa_supplicant运行时输出的log
例如:
logcat -c
./wpa_supplicant
logcat 只查看与wpa_supplicant运行时的log
iw命令简单使用
扫描wifi并打印出扫描到wifi的SSID
iw dev wlan0 scan |grep "SSID:" -i
连接wifi xmzw
iw wlan0 connect xmzw
wpa_cli命令使用
打开debuglog
wpa_cli -iwlan0 -p/data/misc/wifi/sockets log_level debug
扫描AP
wpa_cli -iwlan0 scan
显示扫描结果
wpa_cli -iwlan0 scan_result
例:rk3399_mid:/ # wpa_cli -iwlan0 scan
OK
rk3399_mid:/ # wpa_cli -iwlan0 scan_results
bssid / frequency / signal level / flags / ssid
10:7b:44:79:46:b4 5745 -61 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] A5
70:62:b8:84:a0:90 2417 -61 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] D-Link_DIR-612
10:7b:44:c0:de:82 2437 -48 [WPA2-PSK-CCMP][ESS] dd-wrt_2.4G
f0:92:b4:76:84:19 2412 -55 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] ChinaNet-Jamg
b0:95:8e:b8:64:13 2462 -57 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] TP-LINK blue
f0:92:b4:76:aa:51 2412 -54 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] ChinaNet-GSsw
20:76:93:3a:b0:70 2437 -64 [WPA2-PSK-CCMP][ESS] newifi_2.4G_test
70:af:6a:48:a2:73 2437 -65 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] cpf
ec:88:8f:75:3f:e2 2437 -66 [WPA-PSK-CCMP+TKIP][WPS][ESS] db4iot
14:75:90:79:89:0f 2462 -66 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] CP_2.4G
88:70:22:00:6e:c4 2452 -67 [WPA2-PSK-CCMP][ESS] OrayBox-6-yanfa
24:05:0f:79:48:da 2437 -72 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] cccc
20:76:93:3a:b0:72 5745 -67 [WPA2-PSK-CCMP][ESS] newifi_5G_test
00:24:d2:c6:74:b7 2412 -66 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] WWW
00:26:75:01:ba:09 2412 -78 [WPA2-PSK-CCMP][ESS] LBWiFi410
b0:39:56:66:a2:b3 2412 -67 [WPA2-PSK-CCMP][WPS][ESS] weimob--sz
54:e0:61:21:42:d9 2447 -71 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] ChinaNet-dEPG
cc:08:fb:7e:6c:0d 2462 -76 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] TP-LINK_6C0D
10:7b:44:c0:de:84 5180 -79 [WPA2-PSK-CCMP][ESS] dd-wrt_5G
列出当前联网状态:
rk3399_mid:/ # wpa_cli -iwlan0 status
bssid=10:7b:44:c0:de:84
freq=5180
ssid=dd-wrt_5G
id=1
id_str=%7B%22creatorUid%22%3A%221000%22%2C%22configKey%22%3A%22%5C%22dd-wrt_5G%5C%22WPA_PSK%22%7D
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=192.168.50.117
p2p_device_address=d6:b7:61:9f:3a:3c
address=d4:b7:61:9f:3a:3c
uuid=6f47db9a-277a-56db-b7bf-dc203c2a9905
列出所有备选网络
rk3399_mid:/ # wpa_cli -iwlan0 list_networks
network id / ssid / bssid / flags
0 dd-wrt_2.4G any [DISABLED][TEMP-DISABLED]
1 dd-wrt_5G any [CURRENT]
增加一个备选网络
rk3399_mid:/ # wpa_cli -iwlan0 add_network
2
设置要连接的网络名称
rk3399_mid:/ # wpa_cli -iwlan0 set_network 2 ssid '"dd-wrt_5G"'
OK
设置要连接网络的密码
rk3399_mid:/ # wpa_cli -iwlan0 set_network 2 psk '"12341234"'
OK
启用网络,当扫描到启用网络是会自动连接
rk3399_mid:/ # wpa_cli -iwlan0 enable_network 2
OK
禁用网络
rk3399_mid:/ # wpa_cli -iwlan0 disable_network 2
OK
保存配置:
rk3399_mid:/ # wpa_cli -iwlan0 save_config
OK
原作者:小忽悠0011
|