Jetson TX2 can not communicate with Android clients using WiFi Direct

Jetson TX2 installed system is Ubuntu 16, communication is to use wpa_supplicant.
The implementation is described in the section “Steps prior to R8.2 release” in http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts

But when I p2p_connect, the link will be broken within 10 seconds of success
.
wpa_cli log as follows:

> p2p_connect c2:ee:fb:f7:1e:18 pbc
OK
<3>P2P-FIND-STOPPED 
<3>P2P-GO-NEG-SUCCESS role=GO freq=5220 ht40=1 peer_dev=c2:ee:fb:f7:1e:18 peer_iface=c2:ee:fb:f7:1e:18 wps_method=PBC
<3>P2P-GROUP-FORMATION-SUCCESS 
<3>P2P-GROUP-STARTED p2p-wlan0-0 GO ssid="DIRECT-MS" freq=5220 passphrase="pbiRQiEs" go_dev_addr=02:04:4b:8c:a5:05
<3>AP-STA-CONNECTED c2:ee:fb:f7:1e:18 p2p_dev_addr=c2:ee:fb:f7:1e:18
<3>AP-STA-DISCONNECTED c2:ee:fb:f7:1e:18 p2p_dev_addr=c2:ee:fb:f7:1e:18
<3>P2P-DEVICE-LOST p2p_dev_addr=fe:3f:db:2f:c7:15
<3>P2P-DEVICE-LOST p2p_dev_addr=c2:ee:fb:f7:1e:18
<3>P2P-DEVICE-LOST p2p_dev_addr=12:2a:b3:dc:88:ec
>

Android log as follows:

