Android BLE onCharacteristicChanged 未调用

Android BLE onCharacteristicChanged not invoked

在我的应用程序中,我使用 setCharacteristicNotification 为特征启用通知。在日志猫中,我收到通知 enable true 也在 onDescriptorWrite 回调上获得成功,但回调方法 onCharacteristicChanged 没有 called.Please 帮助我。提前致谢

日志

 D/BluetoothGatt(15694): setCharacteristicNotification() - uuid: 00003c01-0000-1000-8000-00805f9b34fb enable: true

代码

 mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);

            BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
                    UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
           return mBluetoothGatt.writeDescriptor(descriptor);

刚刚在读写操作之间添加了睡眠,现在工作正常。

try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }