public class AylaBaseGattCharacteristic
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
AylaBaseGattCharacteristic.OnCharacteristicChangedListener |
Constructor and Description |
---|
AylaBaseGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic owner) |
Modifier and Type | Method and Description |
---|---|
AylaAPIRequest |
enableCharacteristicNotification(android.bluetooth.BluetoothGatt gatt,
boolean enable,
com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener,
ErrorListener errorListener)
Enable or disable notification on a characteristic.
|
AylaBaseGattCharacteristic.OnCharacteristicChangedListener |
getCharacteristicChangedListener() |
int |
getIntValue()
Return the stored value of this characteristic.
|
java.lang.String |
getName() |
android.bluetooth.BluetoothGattCharacteristic |
getOwner()
Get the owner characteristic hosted by this characteristic.
|
java.lang.String |
getStringValue()
Return the stored value of this characteristic.
|
protected android.os.Handler |
getUiHandler()
Returns the UI handler to post read/write result on the main thread.
|
java.util.UUID |
getUUID() |
byte[] |
getValue()
Return the stored value of this characteristic.
|
void |
onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattCharacteristic characteristic)
Callback triggered as a result of a remote characteristic notification.
|
boolean |
onCharacteristicRead(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattCharacteristic characteristic,
int status)
Callback method to receive the result of a characteristic read operation.
|
boolean |
onCharacteristicWrite(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattCharacteristic characteristic,
int status)
Callback indicating the result of a characteristic write operation.
|
void |
onDescriptorRead(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattDescriptor descriptor,
int status)
Callback reporting the result of a descriptor read operation.
|
void |
onDescriptorWrite(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattDescriptor descriptor,
int status)
Callback indicating the result of a descriptor write operation.
|
AylaAPIRequest |
readCharacteristic(android.bluetooth.BluetoothGatt gatt,
com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener,
ErrorListener errorListener)
readCharacteristic
|
AylaAPIRequest |
readDescriptor(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattDescriptor descriptor,
com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener,
ErrorListener errorListener)
readDescriptor
|
boolean |
setIntValue(int value)
Updates the locally stored value of this characteristic.
|
void |
setOnCharacteristicChangedListener(AylaBaseGattCharacteristic.OnCharacteristicChangedListener listener) |
boolean |
setStringValue(java.lang.String value)
Updates the locally stored value of this characteristic.
|
boolean |
setValue(byte[] value)
Updates the locally stored value of this characteristic.
|
protected boolean |
shouldHandleRead()
Called after data for a characteristic has been read or has changed, in
onCharacteristicRead(BluetoothGatt, BluetoothGattCharacteristic, int) and
in onCharacteristicChanged(BluetoothGatt, BluetoothGattCharacteristic) respectively. |
protected boolean |
shouldHandleWrite()
Called before data for a characteristic is about to be written.
|
AylaAPIRequest |
writeCharacteristic(android.bluetooth.BluetoothGatt gatt,
com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener,
ErrorListener errorListener)
writeCharacteristic
|
AylaAPIRequest |
writeDescriptor(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattDescriptor descriptor,
com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener,
ErrorListener errorListener)
writeDescriptor
|
public AylaBaseGattCharacteristic(@NonNull android.bluetooth.BluetoothGattCharacteristic owner)
public void setOnCharacteristicChangedListener(AylaBaseGattCharacteristic.OnCharacteristicChangedListener listener)
public AylaBaseGattCharacteristic.OnCharacteristicChangedListener getCharacteristicChangedListener()
public final android.bluetooth.BluetoothGattCharacteristic getOwner()
public final java.util.UUID getUUID()
public java.lang.String getName()
public boolean setValue(byte[] value)
public byte[] getValue()
public boolean setIntValue(int value)
public int getIntValue()
public boolean setStringValue(java.lang.String value)
public java.lang.String getStringValue()
protected boolean shouldHandleRead()
onCharacteristicRead(BluetoothGatt, BluetoothGattCharacteristic, int)
and
in onCharacteristicChanged(BluetoothGatt, BluetoothGattCharacteristic)
respectively.protected boolean shouldHandleWrite()
setValue(byte[])
, should override this method and return true to allow the
writing to remote GATT server happening.protected android.os.Handler getUiHandler()
public AylaAPIRequest readCharacteristic(@NonNull android.bluetooth.BluetoothGatt gatt, @NonNull com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener, @NonNull ErrorListener errorListener)
public AylaAPIRequest writeCharacteristic(@NonNull android.bluetooth.BluetoothGatt gatt, @NonNull com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener, @NonNull ErrorListener errorListener)
public AylaAPIRequest enableCharacteristicNotification(@NonNull android.bluetooth.BluetoothGatt gatt, boolean enable, @NonNull com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener, @NonNull ErrorListener errorListener)
enable
- true to enable notification, false to disable notification.successListener
- the listener in response to the notification set result.errorListener
- errorListenerpublic AylaAPIRequest readDescriptor(@NonNull android.bluetooth.BluetoothGatt gatt, @NonNull android.bluetooth.BluetoothGattDescriptor descriptor, @NonNull com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener, @NonNull ErrorListener errorListener)
public AylaAPIRequest writeDescriptor(@NonNull android.bluetooth.BluetoothGatt gatt, @NonNull android.bluetooth.BluetoothGattDescriptor descriptor, @NonNull com.android.volley.Response.Listener<AylaBaseGattCharacteristic> successListener, @NonNull ErrorListener errorListener)
public boolean onCharacteristicRead(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic, int status)
gatt
- GATT client invoked BluetoothGatt.readCharacteristic(android.bluetooth.BluetoothGattCharacteristic)
characteristic
- Characteristic that was read from the associated
remote device.status
- BluetoothGatt.GATT_SUCCESS
if the read operation
was completed successfully.public boolean onCharacteristicWrite(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic, int status)
If this callback is invoked while a reliable write transaction is in progress, the value of the characteristic represents the value reported by the remote device. An application should compare this value to the desired value to be written. If the values don't match, the application must abort the reliable write transaction.
gatt
- GATT client invoked BluetoothGatt.writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic)
characteristic
- Characteristic that was written to the associated
remote device.status
- The result of the write operation
BluetoothGatt.GATT_SUCCESS
if the operation succeeds.public void onDescriptorRead(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattDescriptor descriptor, int status)
gatt
- GATT client invoked BluetoothGatt.readDescriptor(android.bluetooth.BluetoothGattDescriptor)
descriptor
- Descriptor that was read from the associated
remote device.status
- BluetoothGatt.GATT_SUCCESS
if the read operation
was completed successfullypublic void onDescriptorWrite(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattDescriptor descriptor, int status)
gatt
- GATT client invoked BluetoothGatt.writeDescriptor(android.bluetooth.BluetoothGattDescriptor)
descriptor
- Descriptor that was writte to the associated
remote device.status
- The result of the write operation
BluetoothGatt.GATT_SUCCESS
if the operation succeeds.public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt, android.bluetooth.BluetoothGattCharacteristic characteristic)
gatt
- GATT client the characteristic is associated withcharacteristic
- Characteristic that has been updated as a result
of a remote notification event.