07-11 20:50:08.589 6784-6784/? I/wpa_supplicant: p2p0: WPA: Key negotiation completed with 02:04:4b:8c:25:05 [PTK=CCMP GTK=CCMP]
07-11 20:50:08.591 6784-6784/? I/wpa_supplicant: p2p0: CTRL-EVENT-CONNECTED - Connection to 02:04:4b:8c:25:05 completed [id=1 id_str=]
07-11 20:50:08.595 6784-6784/? I/wpa_supplicant: P2P-GROUP-STARTED p2p0 client ssid="DIRECT-t4" freq=5240 go_dev_addr=02:04:4b:8c:a5:05
07-11 20:50:08.612 1390-1626/? D/WifiP2pService: GroupCreatedStatemPendingReformGroupIndication=false
07-11 20:50:08.613 7756-7756/com.amap.ai.wifidirectdemo D/wifidirectdemo: P2P peers changed
07-11 20:50:08.618 7756-7756/com.amap.ai.wifidirectdemo D/wifidirectdemo: Peer status :0
07-11 20:50:08.622 7756-7756/com.amap.ai.wifidirectdemo D/wifidirectdemo: Peer status :0
07-11 20:50:08.721 22926-22926/? E/dhcpcd: fopen `/system/etc/dhcpcd/dhcpcd.conf': No such file or directory
07-11 20:50:08.722 22926-22926/? I/dhcpcd: version 5.5.6 starting
07-11 20:50:08.723 22926-22926/? E/dhcpcd: fopen `/system/etc/dhcpcd/dhcpcd.conf': No such file or directory
07-11 20:50:08.762 22926-22926/? I/dhcpcd: p2p0: rebinding lease of 192.168.49.144
07-11 20:50:09.498 1390-2404/? D/GpsLocationProvider: reportNmea $GPGSA,A,1,,,,,,,,,,,,,,,*1E  timestamp = 1499777409497
07-11 20:50:10.241 1390-1432/? I/ActivityManager: [BgDetect]chkExcessCpu level: 1 doKills: true auto_mode: false uptime: 300085
07-11 20:50:10.258 1390-1432/? I/ActivityManager: [BgDetect]checkExcessiveCpuUsageLocked level 1 in 64ms
07-11 20:50:10.354 723-1788/? D/audio_hw_primary: out_standby: enter: stream (0xf4c03380) usecase(1: low-latency-playback)
07-11 20:50:10.391 723-1788/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback quat_i2s
07-11 20:50:10.393 723-1788/? D/soundtrigger: audio_extn_sound_trigger_update_stream_status: uc_id 1 of type 0 for Event 2, with Raise=0
07-11 20:50:10.394 723-1788/? D/hardware_info: hw_info_append_hw_type : device_name = speaker
07-11 20:50:10.394 723-1788/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
07-11 20:50:10.407 723-1788/? D/aud_dev_arbi: releaseOneDevice: not sending command, device argument (2) does not match any registered device
07-11 20:50:10.407 723-1788/? D/aud_dev_arbi: releaseOneDevice: device 2 owner is 0
07-11 20:50:10.407 723-1788/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 0, with Raise=0
07-11 20:50:12.019 1390-1430/? D/DeviceIdleController: handleMessage(5)
07-11 20:50:12.020 1390-1430/? D/DeviceIdleController: Removing UID 10004 from temp whitelist
07-11 20:50:12.020 1390-1430/? D/DeviceIdleController: Setting wakelock temp whitelist to []
07-11 20:50:12.497 1390-2404/? D/GpsLocationProvider: reportNmea $GPGSA,A,1,,,,,,,,,,,,,,,*1E  timestamp = 1499777412497
07-11 20:50:12.628 1390-1390/? I/DeviceIdleController: updateChargingLocked: charging=true
07-11 20:50:12.628 1390-1390/? I/DeviceIdleController: becomeActiveLocked, reason = charging
07-11 20:50:12.630 3094-3094/? D/AbstractProcessor: onBatteryChange Percent:94 State:2 
07-11 20:50:13.765 22926-22926/? I/dhcpcd: p2p0: broadcasting for a lease
07-11 20:50:18.640 1390-1390/? I/DeviceIdleController: updateChargingLocked: charging=true
07-11 20:50:18.640 1390-1390/? I/DeviceIdleController: becomeActiveLocked, reason = charging
07-11 20:50:18.643 3094-3094/? D/AbstractProcessor: onBatteryChange Percent:94 State:2 
07-11 20:50:22.013 1390-1612/? V/AlarmManager: Triggering alarm #0: Alarm{d0ab6a3 type 3 when 21992479 com.amap.android.ams}operation =Intent { act=com.amap.android.ams.nlp.ALARM_WAKEUP_LOCATOR }
07-11 20:50:22.015 1390-1432/? D/DeviceIdleController: Adding AppId 10004 to temp whitelist
07-11 20:50:22.015 1390-1432/? D/DeviceIdleController: Setting wakelock temp whitelist to [10004]
07-11 20:50:22.016 2392-2746/? I/amsnl: ar
07-11 20:50:22.017 2392-2746/? I/amsnl: t:false, fl: false, p: 20000, ce: true, we: true
07-11 20:50:22.018 1390-2482/? D/ConnectivityService: returning Blocked NetworkInfo for ifname=wlan0, uid=10004
07-11 20:50:22.019 2392-2746/? I/amsnl: c: false, w: true, t: true, l: false
07-11 20:50:22.020 2392-2746/? I/amsnl: crs
07-11 20:50:22.020 2392-2746/? I/amsnl: qg
07-11 20:50:22.028 2392-2746/? I/amsnlp: isConnected, isIdle: false isIgnoreBatOpt: false
07-11 20:50:22.030 1390-1416/? D/ConnectivityService: returning Blocked NetworkInfo for ifname=wlan0, uid=10004
07-11 20:50:22.032 2392-2746/? I/e: hot: htMem:{wx4gd2={"x":"{\"key\":\"RVBMVVNGN0E5MzE2N1NURUw=#network#wifi\",\"lat\":39.99216,\"lon\":116.466551}","time":1499424655974,"num":3}}
07-11 20:50:22.032 2392-2746/? I/e: hot: lst:[wx4gd2]
07-11 20:50:22.033 2392-2746/? E/amsnlp: error -3
07-11 20:50:22.055 2392-2746/? I/amsnl: csr
07-11 20:50:22.056 2392-2746/? I/amsnl: t:false, fl: false, p: 20000, ce: true, we: true
07-11 20:50:22.058 2392-2746/? I/amsnl: rl
07-11 20:50:22.059 2392-2746/? I/amsnl: c: false, w: true, t: false, l: false
07-11 20:50:22.497 1390-2404/? D/GpsLocationProvider: reportNmea $GPGSA,A,1,,,,,,,,,,,,,,,*1E  timestamp = 1499777422497
07-11 20:50:24.642 1390-1390/? I/DeviceIdleController: updateChargingLocked: charging=true
07-11 20:50:24.642 1390-1390/? I/DeviceIdleController: becomeActiveLocked, reason = charging
07-11 20:50:24.649 3094-3094/? D/AbstractProcessor: onBatteryChange Percent:94 State:2 
07-11 20:50:32.066 1390-1430/? D/DeviceIdleController: handleMessage(5)
07-11 20:50:32.067 1390-1430/? D/DeviceIdleController: Removing UID 10004 from temp whitelist
07-11 20:50:32.067 1390-1430/? D/DeviceIdleController: Setting wakelock temp whitelist to []
07-11 20:50:32.498 1390-2404/? D/GpsLocationProvider: reportNmea $GPGSA,A,1,,,,,,,,,,,,,,,*1E  timestamp = 1499777432498
07-11 20:50:36.642 1390-1390/? I/DeviceIdleController: updateChargingLocked: charging=true
07-11 20:50:36.643 1390-1390/? I/DeviceIdleController: becomeActiveLocked, reason = charging
07-11 20:50:36.649 3094-3094/? D/AbstractProcessor: onBatteryChange Percent:94 State:2 
07-11 20:50:39.061 1390-22925/? D/NetUtils: dhcp_start failed : p2p0
07-11 20:50:39.062 1390-22925/? E/DhcpStateMachine: DHCP request failed on p2p0: Timed out waiting for DHCP to finish
07-11 20:50:39.064 1390-1626/? E/WifiP2pService: DHCP failed
07-11 20:50:39.103 6784-6784/? I/wpa_supplicant: p2p0: CTRL-EVENT-DISCONNECTED bssid=02:04:4b:8c:25:05 reason=3 locally_generated=1
07-11 20:50:39.104 6784-6784/? E/wpa_supplicant: eap_proxy: eap_proxy_notify_config
07-11 20:50:39.104 6784-6784/? E/wpa_supplicant: eap_proxy: eap_proxy_notify_config
07-11 20:50:39.104 6784-6784/? E/wpa_supplicant: eap_proxy: eap_proxy_notify_config
07-11 20:50:39.104 6784-6784/? E/wpa_supplicant: eap_proxy: eap_proxy_notify_config
07-11 20:50:39.104 6784-6784/? I/wpa_supplicant: P2P-GROUP-REMOVED p2p0 client reason=REQUESTED

