Google附近连接API:测量信号强度
Google Nearby Connection API: measure signal strength
最近我发现了一种使用 Google Nearby API 在设备之间进行通信的看似很酷的方式。浏览文档并没有回答我的问题 - 是否可以实时测量连接信号强度,或者我应该发明一些东西,例如测量发送和接收数据的时间或其他?
谢谢。
作为 Nearby API 的开发者,在帖子 中表示:
Today, Nearby doesn't expose distance directly
他建议改用BLE RSII
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.
如果您的问题确实是关于 "Nearby Connection API" 而不是 "Nearby Messages API",您可以简单地检查 Wifi 信号强度:
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
int numberOfLevels = 5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
最近我发现了一种使用 Google Nearby API 在设备之间进行通信的看似很酷的方式。浏览文档并没有回答我的问题 - 是否可以实时测量连接信号强度,或者我应该发明一些东西,例如测量发送和接收数据的时间或其他?
谢谢。
作为 Nearby API 的开发者,在帖子
Today, Nearby doesn't expose distance directly
他建议改用BLE RSII
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.
如果您的问题确实是关于 "Nearby Connection API" 而不是 "Nearby Messages API",您可以简单地检查 Wifi 信号强度:
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
int numberOfLevels = 5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);