6

I'm trying to make wifi-direct connection between Android and Linux. I'm using rtl8188au.

I found some tips about wifi direct by using wpa_supplicant, so I get wpa_supplicant v2.0. and this is what I did for wifi-direct.

1.Compiled rtl8288au driver, activated nl80211.
2.Compiled wpa_supplicant and wpa_cli for nl80211.
3.Run wpa_supplicant on linux, with option -Dnl80211. success.
4.Set ip address for wlan0.
5.Run wpa_cli, and try to connect to android device.

The connection can made success at once, but disconnected soon.

Here is wpa_cli logs.

wpa_cli -p /var/run/wpa_supplicant

> p2p_find
OK
<3>P2P-DEVICE-FOUND e6:fa:ed:8a:5e:e8 p2p_dev_addr=e6:fa:ed:8a:5e:e8 
pri_dev_type=10-0050F204-5 name='[Phone] Kulong' config_methods=0x188 
dev_capab=0x25 group_capab=0x0
>
>
> p2p_connect e6:fa:ed:8a:5e:e8 pbc
OK
<3>P2P-FIND-STOPPED
<3>P2P-DEVICE-FOUND e6:fa:ed:8a:5e:e8 p2p_dev_addr=e6:fa:ed:8a:5e:e8 
pri_dev_type=10-0050F204-5 name='[Phone] Kulong' config_methods=0x80 
dev_capab=0x25 group_capab=0x8
<3>P2P-GO-NEG-SUCCESS
<3>CTRL-EVENT-STATE-CHANGE id=-1 state=3 BSSID=00:00:00:00:00:00 SSID=
<3>CTRL-EVENT-CONNECTED - Connection to 38:1d:d9:d4:db:70 completed (auth) 
[id=0 id_str=]
<3>CTRL-EVENT-STATE-CHANGE id=0 state=9 BSSID=38:1d:d9:d4:db:70 SSID=DIRECT-4J
<3>CTRL-EVENT-EAP-STARTED e6:fa:ed:8a:de:e8
<3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=1
<3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=14122 method=254
<3>WPS-REG-SUCCESS e6:fa:ed:8a:de:e8 2d96823c-8a30-5dd0-a267-e3adae8b1564
<3>P2P-GROUP-FORMATION-SUCCESS
<3>P2P-GROUP-STARTED wlan0 GO ssid="DIRECT-4J" freq=2412 
passphrase="xZbKV6sF" go_dev_addr=38:1d:d9:d4:db:70
<3>WPS-SUCCESS
<3>CTRL-EVENT-EAP-FAILURE e6:fa:ed:8a:de:e8
<3>AP-STA-CONNECTED e6:fa:ed:8a:de:e8 p2p_dev_addr=e6:fa:ed:8a:5e:e8
<3>AP-STA-DISCONNECTED e6:fa:ed:8a:de:e8 p2p_dev_addr=e6:fa:ed:8a:5e:e8
<3>P2P-DEVICE-LOST p2p_dev_addr=e6:fa:ed:8a:5e:e8

Is there anything wrong?

If so, what should I do for complete wifi-direct connection?

4

It needs not only wpa_supplicant but also iwpriv, hostapd, dhcpd.

here is what I did for wifi-direct connect.

Device Mode ( Linux requests connection to Android)

ifconfig wlan0 192.168.1.15 up
iwpriv wlan0 p2p_set enable=0
iwpriv wlan0 p2p_get status
iwpriv wlan0 p2p_get role
iwpriv wlan0 p2p_set enable=1
iwpriv wlan0 p2p_set intent=1
iwpriv wlan0 p2p_get status
iwpriv wlan0 p2p_set op_ch=6
iwpriv wlan0 p2p_set ssid=DIRECT-RT
iwpriv wlan0 p2p_set setDN="RTL8192CU"
iwlist wlan0 scan
iwpriv wlan0 p2p_get2 wpsCM=<MAC_ADDRESS_OF_TARGET_DEVICE>
iwpriv wlan0 p2p_get2 devN=<MAC_ADDRESS_OF_TARGET_DEVICE>
iwpriv wlan0 p2p_set prov_disc=<MAC_ADDRESS_OF_TARGET_DEVICE>
iwpriv wlan0 p2p_set got_wpsinfo=3
iwpriv wlan0 p2p_set nego=<MAC_ADDRESS_OF_TARGET_DEVICE>
wpa_supplicant -i wlan0 -c ./wpa_0_8.conf -B
wpa_cli wps_pbc <MAC_ADDRESS_OF_TARGET_DEVICE>

GO Mode ( Android requests connection to Linux)

iwpriv wlan0 p2p_set enable=3
iwpriv wlan0 p2p_get status 
iwpriv wlan0 p2p_get role 
iwpriv wlan0 p2p_set intent=1
iwpriv wlan0 p2p_set op_ch=6
iwpriv wlan0 p2p_set ssid=DIRECT-RT
./hostapd -B ./p2p_hostapd.conf
<<<<< Request connection from Android >>>>
iwpriv wlan0 p2p_get peer_deva
iwpriv wlan0 p2p_get req_cm
iwpriv wlan0 p2p_set got_wpsinfo=3
iwpriv wlan0 p2p_get peer_ifa
./hostapd_cli wps_pbc any
ifconfig wlan0 192.168.1.254
dhcpd

But there's some necessary conditions for wifi-direct connection.

  1. Your wireless driver should support nl80211.
  2. Configure 'nl80211' option when MAKE wpa_supplicant, hostapd.
  3. dhcpd configuration files.(dhcpd.conf, dhcpd.lease)
  4. wpa_supplicant, hostapd configurations( conf files )

I hope this article may be useful for who wants wifi-direct between Linux and Android.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.