【问题标题】:Bluetooth Low Energy: gattCharacteristic.getDescriptor() returns null低功耗蓝牙:gattCharacteristic.getDescriptor() 返回 null
【发布时间】:2015-06-02 10:44:49
【问题描述】:

我在获取特征描述符时遇到问题,它总是返回 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});

我在装有 Android 5.1 的 Nexus 6 和装有 OS 2.0(如 Android 4.3)的诺基亚 X2 DS 上尝试过此操作,但遇到了类似的错误。

等待答案) 感谢您的关注!

【问题讨论】:

    标签: android bluetooth bluetooth-lowenergy descriptor characteristics


    【解决方案1】:

    通知描述符的 uuid 是“00002902-0000-1000-8000-00805f9b34fb”,而不是代码中的“00000001-0000-1000-8000-00805f9b34fb”。

    【讨论】:

    • 非常感谢)它的工作原理!
    • 我来到这里是因为getDescriptor 正在返回null。但是,我已经在使用正确的 UUID :(
    • @me-- 请将此作为单独的问题提出。在 cmets 中很难讨论这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    • 2014-08-23
    • 2018-10-12
    • 2012-05-28
    • 1970-01-01
    相关资源
    最近更新 更多