Android BLE 连接速度问题

标签 android bluetooth-lowenergy

我的 Android 应用程序使用

BluetoothAdapter.startLeScan()

在按下按钮手动要求停止之前扫描结果。

这种态度会影响ble连接时间吗?

我认为绑定(bind)蓝牙服务时扫描会被阻止,并且在建立连接后无需编写任何代码即可解除阻止。这是正确的吗?

连接时间不时变化。平均需要1~2秒左右,但有时需要5~6秒甚至更长。为什么会发生这种情况?

最佳答案

Will this type of attitude affect the time of ble connection time?

有时也许。连接过程是通过发送连接请求来启动的,设备进入连接状态后。如果在设备进入连接状态之前手动停止扫描,可能会中断后续的连接。

I think the scanning is blocked when the bluetooth service is binded, and unblocked after connection establishment without any code to write. Is this right?

是的,确实如此。

The connection time varies from time to time. It takes about 1~2 sec average, but sometimes, it takes about 5 to 6 seconds or even more. Why should this happen?

原因有很多,你可以先考虑一个主要原因。这就是BLE设备的特殊工作模式。它们并不是一直活跃,而是周期性活跃。例如,它每 10 秒激活 100 毫秒,其余 9.9 秒休眠。如果在BLE设备刚刚进入休眠时开始扫描,那么需要9.9s以上。

其次,问题可能是由于您的 Android 设备造成的。检查发送连接请求时是否有任何其他任务或事件可能中断连接过程。

第三,有没有干扰?也许是 WIFI 或 USB 3.0。

关于Android BLE 连接速度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38735248/

相关文章:

安卓回音消除

bluetooth-lowenergy - Nordic nrf51822 和 S130 永远无法获取我的应用程序代码

android - 在 Lollipop 中从远程 BLE 设备读取超过 20 个字节失败

android - android 8.1.0 手机屏幕关闭时 BLE 扫描停止

audio - 谁能解释语音命令如何通过 Android(Nexus 播放器)中的蓝牙 Remote (Nexus 播放器 Remote )工作?

javascript - 是否可以将多个 BLE 设备连接到一个中央设备?

android - 具有两个具有相同 SerializedName 的字段的类

android - 如何禁用 jwplayer 库中的自动旋转?

android - 非法状态异常 : unknown destination during restore

java - 无法解析方法 'fromJson(org.json.JSONObject, java.lang.Class<me.myrottentomatoes.Result[]>)'