1

I'm trying to get Wifi P2P (also known as "Wifi Direct") working on some devices. My goal is for them to be a "Group Owner" (i.e., acting like an access point). However, I'm getting very different results on different systems. Note that I'm talking about different hardware devices, but I think my issue is Linux-based.

I have gotten success with Raspberry Pi OS on a Pi 4B. However, when I try the same commands on a Banana Pi running Arabian I get very different results. However, I think the ultimate issue is system-level, which is why I'm asking here.

So, here's what works on the RPi OS (device_name is set in /etc/wpa_supplicant/wpa_supplicant.conf):

wpa_cli p2p_group_add
ifconfig p2p-wlan0-0 192.168.0.34 metmask 255.255.0.0
dnsmasq -i p2p-wlan0-0 -F192.168.0.40,192.168.0.250 -p0 -z
wpa_cli set p2p_go_intent 15
ifconfig wlan0 down
wpa_cli wps_pbc

From here, if I connect from my Android device, it works, and receives a DHCP response. Unfortunately, there's not much logging, so I can't compare well with other things. Additionally, from trial-and-error, I have determined that this DOESN'T work if my netmask is 255.255.255.0!?!? Weird, but whatever.

If I try the same sequence of commands on my Banana Pi (with a variety of operating systems - Raspbian, Ubuntu, and Armbian), there are several differences. First, if I take down wlan0, nothing after that works. So, leaving it in, it doesn't start advertising unless I issue a "wpa_cli p2p_find". or "wpa_cli p2p_listen". I found that strange, but whatever. However, here, the Android device finds the network, initiates, but the negotiation is never completed and a DHCP lease is never given. The log (which is better on Armbian than on RPiOS) gives the sequence: "P2P-DEVICE-FOUND, P2P-PROV-DISC-PBC-REQ", and "P2P-GO-NEG-REQUEST", but nothing after that.

In any case, I've tried lots of variations, different kernels, different versions of operating systems, etc. It's possibly a hardware issue with my Banana Pi, but I'm not sure why that would be - it's doing Wifi generally just fine, and P2P I think is just a new frame type, which the driver says it supports (uses brcmfmac).

It's possible it's a weird interaction with NetworkManager as well, but I have been unable to turn NetworkManager off and still have wpa_cli still work. Earlier in the syslog, when I enable the P2P group, I get some messages in my syslog which state:

wpa_supplicant: p2p-wlan0-0: interface state UNINITIALIZED->ENABLED
wpa_supplicant: p2p-wlan0-0: AP-ENABLED
wpa_supplicant: p2p-wlan0-0: CTRL-EVENT_CONNECTED
wpa_supplicant: P2P-GROUP-STARTED p2p-wlan0-0 GO .....
wpa_supplicant: bus: Register group object....
NetworkManager: <warn> device (p2p-dev-wlan0): P2P: WPA supplicant notified a group start but we are not trying to connect! Ignoring the event
wpa_supplicant: p2p-wlan0-0: interface state ENABLED->DISABLED
wpa_supplicant: p2p-wlan0-0: AP-DISABLED
wpa_supplicant: p2p-wlan0-0: CTRL-EVENT-DISCONNECTED

I don't know if these are normal (since the RPi 4 isn't logging at this level), but it seems that after enabled AP mode, it then disables it. However, I thought that it should probably stay in AP mode since it is a group owner. I didn't know if NetworkManager ignoring the event was causing anything weird. I'm really unsure how these interactions are supposed to go.

I've also tried a lot of variations on these, like setting the default route, but to no avail. If anyone has suggestions on where to go, I would greatly appreciate it. Sadly, right now my only Linux machines are my Pis, so I can't try this out on a regular PC either.

I also didn't know if there was something I could try at a lower level (using iw or something), because I'm really not familiar with how all of the layers work together, and there isn't great documentation on it either, especially regarding Wifi P2P. Any advice is appreciated.

Also, I've tried turning off NetworkManager, but, anytime I do that, wpa_cli seems to fail entirely.

2
  • Also, I've tried turning off NetworkManager, but, anytime I do that, wpa_cli seems to fail entirely.
    – johnnyb
    Feb 24, 2023 at 16:26
  • 1
    Welcome to U&L. If you have further info like above, or if someone asks for clarification or something in the comments, it's better to edit the question and add directly there. That way the relevant info is readily available. Feb 24, 2023 at 18:21

1 Answer 1

1

So, it turns out the answer was pretty simple. I did need to turn off NetworkManager. However, when turning off NetworkManager, it requires that you have a config file specified for wpa_supplicant (say, supplicant.conf), and that the file contain the line:

ctrl_interface=/run/wpa_supplicant

I don't know much about it, so I don't know if the directory is distribution-specific.

You then start wpa_supplicant with this (I put it in rc.local):

nohup wpa_supplicant -i wlan0 -c /path/to/supplicant.conf &

Then you can run your Wifi Direct / Wifi P2P commands without NetworkManager shutting your groups down.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .