Issue
I have an Android phone, and the goal is to connect the phone to a password protected wifi network.
Steps I know so far:
adb root
adb shell svc wifi enable
Ok sweet, wifi is turned on. Now I need to connect the phone a certain wireless network that requires a password. I am hoping I can connect using an adb shell command.
Any help?
I would rather not download programs onto the device
Solution
This is possible to achieve using wpa_cli
, command line interface of wpa_supplicant
:
# Get to the shell
adb root
adb shell
# Get to wpa_cli prompt
wpa_cli -p /data/misc/wifi/sockets/ -i wlan0
# Add new WiFi network
add_network
set_network 0 auth_alg OPEN
set_network 0 key_mgmt WPA-PSK
set_network 0 ssid "network_name"
set_network 0 proto RSN
set_network 0 mode 0
set_network 0 psk "password"
# Connect to it
select_network 0
enable_network 0
reassociate
# Check the status
status
In the above list of commands, add_network
command will output the index of the new network, which should be used for the subsequent commands. In this example, this index is 0
.
Answered By - Andrejs Cainikovs
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.