【发布时间】:2016-09-07 08:13:53
【问题描述】:
在 android 应用程序中,我们可以使用wifiInfo.getLinkSpeed() 方法获取 WiFi 连接链接速率。
但是有没有办法获得Bluetooth connection Link Rate? 任何可用的 API 或方法?
【问题讨论】:
标签: android api android-bluetooth
在 android 应用程序中,我们可以使用wifiInfo.getLinkSpeed() 方法获取 WiFi 连接链接速率。
但是有没有办法获得Bluetooth connection Link Rate? 任何可用的 API 或方法?
【问题讨论】:
标签: android api android-bluetooth
我从事蓝牙应用程序的工作,我的需求与您的需求相同,但我没有找到以 mbps 为单位获得蓝牙连接速度的解决方案。
因此,此解决方案可能无法按照您的要求为您提供蓝牙链接速率的准确值,但它实际上使用接收信号强度指示器 (RSSI) 为您提供了蓝牙链接质量(好、中、差)的参考.
要读取您的蓝牙 RSSI 的值,您应该在您的类中添加 BroadcastReceiver:
private final BroadcastReceiver receiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
if(BluetoothDevice.ACTION_FOUND.equals(intent.getAction())) {
//Get the RSSI value here
int rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
}
}
};
您的接收器必须使用以下方式注册:
registerReceiver(receiver, new IntentFilter(BluetoothDevice.ACTION_FOUND));
现在,您需要知道数据传输速度会随着 RSSI 值的增加而增加,因此,您所要做的就是为每个链接质量定义一个范围。
PS:请参阅此链接了解更多关于蓝牙的 RSSI 值Bluetooth RSSI values are always in dBm in all Android devices?
希望这会有所帮助:)
【讨论】:
简短的回答是没有这样的界面。 长答案是,蓝牙的速度会因不同设备的硬件和软件差异而有所不同,例如BR/EDR/BLE,蓝牙只定义了BR/EDR/BLE的最大速度数据。在大多数情况下,蓝牙链接不传输用户数据(除了您正在听音乐或打电话),而只是保持链接,因此蓝牙评估链接速度没有意义(至少对于最终用户而言)。
【讨论】: