繁体   English   中英

未调用Android BLE onCharacteristicChanged

[英]Android BLE onCharacteristicChanged not invoked

在我的应用程序中,我使用了setCharacteristicNotification来启用特征通知。 在日志猫中,我正在获取通知启用true,也成功完成了onDescriptorWrite回调,但是未调用回调方法onCharacteristicChanged。请帮助我。 提前致谢

日志

 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();
                }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM