public class GattException extends BuruberiException
Very few gatt error codes are properly documented by the Android SDK, and some vary by device vendor. The error codes documented in this class are a combination of trial and error, and combing the low level Bluetooth implementation in the AoSP. These codes can and will change, and should only be considered a hint.
Modifier and Type | Class and Description |
---|---|
static class |
GattException.Operation
The operation on which the gatt layer encountered an error.
|
Modifier and Type | Field and Description |
---|---|
static int |
GATT_AUTH_FAIL |
static int |
GATT_BUSY |
static int |
GATT_CONN_FAIL_ESTABLISH
Connection failed to establish.
|
static int |
GATT_CONN_TERMINATE_LOCAL_HOST
Connection terminated by local host.
|
static int |
GATT_CONN_TERMINATE_PEER_USER
Connection terminate by peer user.
|
static int |
GATT_CONN_TIMEOUT
Connection timeout.
|
static int |
GATT_DB_FULL |
static int |
GATT_ILLEGAL_PARAMETER |
static int |
GATT_INTERNAL_ERROR
Generic internal error code from the low level Bluetooth implementation.
|
static int |
GATT_INVALID_CFG |
static int |
GATT_NO_RESOURCES |
static int |
GATT_STACK_ERROR
Generic internal error code from the low level Bluetooth implementation.
|
static int |
GATT_WRONG_STATE |
GattException.Operation |
operation
The operation where the gatt exception was encountered, if applicable.
|
int |
statusCode
The status code given by the gatt layer.
|
Constructor and Description |
---|
GattException(int statusCode,
GattException.Operation operation) |
Modifier and Type | Method and Description |
---|---|
boolean |
isInstabilityLikely()
Several failures reported by Buruberi can either be caused by,
or can cause as a side effect, Bluetooth driver instability.
|
static boolean |
isRecoverableConnectError(int statusCode)
Returns whether or not a given error code encountered during a first
connection attempt can be resolved by retrying the connection.
|
static java.lang.String |
statusToString(int status)
Returns the corresponding constant name for a given
GATT_* value. |
isInstabilityLikely
@NonGuaranteed public static final int GATT_ILLEGAL_PARAMETER
@NonGuaranteed public static final int GATT_NO_RESOURCES
@NonGuaranteed public static final int GATT_INTERNAL_ERROR
@NonGuaranteed public static final int GATT_WRONG_STATE
@NonGuaranteed public static final int GATT_DB_FULL
@NonGuaranteed public static final int GATT_BUSY
@NonGuaranteed public static final int GATT_AUTH_FAIL
@NonGuaranteed public static final int GATT_INVALID_CFG
@NonGuaranteed public static final int GATT_STACK_ERROR
This error code shows up if you turn off the Bluetooth radio, and a device has an open gatt layer and is bonded. Retrying your connection after receiving this error will work seemingly 100% of the time.
If this error is reported more than once, the phone's Bluetooth has become unstable, and won't be fixed until the user power cycles their phone's Wi-Fi and Bluetooth radios.
@NonGuaranteed public static final int GATT_CONN_TERMINATE_LOCAL_HOST
@NonGuaranteed public static final int GATT_CONN_TERMINATE_PEER_USER
@NonGuaranteed public static final int GATT_CONN_TIMEOUT
@NonGuaranteed public static final int GATT_CONN_FAIL_ESTABLISH
public final int statusCode
public final GattException.Operation operation
public GattException(int statusCode, GattException.Operation operation)
public static boolean isRecoverableConnectError(int statusCode)
statusCode
- The error code.true
if the error is likely recoverable; false
otherwise.GattPeripheral.connect(OperationTimeout)
public static java.lang.String statusToString(int status)
GATT_*
value.public boolean isInstabilityLikely()
BuruberiException
Bluetooth driver instability varies by vendor, OS Version, and device chip-set. The return value of this method should be considered a guideline, not a hard and fast rule.
If this method returns true
, it is generally a good idea
to power cycle Bluetooth on the host device before trying
subsequent operations.
isInstabilityLikely
in class BuruberiException
true
if GATT_STACK_ERROR
is reported; false
otherwise.for more info.