Skip to main content

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 }

Whether a key is saved on this phone. The SDK keeps one key for the app, not one per terminal.

authKey: String?​

public var authKey: String? { get }

The saved key, as lowercase hexadecimal, or nil.

connectionState: BleConnectionState​

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

The connection state. It is .connected once the terminal has accepted the key, slightly before bleTerminalDidConnect(terminal:error:).

signalStrength: BleSignalStrength​

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

The signal strength to the terminal, updated every second while connected.

terminalID: String​

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

The terminal's Bluetooth name, upper-cased.

lockState: LockState​

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

The vehicle's lock state, read when connecting and with .lock, .unlock and .lockState.

ignitionState: IgnitionState​

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

The vehicle's ignition state, read with .ignitionState.

Methods​

saveAuthKey(authKey:)​

public func saveAuthKey(authKey: String)

Save the authentication key in the keychain, replacing the one saved before.

Parameters​

  • authKey: String - The terminal's key, bluetooth_key from the Fleet API: 64 hexadecimal characters. Anything but pairs of hexadecimal digits fails with saveAuthKeyFailed; spaces around the key are trimmed. A save that fails keeps the key saved before. A key of the wrong length fails at connect time with keyInvalid.

Returns​

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

removeAuthKey()​

public func removeAuthKey()

Remove the authentication key from the keychain, without a callback. Call this when the rental ends.

connect(timeout:)​

public func connect(timeout: Float = 10.0)

Connect to Ble Terminal

Parameters​

  • timeout: Float - Seconds to wait for each step in turn (the scan, the Bluetooth link, the authentication, the lock state read), then for the answer to each command (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:), once the link is down. During a connection attempt, it cancels the attempt and reports the disconnection straight away. With nothing connected, nothing happens and nothing is reported.

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​