Aller au contenu principal

BleListener

Interface: BleListener

Represents a listener for events and state changes related to a BleTerminal. This interface provides methods that will be invoked by the BleTerminal to notify the listener about connection status, data received, errors, etc.

Methods

onError(bleError: BleError)

abstract fun onError(bleError: BleError)

Called when an error occurs during a BleTerminal operation.

Parameters:

  • bleError - The BleError that occurred.

onReconnect()

abstract fun onReconnect()

Called when bluetooth gatt return GATT_ERROR or GATT_FAILURE, after reconnect 3 times then return BleError.GATTError.

onRemoveAuthKeySuccess()

abstract fun onRemoveAuthKeySuccess()

Called when the authentication key is successfully removed.

onSaveAuthKeySuccess(terminal: BleTerminal, authKey: String)

abstract fun onSaveAuthKeySuccess(terminal: BleTerminal, authKey: String)

Called when the authentication key is successfully saved.

Parameters:

  • terminal - The BleTerminal instance
  • authKey - The authentication key that was saved.

onSignalStrength(strength: BleSignalStrength, rssiValue: Int)

abstract fun onSignalStrength(strength: BleSignalStrength, rssiValue: Int)

Called when the signal strength changes.

Parameters:

onTerminalCommandResult(action: BleAction)

abstract fun onTerminalCommandResult(action: BleAction)

Called when a terminal command returns a result.

Parameters:

onTerminalConnected(terminal: BleTerminal)

abstract fun onTerminalConnected(terminal: BleTerminal)

Called when the BleTerminal successfully connects to a device.

Parameters:

onTerminalDisconnected(terminal: BleTerminal)

abstract fun onTerminalDisconnected(terminal: BleTerminal)

Called when terminal is disconnected.

Parameters:

onTerminalDidGetVehicleStats(command: Command, stats: GetVehicleStats)

abstract fun onTerminalDidGetVehicleStats(command: Command, stats: GetVehicleStats)

Called when fetching vehicle statistics.

Parameters:

  • command - The command triggering the fetch operation.
  • stats - The callback to receive the vehicle stat.

onTerminalDidGetVehicleStatus(command: Command, status: GetVehicleStatus)

abstract fun onTerminalDidGetVehicleStatus(command: Command, status: GetVehicleStatus)

Called when fetching vehicle status.

Parameters:

  • command - The command triggering the fetch operation.
  • status - The callback to receive the vehicle status.

Error Types

Common BleError types you may encounter:

  • BleError.KeyNotFound - Authentication key not found
  • BleError.KeyInvalid - Authentication key is invalid
  • BleError.TerminalNotFound - Terminal not in range or not discoverable
  • BleError.BluetoothDisabled - Bluetooth is turned off
  • BleError.BluetoothUnauthorized - Bluetooth permission not granted
  • BleError.LocationUnauthorized - Location permission not granted
  • BleError.NotConnected - Not connected to terminal
  • BleError.GattError - GATT connection error
  • BleError.CtgError - CTG device specific error

See Also