I am interested to know what commands can be used in Android to control WiFi direct from the terminal/command line. I took a look into p2p WIFI direct but I didn't catch these commands!!

I can find commands used with Linux from this link. Can the same be used with Android? If so, how can I access them on a rooted device?

1 Answer 1


On some devices which do support WiFi-Direct, the corresponding binaries come pre-installed (e.g. the wpa_cli command; see also How can I install wpa_cli on my rooted device?). If you have those ready, you can use them on your Android device as you would do on a Linux machine (find a closer description e.g. in the blog post How To : Use wpa_cli To Connect To A Wireless Network).

Of course that would require a terminal emulator to be installed on your device (take e.g. a look at Android Terminal Emulator for a good candidate) -- at least if you want to issue the commands directly.

As the linked "How To" describes, you can use wpa_cli in interactive mode (by directly executing it). On the "wpa_cli shell" you then can execute different commands: scan scans for available networks, with add_network you can select an available network to configure with set_network. An example could look like this:

> add_network
> set_network 0 ssid "WLAN-Network"
> set_network 0 psk "SupahSecretPassphrase"

This would trigger a connection phase, which could look like:

> <2>Trying to authenticate with 00:55:ab:25:ac:5a (SSID='WLAN-Network' freq=2437 MHz)
> <2>Trying to associate with 00:55:ab:25:ac:5a (SSID='WLAN-Network' freq=2437 MHz)
> <2>Associated with 00:55:ab:25:ac:5a
> <2>WPA: Key negotiation completed with 00:55:ab:25:ac:5a [PTK=CCMP GTK=CCMP]
> <2>CTRL-EVENT-CONNECTED - Connection to 00:55:ab:25:ac:5a completed (reauth) [id=0 id_str=]

Another good source to take a look at is Android from the command-line, which gives some more examples -- not only restricted to WiFi.

  • what do you think about previous link that talk about wifi direct commands ?is it not use with android ?
    – H.H
    Mar 8, 2013 at 13:53
  • with only wpa_cli, can i get all require steps as in previous link ? scan--negotiation-connect-send data ? also can i have broadcast packets send?
    – H.H
    Mar 8, 2013 at 13:55
  • last question>> does your method require access point ? as soon as WIFI DIRECT doesn't require AP to connect ?
    – H.H
    Mar 8, 2013 at 13:56
  • @Hanaa, please check the linked sources for details -- not having used that stuff myself, I cannot give closer insight. And no, the wpa_cli stuff is for WiFi-Direct (at least according to the linked article) and thus does not require an AP. As your question was for WiFi-Direct, I restricted my answer to that (and skipped the other stuff).
    – Izzy
    Mar 8, 2013 at 14:27
  • ok, but how do android use WIFI DIRECT without install wpa_cli library ?? if they actually use this library ray how they call their kernal with this commands without this library installed ?
    – H.H
    Mar 8, 2013 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .