星期六, 4月 12, 2014

using wpa_cli setting wifi

妮仔的學習筆記

http://ninitsai0206.blogspot.tw/2010/11/using-wpacli-setting-wifi.html




using wpa_cli setting wifi

#!/system/bb/ash
start wpa_supplicant
sleep 1
wpa_cli -i tiwlan0 scan
wpa_cli -i tiwlan0 scan_result
wpa_cli -i tiwlan0 add_network
wpa_cli -i tiwlan0 set_network 0 key_mgmt NONE
wpa_cli -i tiwlan0 set_network 0 ssid '"QQ"'
wpa_cli -i tiwlan0 enable_network 0
;--------------------------------------------------

#!/system/bb/ash
start wpa_supplicant
sleep 1
wpa_cli -i tiwlan0 scan
wpa_cli -i tiwlan0 scan_result
wpa_cli -i tiwlan0 add_network
wpa_cli -i tiwlan0 set_network 0 key_mgmt NONE
wpa_cli -i tiwlan0 set_network 0 ssid '"'$1'"'
wpa_cli -i tiwlan0 enable_network 0
echo $1


;--------------------------------------------------
使用wpa_cli控制和管理wpa_supplicant
# wpa_cli -i wlan0 status (看看目前的狀態)
# wpa_cli -i wlan0 help (查看參數與指令)
# wpa_cli -i wlan0 terminate (關閉wpa_supplicant)
# wpa_cli -i wlan0 interface (查看有那些無線網卡介面)
# wpa_cli -i wlan0 list_networks (查看wpa_supplicant.conf檔裡的設定)
# wpa_cli -i wlan0 select_network (選擇不同的AP,id為AP代號0,1,2,3...)
# wpa_cli -i wlan0 enable_network
# wpa_cli -i wlan0 disable_network
# wpa_cli -i wlan0 remove_network (刪除AP資訊)
# wpa_cli -i wlan0 reconfigure (重新讀取wpa_supplicant.conf設定內容)
# wpa_cli -i wlan0 save_config (儲存寫入到wpa_supplicant.conf中,否責變更無效)
# wpa_cli -i wlan0 disconnect (斷線)
# wpa_cli -i wlan0 reconnect (重新連線)
# wpa_cli -i wlan0 scan (掃描附近的AP)
# wpa_cli -i wlan0 scan_results (印出附近AP的相關資訊)

;---------------------------------------
http://linux.die.net/man/8/wpa_cli

wpa_cli [ -p path to ctrl sockets ] [ -i ifname ] [ -hvB ] [ -a action file ] [ -P pid file ] [ command ... ]

沒有留言: