如何找出CLIENT_CHARACTERISTIC_CONFIG?
How to find out CLIENT_CHARACTERISTIC_CONFIG?
我需要 CLIENT_CHARACTERISTIC_CONFIG
UUID 来激活我的应用程序中的通知。在 google 示例应用程序中,它们是预定义的:
public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
我只有:
- BidirectionalService : b9e875c0-1cfa-11e6-b797-0002a5d5c51b
- Rx : 0c68d100-266f-11e6-b388-0002a5d5c51b
- Tx : 1ed9e2c0-266f-11e6-850b-0002a5d5c51b
如何获取 UUID:
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(needed UUID here));
descriptor.setValue(enabled?BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : new byte[]{0x00, 0x00});
mBluetoothGatt.writeDescriptor(descriptor);
客户端特征配置的 UUID 为 0x2902,或者长格式的“00002902-0000-1000-8000-00805f9b34fb”,已在您的应用中定义。
作为旁注,您可以找到所有支持的描述符及其 UUID,如 Nick Unucheck 的回答所示:
我需要 CLIENT_CHARACTERISTIC_CONFIG
UUID 来激活我的应用程序中的通知。在 google 示例应用程序中,它们是预定义的:
public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
我只有:
- BidirectionalService : b9e875c0-1cfa-11e6-b797-0002a5d5c51b
- Rx : 0c68d100-266f-11e6-b388-0002a5d5c51b
- Tx : 1ed9e2c0-266f-11e6-850b-0002a5d5c51b
如何获取 UUID:
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(needed UUID here));
descriptor.setValue(enabled?BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : new byte[]{0x00, 0x00});
mBluetoothGatt.writeDescriptor(descriptor);
客户端特征配置的 UUID 为 0x2902,或者长格式的“00002902-0000-1000-8000-00805f9b34fb”,已在您的应用中定义。
作为旁注,您可以找到所有支持的描述符及其 UUID,如 Nick Unucheck 的回答所示: