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 instanceauthKey- 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:
strength- The new BleSignalStrength.rssiValue- Raw RSSI value
onTerminalCommandResult(action: BleAction)
abstract fun onTerminalCommandResult(action: BleAction)
Called when a terminal command returns a result.
Parameters:
action- The BleAction that was executed.
onTerminalConnected(terminal: BleTerminal)
abstract fun onTerminalConnected(terminal: BleTerminal)
Called when the BleTerminal successfully connects to a device.
Parameters:
terminal- The BleTerminal that was connected.
onTerminalDisconnected(terminal: BleTerminal)
abstract fun onTerminalDisconnected(terminal: BleTerminal)
Called when terminal is disconnected.
Parameters:
terminal- The BleTerminal that was connected.
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 foundBleError.KeyInvalid- Authentication key is invalidBleError.TerminalNotFound- Terminal not in range or not discoverableBleError.BluetoothDisabled- Bluetooth is turned offBleError.BluetoothUnauthorized- Bluetooth permission not grantedBleError.LocationUnauthorized- Location permission not grantedBleError.NotConnected- Not connected to terminalBleError.GattError- GATT connection errorBleError.CtgError- CTG device specific error
See Also
- BleTerminal - For terminal operations
- BleService - For SDK initialization
- Error Handling - For detailed error information