public interface GattCharacteristic
GattService
.Modifier and Type | Interface and Description |
---|---|
static interface |
GattCharacteristic.Permissions
Marks an
int as containing one of the
permission constants from GattCharacteristic . |
static interface |
GattCharacteristic.Properties
Marks an
int as containing one of the
property constants from GattCharacteristic . |
Modifier and Type | Field and Description |
---|---|
static int |
PERMISSION_NULL
Indicates no permissions could be found.
|
static int |
PERMISSION_READ
Characteristic read permission
|
static int |
PERMISSION_READ_ENCRYPTED
Allow encrypted read operations
|
static int |
PERMISSION_READ_ENCRYPTED_MITM
Allow reading with man-in-the-middle protection
|
static int |
PERMISSION_WRITE
Characteristic write permission
|
static int |
PERMISSION_WRITE_ENCRYPTED
Allow encrypted writes
|
static int |
PERMISSION_WRITE_ENCRYPTED_MITM
Allow encrypted writes with man-in-the-middle protection
|
static int |
PERMISSION_WRITE_SIGNED
Allow signed write operations
|
static int |
PERMISSION_WRITE_SIGNED_MITM
Allow signed write operations with man-in-the-middle protection
|
static int |
PROPERTY_BROADCAST
Characteristic is broadcastable.
|
static int |
PROPERTY_EXTENDED_PROPS
Characteristic has extended properties
|
static int |
PROPERTY_INDICATE
Characteristic supports indication
|
static int |
PROPERTY_NOTIFY
Characteristic supports notification
|
static int |
PROPERTY_READ
Characteristic is readable.
|
static int |
PROPERTY_SIGNED_WRITE
Characteristic supports write with signature
|
static int |
PROPERTY_WRITE
Characteristic can be written.
|
static int |
PROPERTY_WRITE_NO_RESPONSE
Characteristic can be written without response.
|
Modifier and Type | Method and Description |
---|---|
rx.Observable<java.util.UUID> |
disableNotification(java.util.UUID descriptor,
OperationTimeout timeout)
Disable notification events for a given descriptor.
|
rx.Observable<java.util.UUID> |
enableNotification(java.util.UUID descriptor,
OperationTimeout timeout)
Enable notification events for a given descriptor.
|
int |
getDescriptorPermissions(java.util.UUID descriptor)
Returns the permissions associated with a given descriptor.
|
java.util.List<java.util.UUID> |
getDescriptors()
Returns the descriptors of the characteristic.
|
int |
getPermissions()
Returns the permissions of this characteristic.
|
int |
getProperties()
Returns the properties of this characteristic.
|
GattService |
getService()
Returns the service that owns this characteristic.
|
java.util.UUID |
getUuid()
Returns the identifier of the characteristic.
|
rx.Observable<java.lang.Void> |
write(GattPeripheral.WriteType writeType,
byte[] payload,
OperationTimeout timeout)
Writes a given payload on the characteristic.
|
static final int PROPERTY_BROADCAST
static final int PROPERTY_READ
static final int PROPERTY_WRITE_NO_RESPONSE
static final int PROPERTY_WRITE
static final int PROPERTY_NOTIFY
static final int PROPERTY_INDICATE
static final int PROPERTY_SIGNED_WRITE
static final int PROPERTY_EXTENDED_PROPS
static final int PERMISSION_NULL
static final int PERMISSION_READ
static final int PERMISSION_READ_ENCRYPTED
static final int PERMISSION_READ_ENCRYPTED_MITM
static final int PERMISSION_WRITE
static final int PERMISSION_WRITE_ENCRYPTED
static final int PERMISSION_WRITE_ENCRYPTED_MITM
static final int PERMISSION_WRITE_SIGNED
static final int PERMISSION_WRITE_SIGNED_MITM
java.util.UUID getUuid()
@GattCharacteristic.Properties int getProperties()
@GattCharacteristic.Permissions int getPermissions()
GattService getService()
java.util.List<java.util.UUID> getDescriptors()
@GattCharacteristic.Permissions int getDescriptorPermissions(java.util.UUID descriptor)
descriptor
- The descriptor identifier.0
otherwise.rx.Observable<java.util.UUID> enableNotification(java.util.UUID descriptor, OperationTimeout timeout)
descriptor
- The descriptor to enable notifications for.timeout
- The timeout to apply to the operation.rx.Observable<java.util.UUID> disableNotification(java.util.UUID descriptor, OperationTimeout timeout)
descriptor
- The descriptor to enable notifications for.timeout
- The timeout to apply to the operation.rx.Observable<java.lang.Void> write(GattPeripheral.WriteType writeType, byte[] payload, OperationTimeout timeout)
Important: it appears on some devices that writes are asynchronous on multiple levels. Although the stack may report the write was successful, it doesn't mean the write has actually completed. If you're going to disconnect after a write operation, it's a good idea to add a delay of a few seconds.
The value of writeType is supposed to be automatically inferred during service discovery, but some devices do not consistently populate the value (Verizon Note 4). As such, this value must be provided for every write command call.
writeType
- The type of write to perform.payload
- The payload to write. Must be 20 bytes
or less.timeout
- The timeout to wrap the operation within.