Skip to main content

BleTerminalDelegate

Protocol: BleTerminalDelegate : AnyObject

The callbacks of a BleTerminal. They all come on the main thread.

Methods​

bleTerminalDidSavedKey(terminal:error:)​

func bleTerminalDidSavedKey(terminal: BleTerminal, error: BleError?)

Called right after saveAuthKey(authKey:).

Parameters​

  • terminal: BleTerminal - The terminal instance
  • error: BleError? - Error if save failed, nil if successful

bleTerminalDidConnect(terminal:error:)​

func bleTerminalDidConnect(terminal: BleTerminal, error: BleError?)

Called once per connect(timeout:): without an error once the terminal accepted the key and the SDK read the lock state, or gave up on reading it, or with the error that ended the attempt. Also called with ctgError(45, 23) when the terminal refuses the keep-alive the SDK sends every 7 seconds to an established connection.

Parameters​

  • terminal: BleTerminal - The terminal instance
  • error: BleError? - Error if connection failed, nil if successful

bleTerminalDidAction(terminal:action:error:)​

func bleTerminalDidAction(terminal: BleTerminal, action: BleAction, error: BleError?)

Called once per sendAction(_:), with ctgError(actionCode, 22) when the terminal did not answer within the timeout passed to connect(timeout:).

Parameters​

  • terminal: BleTerminal - The terminal instance
  • action: BleAction - The action that was executed
  • error: BleError? - Error if action failed, nil if successful. For .lock and .unlock, nil means the terminal accepted the command; read terminal.lockState for the state it reported afterwards.

bleTerminalDisconnected(terminal:)​

func bleTerminalDisconnected(terminal: BleTerminal)

Called when a connection reported by bleTerminalDidConnect(terminal:error:) ends, including after disconnect(), and once when disconnect() cancels a connection attempt. A failed attempt reports through bleTerminalDidConnect(terminal:error:) only.

Parameters​

  • terminal: BleTerminal - The terminal instance

bleTerminalSignalUpdate(rssi:strength:)​

func bleTerminalSignalUpdate(rssi: Int, strength: BleSignalStrength)

Called every second while connected.

Parameters​

  • rssi: Int - The RSSI value in dBm
  • strength: BleSignalStrength - The interpreted signal strength level

bleTerminalDidGetVehicleStats(terminal:vehicleStats:error:)​

func bleTerminalDidGetVehicleStats(terminal: BleTerminal, vehicleStats: VehicleStats?, error: BleError?)

Called once per getVehicleStats(), with ctgError(33, 22) when the terminal did not answer within the timeout passed to connect(timeout:).

Parameters​

  • terminal: BleTerminal - The terminal instance
  • vehicleStats: VehicleStats? - The vehicle statistics if successful
  • error: BleError? - Error if request failed, nil if successful

See Also​