4

I am developing a Disruption/Delay Tolerant Network (DTN) application which connects to Android devices using Android Nearby without authentication.

From the Google Nearby docs:

Under the hood, the API uses a combination of Bluetooth, BLE, and Wifi hotspots, leveraging the strengths of each while circumventing their respective weaknesses.

While offline connection negotiation seems to work quite well, I'm not sure if Nearby is using WiFi Direct for data transmission. When I use Nearby in my app, I see the Bluetooth radio active in the Android status bar, but I don't see the WiFi Direct icon when a connection has been established.

The DTN library I'm using will only work off WiFi connections and WiFi Direct.

Is there a way I can force Nearby to connect devices using WiFi Direct only?

shortstheory
  • 470
  • 5
  • 17

1 Answers1

5

No, it's not possible to force WiFi Direct only. We're not keen on exposing that either. Ideally, from our perspective, the DTN library would be rebuilt on top of Nearby Connections.

Disclaimer: I work on Nearby Connections

Xlythe
  • 1,958
  • 1
  • 8
  • 12
  • Rewriting DTN is the current approach I am thinking of taking. Though Nearby gives by far the best connection stability and discoverability, I find its reliance on Bluetooth leaves some improvement to be desired in terms of connection speed (I usually get around 50-150 KB/sec). If I may ask, under what conditions would Nearby start a P2P group for WiFi direct? When I tested it with my Samsung Tablet and Moto G4+, it exclusively relied on Bluetooth for data transmission. – shortstheory Feb 12 '18 at 16:17
  • If you use P2P_STAR, then we'll attempt to upgrade from Bluetooth to LAN / WiFi Direct / WiFi Hotspot, depending on which we think will work best at the time. The upgrade is best effort though, so it may not happen... – Xlythe Feb 13 '18 at 19:43
  • I switched to using P2P_STAR, and I can see that Nearby enables the WiFi radios on both devices automatically. It's still using Bluetooth however. Given that the extra bandwitdth from WiFi would be nice (but not really necessary), should I use P2P_STAR for 1 to 1 device connections? – shortstheory Feb 14 '18 at 04:10
  • Yup. We're actually releasing a new strategy, P2P_POINT_TO_POINT that's made specifically for 1 to 1 connections. But until that rolls out, STAR is the next best recommendation. – Xlythe Feb 14 '18 at 04:18
  • 1
    I find P2P_CLUSTER more stable than P2P_STAR (STAR gives me STATUS_BLUETOOTH_ERROR which I have never seen on CLUSTER) when it comes to discovery and holding the connection, so I'm actually reverting to that for now. Is there any place/forum I can use for reporting bugs and suggesting features to Nearby? – shortstheory Feb 14 '18 at 04:47
  • 1
    Hmm, that's likely just bad luck. Under the hood both are exactly the same for advertising + discovery. Try rebooting once, to refresh both devices. The best place to report bugs/features is either here on StackOverflow or as a GitHub Issue in the repo with our sample apps. – Xlythe Feb 14 '18 at 14:44
  • 1
    I tested it out some more. It turns out that P2P_STAR only works if I call stopAdvertising() (and?) stopDiscovery() before initiating the connection. It does sometimes upgrade the connection to WiFi Direct, but I'm not sure under which circumstances it does this as it's only happened a few times in my testing. – shortstheory Mar 02 '18 at 14:58
  • @Xlythe Is there any technical reason `P2P_CLUSTER` couldn't also use e.g. WiFi Direct in conjunction with BLE? Then the range of the cluster could be significantly extended. I will try this manually but would love to see it in Nearby Connections, if feasible. – Jeffrey Mixon Jan 24 '21 at 23:13
  • WiFi Direct is an extension of WiFi Hotspots. There is one central host (the Group Owner) and a bunch of peers (the Group Clients). It's not possible to connect in an ad-hoc manor, as a Client can only be connected to one Owner at a time, and the Owner likewise cannot act as a Client while they're hosting the group. That's why it's only available in STAR/P2P. There is WiFi Aware, which allows for 2 to 4 ad-hoc connections, so we are evaluating using that in CLUSTER. – Xlythe Jan 25 '21 at 19:50