Realtek Start Guide P2P User Interface
Date: 2011/09/01
Version: 0.5
Start Guide P2P User Interface
Files:
All the necessary files are available in the “WiFi_Direct_User_Interface” folder of Realtek software package.
Definitions:
(1)P2P Device: WFA P2P certified device that is capable of acting as both a P2P Group Owner and a P2P Client.
(2)P2P Group Owner (GO): An “AP(Access Point)-like” entity that may provide and use connectivitybetween P2P Clients
(3)P2P Client: A P2P Device that is connected to a P2P Group Owner.
1Modify wpa_supplicant, wpa.conf, hostapd, hostapd.conf path at first.
In p2p_ui_test_linux.c, default paths for wpa_path, wpa_conf, ap_path and ap_conf were located in our test PC, so it’s mandatory to change these four paths.
2P2P_UI
2.1#gcc -o P2P_UI ./p2p_ui_test_linux.c ./p2p_api_test_linux.c -lpthread
2.2Launch the P2P_UI with interface (eg. wlan0)
#./P2P_UI wlan0
(The window size of user interface is recommended to set 100x40)
3Start using the P2P_UIto connect to other P2P device.(active connection)
We could use P2P functionalities sequentially from top to down as the P2P_UI lists.
3.1Enable P2P functionality (insert cmd:e).
[0] Disable P2P device, disable P2P functionalities
[1] Enable P2P device
[2] Enable P2P device and set as P2P client as default
[3] Enable P2P device and set as P2P GO as default
When using user interface in first time, it’s recommended that enable in p2p device mode.
If we select [1], user interface will scan p2p devices automatically.
3.2Set P2P device intent
3.2.1It’s the degree that we want our P2P device becoming a P2P client or P2P GO(insert cmd:i).
3.2.2degree from [0-15]
3.2.3ps: intent = 15 means this P2P device must be the P2P GO.
3.3Scan P2P devices (insert cmd: a).
After scaning,the P2P_UI will show the scan results of p2p device name, BSSID, if is GO (with *) and config methods that are supported.
Abbreviation for config methods:
LAB: LabelVDIS: Virtual DisplayPDIS: Physical Display
DIS: DisplayENFC: External NFC Token
INFC: Integrated NFC TokenNFC: NFC Interface
VPBC: Virtual Push ButtonPPBC: Physical Push Button
PBC: Push Button
3.4Set peer device address (insert cmd: m).
3.4.1From scan list, we could choose one P2P device to start the P2P connection.
3.4.2Input the numberof device that we want to do P2P handshake.
3.5Issue provision discovery frame (insert cmd: p).
3.5.1The purpose for issuing the provision discovery frame is to set/get the WPS PIN CODE or WPS PBC to/from peer P2P device.
3.5.2In version 0.5, the following procedures of P2P handshake (including set WPS method, group owner negotiation, start wpa_supplicant or hostapd and DHCP client/server) is combined in this step.
3.5.3Select the way to get the WPS configuration method we want to use.
[0]:We input the PIN code that displays on peer device screen.
[1]:Our screen display PIN code and input this PIN code on the peer device
*If we use this WPS configure method, we should input PIN code at first(see 6.4) or use default PIN code: 12345670.
[2]: Both P2P devices will use the WPS PBC
[3]: We input the PIN code that printed on peer device WPS label(like sticker).
3.5.4After 3.5.3, we issue provision discovery and also declaring which WPS method we want to use( this information is inside provision discovery frame)
3.5.5We check p2p status, if status==P2P_STATE_RX_PROVISION_DIS_RSPthen we set the corresponding config method to driver.
3.5.6Then we start negotiation.
3.5.7In group owner negotiation procedure, we will query status regularly.If we detected that status==P2P_STATE_GONEGO_OK, then we will show the P2P handshake successful message.
3.5.8Now, in this example, we set intent==1 and our role is client, so we start wpa_supplicant automatically.We also require wpa_supplicant start WPS connection with the config method that we set before.
3.5.9If wpa_supplicant using WPS connection success, it will show wpa state like the following:
3.5.10After WPS connection successful, user interface will run DHCP client automatically. That time, two P2P devices connected successfully, we could try to ping each other.
3.5.11Otherwise, if our role is P2P GO, then we start hosapd automatically and require it starts WPS connection with the config method that we set before. The following is the information that the client connected successfully, using WPS connection.
3.5.12If WPS connection success, GO will run DHCP server. That time, two P2P devices connected successfully, we could try to ping each other.
*Our P2P_UI is implementing in Fedora, so the route with DHCP server in P2P_UI is writing as default route in Fedora. If you are using another Linux OS, it’s recommended that changing DHCP server route in P2P_UI or marked #define DHCP.
4Start using the P2P_UI to be connectedby other P2P device. (passive connection)
4.1We enable p2p functionalities at first (enable as P2P device)
4.2If we enable as P2P device, then we do polling status with intervalPOLLING_INTERVAL.
4.3Set P2P device intent as 3.2
4.4Set scan as 3.3, for our driver, we only accept P2P handshake request that in our scan list.
4.5If we detected that peer P2P device issue provision discovery request,our status will beP2P_STATE_RX_PROVISION_DIS_REQ, then our driver will respond provision discovery response frame and we will check what config method that peer P2P device want to set as WPS connection and do the corresponding actions:
4.5.1If it’s PIN code and peer device want us to input PIN code on their display, then we will show the following information and we need to input peer’s PIN code,
4.5.2If it’s PIN code and peer P2P device wants to input our PIN code on their device (or input the PIN code that displays on our label), then we need insert command “c” as accepted.
4.5.3If it’s PBC, then we need insert command “b” as accepted.
4.6The following procedures will be similar as 3.5.6
5When P2P device wants to connect P2P GO.
5.1When our driver becomes as P2P GO, we still do polling our driver status to check if some other P2P devices connected.
5.2If P2P GO received provision discovery request from others, the state in P2P GO will be P2P_STATE_RX_PROVISION_DIS_REQ and will respond provision discovery response.
5.3UI will show the information like 4.5.1~4.5.3.
5.4When one P2P device connects to P2P GO, it doesn’t need to do further negotiation handshake. So driver will use the corresponding configuration method to do WPS connection.
5.5If WPS successful, P2P GO successfully connected with other P2P device, it will show like 3.5.11
5.6We could test it’s scenariowithout any P2P handshake before, just Enable P2P device and set as P2P GO as default.
6For customers optimized their own user interface, we keep the previous version of commands that letting customers to start P2P handshake procedure individually.
6.1Marked #defineP2P_AUTO1 before compiled P2P_UI.
6.2With this version, the first 3 steps are the same as 3.1~3.4
6.3Issue provision discovery frame (insert cmd: p).
6.3.1The purpose for issuing the provision discovery frame is to set/get the WPS PIN CODE or WPS PBC to/from peer P2P device.
6.3.2Select the way to get the WPS configuration method we want to use.
[0]: We input the PIN code that displays on peer device screen.
[1]: Our screen display PIN code and input this PIN code on the peer device
*If we use this WPS configure method, we should input PIN code at first (see 6.4) or use default PIN code: 12345670.
[2]: Both P2P devices will use the WPS PBC
[3]: We input the PIN code that printed on peer device WPS label (like sticker).
6.3.3After 6.3.2, we issue provision discovery request and also declaring which WPS method we want to use( this information is inside provision discovery frame)
6.4Input PIN codes (insert cmd: c).
6.4.1This step is optional because the P2P_UI already provides the default PIN Code
6.4.2The P2P_UI willcheck the validation of the inputted PIN code. If we want use [1] in 6.3.2, it’s recommended that we input PIN code before issuing provision discovery
6.4.3If we select [0] in 6.3.2, we input PIN code that displays on the screen of peer P2P device.
6.4.4We don’t need to input PIN code if you select the [2] in 6.3.2
6.4.5If we select [3] in 6.3.2, we should input the PIN code which printed on the label of peer P2P device.
6.5Set WPS configuration method (insert cmd: w).
6.5.1This command is used to inform the P2P driver that the P2P_UI already received the WPS PIN code or WPS PBC. The WPS PIN code and WPS PBC should be acquired by using the command 6.3 and 6.4.
6.5.2We will set WPS configuration method based on 6.3 we issued.
If you select the [0] in 6.3, we will choose the [1] here.
If you select the [1] in 6.3, we will choose the [2] here.
If you select the [2] in 6.3, we will choose the [3] here.
If you select the [3] in 6.3, we will choose the [1] here.
6.6Issue group owner negotiation ( insert cmd: n)
6.6.1It will do the group owner negotiation handshake.If our intent is lower than peer device, the P2P_UI would start wpa_supplicant automatically and act as P2P client.
6.6.2Else, if our intent is higher than peer device, the P2P_UI would start hostapd automatically and act as P2P GO.
6.6.3For group owner negotiation procedure, it could be issued by one of two P2P devices.
6.7DHCP
6.7.1If wpa_supplicant reported“wpa_state=COMPLETED”, it means P2P connection is established successfully and P2P_UI will start dhclient automatically to try to get the IP from the P2P GO.
6.7.2If hostapd reported “dot11RSNAStatsSTAAddress=XX:XX:XX:XX:XX:XX”, it means the P2P connection is established successfully and the P2P_UI will start DHCP server automatically.
6.8For the other P2P device (passive connected), it could do re-flash current state to check whether P2P device connected using P2P handshake.
7Optional commands.
The following are some optional commands that could set or get information from drivers.
7.1Set operation channel (insert cmd: h)
7.1.1It is optional command because the P2P_UI will have the rule to determine the default value for the operation channel. However, this information will be ignored if this P2P device is the P2P client after the group owner negotiation handshake. Also, if hostapd is running, we could not change this value, same as 7.2 and 7.5
7.1.2The P2P_UI will use the value of “channel“ in /hostapd.conf as default value.
7.1.3This operation channel is the channel number which the P2P GO should stay if the local P2P device is the GO.
7.1.4Notice that the value should be the same asthe value of “channel” in /hostapd.conf
7.2Set softAP ssid (insert cmd: t)
7.2.1It’s optional because the P2P_UI will use the content of “ssid”in /hostapd.conf as default
7.2.2This command will inform other drivers the ssid string if this P2P device is the GO.
7.2.3Notice that the value should be the same as the content of “ssid” in /hostapd.conf
7.3Get current P2P role (insert cmd: r)
You can check the P2P role which the driver is acting as.
0: Disable
1: P2PDevice
2:P2PClient
3: P2PGO
7.4Get current P2P status (insert cmd: s)
You can check the current P2P status that the driver stands for.
0: P2P_STATE_NONE
1: P2P_STATE_IDLE
2: P2P_STATE_LISTEN
3: P2P_STATE_SCAN
4: P2P_STATE_FIND_PHASE_LISTEN
5: P2P_STATE_FIND_PHASE_SEARCH
6: P2P_STATE_TX_PROVISION_DIS_REQ
7: P2P_STATE_RX_PROVISION_DIS_RSP
8:P2P_STATE_RX_PROVISION_DIS_REQ
9: P2P_STATE_GONEGO_ING
10: P2P_STATE_GONEGO_OK
11: P2P_STATE_GONEGO_FAIL
12: P2P_STATE_RECV_INVITE_REQ
13: P2P_STATE_PROVISIONING_ING
14: P2P_STATE_PROVISIONING_DONE
7.5Set device name (insert cmd: d)
Set the device name which will be seeing by the other P2P devices. In Default we get this name from /hostapd.conf.
7.5.1It’s optional because the P2P_UI will use the content of “ssid” in /hostapd.conf as default
7.5.2This command will set the P2P device name which will be seeing by other P2P devices.
7.5.3Notice that the value should be the same as the content of “ssid” in /hostapd.conf
7.6Set listen channel (insert cmd: l)
Set the listen channel where the device will stay in the listen state, the listen channel will set channel 1, 6, 11 only, as the spec. described.
7.7Reflash current state (insert cmd: f)
It will reflash current state and other information that P2P_UI maintains.
7.8Quit (insert cmd: q)
Quit P2P user interface, P2P functionality will be disabled.