Hi ddlx,

Please try with following steps.

1.Wpa_cli -I wlan0 p2p_add_group
2.Wpa_cli //you will enter in wpa_cli shell
3.P2p_find
4.P2p_peers
5.Wps_pin any //note the pin prompted on shell
6.On android device, in wifidirect scan page, click on mac of DUT and enter pin from step #5
Connected //Attaching logs, look for AP-STA-CONNECTED

Hi, WayneWWW,

Thanks for your reply.
I tried to follow the method you said, the result is the same, within 10 seconds to disconnect the link.
Are there any other ideas?

The log is as follows:

> ...

> wps_pin any
79027175

// ... Android devices use pin code to link, Jetson TX2 shows Log as follows

<3>CTRL-EVENT-EAP-STARTED c2:ee:fb:f7:1e:18
<3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=1
<3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=14122 method=254
<3>WPS-REG-SUCCESS c2:ee:fb:f7:1e:18 dc4d065f-6148-5388-a0d4-9187e0ea0a78
<3>WPS-SUCCESS 
<3>CTRL-EVENT-EAP-FAILURE c2:ee:fb:f7:1e:18
<3>AP-STA-CONNECTED c2:ee:fb:f7:1e:18 p2p_dev_addr=c2:ee:fb:f7:1e:18

