Wifi direct on linux?

Hi all,
is wifi direct supports on linux/how to enable support for wifi-direct?

Regards,
Laxman

Seeing your recent question, I assume you refer to 820c board.
Yes WiFi p2p is supported by the hw/driver/wpa_supplicant layers.

I suggest you to have a look at https://w1.fi/cgit/hostap/plain/wpa_supplicant/README-P2P.

To test this feature you can use the following procedure:

Stop any ongoing wpa_supplicant instance:
$ service wpa_supplicant stop

Create /etc/wpa_supplicant.conf file on device 1 with the following content:

ctrl_interface=/var/run/wpa_supplicant
device_name=My P2P Device 1
device_type=1-0050F204-1

Create /etc/wpa_supplicant.conf file on device 2 with the following content:

ctrl_interface=/var/run/wpa_supplicant
device_name=My P2P Device 2
device_type=1-0050F204-1

Start wpa_supplicant on each device:
$ wpa_supplicant -D nl80211 -i wlanX -c /etc/wpa_supplicant.conf &

On device 1, run wpa client tool and enable p2p listen mode:
$ wpa_cli
> p2p_listen

On device 2, run wpa client tool and run p2p find command:
$ wpa_cli
> p2p_find

On device 2, once device 1 is found run the connect command:
> p2p_connect MAC_ADDR_DEV1 pbc

On device 2, once received connect request, run the same command:
> p2p_connect MAC_ADDR_DEV2 pbc

You can now leave wpa_cli, you will see a new network p2p-wlanX-0 interface on each device.
You can configure this interface manually or use dhcp as well.

On device 1:
$ ifconfig p2p-wlan0-0 172.0.0.1

On device 2
$ ifconfig p2p-wlan0-0 172.0.0.2
$ ping 172.0.0.1
PING 172.0.0.1 (172.0.0.1) 56(84) bytes of data.
64 bytes from 172.0.0.1: icmp_seq=1 ttl=64 time=1115 ms

Your link is established.

1 Like

Hi loic,
when i try to connect devices using p2p_connect i’m getting the below error

Could not read interface p2p-wlp1s0-0 flags: No such device
nl80211: Driver does not support authentication/association or connect commands
nl80211: deinit ifname=p2p-wlp1s0-0 disabled_11b_rates=0
Could not read interface p2p-wlp1s0-0 flags: No such device
p2p-wlp1s0-0: Failed to initialize driver interface
P2P: Failed to create new wpa_supplicant interface

is this the problem with nl80211 and how control interface gets created in /var/run/wpa_supplicant?

Regards,
Laxman

This is on ‘computer’ side, right ? In that case maybe you could try wext instead of nl80211.
on computer side: wpa_supplicant -D wext -i wlanX -c /etc/wpa_supplicant.conf &

Hi Loic,
sorry for the delay.
now the connection is successfully established between my android phone and linux device.
but file transfering doesn’t happening from my android phone to linux device.How can it be done?

Regards,
Laxman

File transfer is not specific to P2P, once your link is established, a protocol (on top of IP) needs to be used for this (FTP, HTTP, Custom…). So this is really dependent on the Android P2P application you are running.

1 Like

Hi Loic,
is wifi direct supports on db410c?
i tried enabling on db410c, but failing. any suggestions on this? i run command with debug option and i can see the below logs.
wlan0: State: INACTIVE -> DISCONNECTED
nl80211: Set wlan0 operstate 0->0 (DORMANT)
netlink: Operstate: ifindex=2 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)
random: Got 20/20 bytes from /dev/random
RTM_NEWLINK: ifi_index=2 ifname=wlan0 operstate=2 linkmode=1 ifi_family=0 ifi_flags=0x1003 ([UP])
EAPOL: disable timer tick

it got stuck here.

complete log:
linaro-alip:~# wpa_supplicant -Dnl80211 -iwlan0 -c /etc/wpa_supplicant.conf -d
wpa_supplicant v2.6
random: Trying to read entropy from /dev/random
Successfully initialized wpa_supplicant
Initializing interface ‘wlan0’ conf ‘/etc/wpa_supplicant.conf’ driver ‘nl80211’ ctrl_interface ‘N/A’ bridge ‘N/A’
Configuration file ‘/etc/wpa_supplicant.conf’ -> ‘/etc/wpa_supplicant.conf’
Reading configuration file ‘/etc/wpa_supplicant.conf’
ctrl_interface=’/var/run/wpa_supplicant’
device_name=‘My_P2P_Device_1’
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supports Probe Response offload in AP mode
nl80211: Using driver-based off-channel TX
nl80211: Driver-advertised extended capabilities (default) - hexdump(len=8): 00 00 00 00 00 00 00 40
nl80211: Driver-advertised extended capabilities mask (default) - hexdump(len=8): 00 00 00 00 00 00 00 40
nl80211: interface wlan0 in phy phy0
nl80211: Set mode ifindex 2 iftype 2 (STATION)
nl80211: Subscribe to mgmt frames with non-AP handle 0xaaaaeaafa210
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=040a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=040b
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=040c
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=040d
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=090a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=090b
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=090c
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=090d
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=0409506f9a09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=7f506f9a09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=0801
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=06
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=0a07
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=0a11
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=1101
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=1102
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=0505
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xaaaaeaafa210 match=0500
rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0
netlink: Operstate: ifindex=2 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT)
Add interface wlan0 to a new radio phy0
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz 20 mBm
nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR)
nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)
nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR)
nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR)
nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR)
nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR)
nl80211: 57240-63720 @ 2160 MHz 0 mBm
nl80211: Added 802.11b mode based on 802.11g information
wlan0: Own MAC address: 58:fc:db:41:02:52
wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=4 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=5 set_tx=0 seq_len=0 key_len=0
wlan0: RSN: flushing PMKID list in the driver
nl80211: Flush PMKIDs
wlan0: State: DISCONNECTED -> INACTIVE
TDLS: TDLS operation not supported by driver
TDLS: Driver uses internal link setup
TDLS: Driver does not support TDLS channel switching
wlan0: WPS: UUID based on MAC address: d3253963-d97d-5875-816b-e659e0a7a8a1
ENGINE: Loading dynamic engine
ENGINE: Loading dynamic engine
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
nl80211: Skip set_supp_port(unauthorized) while not associated
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
wlan0: Added interface wlan0
wlan0: State: INACTIVE -> DISCONNECTED
nl80211: Set wlan0 operstate 0->0 (DORMANT)
netlink: Operstate: ifindex=2 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)
random: Got 20/20 bytes from /dev/random
RTM_NEWLINK: ifi_index=2 ifname=wlan0 operstate=2 linkmode=1 ifi_family=0 ifi_flags=0x1003 ([UP])
EAPOL: disable timer tick

The driver does not support it.
If you look at the iw phy0 info output, you will see that Supported interface modes does not list P2P modes.

Hi Loic,
Thanks and I want to know, is the p2p support can be added to existing driver? if so can i have some inputs on how it can be implemented on 410.

Regards,
Laxman