4

want to ask help, for setting the desired password for p2p_group_add command,

if we run p2p_group_add on wpa_cli, it will generate random ssid and passphrase

P2P-GROUP-STARTED p2p-wlan0-3 GO ssid="DIRECT-uv" freq=2437 passphrase="UqZ76VLR" go_dev_addr=0a:a1:12:84:45:6e

How can we set our own password ?

2 Answers 2

4

To setup your autonomous group owner, started with p2p_group_add, with a custom ssid and password you have to make it persistent and have a network block inserted in /etc/wpa_supplicant/wpa_supplicant.conf. The easiest way to get the network block in wpa_supplicant.conf is to let it do wpa_supplicant itself. Just start the p2p group with p2p_group_add as usual but persistent and remove it just after that again:

rpi ~$ wpa_cli -ip2p-dev-wlan0
> p2p_group_add persistent
> p2p_group_remove p2p-wlan0-0
> quit
rpi ~$

Now you should find the persistent network block in /etc/wpa_supplicant/wpa_supplicant.conf. From my test it looks like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
device_name=DIRECT-RasPi1
p2p_go_ht40=1
country=DE

network={
        ssid="DIRECT-Ca"
        bssid=56:1d:c5:95:c2:e9
        psk="yfmyjT8o"
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP
        auth_alg=OPEN
        mode=3
        disabled=2
}

Now just edit this and set ssid and psk as you like. When ready then restart your wpa_supplicant to make the change available.

The first network block has number 0 and so on. Now start the persistent autonomous group owner by addressing this network block with:

rpi ~$ wpa_cli -ip2p-dev-wlan0
> p2p_group_add persistent=0

That's it.


Reference:
[1] want to generate own password while running p2p_group_add in wpa_cli

2
  • For some reason, when trying to connect with Android, it is disconnected after 5 seconds or so. Commented Jul 18, 2023 at 19:59
  • 1
    @Luis A. Florit To get android to connect, you Must provide a dhcp server on the p2p network interface. Android searches for DHCP configuration for five seconds, and closes the connection if it can't get an IP address. Commented Jul 22 at 17:09
0

Each p2p connection requires two network blocks. The first is used for initial WPAS authentication; the second (and subsequent networks) are used for fast connections, once the initial group connection has been made. When set up properly, your users should have to enter passwords only once; and all subsequent connections will be made without requiring users to enter passwords, using the networks with ssids of the form "DIRECT-xx-xyz, and randomly generated PSKs in the fast-connection networks. Assuming your networks are persistent.

You should create a group with a plain ssid (e.g. xyz), and set p2p_suffix to "-xyz". The first network group will have an ssid of "xyz". Fast-connect networks will show up with ssids of the general form "DIRECT-xx-xy" in the p2p config file. The psk for the first group will remain as-is. The PSKs for for subsequent fast-connect networks are randomly generated, and you absolutely should not mess with them. The are used for EAP authentication of network access points, and it's much better if then are not human generated.

Your (or your user) enters the PIN for first connection. A connection is made to the GO group (plain ssid), and the two parties negotiate credentials to be used for future fast connections. The client then saves the randomly-generated fast-connect credentials for future use, so that it can completely skip the WPAS authentication step, and directly connect to the fast-connect network. For the first connection there are two authentication rounds (WPAS negotiation using your pin; and then a fast-connect authentication using private PSKs). For the second and subsequent connections, only the fast-connect authentication round is performed..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.