0

I'm trying to connect android and Raspberry PI using WIFI Direct. It is connected successfully but it's the disconnect after 10 seconds automatically.

My configuration file is as per below

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant

country=IN ap_scan=1 device_name=rasberry device_type=1-0050F204-1 driver_param=use_p2p_group_interface=1 p2p_go_intent=15 p2p_go_ht40=1 p2p_listen_reg_class=81 p2p_listen_channel=1 p2p_oper_reg_class=81 p2p_oper_channel=1

network={ ssid="DIRECT-Ke" bssid=52:6d:c8:0d:bf:4c psk="Y2s38gWz" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP auth_alg=OPEN mode=3 disabled=2 }

network={ ssid="DIRECT-Wx" bssid=62:cf:4f:8d:2d:d0 psk="rm9CdjHH" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP auth_alg=OPEN mode=3 disabled=2 }

network={ ssid="DIRECT-ZY" bssid=66:38:5e:c6:c0:38 psk="nR5wfpTa" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP auth_alg=OPEN mode=3 disabled=2 }

My Commands are as per below.

 root@raspberrypi:/home/pi# 
root@raspberrypi:/home/pi# pkill wpa_supplicant
root@raspberrypi:/home/pi# 
root@raspberrypi:/home/pi# 
root@raspberrypi:/home/pi# wpa_supplicant -B -iwlan0 -Dnl80211 -c /etc/wpa_supplicant/wpa_supplicant.conf
Successfully initialized wpa_supplicant
root@raspberrypi:/home/pi# wpa_cli -iwlan0 p2p_group_add persistent
OK
root@raspberrypi:/home/pi# ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether b8:27:eb:98:b2:af  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

