BleError
Sealed Class: BleError
Error Handler related to BLE Connection
Properties
actionCode: Int
Action code associated with the error. For BleError.CtgError it is the actionCode of the underlying CtgError, which only CtgError.Fail sets; otherwise it is -1.
errorCode: Int
Error code identifier. BleError codes run from 1 to 9 and CtgError codes from 21 to 28, but GattError.errorCode is the raw Android GATT status, which can coincide with a BleError code (5 is both KeyNotFound and GATT_INSUFFICIENT_AUTHENTICATION). Match on the type (is BleError.GattError) rather than on the code.
localizedDescription: String
Human-readable description of the error
Parameters
errorCode- Error code identifierlocalizedDescription- Human-readable error descriptionactionCode- Action code associated with the error
Error Types
BluetoothDisabled
object BluetoothDisabled : BleError
- Bluetooth is disabled
- ErrorCode: 2
- Description: Phone: Bluetooth is disabled, please go to settings to enable it
- Declared for Bluetooth being turned off while the SDK is in use. The SDK reports
BleListener.onTerminalDisconnectedas soon as Bluetooth starts turning off, so handle that callback rather than waiting for this error. If Bluetooth is already off when you connect, the attempt ends inTerminalNotFoundinstead.
BluetoothUnauthorized
object BluetoothUnauthorized : BleError
- Bluetooth permission is not granted. Ask user to grant permission from phone settings
- ErrorCode: 1
- Description: Phone: Bluetooth permission is not granted, please go to settings to grant permission
BluetoothUnsupported
object BluetoothUnsupported : BleError
- Device does not support Bluetooth Low Energy
- ErrorCode: 3
- Description: Phone: Device does not support Bluetooth Low Energy
KeyInvalid
object KeyInvalid : BleError
- Authentication key in Shared Preference is invalid: it is not 64 hexadecimal characters.
BleTerminal.saveAuthKey()does not check the format, so this is reported when connecting. - ErrorCode: 6
- Description: BLE: Authentication key is invalid
KeyNotFound
object KeyNotFound : BleError
- Authentication key not found in Shared Preference
- ErrorCode: 5
- Description: Shared Preference: Authentication key not found
LocationUnauthorized
object LocationUnauthorized : BleError
- Location permission is not granted, or location services are off (neither the GPS nor the network location provider is enabled)
- ErrorCode: 9
- Description: Phone: Location permission is not granted, please go to settings to grant permission
NotConnected
object NotConnected : BleError
- Not connected to Ble Terminal. Call
BleTerminal.scanAndConnectToPeripheral()first - ErrorCode: 8
- Description: Not connected to Ble Terminal. Please connect first.
SaveAuthKeyFailed
object SaveAuthKeyFailed : BleError
- Failed to save authentication key in Shared Preference
- ErrorCode: 4
- Description: Shared Preference: Failed to save the key in Shared Preference
TerminalNotFound
object TerminalNotFound : BleError
- Unable to discover Ble Terminal, terminal might be out of range. Also reported when Bluetooth was off at the start of the attempt, and, from 3.0.4, when the terminal was found but did not accept the Bluetooth connection within the timeout. See Troubleshooting.
- ErrorCode: 7
- Description: BLE Scan: Terminal not found
CtgError
class CtgError(val ctgError: CtgError?) : BleError
The terminal refused a command or the key, or the SDK gave up on a command; refer to CtgError. errorCode, localizedDescription and actionCode are those of the underlying CtgError. The ctgError property, for matching on the exact error, is available from 3.0.4. A CtgError does not close the connection.
GattError
class GattError(val gattError: GattError?) : BleError
Gatt Error. Called when BluetoothGatt onConnectionStateChange returns an error status; see GattError for which statuses are reported. errorCode and localizedDescription are those of the underlying GattError. The gattError property, for matching on the exact status, is available from 3.0.4.
See Also
- CtgError - Terminal-specific errors
- GattError - GATT connection errors
- BleListener - For error handling callbacks