On Android when you want to receive BLE notifications for characteristic changes you use something like the following:
BluetoothGattCharacteristic characteristic = ...
gatt.setCharacteristicNotification(characteristic, true);
BluetoothGattDescriptor descriptor =
characteristic.getDescriptor(CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID);
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
gatt.writeDescriptor(descriptor);
My question is: what is the gatt.setCharacteristicNotification()
doing?
My assumption is that the above code represents:
- Tell Android to pay attention for notifications from characteristic X
- Tell the BLE device to start broadcasting change notifications for X
It seems logical, but I haven't seen it documented anywhere - instead the docs simply tell you to do what I wrote above. I'd like to confirm the purpose of setCharacteristicNotification()
in this process.