我在与自定义 BLE 传感器板通信的 Android 手机上使用 BLE 应用程序。该板提供了两个特性,加速度和心电图。在电话方面,我想从传感器板接收两个特性的通知。我设置通知的代码:
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);
但是,我只能收到第一个特征的通知。当我只为一个特性注册通知时,它运行良好。ECG 和加速度的采样频率均为 100Hz。那么如何接收来自这两个特征的通知呢?谢谢。