public class BluetoothGattDescriptor extends Object implements Parcelable
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.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<BluetoothGattDescriptor> |
CREATOR |
static byte[] |
DISABLE_NOTIFICATION_VALUE
Value used to disable notifications or indicatinos
|
static byte[] |
ENABLE_INDICATION_VALUE
Value used to enable indication for a client configuration descriptor
|
static byte[] |
ENABLE_NOTIFICATION_VALUE
Value used to enable notification for a client configuration descriptor
|
protected BluetoothGattCharacteristic |
mCharacteristic
Back-reference to the characteristic this descriptor belongs to.
|
protected int |
mInstance
Instance ID for this descriptor.
|
protected int |
mPermissions
Permissions for this descriptor
|
protected UUID |
mUuid
The UUID of this descriptor.
|
protected byte[] |
mValue
The value for this descriptor.
|
static int |
PERMISSION_READ
Descriptor read permission
|
static int |
PERMISSION_READ_ENCRYPTED
Descriptor permission: Allow encrypted read operations
|
static int |
PERMISSION_READ_ENCRYPTED_MITM
Descriptor permission: Allow reading with man-in-the-middle protection
|
static int |
PERMISSION_WRITE
Descriptor write permission
|
static int |
PERMISSION_WRITE_ENCRYPTED
Descriptor permission: Allow encrypted writes
|
static int |
PERMISSION_WRITE_ENCRYPTED_MITM
Descriptor permission: Allow encrypted writes with man-in-the-middle
protection
|
static int |
PERMISSION_WRITE_SIGNED
Descriptor permission: Allow signed write operations
|
static int |
PERMISSION_WRITE_SIGNED_MITM
Descriptor permission: Allow signed write operations with
man-in-the-middle protection
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
BluetoothGattDescriptor(UUID uuid,
int permissions)
Create a new BluetoothGattDescriptor.
|
BluetoothGattDescriptor(UUID uuid,
int instance,
int permissions) |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
BluetoothGattCharacteristic |
getCharacteristic()
Returns the characteristic this descriptor belongs to.
|
int |
getInstanceId()
Returns the instance ID for this descriptor.
|
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
BluetoothGatt.readDescriptor(android.bluetooth.BluetoothGattDescriptor) . |
boolean |
setValue(byte[] value)
Updates the locally stored value of this descriptor.
|
void |
writeToParcel(Parcel out,
int flags)
Flatten this object in to a Parcel.
|
public static final byte[] ENABLE_NOTIFICATION_VALUE
public static final byte[] ENABLE_INDICATION_VALUE
public static final byte[] DISABLE_NOTIFICATION_VALUE
public static final int PERMISSION_READ
public static final int PERMISSION_READ_ENCRYPTED
public static final int PERMISSION_READ_ENCRYPTED_MITM
public static final int PERMISSION_WRITE
public static final int PERMISSION_WRITE_ENCRYPTED
public static final int PERMISSION_WRITE_ENCRYPTED_MITM
public static final int PERMISSION_WRITE_SIGNED
public static final int PERMISSION_WRITE_SIGNED_MITM
protected UUID mUuid
protected int mInstance
protected int mPermissions
protected BluetoothGattCharacteristic mCharacteristic
protected byte[] mValue
public static final Parcelable.Creator<BluetoothGattDescriptor> CREATOR
public BluetoothGattDescriptor(UUID uuid, int permissions)
Requires android.Manifest.permission#BLUETOOTH
permission.
uuid
- The UUID for this descriptorpermissions
- Permissions for this descriptorpublic BluetoothGattDescriptor(UUID uuid, int instance, int permissions)
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel out, int flags)
Parcelable
writeToParcel
in interface Parcelable
out
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public BluetoothGattCharacteristic getCharacteristic()
public UUID getUuid()
public int getInstanceId()
If a remote device offers multiple descriptors with the same UUID, the instance ID is used to distuinguish between descriptors.
Requires android.Manifest.permission#BLUETOOTH
permission.
public int getPermissions()
public byte[] getValue()
This function returns the stored value for this descriptor as
retrieved by calling BluetoothGatt.readDescriptor(android.bluetooth.BluetoothGattDescriptor)
. The cached
value of the descriptor is updated as a result of a descriptor read
operation.
public boolean setValue(byte[] value)
This function modifies the locally stored cached value of this
descriptor. To send the value to the remote device, call
BluetoothGatt.writeDescriptor(android.bluetooth.BluetoothGattDescriptor)
to send the value to the
remote device.
value
- New value for this descriptor