WiFi direct allows for devices to connect and communicate without requiring an access point. The following article describes how to enable and test WiFi Direct (P2P) on two phyBOARD-Mira development kits.
- You will need to have a working build of the BSP to make the package adjustments described below. Instructions for building the BSP are provided in the BSP manual: i.MX6 BSP Manual
- The wpa_supplicant package is a requirement for using WiFi direct. On your host PC verify that the package has been included in your build by checking the local.conf build configuration file. In your BSP directory the file is located in the following location.
Code Block |
---|
vim /<BSP Directory>/build/conf/local.conf |
- In the local.conf file verify that the following line has been added.
Code Block |
---|
IMAGE_INSTALL_append = " wpa-supplicant" |
- Navigate to the wpa-supplicant source in your Yocto BSP.
Code Block |
---|
cd /<BSP DIRECTORY>/build/tmp/work/cortexa9hf-neon-phytec-linux-gnueabi/wpa-supplicant/2.5-r0/wpa_supplicant-2.5/ |
- Open the wpa-supplicant configuration file and enable CONFIG_P2P by uncommenting the line CONFIG_P2P=y in the file
Code Block |
---|
vim wpa_supplicant/.config |
Code Block |
---|
# P2P (Wi-Fi Direct)
# This can be used to enable P2P support in wpa_supplicant. See README-P2P for
# more information on P2P operations.
CONFIG_P2P=y |
- Navigate back to the root BSP Directory and prepare to re-build.
Code Block |
---|
cd /<BSP DIRECTORY>/ |
- Run the following command to setup your build environment variables. This step is required each time you build in a new shell session.
Code Block |
---|
source sources/poky/oe-init-build-env |
- Run the following commands to rebuild the wpa_supplicant package and regenerate the root filesystem image. phytec-headless-image is used in this example but if you used a different recipe in your BSP build (ex. phytec-qt5demo-image) you will want to use the recipe name in place of phytec-headless-image.
Code Block |
---|
bitbake -f -c compile wpa-supplicant
bitbake phytec-headless-image |
- Built images are located in the following location. Use the instructions in the BSP Manual to update the filesystem on both sets of hardware.
Code Block |
---|
/<BSP DIRECTORY>/build/deploy/images/phyboard-mira-imx6-#/ |
Update the wpa_supplicant.conf file for WiFi Direct
The following instructions will need to be done on both phyBOARD-Mira boards for proper WiFi Direct configuration. These steps should only need to be done once, after the files are saved they do not to be repeated when you reboot the board.
- Make sure the boards are connected to separate terminal emulators, power on, and boot into Linux.
- Edit the wpa_supplicant file using the vi editor.
Code Block |
---|
vi /etc/wpa_supplicant |
- Use the editor to make the following modifications to the file. Comment out the 'network' node and change the 'device_name' to something unique for each device. save and exit.
Code Block |
---|
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
device_name=<unique device name>
device_type=2-0050F204-1
p2p_listen_reg_class=81
p2p_listen_channel=1
p2p_oper_reg_class=81
p2p_oper_channel=1
p2p_go_intent=1
p2p_no_group_iface=1
#network={
# key_mgmt=NONE
#} |
- Reboot the unit to load the new configuration settings
Start Main Board in Group Owner Mode
Choose one of the units to be the Group owner. The unit selected is referred to as phyBOARD-Mira #1 (Group Owner) in this guide.
Follow the below commands to initiate the group. After setting up the group make sure to note the group owner MAC address and group pin as this information will be needed when you connect a device.
- Restart the wlan0 interface and assign an IP address. 192.168.3.10 is used in this example but this can be replaced with another value.
Code Block |
---|
ifconfig wlan0 down
ifconfig wlan0 192.168.3.10 |
- Start wpa_supplicant service using the following command
Code Block |
---|
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -Dnl80211& |
- Run the following command to start wpa_cli interactive mode
Command | Result |
---|
Code Block |
---|
wpa_cli -i wlan0 |
| Code Block |
---|
root@phyboard-mira-imx6-10:~# wpa_cli -i wlan0
wpa_cli v2.5
Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
Interactive mode
> |
|
- Create a new group from this prompt by entering the following. Note the device MAC Address as this will be needed to connect the second device. In this example the device MAC address is
5c:31:3e:f1:32:61.
Command | Result |
---|
| Code Block |
---|
> p2p_group_add
OK
> wlcore: down
Using interface wlan0 with hwaddr 5c:31:3e:f1:32:61 and ssid
"DIRECT-Xo"
random: Cannot read from /dev/random: Resource temporarily
unavailable
random: Only 15/20 bytes of strong random data [ 540.760138] IPv6:
ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
available from /dev/random
random: Not enough entropy pool available for secure operations
WPA: Not enough entropy in random pool for secure operations -
update keys later when the first station connects
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
<3>AP-ENABLED
wlan0: CTRL-EVENT-CONNECTED - Connection to 5c:31:3e:f1:32:61
completed [id=0 id_str=]
<3>CTRL-EVENT-CONNECTED - Connection to 5c:31:3e:f1:32:61
completed [id=0 id_str=]
<3>P2P-GROUP-STARTED wlan0 GO ssid="DIRECT-Xo" freq=2412
passphrase="xL21xNTG" go_dev_addr=5c:31:3e:f1:32:61
P2P-GROUP-STARTED wlan0 GO ssid="DIRECT-Xo" freq=2412
go_dev_addr=5c:31:3e:f1:32:61 |
|
- Request a pin which will be used to connect the second device. In this example the pin is 38218958.
Command | Result |
---|
| Code Block |
---|
> > wps_pin any
38218958 |
|
Connect Second Board to the Group
The other phyBOARD-Mira can now be used to connect to the established group. This unit is referred to as phyBOARD-Mira #2 in this guide.
- Restart the wlan0 interface and assign an IP address. 192.168.3.11 is used in this example but this can be replaced with another value.
Code Block |
---|
ifconfig wlan0 down
ifconfig wlan0 192.168.3.11 |
- Start wpa_supplicant service using the following command
Code Block |
---|
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -Dnl80211& |
- Run the following command to start wpa_cli interactive mode
Command | Result |
---|
Code Block |
---|
wpa_cli -i wlan0 |
| Code Block |
---|
root@phyboard-mira-imx6-10:~# wpa_cli -i wlan0
wpa_cli v2.5
Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
Interactive mode
> |
|
- Connect to the group using the group owner MAC address (ex. 5c:31:3e:f1:32:61) and group pin (38218958)
Command | Result |
---|
Code Block |
---|
p2p_connect 5c:31:3e:f1:32:61 38218958 join |
| Code Block |
---|
> > p2p_connect 5c:31:3e:f1:32:61 38218958 join
OK
<3>CTRL-EVENT-SCAN-STARTED
P2P-DEVICE-LOST p2p_dev_addr=72:5a:0f:a2:65:0f
<3>P2P-DEVICE-LOST p2p_dev_addr=72:5a:0f:a2:65:0f
P2P-DEVICE-LOST p2p_dev_addr=aa:6b:ad:1d:b4:93
<3>P2P-DEVICE-LOST p2p_dev_addr=aa:6b:ad:1d:b4:93
P2P-DEVICE-LOST p2p_dev_addr=5c:31:3e:f1:32:61
<3>P2P-DEVICE-LOST p2p_dev_addr=5c:31:3e:f1:32:61
P2P-DEVICE-FOUND 5c:31:3e:f1:32:61
p2p_dev_addr=5c:31:3e:f1:32:61 pri_dev_type=2-0050F204-1
name='mira62' config_methods=0x1108 dev_capab=0x25
group_capab=0x89 new=1
<3>P2P-DEVICE-FOUND 5c:31:3e:f1:32:61
p2p_dev_addr=5c:31:3e:f1:32:61 pri_dev_type=2-0050F204-1
name='mira62' config_methods=0x1108 dev_capab=0x25
group_capab=0x89 new=1
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-RESULTS
[ 982.831281] wlcore: down
wlan0: SME: Trying to authenticate with 5c:31:3e:f1:32:61
(SSID='DIRECT-Cb' freq=2412 MHz)
<3>SME: Trying to authenticate with 5c:31:3e:f1:32:61 (SSID='DIRECT-
Cb' freq=2412 MHz)
[ 982.881348] wlan0: authenticate with 5c:31:3e:f1:32:61
[ 982.912994] wlan0: send auth to 5c:31:3e:f1:32:61 (try 1/3)
[ 983.007061] wlan0: authenticated
wlan0: Trying to associate with 5[ 983.013183] wlan0: associate with
5c:31:3e:f1:32:61 (try 1/3)
c:31:3e:f1:32:61 (SSID='DIRECT-Cb' freq=2412 MHz)
<3>Trying to associate with 5c:31:3e:f1:32:61 (SSID='DIRECT-Cb'
freq=2412 MHz)
[ 983.042538] wlan0: RX AssocResp from 5c:31:3e:f1:32:61
(capab=0x411 status=0 aid=1)
[ 983.072490] wlan0: associated
wlan0: Associated with 5c:31:3e:f1:32:61
wlan0: CTRL-EVENT-EAP-STARTED EAP authentication started
<3>Associated with 5c:31:3e:f1:32:61
<3>CTRL-EVENT-EAP-STARTED EAP authentication started
<3>CTRL-EVENT-EAP-STATUS status='started' parameter=''
wlan0: CTRL-EVENT-EAP-PROPOSED-METHOD vendor=14122
method=1
wlan0: CTRL-EVENT-EAP-METHOD EAP vendor 14122 method 1 (WSC)
selected
<3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=14122 method=1
<3>CTRL-EVENT-EAP-STATUS status='accept proposed method'
parameter='WSC'
<3>CTRL-EVENT-EAP-METHOD EAP vendor 14122 method 1 (WSC)
selected
wlan0: WPS-CRED-RECEIVED
<3>WPS-CRED-RECEIVED
wlan0: WPS-SUCCESS
<3>WPS-SUCCESS
P2P-GROUP-FORMATION-SUCCESS
<3>P2P-GROUP-FORMATION-SUCCESS
<3>CTRL-EVENT-EAP-STATUS stat[ 984.012672] wlan0:
deauthenticating from 5c:31:3e:f1:32:61 by local choice (Reason:
3=DEAUTH_LEAVING)
us='completion' parameter='failure'
wlan0: CTRL-EVENT-EAP-FAILURE EAP authentication failed
<3>CTRL-EVENT-EAP-FAILURE EAP authentication failed
[ 984.100603] cfg80211: Calling CRDA to update world regulatory
domain
wlan0: CTRL-EVENT-DISCONNECTED bssid=5c:31:3e:f1:32:61 reason=3
locally_generated=1
<3>CTRL-EVENT-DISCONNECTED bssid=5c:31:3e:f1:32:61 reason=3
locally_gene[ 984.121130] wlan0: authenticate with 5c:31:3e:f1:32:61
rated=1
wlan0: SME: Trying to authenticate with 5c:31:3e:f1:32:61
(SSID='DIRECT-Cb' freq=2412 MHz)
<3>SME: Trying to authenticate with 5c:31:3e:f1:32:61 (SSID='DIRECT-
Cb' freq=2412 MHz)
[ 984.174477] wlan0: send auth to 5c:31:3e:f1:32:61 (try 1/3)
[ 984.181682] cfg80211: World regulatory domain updated:
[ 984.186955] cfg80211: DFS Master region: unset
[ 984.191337] cfg80211: (start_freq - end_freq @ bandwidth),
(max_antenna_gain, max_eirp), (dfs_cac_time)
[ 984.201224] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz),
(N/A, 2000 mBm), (N/A)
[ 984.209330] cfg80211: (2457000 KHz - 2482000 KHz @ 40000 KHz),
(N/A, 2000 mBm), (N/A)
[ 984.217435] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz),
(N/A, 2000 mBm), (N/A)
[ 984.225537] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz,
160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
[ 984.235143] cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz,
160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
[ 984.244787] cfg80211: (5490000 KHz - 5730000 KHz @ 160000 KHz),
(N/A, 2000 mBm), (0 s)
[ 984.253016] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz),
(N/A, 2000 mBm), (N/A)
[ 984.261075] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000
KHz), (N/A, 0 mBm), (N/A)
wlan0: CTRL-EVENT-REGDOM-CHANGE i[ 984.270961] wlan0:
authenticated
nit=CORE type=WORLD
<3>CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: Tryi[ 984.282170] wlan0: associate with 5c:31:3e:f1:32:61 (try
1/3)
ng to associate with 5c:31:3e:f1:32:61 (SSID='DIRECT-Cb' freq=2412
MHz)
<3>Trying to associate with 5c:31:3e:f1:32:61 (SSID='DIRECT-Cb'
freq=2412 MHz)
[ 984.313220] wlan0: RX AssocResp from 5c:31:3e:f1:32:61
(capab=0x411 status=0 aid=1)
[ 984.333125] wlan0: associated
wlan0: Associated with 5c:31:3e:f1:32:61
<3>Associated with 5c:31:3e:f1:32:61
wlan0: WPA: Key negotiation completed with 5c:31:3e:f1:32:61
[PTK=CCMP GTK=CCMP]
<3>WPA: Key negotiation completed with 5c:3[ 984.404425] wlcore:
Association completed.
1:3e:f1:32:61 [PTK=CCMP GTK=CCMP]
wlan0: CTRL-EVENT-CONNECTED - Connection to 5c:31:3e:f1:32:61
completed [id=0 id_str=]
<3>CTRL-EVENT-CONNECTED - Connection to 5c:31:3e:f1:32:61
completed [id=0 id_str=]
<3>P2P-GROUP-STARTED wlan0 client ssid="DIRECT-Cb" freq=2412
psk=a672d38839deaf700ef1a114f958f0f4b7699e9887cd613376f94b46
f7ca8073
go_dev_addr=5c:31:3e:f1:32:61
P2P-GROUP-STARTED wlan0 client ssid="DIRECT-Cb" freq=2412
go_dev_addr=5c:31:3e:f1:32:61 |
|
Test the connection
Make sure the wpa_cli Interactive menu has been exited by entering 'q'.
- Ping each of the boards. For this example the ping test looks like the following. If the test is successful you should receive data back from the ping request.
phyBOARD-Mira #1 (Group Organizer) | phyBOARD-Mira #2 |
---|
Code Block |
---|
ping 192.168.3.11 |
| Code Block |
---|
ping 192.168.3.10 |
|
- Copy a file from the group owner to the device.
- Create a test file on the phyBOARD-Mira #1 (Group Organizer)
Code Block |
---|
echo "Hello World" > test.txt |
- Use scp on phyBOARD-Mira #2 to copy the file.
Code Block |
---|
scp root@192.168.3.10:./test.txt . |
- Verify that the file was copied correctly on the phyBOARD-Mira #2
Code Block |
---|
cat test.txt
# Expected result
Hello World |
Related articles
Content by Label |
---|
showLabels | false |
---|
max | 5 |
---|
spaces | SUP |
---|
showSpace | false |
---|
sort | modified |
---|
reverse | true |
---|
type | page |
---|
cql | label = "kb-article" and type = "page" and space = "PRODUCTINFO" |
---|
labels | wifi p2p |
---|
|