Search code examples
androidbluetoothbluetooth-lowenergydescriptorcharacteristics

Bluetooth Low Energy: gattCharacteristic.getDescriptor() returns null


I have a problem with getting characteristic's descriptor, it always returns null. There is a chunck of my code:

public static final String CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID = "00000001-0000-1000-8000-00805f9b34fb";
public final static UUID tmp_uuid_1 = UUID.fromString(CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID);

...

BluetoothGattDescriptor descriptor = gattCharacteristic.getDescriptor(tmp_uuid_1);
descriptor.setValue(true ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : new byte[]{0x00, 0x00});

I tried this on Nexus 6 with Android 5.1 and Nokia X2 DS with OS 2.0 like Android 4.3, and have a similar error.

Waiting for answers ) Thank you for your attention!


Solution

  • The uuid for notification descriptor is "00002902-0000-1000-8000-00805f9b34fb" instead of the "00000001-0000-1000-8000-00805f9b34fb" in your code.