DFU 模式下的蓝牙:某些设备连接总是失败

Bluetooth in DFU mode: connection always fails for some devices

我正在使用 Nordic Semiconductor 的 Android-DFU-Library 来更新蓝牙低功耗 (BLE) 设备的固件。我已经在 github 上寻求帮助,但我认为更多人可以在这里看到这个问题(要么提供帮助,最终找到并回答)。

所以,这是我对 github issue 的描述:


过去两天我一直在努力解决这个问题,但找不到任何线索。希望这里有人能给我提示,我将不胜感激。

我有 4 台设备:

连接蓝牙设备进行更新后,我发送了一些特定的命令进入DFU模式,然后几秒钟后断开连接。到这一步都ok了。

然后,我使用Android-DFU-Library 开始固件更新过程。它适用于 android 5.1 三星设备,但无法将 [status 133] 与其他 3 台设备连接。知道发生了什么事吗?

非常感谢您的帮助。


当我在 nRF Connect 中手动执行时它有效。当我首先使用我的应用程序启用 DFU 模式,然后 nRF Connect 在稍微扫描以找到设备后立即连接到设备时,它甚至可以工作。

我在我的应用程序中的做法是:启用 DFU 模式后,我扫描 10 秒以找到新的 mac 地址并确保只有一台设备处于 DFU 模式一个时间。然后,我使用这个库进行实际的固件更新。

大约需要30s才能抛出status=133错误,所以看起来是因为超时。

07-26 10:49:47.525 ... D/BluetoothGatt: connect() - device: ... , auto: false

07-26 10:50:17.543 ... D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=5...

更多日志:

07-26 10:49:46.590 ... I/DfuBaseService: DFU service created. Version: 1.6.1

07-26 10:49:47.524 ... I/DfuBaseService: Connecting to the device...

07-26 10:50:17.543 ... E/DfuBaseService: Connection state change error: 133 newState: 0

07-26 10:50:17.544 ... E/DfuBaseService: Device not reachable. Check if the device with address [MAC] is in range, is advertising and is connectable

07-26 10:50:17.549 ... I/DfuBaseService: Refreshing result: true

07-26 10:50:17.549 ... I/DfuBaseService: Cleaning up...

07-26 10:50:18.186 ... I/DfuBaseService: DFU service destroyed

由于 philips77,我终于设法让它工作了。

我正在使用 BluetoothLeScanner 和延迟批处理报告,通过 ScanSettings

   ScanSettings scanSettings = new ScanSettings.Builder()
       ...
       .setReportDelay(delay)
       .build();

因此,通过消除延迟报告,我能够在 DFU 模式下成功连接到设备。

我现在还不完全了解根本原因,但您可以在 github issue.

中找到更多相关信息