1.1 linux系统中使用wpa_cli命令连接wifi
echo "ctrl_interface=/var/run/wpa_supplicant" > /tmp/wpa_supplicant.conf
echo "ap_scan=1" >> /tmp/wpa_supplicant.conf
wpa_supplicant -Dnl80211 -iwlan0 -c/tmp/wpa_supplicant.conf -B -P/var/run/wpa_supplicant.pid &
sleep 2;
wpa_cli -iwlan0 add_network;
sleep 2;
wpa_cli -iwlan0 set_network 0 scan_ssid 1;
sleep 2;
wpa_cli -iwlan0 set_network 0 ssid '"TP-LINK_XXXX"';
sleep 2;
wpa_cli -iwlan0 set_network 0 key_mgmt WPA-PSK;
sleep 2;
wpa_cli -iwlan0 set_network 0 psk '"12345678"';
sleep 2;
wpa_cli -iwlan0 enable_network 0;
sleep 2;
wpa_cli -iwlan0 select_network 0;
sleep 2;
udhcpc -i wlan0
sleep 2