TKMCommandExecutionFacade

public protocol TKMCommandExecutionFacade

Offers commands to be executed on Tapkey locks. Methods of this class expect a TLCP connection to a Tapkey lock and take a cancellation token for execution control.

The example below outlines a possible usage of triggerLockAsync(lock:cancellationToken:). In the present example, the required TLCP connection is established using the TKMBleLockCommunicator.

// The Bluetooth Communicator establishes a connection to the Tapkey lock via Bluetooth and lets
// the CommandExecutionFacade use this connection to execute a TriggerLock command.
return bleLockCommunicator.executeCommandAsync(bluetoothAddress, physicalLockId, { tlcpConnection in

    // Now, with the TlcpConnection to the lock available, the TKMCommandExecutionFacade
    // asynchronously executes the trigger lock command.
    return commandExecutionFacade.triggerLockAsync(tlcpConnection, cancellationToken: ct)

}, ct).continueOnUi { commandResult -> Bool in

    switch (commandResult.code) {
        case Ok:
            return true
        // Handle error results.
        ...
    }
    return false

}.catchOnUi { e -> Bool in

    Log.e(TAG, "Could not execute trigger lock command.", e)
    if (!ct.isCancellationRequested()) {
         // Handle any exceptions and let the user know, something went wrong.
    }
    return false

}