Aller au contenu principal

BleTerminal

Class: BleTerminal

Provide interaction to Ble Terminal. Call BleService.getTerminal(terminalID:) to get an instance of BleTerminal.

Properties

delegate: BleTerminalDelegate?

public weak var delegate: BleTerminalDelegate?

The object that acts as the delegate of the Ble Terminal

hasKey: Bool

public var hasKey: Bool { get }

Indicate whether terminal authentication key is available

authKey: String?

public var authKey: String? { get }

Indicate the terminal authentication key

connectionState: BleConnectionState

public private(set) var connectionState: BleConnectionState { get }

Indicate current connection state to Ble Terminal

signalStrength: BleSignalStrength

public private(set) var signalStrength: BleSignalStrength { get }

Indicate current signal strength to Ble Terminal

terminalID: String

public private(set) var terminalID: String { get }

Terminal ID

lockState: LockState

public private(set) var lockState: LockState { get }

Indicate current vehicle door lock state, updated upon connect, lock, unlock, and lockState action

ignitionState: IgnitionState

public private(set) var ignitionState: IgnitionState { get }

Indicate current vehicle ignition state, updated upon ignitionState action

Methods

saveAuthKey(authKey:)

public func saveAuthKey(authKey: String)

Save authentication key to keychain

Parameters

  • authKey: String - Authentication key

Returns

Via delegate function BleTerminalDelegate.bleTerminalDidSavedKey(terminal:error:)

removeAuthKey()

public func removeAuthKey()

Remove authentication key from keychain. Call this when vehicle rental is done

connect(timeout:)

public func connect(timeout: Float = 10.0)

Connect to Ble Terminal

Parameters

  • timeout: Float - How many seconds to wait for connection (default: 10.0)

Returns

Via delegate function BleTerminalDelegate.bleTerminalDidConnect(terminal:error:)

disconnect()

public func disconnect()

Disconnect from Ble Terminal

Returns

Via delegate function BleTerminalDelegate.bleTerminalDisconnected(terminal:)

getVehicleStats()

public func getVehicleStats()

Get vehicle stats from Ble Terminal

Returns

Via delegate function BleTerminalDelegate.bleTerminalDidGetVehicleStats(terminal:vehicleStats:error:)

sendAction(_:)

public func sendAction(_ action: BleAction)

Send action to Ble Terminal. Avoid calling this if signal is weak, ask user to get closer to terminal first

Parameters

  • action: BleAction - The action to send to the terminal

Returns

Via delegate method BleTerminalDelegate.bleTerminalDidAction(terminal:action:error:)

See Also