5

Recently I found a seemingly cool way to communicate between devices using Google Nearby API. Skimming through the documentation didn't answer my question - is it possible to measure the connection signal strength in real time, or should I invent some kludges e.g. measuring time of sending and receiving data or something else?

Thank you.

sonderlain
  • 312
  • 2
  • 15
  • From what's available in the reference documentation, looks like no. – Andy Sep 28 '15 at 16:29
  • Is this about Nearby Connection API or Nearby Messages API? Because the accepted answer seems to be for Messages, while the Question Title is about Connection... – StefanTo Nov 27 '15 at 08:39

2 Answers2

5

As a developer of Nearby API stated in thread Google Nearby Messages - Cancel initial link between devices :

Today, Nearby doesn't expose distance directly

He suggests to use BLE RSII instead

You can get a rough approximation of distance by measuring BLE RSSI if one of the devices is capable of BLE advertising. This will be sensitive to how the device is held, antenna gain and environmental factors but better than random.

There's not a straight-forward "tape measure" API, though.

Community
  • 1
  • 1
saibots
  • 66
  • 3
1

If your question really is about "Nearby Connection API" and not "Nearby Messages API", you could simply check the Wifi-Signal Strength:

WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
int numberOfLevels = 5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
StefanTo
  • 971
  • 1
  • 10
  • 28