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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With