[EDITED AFTER FINDING A SOLUTION]
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
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.
Alternatively:
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).
wpa_cli
?