Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to discovering peers with Wifi Direct as it requires both phones running WiFi Direct discovery

I am trying to discover WiFi Direct peer to peer android devices but peers are discovered only when both phones are running WiFi Direct discovery.

What I have Understood so far is, they will see each other only when they are both scanning for WiFi direct connections at the same time. This is because the way WiFi Direct works is that when phones are scanning for WiFi Direct connections, they will negotiate with the other peers for the role of Access Point or Slave device. Hence both need to call discoverPeers() to become discoverable themselves and find nearby devices.

What I want in my application is that only one device starts the scanning process and all nearby devices supporting wifi direct should be listed. So how can this be achieved using wifi Direct? Are there any other alternatives to this.

Thanks in Advance

like image 904
Sarang S. Chaturvedi Avatar asked Oct 12 '25 08:10

Sarang S. Chaturvedi


1 Answers

There is no way to achieve your goal using WiFiDirect. You need to turn on WiFiDirect (programmatically or manual) on all devices which are going to be connected.

But there is a way to reduce discovering process effort. You can use a service discovering instead of regular p2p connection.

It allows doing p2p discovering only on one device (client). A second device (server) is just waiting for a connection invite.

In one of our application, we had an issue: when a device does p2p discovering, a bandwidth of the network is extremely decreased what led to disconnect already connected devices.

Using a service discovering really helped us. You can use the code as an example.

like image 122
Oleg Sokolov Avatar answered Oct 14 '25 00:10

Oleg Sokolov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!