每一个连接请求被视为直接连接请求+安卓BLE [英] Every connection request is being treated as direct connect request + android ble

查看:427
本文介绍了每一个连接请求被视为直接连接请求+安卓BLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在写在这里想与我们想要连接外围的持久连接的应用程序BLE。出于同样的目的,我们希望每当我们失去一个现有的连接与外围重新连接。因此,我们的Andr​​oid应用程序为中心仅有试图通过创造新的bluetoothgatt对象以重新调用bluetoothdevice.connectgatt与自动连接为真。

但每当我们试图做的,我们重新连接被失败

  21 12-02:47:11.865:D / BluetoothGatt(31963):onClientConnectionState() - 状态= 133 clientIf = 6 DEVICE = ********回调。

由于我们的连接请求被视为直接连接请求Nexus 5的棒棒糖

下面是日志

 十一月12日至3日:46:12.804:D / BluetoothGatt(6902):连接() - 设备:58:EB:14:3D:2A:38,自动:真
十一月12日至3日:46:12.804:D / BluetoothGatt(6902):registerApp()
十一月12日至3日:46:12.804:D / BluetoothGatt(6902):registerApp() - UUID = b8f9298b-4a95-41be-80d6-22d82c498c5c
十一月12日至3日:46:12.807:D / BtGatt.GattService(31817):registerClient() - UUID = b8f9298b-4a95-41be-80d6-22d82c498c5c
十一月12日至3日:46:12.808:D / BtGatt.GattService(31817):onClientRegistered() - UUID = b8f9298b-4a95-41be-80d6-22d82c498c5c,clientIf = 6
十一月12日至3日:46:12.808:D / BluetoothGatt(6902):onClientRegistered() - 状态= 0 clientIf = 6
十一月12日至3日:46:12.808:D / BtGatt.GattService(31817):clientConnect() - 地址= 58:EB:14:3D:2A:38,isDirect =真
十一月12日至3日:46:12.809:D / BtGatt.btif(31817):btif_get_device_type:设备[58:EB:14:3D:2A:38] 2型,地址。 0型
十一月12日至3日:46:12.811:D / BLEManager(6902):试图创建一个新的连接。


解决方案

该问题是在这里所描述的竞争状态:的 HTTPS://$c$c.google.com/p/android/issues/detail ID = 69834

一个可能的解决方案,直到他们修复它(他们会?)是使用反射来手动构建一个关贸总协定对象,设置mAutoConnect标志为true,并调用connect。

We are writing a ble application where want to have a persistent connection with the peripheral we want to connect. For the same purpose we want to re-connect with the peripheral whenever we loose a existing connection. So our android application as a central just tries to reconnect by creating new bluetoothgatt object by calling bluetoothdevice.connectgatt with autoconnect as true.

But whenever we try to do that our reconnection gets failed with

12-02 21:47:11.865: D/BluetoothGatt(31963): onClientConnectionState() - status=133 clientIf=6 device=******** callback.

because our connection request is being treated as a direct connection request on nexus 5 lollipop

Here are the logs

12-03 11:46:12.804: D/BluetoothGatt(6902): connect() - device: 58:EB:14:3D:2A:38, auto: true
12-03 11:46:12.804: D/BluetoothGatt(6902): registerApp()
12-03 11:46:12.804: D/BluetoothGatt(6902): registerApp() - UUID=b8f9298b-4a95-41be-80d6-22d82c498c5c
12-03 11:46:12.807: D/BtGatt.GattService(31817): registerClient() - UUID=b8f9298b-4a95-41be-80d6-22d82c498c5c
12-03 11:46:12.808: D/BtGatt.GattService(31817): onClientRegistered() - UUID=b8f9298b-4a95-41be-80d6-22d82c498c5c, clientIf=6
12-03 11:46:12.808: D/BluetoothGatt(6902): onClientRegistered() - status=0 clientIf=6
12-03 11:46:12.808: D/BtGatt.GattService(31817): clientConnect() - address=58:EB:14:3D:2A:38, isDirect=true
12-03 11:46:12.809: D/BtGatt.btif(31817): btif_get_device_type: Device [58:eb:14:3d:2a:38] type 2, addr. type 0
12-03 11:46:12.811: D/BLEManager(6902): Trying to create a new connection.

解决方案

The problem is a race condition described here: https://code.google.com/p/android/issues/detail?id=69834

A possible solution until they fix it (will they?) is to use reflection to manually construct a gatt object, set the mAutoConnect flag to true and call connect.

这篇关于每一个连接请求被视为直接连接请求+安卓BLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