public static enum NotificationListener.Status extends java.lang.Enum<NotificationListener.Status> implements UsesCustomNull
GenericListener_Void.onEvent(Event)
by way of NotificationListener.NotificationEvent.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 . |
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_TOGGLE_NOTIFICATION
BluetoothGatt.setCharacteristicNotification(BluetoothGattCharacteristic, boolean)
returned false for an unknown reason. |
INVALID_DATA
For now only used when giving a negative or zero value to
BleDevice.negotiateMtu(int, ReadWriteListener) . |
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, not used.
|
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.
|
REMOTE_GATT_FAILURE
The operation failed in a "normal" fashion, at least relative to all the other strange ways an operation can fail.
|
SUCCESS
This is used to indicate that toggling a notification/indication was successful.
|
UNKNOWN_ERROR
This is a generic error state which means something went wrong, and we're not sure why.
|
Modifier and Type | Method and Description |
---|---|
static NotificationListener.Status |
fromReadWriteStatus(ReadWriteListener.Status status) |
boolean |
isNull()
Returns
true if the object's state represents what would otherwise be Java's built-in null . |
static NotificationListener.Status |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static NotificationListener.Status[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final NotificationListener.Status NULL
public static final NotificationListener.Status SUCCESS
public static final NotificationListener.Status NULL_DEVICE
public static final NotificationListener.Status NOT_CONNECTED
BleDeviceState.BLE_CONNECTED
.public static final NotificationListener.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 NotificationListener.Status OPERATION_NOT_SUPPORTED
public static final NotificationListener.Status ANDROID_VERSION_NOT_SUPPORTED
BleDevice.negotiateMtu(int, ReadWriteListener)
, which requires API level 21, and you are at level 18.public static final NotificationListener.Status CANCELLED_FROM_DISCONNECT
BleDeviceState.BLE_DISCONNECTED
.public static final NotificationListener.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 NotificationListener.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 NotificationListener.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 NotificationListener.Status INVALID_DATA
BleDevice.negotiateMtu(int, ReadWriteListener)
.public static final NotificationListener.Status FAILED_TO_TOGGLE_NOTIFICATION
BluetoothGatt.setCharacteristicNotification(BluetoothGattCharacteristic, boolean)
returned false
for an unknown reason.public static final NotificationListener.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 NotificationListener.Status UNKNOWN_ERROR
public static NotificationListener.Status[] values()
for (NotificationListener.Status c : NotificationListener.Status.values()) System.out.println(c);
public static NotificationListener.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 boolean isNull()
UsesCustomNull
true
if the object's state represents what would otherwise be Java's built-in null
.isNull
in interface UsesCustomNull
public static NotificationListener.Status fromReadWriteStatus(ReadWriteListener.Status status)