4

最近我发现了一种使用Google Nearby API在设备之间进行通信的看似很酷的方式。浏览文档并没有回答我的问题 - 是否可以实时测量连接信号强度,还是我应该发明一些工具,例如测量发送和接收数据的时间或其他东西?

谢谢你。

4

2 回答 2

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.

于 2015-10-16T19:13:11.457 回答
1

如果您的问题确实是关于“附近的连接 API”而不是“附近的消息 API”,您可以简单地检查 Wifi 信号强度:

WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
int numberOfLevels = 5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
于 2015-11-27T08:43:19.327 回答