使用蓝牙低功耗接收和收听更改

时间:2015-01-21 09:49:51

标签: android bluetooth bluetooth-lowenergy

我希望在设备BLE上的特定特征发生变化时收到通知,我使用了onCharacteristicChanged和setCharacteristicNotification()上的方法,但是当我更改连接设备的操作时没有发生更改。

使用BLE接收设备更改的任何示例?

1 个答案:

答案 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