Android device: How to connect wifi by "Adb shell cmd wifi" command?
I tried to connect wifi by adb to avoid tedious click and verification operations by appium. And i found that the "adb shell cmd wifi" have a keyword "connect-network", but i cant connect the wifi by this way. Does anyone know how to use it? Thank a lot guys!
Here is the usage of the "Adb shell cmd wifi connect-network":Wi-Fi (wifi) commands:
connect-network <ssid> open|owe|wpa2|wpa3 [<passphrase>] [-m] [-d] [-b <bssid>]
Connect to a network with provided params and add to saved networks list
<ssid> - SSID of the network
open|owe|wpa2|wpa3 - Security type of the network.
- Use 'open' or 'owe' for networks with no passphrase
- 'open' - Open networks (Most prevalent)
- 'owe' - Enhanced open networks
- Use 'wpa2' or 'wpa3' for networks with passphrase
- 'wpa2' - WPA-2 PSK networks (Most prevalent)
- 'wpa3' - WPA-3 PSK networks
-m - Mark the network metered.
-d - Mark the network autojoin disabled.
-b <bssid> - Set specific BSSID.
And my input is adb shell cmd wifi connect-network WIFIName open wpa2 Loginpassword, it return me a Connection initiated, But the connect is not successful. Why this happen? Should i input the wifi login account? And what the whole command should be?
Hey I think that you should use either 'open' or 'wpa2' not both. But If we assume that wifi is secured by a wpa2 password so proper command would be:
Also, take into consideration that only the root user can invoke wifi commands, and root access is not available in most cases.