Wifi direct connection between several devices

81 views Asked by At

Imagine this scenario:

AndroidA knows AndroidB but doesn't know Android C.

AndroidB knows AndroidC and Android A.

Is it possible to connect Android A to Android C using AndroidB with WifiDirect? Like a electrical circuit in series.

Update: AndroidC and AndroidB are sensors, and i need to pass to AndroidA the GPS localization (latitude/longitude) and a flag. Only AndroidA has communication with the user.

Thanks

1

There are 1 answers

0
JAD On

Yes, its possible.

To do this, you have to do the following:

  1. Call WiFiP2PManager "Connect" from Android A to Android B, make sure to set the WifiP2pConfig "groupOwnerIntent" to 0 (which will make sure that Android B will become the group owner).
  2. Do the same from Android C to Android B, Connect with "groupOwnerIntent" equals to 0 (now we have the same group for the 3 devices and Android B is the Owner / Server / Manager).
  3. Start Sockets server at Android B, and connect to it from A and C via sockets.
  4. At Android B, when receiving a message or data from Android A, forward it to Android C (or all connected devices / act as a broadcast server).

Goodluck.