Android BLE:“扫描失败,原因是UUID的应用注册失败”

问题描述 投票:6回答:2

我正在使用RxAndroidBle库开发一个应用程序,该库每隔30秒定期执行BLE扫描,并且每分钟左右执行一些BLE操作。几个小时后,通常在5到24小时之间,扫描停止工作。每次应该开始扫描时,我得到:

09-05 09:08:37.160 8160-8160/myapp D/BluetoothAdapter: startLeScan(): null
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothLeScanner: Start Scan
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.165 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.170 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: onClientRegistered() - status=133 clientIf=0
09-05 09:08:37.210 8160-12850/myapp D/BluetoothLeScanner: Registration failed, unregister clientIf = 0
09-05 09:08:37.215 8160-8160/myapp D/BluetoothLeScanner: Scan failed, reason app registration failed for UUID = 4c321920-a2b7-449a-bc24-ea4361f7a255
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: unsubscribing scan
09-05 09:08:44.150 8160-8160/myapp V/myapp.debug: Clearing scan subscription
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: stopLeScan()
09-05 09:08:44.150 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothAdapter: STATE_ON
09-05 09:08:44.155 8160-8160/myapp D/BluetoothLeScanner: could not find callback wrapper

有没有人知道导致这个问题的原因或者可以采取哪些措施来解决这个问题?

android bluetooth bluetooth-lowenergy android-bluetooth rxandroidble
2个回答
0
投票

问题是,在几次连接后,你达到了最大数量的BluetoothGatt对象。

在开始新的骗局之前断开每个设备之后,在你的qazxsw poi对象上调用qazxsw poi。


0
投票

在较旧的Android实现中,启用蓝牙适配器和扫描速度之间似乎存在竞争条件。您可以通过尝试使用已禁用的蓝牙适配器扫描或正在转换(或具有打开的连接并尝试读取)来触发此错误。在我的应用程序中导致它的根本问题是蓝牙子系统无法获得新的蓝牙插槽。上面的答案(用完GATT资源)可能是其中的一部分。旧版Android设备中用于避免此问题的整体逻辑是:1。确保每扫描一次禁用/启用蓝牙适配器。这似乎有助于清除旧的缓存数据。 2.确保在未启用蓝牙适配器时不尝试启动扫描(如果您定期禁用/启用,则可以进行扫描)。 3.确保在断开GATT接口和进行下一次扫描之间存在延迟。 4.不要试图一次读取超过3个设备的GATT特性。

总的来说,它在一个较旧的Android设备中有些不可避免地完全避免了这个问题,但你可以通过仔细计时扫描/停止扫描/连接/断开/循环来缓解它。

© www.soinside.com 2019 - 2024. All rights reserved.