不通过android UI操作,直接命令打开wifi,测试wifi功能,适用于amlogic平台的android O之后的版本。
1. hardware/amlogic/wifi/multi_wifi/config/wpa_supplicant.conf
加入:ctrl_interface=/data/misc/wifi/wpa_supplicant
2.shell脚本:
#/bin/sh
svc wifi disable //关闭wifi
sleep 2
insmod /vendor/lib/modules/dhd.ko firmware_path=/vendor/etc/wifi/AP6398/fw_bcm4359c0_ag.bin nvram_path=/vendor/etc/wifi/AP6398/nvram.txt
/vendor/bin/hw/wpa_supplicant -iwlan0 -Dnl80211 -c /vendor/etc/wifi/wpa_supplicant.conf &
ifconfig wlan0 192.168.199.123 //配置本地ip
sleep 5
wpa_cli -i wlan0 -p /data/misc/wifi/wpa_supplicant add_network //连接指定ssid,psd的wifi热点
wpa_cli -i wlan0 -p /data/misc/wifi/wpa_supplicant set_network 0 ssid '"431-wifi-test"'
wpa_cli -i wlan0 -p /data/misc/wifi/wpa_supplicant set_network 0 key_mgmt WPA-PSK
wpa_cli -i wlan0 -p /data/misc/wifi/wpa_supplicant set_network 0 psk '"123456789"'
wpa_cli -i wlan0 -p /data/misc/wifi/wpa_supplicant enable_network 0
ping -c 5 192.168.199.1 //ping 网关测试
if [ $? = 0 ];then
echo "test wifi success"
else
echo "test wifi failed"
fi