Search code examples
androidgoogle-nearbygoogle-nearby-connections

Android Nearby Connection send payload partially wifi aware and bluetooth


I'm sending image payload between two devices using P2P_POINT_TO_POINT (STAR too and every payload tranfer, we make connection and disconnect it).

but the throughput is much lower than i expected so I checked the logs

04-16 10:15:10.456 I 13712    31046    NearbyConnections:                                             Sent FILE data(2686932 bytes) via WIFI_DIRECT used 324 milliseconds, throughput is 7.91 MB/s (8098.63 KB/s), File IO takes 3 ms, Encryption takes 66 ms, Socket IO takes 240 ms [CONTEXT service_id=54 ] 
04-16 10:15:10.456 I 13712    31046    NearbyConnections:                                             Sent FILE data(488182 bytes) via BLUETOOTH used 6498 milliseconds, throughput is 0.07 MB/s (73.37 KB/s), File IO takes 4 ms, Encryption takes 67 ms, Socket IO takes 6404 ms [CONTEXT service_id=54 ] 
04-16 10:15:10.456 I 13712    31046    NearbyConnections:                                             Sent FILE data(3175114 bytes) SUCCEEDED, overall used 7370 milliseconds, throughput is 0.41 MB/s (420.72 KB/s), File IO takes 7 ms, Encryption takes 133 ms, Socket IO takes 6644 ms [CONTEXT service_id=54 ] 

so Nearby connection sent part of payload thru Bluetooth and that makes sending payload delayed.

Is there any solution for sending it by only wifi? Since we're building app using the 'snake' strategy, throughput is the matter.


Solution

  • Not at the moment, unfortunately. Your best bet is to delay large file transfers for the first ~5s after connecting.

    There's a hidden API that fires a callback event when we've upgraded to WiFi. I've nudged someone about publicly exposing that, but it'll take a while to go through the formal process.