• 07/14/2017
  • Public Content

Wi-Fi Direct

Wi-Fi Direct allows two devices to establish a peer-to-peer connection using Wi-Fi technology without the need for an intermediary access point such as a router. (For more information on Wi-fi Direct see http://www.wi-fi.org/discover-wi-fi/wi-fi-direct).
To enable this built-in feature in Ref-OS-IoT we need to create a ‘p2p group’ to which another peer can connect.
  1. If Wi-Fi access is not already enabled then issue the following connman command:
    $ connmanctl enable wifi Enabled wifi
  2. Once Wi-Fi is enabled the wpa_supplicant daemon must be stopped and disabled before we make changes to its configuration
    $ systemctl stop wpa_supplicant $ systemctl disable wpa_supplicant
  3. Next, restart wpa_supplicant with a new configuration for the driver, interface and config file:
    $ wpa_supplicant -Dn180211 -iwlan0 -c/etc/wpa_supplicant.conf & Successfully initialized wpa_supplicant
  4. Now that WPA is initialized and configured we can new add a Wi-Fi Direct supported p2p group using the WPA Command Line Interface tool (wpa_cli)
    $ wpa_cli
  5. Once the wpa_cli prompt is started we can add our new p2p group with the following command:
    > p2p_group_add
  6. When correctly initialized this should provide information at the command line as shown below, including the randomly generated SSID name (e.g., “DIRECT-wK”) and password (e.g., “MKbq90iM):
    > Using interface p2p_wlan0-0 with hwaddr a0:c5:89:04:93:5b and ssid "DIRECT-wK"
    p2p_wlan0-0: interface state UNINITIALIZED->ENABLED
    p2p_wlan0-0: AP-ENABLED
    p2p_wlan0-0: CTRL-EVENT-CONNECTED - Connection to a0:c5:89:04:93:5b completed [id=0 id_str=]
    P2P-GROUP-STARTED p2p_wlan0-0GO ssid="DIRECT-wK" freq=2462 go_dev_addr=a0:c5:89:04:93:5a
    <3>P2P-GROUP-STARTED p2p_wlan0-0GO ssid="DIRECT-wK" freq=2462 passphrase="MKbq9OiM" go_dev_addr=a0:c5:89:04:93:5a
  7. With this set up the final step it to exit wpa_cli (CTRL+D) and set an IP address for this new p2p group interface:
$ ifconfig p2p_wlan0-0
To get real-time diagnostic information on this new interface simply restart wpa_cli specifying the interface name:
$ wpa_cli -i p2p_wlan0-0
Any appropriate device should now be able to view the SSID and connect using the passphrase.
: This configuration will not assign an IP address automatically so you need to set it manually for the other device as well (from the same subnet).
If you want to remove the p2p group and return WPA to its original configuration, the simplest method is to reboot the device using the following command:
$ shutdown -r
down –r

Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.