Android APIs
public class

BluetoothGattDescriptor

extends Object
java.lang.Object
   ↳ android.bluetooth.BluetoothGattDescriptor

Class Overview

Represents a Bluetooth GATT Descriptor

GATT Descriptors contain additional information and attributes of a GATT characteristic, BluetoothGattCharacteristic. They can be used to describe the characteristic's features or to control certain behaviours of the characteristic.

Summary

Constants
int PERMISSION_READ Descriptor read permission
int PERMISSION_READ_ENCRYPTED Descriptor permission: Allow encrypted read operations
int PERMISSION_READ_ENCRYPTED_MITM Descriptor permission: Allow reading with man-in-the-middle protection
int PERMISSION_WRITE Descriptor write permission
int PERMISSION_WRITE_ENCRYPTED Descriptor permission: Allow encrypted writes
int PERMISSION_WRITE_ENCRYPTED_MITM Descriptor permission: Allow encrypted writes with man-in-the-middle protection
int PERMISSION_WRITE_SIGNED Descriptor permission: Allow signed write operations
int PERMISSION_WRITE_SIGNED_MITM Descriptor permission: Allow signed write operations with man-in-the-middle protection
Fields
public static final byte[] DISABLE_NOTIFICATION_VALUE Value used to disable notifications or indicatinos
public static final byte[] ENABLE_INDICATION_VALUE Value used to enable indication for a client configuration descriptor
public static final byte[] ENABLE_NOTIFICATION_VALUE Value used to enable notification for a client configuration descriptor
Public Constructors
BluetoothGattDescriptor(UUID uuid, int permissions)
Create a new BluetoothGattDescriptor.
Public Methods
BluetoothGattCharacteristic getCharacteristic()
Returns the characteristic this descriptor belongs to.
int getPermissions()
Returns the permissions for this descriptor.
UUID getUuid()
Returns the UUID of this descriptor.
byte[] getValue()
Returns the stored value for this descriptor

This function returns the stored value for this descriptor as retrieved by calling readDescriptor(BluetoothGattDescriptor).

boolean setValue(byte[] value)
Updates the locally stored value of this descriptor.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int PERMISSION_READ

Added in API level 18

Descriptor read permission

Constant Value: 1 (0x00000001)

public static final int PERMISSION_READ_ENCRYPTED

Added in API level 18

Descriptor permission: Allow encrypted read operations

Constant Value: 2 (0x00000002)

public static final int PERMISSION_READ_ENCRYPTED_MITM

Added in API level 18

Descriptor permission: Allow reading with man-in-the-middle protection

Constant Value: 4 (0x00000004)

public static final int PERMISSION_WRITE

Added in API level 18

Descriptor write permission

Constant Value: 16 (0x00000010)

public static final int PERMISSION_WRITE_ENCRYPTED

Added in API level 18

Descriptor permission: Allow encrypted writes

Constant Value: 32 (0x00000020)

public static final int PERMISSION_WRITE_ENCRYPTED_MITM

Added in API level 18

Descriptor permission: Allow encrypted writes with man-in-the-middle protection

Constant Value: 64 (0x00000040)

public static final int PERMISSION_WRITE_SIGNED

Added in API level 18

Descriptor permission: Allow signed write operations

Constant Value: 128 (0x00000080)

public static final int PERMISSION_WRITE_SIGNED_MITM

Added in API level 18

Descriptor permission: Allow signed write operations with man-in-the-middle protection

Constant Value: 256 (0x00000100)

Fields

public static final byte[] DISABLE_NOTIFICATION_VALUE

Added in API level 18

Value used to disable notifications or indicatinos

public static final byte[] ENABLE_INDICATION_VALUE

Added in API level 18

Value used to enable indication for a client configuration descriptor

public static final byte[] ENABLE_NOTIFICATION_VALUE

Added in API level 18

Value used to enable notification for a client configuration descriptor

Public Constructors

public BluetoothGattDescriptor (UUID uuid, int permissions)

Added in API level 18

Create a new BluetoothGattDescriptor.

Requires BLUETOOTH permission.

Parameters
uuid The UUID for this descriptor
permissions Permissions for this descriptor

Public Methods

public BluetoothGattCharacteristic getCharacteristic ()

Added in API level 18

Returns the characteristic this descriptor belongs to.

Returns
  • The characteristic.

public int getPermissions ()

Added in API level 18

Returns the permissions for this descriptor.

Returns
  • Permissions of this descriptor

public UUID getUuid ()

Added in API level 18

Returns the UUID of this descriptor.

Returns
  • UUID of this descriptor

public byte[] getValue ()

Added in API level 18

Returns the stored value for this descriptor

This function returns the stored value for this descriptor as retrieved by calling readDescriptor(BluetoothGattDescriptor). The cached value of the descriptor is updated as a result of a descriptor read operation.

Returns
  • Cached value of the descriptor

public boolean setValue (byte[] value)

Added in API level 18

Updates the locally stored value of this descriptor.

This function modifies the locally stored cached value of this descriptor. To send the value to the remote device, call writeDescriptor(BluetoothGattDescriptor) to send the value to the remote device.

Parameters
value New value for this descriptor
Returns
  • true if the locally stored value has been set, false if the requested value could not be stored locally.