1

我有一個獲取特徵描述符的問題,它總是返回null。 還有就是我的代碼chunck:Bluetooth Low Energy:gattCharacteristic.getDescriptor()返回null

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

我與OS 2.0試過這種在Nexus 6與Android 5.1和諾基亞X2 DS一樣的Android 4.3,並且具有類似的錯誤。

等待答案) 感謝您的關注!

回答

3

通知描述符的uuid是「00002902-0000-1000-8000-00805f9b34fb」而不是代碼中的「00000001-0000-1000-8000-00805f9b34fb」。

+1

非常感謝)It Works! –

+0

我到達這裏是因爲'getDescriptor'返回'null'。但是,我已經在使用正確的UUID :( –

+0

@ me--請把它作爲一個單獨的問題,在評論中很難討論這個問題。 – reTs