public static enum ReadWriteListener.Status extends java.lang.Enum<ReadWriteListener.Status> implements UsesCustomNull
GenericListener_Void.onEvent(Event)
by way of ReadWriteListener.ReadWriteEvent.status()
that indicates success of the
operation or the reason for its failure. This enum is not
meant to match up with BluetoothGatt
.GATT_* values in any way.Enum Constant and Description |
---|
ANDROID_VERSION_NOT_SUPPORTED
The android api level doesn't support the lower level API call in the native stack.
|
CANCELLED_FROM_BLE_TURNING_OFF
The operation was cancelled because
BleManager went BleManagerState.TURNING_OFF and/or
BleManagerState.OFF . |
CANCELLED_FROM_DISCONNECT
The operation was cancelled by the device becoming
BleDeviceState.BLE_DISCONNECTED . |
DEVICE_CHIPSET_NOT_SUPPORTED
The android device's chipset doesn't support an API in the native stack.
|
DISCONNECTING
Device is connected, but it queued to be disconnected
|
EMPTY_DATA
Used either when
ReadWriteListener.ReadWriteEvent.type() ReadWriteListener.Type.isRead() and the operation was "successful" but
returned a zero-length array for ReadWriteListener.ReadWriteEvent.data() , or BleDevice.write(UUID, byte[]) (or overload(s) )
was called with a non-null but zero-length data parameter. |
FAILED_TO_SEND_OUT
The call to
BluetoothGatt.readCharacteristic(BluetoothGattCharacteristic)
or BluetoothGatt.writeCharacteristic(BluetoothGattCharacteristic)
or etc. |
FAILED_TO_SET_VALUE_ON_TARGET
BluetoothGattCharacteristic.setValue(byte[]) (or one of its overloads) or
BluetoothGattDescriptor.setValue(byte[]) (or one of its overloads) returned false . |
FAILED_TO_TOGGLE_NOTIFICATION
BluetoothGatt.setCharacteristicNotification(BluetoothGattCharacteristic, boolean)
returned false for an unknown reason. |
GATT_CONCURRENT_EXCEPTION
Sometimes android can throw a
ConcurrentModificationException when we try to retrieve a BluetoothGattService ,
BluetoothGattCharacteristic , or BluetoothGattDescriptor . |
GATT_RANDOM_EXCEPTION
Sometimes android can throw an
Exception when we try to retrieve a BluetoothGattService ,
BluetoothGattCharacteristic , or BluetoothGattDescriptor . |
INVALID_DATA
For now only used when giving a negative or zero value to
BleDevice.negotiateMtu(int, ReadWriteListener) . |
INVALID_TRANSACTION
The
BleTransaction provided was either not started or not the current. |
NO_DESCRIPTOR_UUID
This is only used when performing a descriptor read.
|
NO_MATCHING_TARGET
Couldn't find a matching
ReadWriteListener.ReadWriteEvent.target() for the ReadWriteListener.ReadWriteEvent.charUuid() (or
ReadWriteListener.ReadWriteEvent.descUuid() if ReadWriteListener.ReadWriteEvent.target() is ReadWriteListener.Target.DESCRIPTOR ) which was given to
BleDevice.read(UUID, ReadWriteListener) , BleDevice.write(UUID, byte[]) , etc. |
NOT_CONNECTED
Device is not
BleDeviceState.BLE_CONNECTED . |
NULL
As of now, only used for
DeviceReconnectFilter.ConnectFailEvent.txnFailReason() in some cases. |
NULL_DATA
Used either when
ReadWriteListener.ReadWriteEvent.type() ReadWriteListener.Type.isRead() and the stack returned a null
value for BluetoothGattCharacteristic.getValue() despite the operation being otherwise "successful", or
BleDevice.write(UUID, byte[]) (or overload(s) ) were called with a null data parameter. |
NULL_DEVICE
|
OPERATION_NOT_SUPPORTED
You tried to do a read on a characteristic that is write-only, or
vice-versa, or tried to read a notify-only characteristic, or etc., etc.
|
RELIABLE_WRITE_ABORTED
Specific to
ReadWriteListener.Target.RELIABLE_WRITE , this means BleDevice.reliableWrite_abort() was called. |
RELIABLE_WRITE_ALREADY_BEGAN
Specific to
ReadWriteListener.Target.RELIABLE_WRITE , this means BleDevice.reliableWrite_begin(ReadWriteListener) was
called twice without an intervening call to either BleDevice.reliableWrite_abort() or BleDevice.reliableWrite_execute() . |
RELIABLE_WRITE_FAILED_TO_BEGIN
Specific to
ReadWriteListener.Target.RELIABLE_WRITE , this means the underlying call to BluetoothGatt.beginReliableWrite()
returned false . |
RELIABLE_WRITE_NEVER_BEGAN
Specific to
ReadWriteListener.Target.RELIABLE_WRITE , this means BleDevice.reliableWrite_abort() or BleDevice.reliableWrite_execute()
was called without a previous call to BleDevice.reliableWrite_begin(ReadWriteListener) . |
REMOTE_GATT_FAILURE
The operation failed in a "normal" fashion, at least relative to all the other strange ways an operation can fail.
|
SUCCESS
If
ReadWriteListener.ReadWriteEvent.type() ReadWriteListener.Type.isRead() then ReadWriteListener.ReadWriteEvent.data() will contain some data returned from
the device. |
TIMED_OUT
Operation took longer than time specified in
BleNodeConfig.taskTimeoutRequestFilter so we cut it loose. |
Modifier and Type | Method and Description |
---|---|
boolean |
isNull()
Returns
true if the object's state represents what would otherwise be Java's built-in null . |
static ReadWriteListener.Status |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static ReadWriteListener.Status[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
boolean |
wasCancelled()
|
public static final ReadWriteListener.Status NULL
DeviceReconnectFilter.ConnectFailEvent.txnFailReason()
in some cases.public static final ReadWriteListener.Status SUCCESS
ReadWriteListener.ReadWriteEvent.type()
ReadWriteListener.Type.isRead()
then ReadWriteListener.ReadWriteEvent.data()
will contain some data returned from
the device. If type is ReadWriteListener.Type.WRITE
then ReadWriteListener.ReadWriteEvent.data()
was sent to the device.public static final ReadWriteListener.Status NULL_DEVICE
BleDevice.read(UUID, ReadWriteListener)
, BleDevice.write(UUID, byte[])
,
etc. was called on BleDevice.NULL
.public static final ReadWriteListener.Status NOT_CONNECTED
BleDeviceState.BLE_CONNECTED
.public static final ReadWriteListener.Status DISCONNECTING
public static final ReadWriteListener.Status NO_DESCRIPTOR_UUID
public static final ReadWriteListener.Status NO_MATCHING_TARGET
ReadWriteListener.ReadWriteEvent.target()
for the ReadWriteListener.ReadWriteEvent.charUuid()
(or
ReadWriteListener.ReadWriteEvent.descUuid()
if ReadWriteListener.ReadWriteEvent.target()
is ReadWriteListener.Target.DESCRIPTOR
) which was given to
BleDevice.read(UUID, ReadWriteListener)
, BleDevice.write(UUID, byte[])
, etc. This most likely
means that the internal call to BluetoothGatt.discoverServices()
didn't find any
BluetoothGattService
that contained a BluetoothGattCharacteristic
for ReadWriteListener.ReadWriteEvent.charUuid()
.
This can also happen if the internal call to get a BluetoothService(s) causes an exception (seen on some phones).public static final ReadWriteListener.Status GATT_CONCURRENT_EXCEPTION
ConcurrentModificationException
when we try to retrieve a BluetoothGattService
,
BluetoothGattCharacteristic
, or BluetoothGattDescriptor
. In this case, it's best to just try your operation again.public static final ReadWriteListener.Status GATT_RANDOM_EXCEPTION
Exception
when we try to retrieve a BluetoothGattService
,
BluetoothGattCharacteristic
, or BluetoothGattDescriptor
.public static final ReadWriteListener.Status RELIABLE_WRITE_FAILED_TO_BEGIN
ReadWriteListener.Target.RELIABLE_WRITE
, this means the underlying call to BluetoothGatt.beginReliableWrite()
returned false
.public static final ReadWriteListener.Status RELIABLE_WRITE_ALREADY_BEGAN
ReadWriteListener.Target.RELIABLE_WRITE
, this means BleDevice.reliableWrite_begin(ReadWriteListener)
was
called twice without an intervening call to either BleDevice.reliableWrite_abort()
or BleDevice.reliableWrite_execute()
.public static final ReadWriteListener.Status RELIABLE_WRITE_NEVER_BEGAN
ReadWriteListener.Target.RELIABLE_WRITE
, this means BleDevice.reliableWrite_abort()
or BleDevice.reliableWrite_execute()
was called without a previous call to BleDevice.reliableWrite_begin(ReadWriteListener)
.public static final ReadWriteListener.Status RELIABLE_WRITE_ABORTED
ReadWriteListener.Target.RELIABLE_WRITE
, this means BleDevice.reliableWrite_abort()
was called.public static final ReadWriteListener.Status OPERATION_NOT_SUPPORTED
public static final ReadWriteListener.Status ANDROID_VERSION_NOT_SUPPORTED
BleDevice.negotiateMtu(int, ReadWriteListener)
, which requires API level 21, and you are at level 18.public static final ReadWriteListener.Status DEVICE_CHIPSET_NOT_SUPPORTED
BleDevice.setPhyOptions(Phy, ReadWriteListener)
,
and the device doesn't have a Bluetooth 5 radio.public static final ReadWriteListener.Status FAILED_TO_TOGGLE_NOTIFICATION
BluetoothGatt.setCharacteristicNotification(BluetoothGattCharacteristic, boolean)
returned false
for an unknown reason. This ReadWriteListener.Status
is only relevant for calls to
BleDevice.enableNotify(UUID, ReadWriteListener)
and BleDevice.disableNotify(UUID, ReadWriteListener)
(or the various overloads).public static final ReadWriteListener.Status FAILED_TO_SET_VALUE_ON_TARGET
BluetoothGattCharacteristic.setValue(byte[])
(or one of its overloads) or
BluetoothGattDescriptor.setValue(byte[])
(or one of its overloads) returned false
.public static final ReadWriteListener.Status FAILED_TO_SEND_OUT
BluetoothGatt.readCharacteristic(BluetoothGattCharacteristic)
or BluetoothGatt.writeCharacteristic(BluetoothGattCharacteristic)
or etc. returned false
and thus failed immediately
for unknown reasons. No good remedy for this...perhaps try BleManager.reset()
.public static final ReadWriteListener.Status CANCELLED_FROM_DISCONNECT
BleDeviceState.BLE_DISCONNECTED
.public static final ReadWriteListener.Status CANCELLED_FROM_BLE_TURNING_OFF
BleManager
went BleManagerState.TURNING_OFF
and/or
BleManagerState.OFF
. Note that if the user turns off BLE from their OS settings (airplane mode, etc.) then
ReadWriteListener.ReadWriteEvent.status()
could potentially be CANCELLED_FROM_DISCONNECT
because SweetBlue might get
the disconnect callback before the turning off callback. Basic testing has revealed that this is *not* the case, but you never know.
public static final ReadWriteListener.Status NULL_DATA
ReadWriteListener.ReadWriteEvent.type()
ReadWriteListener.Type.isRead()
and the stack returned a null
value for BluetoothGattCharacteristic.getValue()
despite the operation being otherwise "successful", or
BleDevice.write(UUID, byte[])
(or overload(s) ) were called with a null data parameter. For the read case, the library
will throw an UhOhListener.UhOh.READ_RETURNED_NULL
, but hopefully it was just a temporary glitch. If the problem persists try BleManager.reset()
.public static final ReadWriteListener.Status EMPTY_DATA
ReadWriteListener.ReadWriteEvent.type()
ReadWriteListener.Type.isRead()
and the operation was "successful" but
returned a zero-length array for ReadWriteListener.ReadWriteEvent.data()
, or BleDevice.write(UUID, byte[])
(or overload(s) )
was called with a non-null but zero-length data parameter. Note that ReadWriteListener.ReadWriteEvent.data()
will be a zero-length array for
all other error statuses as well, for example NO_MATCHING_TARGET
, NOT_CONNECTED
, etc. In other words it's never null.public static final ReadWriteListener.Status INVALID_DATA
BleDevice.negotiateMtu(int, ReadWriteListener)
.public static final ReadWriteListener.Status REMOTE_GATT_FAILURE
BluetoothGattCallback.onCharacteristicRead(BluetoothGatt, BluetoothGattCharacteristic, int)
returned a status code that was not zero. This could mean the device went out of range, was turned off, signal was disrupted,
whatever. Often this means that the device is about to become BleDeviceState.BLE_DISCONNECTED
. ReadWriteListener.ReadWriteEvent.gattStatus()
will most likely be non-zero, and you can check against the static fields in BleStatuses
for more information.public static final ReadWriteListener.Status TIMED_OUT
BleNodeConfig.taskTimeoutRequestFilter
so we cut it loose.public static final ReadWriteListener.Status INVALID_TRANSACTION
BleTransaction
provided was either not started or not the current.public static ReadWriteListener.Status[] values()
for (ReadWriteListener.Status c : ReadWriteListener.Status.values()) System.out.println(c);
public static ReadWriteListener.Status valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic final boolean wasCancelled()
public final boolean isNull()
UsesCustomNull
true
if the object's state represents what would otherwise be Java's built-in null
.isNull
in interface UsesCustomNull