问题
我试图将多个蓝牙LE设备(心率监视器)连接到我的Android设备。我可以扫描并连接到它们。他们流传输很好,只是当我输出通知时,它会在一个传感器的数据之间跳转到另一个。试图通过蓝牙LE连接多个设备到Android设备
我基本上是用this GitHub的源代码对于大多数这个项目的。在项目中,他们使用ONE服务(称为BluetoothLeService)。在项目中,我创建了两个服务,彼此相当多的重复,除了一个处理一个用户通话,另一个用于处理其他用户。
我得到这个输出到控制台:
07-27 21:14:01.786 9062-9062/com.example.android.aware d/BluetoothGatt:setCharacteristicNotification() - UUID:00002a37 -0000-1000-8000-00805f9b34fb enable:true
07-27 21:14:01.786 9062-9062/com.example.android.aware D/BluetoothLeService2:尝试使用现有的mBluetoothGatt进行连接。此错误来自BLS2
07-27 21:14:01.796 9062-10009/com.example.android.aware D/BluetoothGatt:onClientConnectionState() - status = 133 clientIf = 7 device = E3:64:43: 37:D2:AA
07-27 21:14:01.796 9062-10009/com.example.android.aware I/BluetoothLeService2:断开与GATT服务器的连接。
07-27 21:14:01.796 9062-9062/com.example.android.aware d/BluetoothGatt:setCharacteristicNotification() - UUID:00002a37-0000-1000-8000-00805f9b34fb启用:真
07 -27 21:14:01.816 9062-9062/com.example.android.aware d/BluetoothLeService:试图使用现有mBluetoothGatt进行连接。此错误来自BLS1
07-27 21:14:01.826 9062-10009/com.example.android.aware D/BluetoothGatt:onClientConnectionState() - status = 133 clientIf = 6 device = 00:22:D0: 41:CA:B6
07-27 21:14:01.826 9062-10009/com.example.android.aware I/BluetoothLeService:与GATT服务器断开连接。
尝试
我试图添加一个新的CLIENT_CHARACTERISTIC_CONFIG(称之为CLIENT_CHARACTERISTIC_CONFIG2)在SampleGattAttributes类的字符串,该进来下面的代码片段播放(从服务分类):
BluetoothGattDescriptor descriptor = characteristic .getDescriptor(UUID .fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
我想问题,如控制台说,有事情做,在这两种服务称为mBluetoothGatt(这是一个BluetoothGatt类型的对象)的变量。我的想法是这样的:
如果我有同步运行两个服务,那么如果我创造各两个不同BluetoothGatt对象,为什么我被告知正在使用相同BluetoothGatt对象?
即使您认为您应该可以在实践中独立处理这两种设备,但我发现让事情可靠的唯一方法是同步多个外围设备的代码,以便我只有一个请求外设一次。它使启动缓慢。 – Ifor