0

I want to do the same thing as this post : WiFi Direct (Android 4.0) with multiple (3+) devices

but with bidirectionnal messages.

A -> B and B -> A

B -> C and C -> B

Is there a way to do that?

Community
  • 1
  • 1
arezkibe
  • 13
  • 1
  • 6

1 Answers1

1

Yes. You have to create a wifi direct group, and all of your devices have to connect to the group owner device. After this, all devices in this group knows the group owner IP address. Now you have to do these steps:

  • All device (except the group owner) have to send a message (the content of the message is unrelevant) to the group owner. You can do this with the group owner address.

  • Now the group owner receive the message. This is not important, but the socket is! You can get the clients IP address from the socket! Now store that IP adddresses.

  • Now the group owner knows all IP address. So you can send messages to any device, just make a good routing

László Magyar
  • 355
  • 1
  • 16
  • Thanks I did it, I will push the project on github soon. – arezkibe Dec 18 '14 at 10:36
  • @arezkibe Can you please give a link to your github project? – unrealsoul007 Jan 16 '15 at 10:57
  • you sayed:"So you can send messages to any device, just make a good routing". how to make good routing? I face with "failed to connect to /192.168.49.24 (port 8988) after 5000ms: isConnected failed: EHOSTUNREACH (No route to host)" – David Sep 26 '15 at 17:56
  • As of this writing (API level 33/Android 13), organizing a Wifi Direct Group is only necessary for support of "legacy" devices. See https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager?authuser=1#createGroup(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pManager.ActionListener) – eppineda Feb 04 '23 at 02:33