我希望在设备BLE上的特定特征发生变化时收到通知,我使用了onCharacteristicChanged和setCharacteristicNotification()上的方法,但是当我更改连接设备的操作时没有发生更改。
使用BLE接收设备更改的任何示例?
答案 0 :(得分:0)
你使用了descriptor.setValue()吗?
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#notification