0
我在与自定义BLE传感器板进行通信的Android手机上使用BLE应用程序。板有两个特征,加速度和心电图。在电话方面,我希望收到来自传感器板的两个特征通知。我的代码来设置通知:Bluetooth LE听取多个特征通知
mGatt.setCharacteristicNotification(ecgChar, true);
BluetoothGattDescriptor descriptor = ecgChar.getDescriptor(
UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mGatt.writeDescriptor(descriptor);
mGatt.setCharacteristicNotification(accelChar, true);
descriptor = ecgChar.getDescriptor(
UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mGatt.writeDescriptor(descriptor);
但是,我只能接收第一个特征的通知。当我只注册一个特征的通知时,它运行良好。心电图和加速度采样频率均为100Hz。那么,我怎样才能从这两个特征接收通知?谢谢。
事实上,我知道gatt操作是序列化的,所以我试图在两次写入之间添加延迟,但没有奏效。现在我使用回调来处理序列化,这是正确的方式,它运作良好!谢谢! – Sentimental