I am able to connect successfully with the android device with the following wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=root


I started wpa_cli in interactive mode. Then adding a persistent group with p2p_group_add cmd as follows

p2p_group_add  persistent=0

enabling the pin by wps pin as follows

wps_pin any 12345670

with this I was able to connect a android device with Respberry pi automatically (with out giving pin in android device repeatedly).

But when I restart the pi and run the same command p2p_group_add persistent=0 not able to connect device with the preexisting persistent group.

  • What are these commands you are using? Do you use them with wpa_cli? – Ingo Sep 24 '20 at 17:05
  • yes, i have used with wpa_cli, sorry i missed it. – arayan Sep 25 '20 at 5:20


To summarize the issue, when restarting wpa_supplicant on the Raspberry Pi and reinvoking a previously defined persistent group, the P2P Clients (e.g., Android phones) are no more able to rejoin the saved group with fast reconnection and a new enrolling process is started instead, so that the saved group on the Android phones remains useless.

The problem occurs because, to improve security, the WLAN device driver of the Raspberry Pi 802.11 wireless interface uses randomized MAC addresses by default when starting network interfaces. Anyway, when using Wi-Fi Direct P2P persistent groups, MAC addresses shall not vary in order to avoid breaking the group restart.

A new version of wpa_supplicant now supports p2p_device_random_mac_addr=2, which allows correctly managing persistent groups on a Raspberry Pi, by reusing a previously saved MAC address.

How to compile, install and use this option is described here.

See also:

The following note shortly describes how to use a Wi-Fi Direct P2P persistent group.

A Wi-Fi Direct persistent group can be for instance created by manually editing the wpa_supplicant.conf configuration shown in the question, defining it as the first network profile (n. 0).

Add p2p_device_random_mac_addr=2 to wpa_supplicant configuration file.

Use the following commands to start the persistent group via wpa_cli:

wpa_cli -i p2p-dev-wlan0
set config_methods keypad

set config_methods keypad means that you want to enter a PIN with your smartphone and confirm it with your Rpi.

p2p_group_add persistent=0

interface lists the available interfaces; you need to find the one starting with p2p-wlan...

interface <group_name>

For instance, interface p2p-wlan0-0.

set config_methods keypad

Then, on the Android client:

Settings > Wi-Fi > Wi-Fi Direct; as soon as the SSID appears, select it and enter the PIN (say for instance 00000000, 8 digits).

Immediately after receiving the WPS-ENROLLEE-SEEN event, on that newly created interface issue the following:

wps_pin any 00000000

After some seconds, the device gets connected.


wpa_cli -i p2p-wlan0-0 wps_pin any 00000000

Notice the used interface name.

When the connection is activated, a new saved group appears on the Wi-Fi Direct Android panel, to allow fast reconnection. In fact, if you now disconnect the link on the Android phone and try to reconnect it, including Android reboot and Raspberry Pi reboot, the connection becomes immediately active without password request (i.e., reusing the same saved group).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.