Filter results by

Wi-Fi Direct (P2P)

In addition to its normal Wi-Fi® client configuration, ARTIK can be set up for Wi-Fi Direct / Point-to-Point (P2P) communication.

Prerequisites

  • Connect to the ARTIK board with your usual terminal emulator program. If using two boards, you should connect with separate terminal instances over separate ports to each board.

Wi-Fi Direct / P2P Mode

The P2P (or Wi-Fi Direct) mode allows two devices to each connect with the Wi-Fi adapter of the other, without requiring a third party Access Point.

Steps:

  1. On the main board, update the wpa_supplicant.conf file for Wi-Fi Direct mode.
  2. Program the main board to Group Owner mode
  3. Follow the connect sequence that applies to the second device you want to use:
    • another ARTIK board
      – or –
    • an Android cell phone.

This procedure assumes that you are starting from a known-working state, where the boards already have WPA supplicant services configured and running successfully as a client. Refer to Configuring Wi-Fi on ARTIK for details.

Reconfigure Main Board WPA Supplicant Service

Perform these steps on the main board to configure it for operation in Group Owner mode. You only need to set this up once. If you plan to connect to a second board, you do not need to make these changes on that board.

  1. Start vi or another editor in order to modify the wpa_supplicant.conf file.
    # vi /etc/wpa_supplicant/wpa_supplicant.conf

  2. Select and copy the configuration details below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
ap_scan=2
ctrl_interface=/var/run/wpa_supplicant
update_config=0
device_name=Direct-p2p-mode
device_type=1-0050F204-1
config_methods=virtual_push_button physical_display keypad
p2p_go_intent=7
country=US
p2p_go_max_inactivity=600
p2p_go_ht40=1
disassoc_low_ack=1
p2p_listen_reg_class=81
p2p_listen_channel=36
driver_param=use_p2p_group_interface=1
  1. In the vi editor:
    • Use the cursor keys to position the cursor at the head of the file
    • Hit [Insert]
    • Hit [Enter] to create a blank line, and hit the Up arrow to go to it
    • Right-click the mouse to paste the copied section
    • Edit or comment out existing information if needed to eliminate conflicts.
  2. Hit [Esc] - [:] - [w] - [q] - [Enter] to write the changes and exit.
  3. Reset the board to use the new configuration file.

Run Main Board in Group Owner Mode

Copy each of the command lines below to the main board terminal emulator program at the prompt (#). You can right-click the mouse to paste.

  1. Stop any connection manager service currently being executed on the system.
    systemctl stop connman

  2. Start WPA supplicant service (if not already running).
    wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -Dnl80211&

  3. Program the board WPA supplicant service to Group Mode.
    wpa_cli -iwlan0 p2p_group_add

  4. Request the PIN. You will need this to set up the second board or phone.
    wpa_cli wps_pin any
    (returns 8-digit numeric < PIN >)

  5. Request pass phrase. You will need this only if connecting to a cell phone.
    wpa_cli -ip2p-wlan0-0 p2p_get_passphrase
    (returns alphanumeric < PASSPHRASE >)

  6. Assign an IP address.

    • For Static configuration, enter:
      ifconfig p2p-wlan0-0 192.168.1.15

    • or to use DHCP for automatic IP address assignment, enter:

      ifconfig p2p-wlan0-0 192.168.1.1 up

      dnsmasq -x /var/run/dnsmasq.pid-p2p-wlan0-0 -i p2p-wlan0-0 -F192.168.1.11,192.168.1.99

The main board is now set for communicating with either another board or a phone with P2P capability.

Take the following steps to P2P-connect a second ARTIK board to the first. Note that you should not need to modify the configuration file of the second board.

Set Up the Connection

  1. Stop any connection manager service currently being executed on the system.
    systemctl stop connman

  2. Start WPA supplicant service (if not already running).
    wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -Dnl80211&
    You should see a 'success' message and may also see some other warnings.

  3. Search for available P2P connections.
    wpa_cli p2p_find 10

    The search returns all active devices found. Look for the one with the name you gave it in the configuration file (Direct-p2p-mode).

  4. Compose the command line to establish a connection.

    a. Copy the line below to the terminal emulator, but do not hit [Enter] yet:
    wpa_cli p2p_connect [addr] [PIN] join

    b. Use the mouse to highlight the p2p_dev_addr= value (in the example above it is ea:50:8b:97:86:86). Use the keyboard to get to [addr] and delete it, then right-click the mouse to copy in the highlighted value.

    c. Similarly, use the mouse to highlight the 8-digit PIN number, but in the main board terminal emulator window. Back in the second board terminal window, use the keyboard to delete [PIN], then right-click the mouse to insert the highlighted value.

    d. Make sure join still appears at the end of the line, then hit [Enter].

  5. Assign an IP address to the second board.

    • For Static configuration, enter:
      ifconfig p2p-wlan0-0 192.168.1.14

    • or to use DHCP for automatic IP address assignment, enter:
      dhclient -v p2p-wlan0-0
      and use the 'bound to' IP address provided when referencing this second board.

Test the Connection

From the second board, try pinging the main board:
ping 192.168.1.15 (static)
ping 192.168.1.1 (DHCP)

Now try copying a file that you know to exist on the main board, for example:
scp root@192.168.1.15:./player.c .

Take the following steps on a P2P-capable cell phone to connect it to the main board you configured earlier.

Set Up the Connection

These operations all take place on the phone itself.

  1. Select Settings for Wi-Fi to add a new device.

  2. Find and select the < SSID > or identifier for the main board. It may be something like:
    DIRECT-xx

  3. Input < PASSPHRASE > that you got from the main board.

  4. Configure the IP address on the cell phone.
    For Static configuration, enter:

    • IP address [192.168.1.15]
    • Default gateway [192.168.1.1]

    or to use DHCP for automatic IP address assignment, simply select DHCP.

Test the Connection

Test from the board for a response from the phone:
ping 192.168.1.15 (or the IP address chosen by DHCP)

Last updated on: