WIFI P2P User Guide


1. Overview

This article mainly introduces the use of SSTAR WIFI P2P under Linux system. P2P uses GC and GO to connect and communicate using wpa_supplicant. The following wpa_supplicant uses Version 2.6.

Note:

If the development board, mobile phone, and Windows 10 computer are connected via wifi display, the connection will be disconnected soon if no image is transmitted. According to the test, the Windows 10 computer will be disconnected in about 1 minute after connection, and P2P_LISTEN needs to be re-executed.


2. Compile the macros that need to be turned on

You can choose either NL80211 or WEXT. NL80211 is recommended.


3. Configuration File

Copy p2p_supplicant.conf to the board\customer\wifi directory:

p2p_supplicant.conf

Required documents:

ctrl_interface=/tmp/p2p_supplicant //Create a netlink interface to interact with wpa_supplicant

update_config=1 //The connected device information will refresh the configuration file here

device_name=IPC_DEVICES2 //The name of the device being broadcast

device_type=10-0050F204-5 //There are many types. For the current test, just configure this file directly.

config_methods=virtual_push_button physical_display keypad //Configure according to this file

p2p_ssid_postfix=-IPC_DEVICES2

persistent_reconnect=1 //Reconnect

Optional Files:

p2p_listen_reg_class=81

p2p_listen_channel=1

p2p_oper_reg_class=115

p2p_oper_channel=36

p2p_go_intent=15 //go and gc negotiation level, 15 is the highest, so it will become go (After configuration, the module will always do go, that is, ap)

country=CN

4. Device execution steps

4.1. Device as GO

  1. Run wpa_supplicant

    SSTAR WIFI can only use p2p0 for P2P function.

    ./wpa_supplicant -i p2p0 -Dnl80211 -c p2p_supplicant.conf -B
    

    Because it will act as a GO, you need to configure a DHCP server.

    ifconfig p2p0 192.168.100.1
    ./dnsmasq -i p2p0 --no-daemon --no-resolv --leasefile-ro --no-poll --dhcp-range=192.168.100.2,192.168.100.254,12h &
    or:
    ./dnsmasq -i p2p0 --no-daemon -C /customer/wifi/dnsmasq.conf &
    
  2. Enter the interactive interface with the wpa_supplicant command

    ./wpa_cli –p /tmp/p2p_supplicant
    

    Set P2P related parameters

    SET wifi_display 1
    WFD_SUBELEM_SET 0 000600111c440032
    P2P_GROUP_ADD persistent=0
    P2P_FLUSH
    P2P_SET listen_channel 6
    P2P_LISTEN
    

    image.png

  3. Set wpa_supplicant parameters derectly

    ./wpa_cli -p /tmp/p2p_supplicant SET wifi_display 1
    ./wpa_cli -p /tmp/p2p_supplicant WFD_SUBELEM_SET 0 000600111c440032
    ./wpa_cli -p /tmp/p2p_supplicant P2P_GROUP_ADD persistent=0
    ./wpa_cli -p /tmp/p2p_supplicant P2P_FLUSH
    ./wpa_cli -p /tmp/p2p_supplicant P2P_SET listen_channel 6
    ./wpa_cli -p /tmp/p2p_supplicant p2p_LISTEN
    
  4. After the execution is completed, you can search for the IPC_DEVICES2 (or ssw101bap) device in the corresponding interface of other devices (mobile phones or Windows 10).

    Windows 10 P2P Interface:

    Mobile P2P interface:

  5. The board actively connects to the phone in GO mode

    P2p_find 10:

    Search for 10 seconds, you can stop the search with p2p_stop_find

    p2p_peers:

    View the searched P2P devices, only the MAC address is displayed, and some can be connected

    p2p_connect 02:08:22:da:fc:fb pbc go_intent=15

  6. Connect to the phone as GO. After the board enters the command, wait for the phone to confirm

    Mobile phone display:

    After clicking accept on your mobile phone:

    Note: The mobile phone needs to confirm as soon as possible, otherwise a timeout error will occur

  7. The phone actively connects to the board, and the device forces GO mode to connect

    P2P_SET listen_channel 6

    P2P_LISTEN, set the monitoring channel and enter the monitoring mode, the phone will display the device

    Mobile phone initiates connection

    The board prints as follows:

    The board is forced to act as GO and answer the connection initiated by the mobile phone:

    Connection Status:

  8. The device is in GO mode, and the phone actively connects to the board

    Mobile phone initiates connection:

    Confirm the connection on the board:

    Note:

    The mobile phone needs to respond as soon as possible after requesting a connection, otherwise a timeout error will occur.

    If a mobile phone actively initiates a connection, the phone will be disconnected in about 1 minute if it fails to send a picture after the connection.

  9. Check the status and connected devices

  10. Click on the phone to disconnect, the board is still in GO mode

  11. The board will be disconnected and will exit GO mode

    Enter disconnect in the command interface to disconnect.


4.2. Device as GC

  1. Run wpa_supplicant

    SSTAR WIFI can only use p2p0 for P2P function.

    p2p_supplicant.conf content:

    wpa_supplicant –ip2p0 –Dnl80211 –c p2p_supplicant.conf –B
    
  2. Enter the interactive interface with the wpa_supplicant command

    wpa_cli –p /tmp/p2p_supplicant
    

  3. Set P2P related parameters

    SET wifi_display 1
    WFD_SUBELEM_SET 0 000600111c440032
    P2P_FLUSH
    P2P_SET listen_channel 6
    P2P_LISTEN
    

    After the execution is completed, the IPC_DEVICES2 device will be searched in the corresponding interface of other devices (mobile phone or Windows 10).

    Windows 10 P2P Interface:

    Mobile P2P interface:

  4. The board actively initiates a connection in GC mode

    P2p_find 10, search for 10 seconds:

    p2p_peers:

    View the searched P2P devices, only the MAC address is displayed, and some can be connected

    p2p_connect 02:08:22:da:fc:fb pbc go_intent=0, connect to the mobile phone as GC.

    After entering the command on the board, wait for the phone to confirm:

    Mobile interface:

    After the mobile phone confirms, the board prints:

    After connecting, exit and obtain the IP address:

    Check status:

  5. The mobile phone actively initiates the connection, and the board responds to the connection in GC mode

    P2P_SET listen_channel
    
    6 P2P_LISTEN
    

    Set the monitoring channel and enter monitoring mode. The phone will display the device:

    The mobile phone initiates the connection to the board and prints the following:

    The board is forced to act as a GC and answer the connection initiated by the mobile phone:

    The connection is successful and the IP address is obtained:

    To disconnect, operate on the phone interface or enter disconnect on the board.

    image.png


4.3. Device as GO (AP)

  1. Configure p2p_supplicant.conf

    image.png

    ctrl_interface=/tmp/p2p_supplicant
    update_config=1
    device_name=IPC_DEVICES2
    device_type=10-0050F204-5
    config_methods=virtual_push_button physical_display keypad
    p2p_listen_reg_class=81
    p2p_listen_channel=1
    p2p_oper_reg_class=115
    p2p_oper_channel=36
    p2p_go_intent=15 p2p_ssid_postfix=-IPC_DEVICES2
    
    ## Newly added parts
    p2p_passphrase_len=8 #The password is limited to 8 characters
    p2p_no_group_iface=1 max_num_sta=8 #The maximum number of connections is 8
    network={
        ssid="DIRECT-IPC_DEVICES2"#Note that ssid must start with DIRECT-
        psk="12345678"
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP
        auth_alg=OPEN
        mode=3
        disabled=2
    }
    
  2. Run wpa_supplicant

    First execute rm -f /dev/random;ln -s /dev/urandom /dev/random

    Then execute wpa_supplicant -Dnl80211 -ip2p0 -c p2p_supplicant.conf -B

  3. Enter the interactive interface with the wpa_supplicant command

    Let P2P broadcast carry ssid, so that mobile phones can search for it:

    wpa_cli –p /tmp/p2p_supplicant SET wifi_display 1 wpa_cli –p /tmp/p2p_supplicant WFD_SUBELEM_SET 0 000600111c440032
    

  4. Force to enter GO mode

    wpa_cli –p /tmp/p2p_supplicant P2P_GROUP_ADD persistent=0
    

    Parameter Description:

    P2P_GROUP_ADD forces entry into GO mode.

    persistent=0

    persistent is configured as 1, a network configuration item will be generated in the p2p_supplicant.conf file. The ssid will have the Direct-xx information added in front of the ssid in the figure above, and the pwd will also change accordingly, resulting in a failure to connect normally when entering the password 12345678.

    When persistent is configured to 0, no new network configuration item will be generated. The ssid in beacon is the ssid in the network configured in p2p_supplicant.conf.

  5. GO name found by mobile p2p search

  6. Mobile phone initiates connection

    The ap found on the mobile wifi interface

  7. Connect your phone to the AP as a STA

    The printed information on the GO (AP) side is as follows:

    Note: No need to send commands, STA is the same as connecting to AP.