p2p-wlan0-0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet6 fe80::7afe:3a80:7306:daac prefixlen 64 scopeid 0x20<link> ether aa:5c:a2:ac:60:88 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13 bytes 2236 (2.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether b8:27:eb:cd:e7:fa txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

root@raspberrypi:/home/pi# root@raspberrypi:/home/pi# wpa_cli -ip2p-wlan0-0 wps_pin any 0000 0000root@raspberrypi:/home/pi# root@raspberrypi:/home/pi# root@raspberrypi:/home/pi# root@raspberrypi:/home/pi# wpa_cli wpa_cli v2.8-devel Copyright (c) 2004-2019, Jouni Malinen <j@w1.fi> and contributors

This software may be distributed under the terms of the BSD license. See README for more details.

Selected interface 'p2p-wlan0-0'

Interactive mode

<3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0 <3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0 <3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0 <3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0 <3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0 <3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0 <3>WPS-ENROLLEE-SEEN 16:ad:ad:44:6d:08 52069f7c-c906-589a-8745-74c79d7d0d35 0-00000000-0 0x3148 0 1 [ ] <3>RX-PROBE-REQUEST sa=16:ad:ad:44:6d:08 signal=0 <3>WPS-ENROLLEE-SEEN 16:ad:ad:44:6d:08 52069f7c-c906-589a-8745-74c79d7d0d35 0-00000000-0 0x3148 0 1 [ ] <3>RX-PROBE-REQUEST sa=16:ad:ad:44:6d:08 signal=0 <3>WPS-ENROLLEE-SEEN 16:ad:ad:44:6d:08 52069f7c-c906-589a-8745-74c79d7d0d35 0-00000000-0 0x3148 0 1 [ ] <3>RX-PROBE-REQUEST sa=16:ad:ad:44:6d:08 signal=0 <3>CTRL-EVENT-SUBNET-STATUS-UPDATE status=0 <3>CTRL-EVENT-EAP-STARTED 8a:a3:03:ae:5e:ff <3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=1 <3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=14122 method=254 <3>WPS-REG-SUCCESS 8a:a3:03:ae:5e:ff 52069f7c-c906-589a-8745-74c79d7d0d35 <3>WPS-SUCCESS <3>CTRL-EVENT-EAP-FAILURE 8a:a3:03:ae:5e:ff <3>CTRL-EVENT-SUBNET-STATUS-UPDATE status=0 <3>AP-STA-CONNECTED 8a:a3:03:ae:5e:ff p2p_dev_addr=8a:a3:03:ae:de:ff > p2p_peers 8a:a3:03:ae:de:ff > > > > > status bssid=aa:5c:a2:ac:60:88 freq=2412 ssid=DIRECT-NU id=0 mode=P2P GO pairwise_cipher=CCMP group_cipher=CCMP key_mgmt=WPA2-PSK wpa_state=COMPLETED ip_address=169.254.68.39 p2p_device_address=aa:5c:a2:ac:e0:88 address=aa:5c:a2:ac:60:88 uuid=a745cd13-965d-5f14-ba81-c7e7e99f8391 <3>AP-STA-DISCONNECTED 8a:a3:03:ae:5e:ff p2p_dev_addr=8a:a3:03:ae:de:ff <3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0 <3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0 <3>RX-PROBE-REQUEST sa=8a:a3:03:ae:de:ff signal=0

Requested-Log of wpa_supplicant Connection creation and disconnected

AP-STA-CONNECTED fe:31:25:c7:57:0b p2p_dev_addr=fe:31:25:c7:57:0b
nl80211: Set STA flags - ifname=p2p-wlan0-0 addr=fe:31:25:c7:57:0b total_flags=0x61 flags_or=0x1 flags_and=0xffffffff authorized=1
hostapd_logger: STA fe:31:25:c7:57:0b - authorizing port
hostapd_logger: STA fe:31:25:c7:57:0b - pairwise key handshake completed (RSN)
EAPOL: disable timer tick
P2P: Expiring old peer entry fa:d0:27:39:c8:98
P2P-DEVICE-LOST p2p_dev_addr=fa:d0:27:39:c8:98
p2p-wlan0-0: Control interface command 'SCAN'
p2p-wlan0-0: Setting scan request: 0.000000 sec
p2p-wlan0-0: Starting AP scan for wildcard SSID
WPS: Building WPS IE for Probe Request
WPS:  * Version (hardcoded 0x10)
WPS:  * Request Type
WPS:  * Config Methods (3148)
WPS:  * UUID-E
WPS:  * Primary Device Type
WPS:  * RF Bands (1)
WPS:  * Association State
WPS:  * Configuration Error (0)
WPS:  * Device Password ID (0)
WPS:  * Manufacturer
WPS:  * Model Name
WPS:  * Model Number
WPS:  * Device Name
WPS:  * Version2 (0x20)
P2P: * P2P IE header
P2P: * Capability dev=25 group=00
P2P: * Listen Channel: Regulatory Class 81 Channel 1
p2p-wlan0-0: Add radio work 'scan'@0xbb6a70
p2p-wlan0-0: First radio work item in the queue - schedule start immediately
p2p-wlan0-0: Starting radio work 'scan'@0xbb6a70 after 0.000086 second wait
p2p-wlan0-0: nl80211: scan request
Scan requested (ret=0) - scan timeout 10 seconds
nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for p2p-wlan0-0
p2p-wlan0-0: nl80211: Scan trigger
p2p-wlan0-0: Event SCAN_STARTED (46) received
p2p-wlan0-0: Own scan request started a scan in 0.000222 seconds
RTM_NEWLINK: ifi_index=4 ifname=p2p-wlan0-0 wext ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
nl80211: Drv Event 34 (NL80211_CMD_NEW_SCAN_RESULTS) received for p2p-wlan0-0
p2p-wlan0-0: nl80211: New scan results available
nl80211: Scan probed for SSID ''
nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472
p2p-wlan0-0: Event SCAN_RESULTS (3) received
p2p-wlan0-0: Scan completed in 0.807521 seconds
nl80211: Received scan results (2 BSSes)
p2p-wlan0-0: BSS: Start scan result update 1
p2p-wlan0-0: BSS: Add new id 0 BSSID fa:d0:27:39:48:98 SSID 'DIRECT-2739C898' freq 2447
p2p-wlan0-0: BSS: Add new id 1 BSSID 32:cd:a7:c6:e8:09 SSID 'DIRECT-ZzM2070 Series' freq 2412
BSS: last_scan_res_used=2/32
p2p-wlan0-0: Ignore scan results in AP mode
p2p-wlan0-0: Radio work 'scan'@0xbb6a70 done in 0.813949 seconds
p2p-wlan0-0: radio_work_free('scan'@0xbb6a70): num_active_works --> 0
p2p-dev-wlan0: Updating scan results from sibling
nl80211: Received scan results (2 BSSes)
p2p-dev-wlan0: BSS: Start scan result update 151
BSS: last_scan_res_used=2/32
p2p-dev-wlan0: New scan results available (own=0 ext=0)
WPS: AP fa:d0:27:39:48:98 type 0 added
WPS: AP 32:cd:a7:c6:e8:09 type 1 added
WPS: AP[0] fa:d0:27:39:48:98 type=0 tries=0 last_attempt=-1 sec ago blacklist=0
WPS: AP[1] 32:cd:a7:c6:e8:09 type=1 tries=0 last_attempt=-1 sec ago blacklist=0
wlan0: Updating scan results from sibling
nl80211: Received scan results (2 BSSes)
wlan0: BSS: Start scan result update 151
BSS: last_scan_res_used=2/32
wlan0: New scan results available (own=0 ext=0)
WPS: AP fa:d0:27:39:48:98 type 0 added
WPS: AP 32:cd:a7:c6:e8:09 type 1 added
WPS: AP[0] fa:d0:27:39:48:98 type=0 tries=0 last_attempt=-1 sec ago blacklist=0
WPS: AP[1] 32:cd:a7:c6:e8:09 type=1 tries=0 last_attempt=-1 sec ago blacklist=0
wlan0: No suitable network found
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for p2p-wlan0-0
nl80211: Delete station fe:31:25:c7:57:0b
p2p-wlan0-0: Event DISASSOC (1) received
p2p-wlan0-0: Disassociation notification
p2p-wlan0-0:  * reason 0
p2p-wlan0-0:  * address fe:31:25:c7:57:0b
Disassociation frame IE(s) - hexdump(len=0): [NULL]
hostapd_logger: STA fe:31:25:c7:57:0b - disassociated
p2p-wlan0-0: AP-STA-DISCONNECTED fe:31:25:c7:57:0b p2p_dev_addr=fe:31:25:c7:57:0b
AP-STA-DISCONNECTED fe:31:25:c7:57:0b p2p_dev_addr=fe:31:25:c7:57:0b
hostapd_logger: STA fe:31:25:c7:57:0b - event 2 notification
bhvn
  • 15
  • 5

2 Answers2

2

I do not understand the setup in /etc/wpa_supplicant/wpa_supplicant.conf. For me it looks like a mix up of an autonomous group owner with a dynamic negotiated group owner. Then with

p2p_listen_reg_class=81
p2p_listen_channel=1
p2p_oper_reg_class=81
p2p_oper_channel=1

you restricted the communication to use only channel 1 rather than 1, 6 and 11. This is only for debugging. You should not use it for normal operation. I suggest to try to Connect Android smartphone with Wi-Fi Direct to a Raspberry Pi.

Ingo
  • 42,107
  • 20
  • 85
  • 197
  • @ino thank you for comment. I follow the steps as per the link mention by you, When I connect it's getting connected but after some time it's automatically getting disconnected. – bhvn Oct 05 '20 at 08:47
  • @bhavinpanara What connection method do you use? Have you tried default pin code authentication? What messages does wpa_supplicant give you why it stops the connection? – Ingo Oct 05 '20 at 08:56
  • I have tried with the default pin code authentication method also but the observation is the same. Currently, i have put log of Connect with the pin code method, with pin set by the smartphone method. – bhvn Oct 05 '20 at 09:35
  • @bhavinpanara What Android version do you use on the smartphone? – Ingo Oct 05 '20 at 09:39
  • Android version: 10 QP1A.190711.020 – bhvn Oct 05 '20 at 12:28
  • I have also tested with Android version: 8.1.0 and observation are the same that it's disconnected automatically after connected. And i also check android to the android connection between 8.1.0 and 10 QP1A.190711.020 it's working perfectly. Thank you for your time! – bhvn Oct 05 '20 at 13:20
  • @ ingo Your guidance into this problem is really help full to me. If you have any idea that I have to try out please share it. Thank you. – bhvn Oct 06 '20 at 07:46
  • @bhavinpanara Do you start the connection from the beginning? Do you run wpa_supplicant in the foreground with the help of screen? Does the frequencies match? Does the P2P-PROV-DISC-*-REQ * message match the pin authentication method? Do you have invited an other Available device? – Ingo Oct 06 '20 at 07:58
  • @ ingo(1)Yes, I have start connection from the beginning. (2) Yes, I have run wpa_supplicant in the foreground with the help of two screen logs are updated in the question section (3) Frequency match, not sure but from the log found P2P-GROUP-STARTED p2p-wlan0-0 GO ssid="DIRECT-Q0" freq=2437 go_dev_addr=2e:2c:5b:36:09:20 (4) Yes It's match. P2P-PROV-DISC-SHOW-PIN fe:31:25:c7:57:0b 22929280 p2p_dev_addr=fe:31:25:c7:57:0b pri_dev_type=10-0050F204-5 name='Redmi 9i' config_methods=0x188 dev_capab=0x25 group_capab=0x0 (5) Not invite any other device. – bhvn Oct 06 '20 at 09:09
  • @ ingo did you found anything wrong? Thank you for your time!! – bhvn Oct 06 '20 at 09:57
  • I*m out of ideas now. The problem is that I can't reproduce it. It's working for me. I cannot look for an error that isn't present. You can try to start wpa_supplicant with the additional option -d, means debug. But this gives you a huge amount of additional messages that may more confuse than help. You can try to redirect the output into a file to examine it later, e.g. sudo /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-wlan0.conf -Dnl80211 -iwlan0 -d > debug.out. – Ingo Oct 06 '20 at 17:04
  • I have started wpa_supplicant as per your suggested way. I found log nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for p2p-wlan0-0 This command NL80211_CMD_DEL_STATION is responsible for delete connection. but I'm finding it's the reason why this NL80211_CMD_DEL_STATION command is executing in wpa_supplicant. I have also edited the log in the question section. if you know the reasion please guide me into that. Thank you for support !! – bhvn Oct 07 '20 at 06:27
  • @ ingo One more observation is that I can create successful communication between two Linux machines using wifi direct. My ultimate goal was to establish communication between Windows 10 and Linux. Here [ https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware/how-to-implement-wifi-direct-between-windows10-and/4ca49250-38a0-4327-9f39-47284a9af800?tm=1585548436542 ]. In windows to Linux have the same observation as android to Linux. And android to windows is working. So something I'm missing on the Linux side. – bhvn Oct 07 '20 at 12:49
  • This does not look like a dynamic negotiated group, because p2p_connect is not used. A number of persistent groups are indeed created in the configuration file with different bssid, possibly due to the randomized address issue each time wpa_supplicant is restarted. – ircama Feb 24 '21 at 20:26
0

Is your IP address 169.254.68.39 appropriate with wpa_cli -i p2p-wlan0-0 status?

From your ifconfig output, the IPv4 addressing appears to be missing for p2p-wlan0-0 (the P2P-GO persistent group). Check your systemd-networkd configuration (if you are using this method) or your dnsmasq configuration, so that an IP address is appropriately given to this virtual interface. In general, this is a typical problem producing fast disconnection just after the P2P session is successfully activated.

Example of systemd-networkd configuration in a file under /etc/systemd/network/:

[Match]
Name=p2p-wlan0-*
[Network]
Address=192.168.4.1/24
DHCPServer=yes

Alternative example of /etc/dnsmasq.conf:

interface=p2p-wlan0-*
dhcp-range=192.168.4.50,192.168.4.199,12h
dhcp-option=3

Notice also that you are using a 4-digit PIN. By default, 8-digit PINs are configured.

ircama
  • 178
  • 1
  • 7