8.7 Running in the ATWILC P2P Mode

A P2P group includes two devices: One device acts as a P2P Group Owner (GO) and the other device acts as a P2P Client. The ATWILC devices support both P2P GO and P2P Client modes. The following is the procedure to test P2P mode on ATWILC.

There are two scenarios in which the P2P mode can be tested. The following section describes each scenario:

Scenario 1 - WILC device as a group owner and mobile phone as a P2P client

Configuring the WILC device as a group owner:

  1. Load both the WILC modules, using the following command:
    modprobe wilc-sdio
    echo <mode> > /sys/wilc/p2p_mode
    where, mode = 1 for P2P GO and mode = 0 for P2P Client.
  2. Add the p2p0 virtual interface:
    iw phy0 interface add p2p0 type station
  3. Start the WPA supplicant service and open the P2P device, using the following command:
    wpa_supplicant -Dnl80211 -ip2p0 -c/etc/wilc_p2p_supplicant.conf &
  4. Configure the IP address of the P2P GO and start the DHCP server, using the following command:
    ifconfig p2p0 192.168.0.1
    /etc/init.d/S80dhcp-server start
  5. On the terminal, enter into wpa_cli interactive mode, using the following command:
    wpa_cli -ip2p0
    
  6. Scan for neighbouring P2P devices for specified duration, using the following command:
    p2p_find <scan_duration_in_seconds>
  7. After scan is complete, list the available P2P peers using the following command:
    p2p_peers

    This command lists the BSSID of the P2P peer.

  8. Connect to the P2P Client using the BSSID of the P2P peer, using the following command:
    p2p_connect <MAC_ADDRESS> pbc

Configuring a mobile phone as a P2P client:

In the Wi-Fi settings menu on the phone, enter into Wi-Fi Direct® mode and perform the following to establish the connection.

  • Trigger connection from WILC:
    1. Enter p2p_find command without timeout value on the WILC.

      The SSID of the P2P peer appears on the phone.

    2. Enter the p2p_connect command as shown above in the WILC. A pop-up window appears on the phone.
    3. Click the Accept button or prompt to connect.
  • Trigger connection from phone:
    1. Click the SSID displayed on the phone and send a P2P invite.
    2. Enter the p2p_connect <MAC_ADDRESS> pbc command in the WILC to form a P2P group.

Scenario 2 - WILC device as a P2P client and mobile phone as a group owner

Configuring WILC device as a P2P client:

  1. Load both the WILC modules, using the following command:
    modprobe wilc-sdio
  2. Add the p2p0 virtual interface:
    iw phy0 interface add p2p0 type station
  3. Start the WPA supplicant service and open the P2P device, using the following command:
    wpa_supplicant -Dnl80211 -ip2p0 -c/etc/wilc_p2p_supplicant.conf &
  4. On the terminal, enter into wpa_cli interactive mode, using the following command:
    wpa_cli -ip2p0
    
  5. Scan for neighbouring P2P devices for specified duration, using the following command:
    p2p_find <scan_duration_in_seconds>
  6. After the scan is complete, list the available P2P peers, using the following command:
    p2p_peers

    This command lists the BSSID of the P2P peer.

  7. Connect to the P2P Go using the BSSID of the P2P peer, using the following command:
    p2p_connect <MAC_ADDRESS> pbc go_intent=1
  8. Press Ctrl+c to exit the interactive mode.
  9. Run the DHCP client on the WILC to obtain IP address.
    dhcpcd p2p0 &

Configuring a mobile phone as a group owner:

In the Wi-Fi settings menu on the phone, enter into Wi-Fi Direct mode and perform the following to establish the connection.

  • Trigger connection from WILC:
    1. Enter the p2p_find command without time-out value on the WILC.

      The SSID of the P2P peer appears on the phone.

    2. Enter the p2p_connect command as shown above in the WILC. A pop-up window appears on the phone.
    3. Click the Accept button or prompt to connect.
  • Trigger connection from phone:
    1. Click the SSID displayed on the phone and send a P2P invite.
    2. Enter the p2p_connect <MAC_ADDRESS> pbc command in the WILC to form a P2P group.