I think it depends on how you use wpa_cli to setup a connection. You did not mention the issued commands, but I presume you are using the following:
wpa_cli -i wlan0 list_networks # list all configured networks; in you example, you appeared to have just defined network n. 0
wpa_cli -i wlan0 select_network 0
The select_network 0
command is not using P2P and it just connects the Raspberry Pi to the Access Point defined in the network profile 0.
Alternatively, you might have created a second network using for instance the following commands:
wpa_cli -i wlan0 add_network # this returns the new network profile number; let us consider that 1 is returned
wpa_cli -i wlan0 set_network 1 ssid \"MYSSID\"
wpa_cli -i wlan0 set_network 1 psk \"passphrase\"
wpa_cli -i wlan0 enable_network 1 # alternatively to these commands, you might have added a new network profile by editing wpa_supplicant.conf
wpa_cli -i wlan0 list_networks # in this example, we added network 1
wpa_cli -i wlan0 save_config # optional command to save the newly defined network profile 1 into wpa_supplicant.conf
wpa_cli -i wlan0 select_network 1 # this leaves network 0 and connects to network 1
These commands are again not using P2P and just switch the connection of the Raspberry Pi from the Access Point defined in network profile 0 to the other AP defined in profile 1.
Wi-Fi Direct uses different wpa_cli commands and allows compliant devices to form ad-hoc communication groups without interrupting conventional access point-based Wi-Fi communication.
You should change device_name=RPi_3
to device_name=DIRECT-RPi_3
.
You can then use wpa_cli -i p2p-dev-wlan0 p2p_connect <addr> <8-digit password> display
to negotiate the group with the Android device. Alternatively, you can define an autonomous group, or a persistent group.
Example of group negotiation mode:
wpa_cli -i p2p-dev-wlan0
set config_methods keypad
p2p_find
p2p_connect <addr> <8-digit password> display
Example of persistent group mode (assuming that p2p_group_add creates group p2p-wlan0-0):
wpa_cli -i p2p-dev-wlan0
set config_methods keypad
set_network 0 mode 3
set_network 0 disabled 2
p2p_group_add persistent=0
interface p2p-wlan0-0
With the Wi-Fi Direct interface of the Android device, select DIRECT-RPi_3.
Insert PIN 00000000 through the keypad panel of the Android smartphone to enroll.
interface p2p-wlan0-0
wps_pin any 00000000
Check Connect Android smartphone with Wi-Fi Direct to a Raspberry Pi for further information.