IVI/Wi-Fi Direct

From Tizen Wiki
Jump to: navigation, search

The purpose of this page is to introduce the Wi-Fi Direct technology and explain how to get it working on Linux and more specifically on Tizen IVI.

Wi-Fi Direct

Wi-Fi Direct, also called Wi-Fi P2P, allows two or more devices to connect together through a peer-to-peer connection without having to rely on or setup an access point. It's key features are:

Wi-Fi Direct authentication relies on WPS (Wi-Fi Protected Setup) which means that the authentication is made through an 8-digit PIN code or a push button (PBC).

Connected Wi-Fi Direct devices can be either group owner (GO) or client. Two devices with the same role can't be connected to each other, which means that a connection is always a client connected to a GO. Roles can be automatically attributed at connection time through a process called "GO negotiation". A GO can be connected to several clients at the same time thus acting as a relay between its clients. The client role can assimilated to the station role and the GO role to the AP role when in a "classic" Wi-Fi setup.

GO negotiation

GO negotiation happens during the connection process to define who is going to be the GO (and the client). During the GO negotiation the intention of the two devices to be GO is compared. This is made through a value called "GO intent" that is configured on each devices. This value goes though 0 to 15. The higher the value the higher is the intention to be GO, 15 meaning that the device MUST be GO which results in the impossibility to connect two devices with a GO intent equal to 15. If both devices have the same GO intent a tie breaker bit is used to determine which is the GO.


A persistent group is a group in which the devices can be reconnected without having to realize the GO negotiation process and the whole authentication process (no need to enter a PIN code or push the PBC button). For persitence to work both devices need to support it and a first successful "standard" connection should be have been established before.

Hardware and drivers

All Wi-Fi chipsets are able to perform Wi-FI Direct connections as long as their drivers supports it. Most of recent chipsets support Wi-Fi Direct through their driver which is not the case of older ones. If you're not running IVI on the targeted devices, you might not have the same Wi-Fi chipset. In that case the proper firmware is probably not present on your installation. The same thing goes with the driver.

Add a Wi-Fi chipset firmware

By default only the targeted Wi-Fi chipsets have their firmwares included in IVI. To add a specific Wi-Fi chipset firmware you need to add it in the spec file of the linux-firmware package in the %files ivi section.

For example, for the TP-LINK TL-WN722N USB dongle, which is equipped with an Atheros AR9271 chipset, you need to add the htc_9271.fw file to the %files ivi section of the spec file.

Once you've made this modification just build the linux-firmware package and upgrade it on IVI.

Add a Wi-Fi driver

All Wi-Fi drivers are not present in the Tizen IVI kernel. To add a driver to the kernel you need to enable it in the build configuration file of the kernel-x86-ivi package then build the kernel and update it on IVI. How to modify the configuration file is explained here: https://wiki.tizen.org/wiki/IVI/artem-kernel#How_to_change_the_configuration_file.

For example, for the TP-LINK TL-WN722N USB dongle, which is equipped with an Atheros AR9271 chipset, you need to enable the wireless Atheros modules. This results in adding the "CONFIG_ATH_CARDS=m" and "CONFIG_ATH9K_HTC=m" to the configuration file.


wpa_supplicant is designed to be a "daemon" program that runs in the background and acts as the backend component controlling the wireless connection.

Enable Wi-Fi Direct in wpa_supplicant

How to get Wi-Fi Direct support in wpa_supplicant http://wireless.kernel.org/en/developers/p2p/howto

If you want to fully support the persistent group feature you need to add the option "update_config=1". Without this option the persistent groups will be lost if wpa_supplicant is stopped.


man page http://linux.die.net/man/8/wpa_supplicant

About wpa_supplicant http://hostap.epitest.fi/wpa_supplicant/


Wi-Fi Direct support in connman has been planned. TIVI-1317

Check Wi-Fi Direct support

To verify that Wi-Fi Direct is supported you can either try to send P2P commands to wpa_supplicant through wpa_cli or use the iw CLI tool.


Launch wpa_supplicant

# wpa_supplicant -D nl80211 -i <iface> -c /etc/wpa_supplicant/wpa_supplicant-p2p.conf

Launch wpa_cli then launch a P2P command

# wpa_cli -i <iface>
> p2p_find 10

If the P2P command returns "FAIL", Wi-Fi Direct is not supported by your device.


Note that iw is not yet available in IVI repo: TIVI-2539

To see if a device supports Wi-Fi Direct enter the command:

iw list

Then search for the Supported interface modes section and check that you can find both P2P-client and P2P-GO. If you can't find those, your device don't support Wi-Fi Direct.


About iw: http://wireless.kernel.org/en/users/Documentation/iw

Testing Wi-Fi Direct

wpa_supplicant comes witha CLI tool to configure and manage P2P connections.

There are several ways to establish a P2P connection.

Devices A create a group and device B connects to this group

In this configuration there is no GO negotiation because device A creates the group which means that it is the GO. Note that this configuration is the only one I tested that works.

Device A Device B Notes
p2p_group_add Create a group
p2p_find 10 Scan for P2P devices
p2p_connect <Device_A_MAC_@> pin display Connect to a discovered device (device A) using the "display" authentication method. Device B displays a PIN code.
p2p_connect <Device_B_MAC_@> <PIN_CODE> Connect to device B (after receiving the connection request) with the PIN code displayed by device B.


Texas Intstrument Wi-Fi Direct documentation: http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts

Realtek Wi-Fi Direct documentation: http://dishingtech.blogspot.fr/2012/01/realtek-wi-fi-direct-programming-guide.html

Attributing IP addresses

Once the connection between the two devices is establish the GO will have to start a DHCP server service and the client a DHCP client service on their respective Wireless P2P interface.

On IVI the package udhcp can deliver both of these services through udhcpc and udhcpd. The package dnsmasq can also delivers the DHCP server service. Note that those packages are not installed by default on IVI but are present in the repo.

Setting up a DHCP server with dnsmasq

Install the dnsmasq package

zypper in dnsmasq

Create a new config file or edit the default one (/etc/dnsmasq.conf).

Example of a very simple config file for dnsmasq:

# Prevents dnsmasq from using /etc/resolv.conf

# Interface listening to DHCP requests

# Defines the range of IP to use

# DNS server

# Alternate DNS server

Launching dnsmask:


You can add the options:

  • --conf-file=</path/to/your/config/file> if you don't use the default config file (/etc/dnsmasq.conf)
  • --dhcp-leasefile=</path/to/your/lease/file> if you don't want to use the default one (/var/lib/misc/dnsmasq.leases), useful for testing if dnsmasq is used on other interfaces or for other purposes

Requesting for an IP address with udhcpc

Install the udhcp package

zypper in udhcp

Request for an IP address:

udhcpc -i <p2p_iface>

Tested configurations on IVI

TIVI image: tizen_20131227.1_ivi-mbr-i586

Remote device uses latest version of wpa_supplicant (commit: ab41595f3524e397107c82213ed5b1cac8ce09bf)

Configuration IVI role Note
Devices A create a group and device B connects to this group WPS=Display Device B OK
Devices A create a group and device B connects to this group WPS=Display Device A Fail

Tested device on IVI

Product Type Chip Firmware Kernel options/Driver Wi-Fi Direct support
TP-LINK TL-WN722N USB Atheros AR9172 htc_9271.fw CONFIG_ATH_CARDS=m
PCI-express Intel Centrino Advanced-N 6205 [Taylor Peak] iwlwifi-6000g2a-6.ucode (enabled by default) No (but officially yes...)


libnl documentation http://www.carisma.slowglass.com/~tgr/libnl/doc/core.html