// ... The link was successful and broke in 10 seconds

<3>AP-STA-DISCONNECTED c2:ee:fb:f7:1e:18 p2p_dev_addr=c2:ee:fb:f7:1e:18

> ...

Hi ddlx,

This is sometimes related to both peers. Could you try other android phone and see if this is issue from tegra?

Hi, WayneWWW,

I tried two Android phones, there are the same problem.

However, the use of WiFi Direct links between two Android phones is good.

Is it a problem with Jetson TX2?

I am checking this internally. Thanks.

Hi ddlx,

Could you try to run the test again with dhcp server setup?

Please try following steps:

Steps:

1) Install isc-dhcp-server Install isc-dhcp-server (sudo apt install isc-dhcp-server) 
2) Edit the file /etc/default/isc-dhcp-server and set INTERFACES like this:
   INTERFACES="p2p-wlan0-0" 
3) In /etc/dhcp/dhcpd.conf Find below lines and put # before it. It should look like after editing

   # option definitions common to all supported networks…
   #option domain-name “example.org”;
   #option domain-name-servers ns1.example.org, ns2.example.org;

4) Again comment out following lines too 


   #default-lease-time 600;
   #max-lease-time 7200;

5) Add following lines at end
   subnet 10.10.0.0 netmask 255.255.255.0 {
           range 10.10.0.2 10.10.0.16;
           option domain-name-servers 8.8.4.4, 208.67.222.222;
           option routers 10.10.0.1;
   }

7)In /etc/network/interfaces, Add below 

   auto p2p-wlan0-0
   iface p2p-wlan0-0 inet static
   address 10.10.0.1
   netmask 255.255.255.0
  
8).wpa_cli -i wlan0 p2p_group_add
9) wpa_cli //you will enter in wpa_cli shell
10)p2p_find
10)p2p_peers
11) p2p_stop
12)wps_pin any //note the pin prompted on shell
13)On android device, in wifidirect scan page, click on mac of DUT and enter pin from step #5
Connected //Attaching logs, look for AP-STA-CONNECTED
14) If you see ubuntu p2p interface as GO role, you need to start dhcp server(follow next 2 steps)
<3>P2P-GROUP-STARTED p2p-wlan0-0 GO ssid="DIRECT-MS" freq=5220 passphrase="pbiRQiEs" go_dev_addr=02:04:4b:8c:a5:05
15) ifconfig p2p-wlan0-0 10.10.0.1
16)  sudo service isc-dhcp-server start

Hey WayneWWW,

I recently ran into the same problem like ddlx. I have a NVIDIA Jetson TX2 development kit and installed Ubuntu 16.04. My Android device is a LG VK810 Tablet running Android 5.0.1.
I followed your instructions in the approved answer above. I should mention that I was not able to set up WifiDirect as mentioned on this page: http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts. Maybe that’s the issue. I couldn’t figure out if your answer is a complete one.
Anyway after generating a random pin with wps_pin any, I can see my Jetson TX2 in the Android’s WiFi Direct Menu but when I try to connect by clicking it, I send out an invitation to the Jetson TX2 with a random generated pin again. There is no option to type in a pin.
When sending out that Android based invitation to the Jetson, I also cannot connect to it with p2p_connect . The output only shows FAILED.
Do you have an idea? Is there maybe a newer way to approach this issue?