我遇到一个案例,当我需要使用 NetworkManager (nmcli) 建立 WiFi Direct (WiFi-P2P) 时。目前,我使用的是 Ubuntu 20.04。看来我的网络适配器应该支持 WiFi-P2P 连接。
iw 列表输出:
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
不幸的是,我无法找到任何有关如何使用 NetworkManager 功能与 P2P-GO 建立 WiFi-Direct 连接的官方信息。只在论坛里找到了一些帖子,把它们合并到
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
不幸的是,它不起作用,我得到下一个输出
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')