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
Use this procedure [more details included :) ]
1- Make sure wpa_supplicant is running. Look for its pid using this command:
This command should return the pid of wpa_supplicant process. If nothing returned, wpa_supplicant is not running. Use svc command to turn off wifi and then turned it on again:
2- Read control interface directory from wpa_supplicant.conf file. This file usually exists in /data/misc/wifi/. Open this file using cat command:
Note: to find wpa_supplicant.conf file you can search using find command in root directory. Goto root directory using cd / command and use find command to find wpa_supplicant.conf:
find . -name wpa_supplicant.conf
Go to control interface directory specified by ctrl_interafce. First file in this directory is the interface name.
You are going to need "control interface" and "interface name" for executing wpa_cli command.
Note: if you incorrectly input these 2 parameters for wpa_cli command, the wpa_cli could not connect to wpa_supplicant and returns this message:
Or it may connect to wpa_supplicant but return UNKNOW COMMAND for its interactive commands like this:
3- Execute wpa_cli command using above mentioned parameters:
This commands then enter to interactive mode where you can scan and find networks, attach to them and ...
Using save_config you can store these settings back into the wpa_supplicant.conf file for future use. You can recall these setting next time by enable_network command. Next time you want to enable wifi use these commands:
0 is network id. You can use list_networks to find other stored configurations. For further information regarding wpa_cli refer to this document: Also full interactive commands of wpa_cli is documented in this page.
http://w1.fi/cgit/hostap/plain/wpa_supplicant/README
I used this procedure for configuring wifi on Android on Orange Pi 2G IOT.
This is possible to achieve using
wpa_cli
, command line interface ofwpa_supplicant
: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 is0
.