I got a case when I need to establish WiFi Direct (WiFi-P2P) by using NetworkManager (nmcli). As for now, I use Ubuntu 20.04. It seems that my network adapter should support WiFi-P2P connections.
iw list output:
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* P2P-client
* P2P-GO
* P2P-device
valid interface combinations:
* #{ managed } <= 1, #{ AP, P2P-client, P2P-GO } <= 1, #{ P2P-d evice } <= 1,
total <= 3, #channels <= 2
Unfortunately, I wasn't able to find any official information on how to establish a WiFi-Direct connection with P2P-GO using NetworkManager capabilities. Only found some posts in forums and combined them to
nmcli connection add connection.type wifi-p2p ifname p2p-dev-wlp1s0 wifi-p2p.peer <REMOTE DEVICE MAC> autoconnect no
nmcli con up wifi-p2p-p2p-dev-wlp1s0
Unfortunately, it doesn't work and I get the next output
nmcli con up wifi-p2p-p2p-dev-wlp1s0
Error: Connection activation failed: The base network connection was interrupted
Hint: use 'journalctl -xe NM_CONNECTION=5e2e6f4a-0818-4344-afc1-70fd6b490c0d + NM_DEVICE=p2p-dev-wlp1s0' to get more details
NetworkManager[659]: <info> [1645564279.6405] manager: (p2p-dev-wlp1s0): new 802.11 Wi-Fi P2P device (/org/freedesktop/NetworkManager/Devices/6)
NetworkManager[2525]: <info> [1645564287.3484] manager: (p2p-dev-wlp1s0): new 802.11 Wi-Fi P2P device (/org/freedesktop/NetworkManager/Devices/6)
NetworkManager[2525]: <info> [1645564287.3495] device (p2p-dev-wlp1s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
NetworkManager[2525]: <info> [1645564287.3530] device (p2p-dev-wlp1s0): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
NetworkManager[2525]: <info> [1645564314.1324] device (p2p-dev-wlp1s0): state change: disconnected -> unavailable (reason 'supplicant-failed', sys-iface-state: 'managed')
NetworkManager[2525]: <info> [1645564344.0619] device (p2p-dev-wlp1s0): state change: unavailable -> disconnected (reason 'supplicant-available', sys-iface-state: 'managed')
NetworkManager[2525]: <info> [1645566035.2989] device (p2p-dev-wlp1s0): Activation: starting connection 'wifi-p2p-p2p-dev-wlp1s0' (5e2e6f4a-0818-4344-afc1-70fd6b490c0d)
NetworkManager[2525]: <info> [1645566035.2996] device (p2p-dev-wlp1s0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
NetworkManager[2525]: <info> [1645566039.0283] device (p2p-dev-wlp1s0): state change: prepare -> unavailable (reason 'supplicant-failed', sys-iface-state: 'managed')