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
}
-
Triggers the lock. Takes a TlcpConnection to a Tapkey lock and a cancellation token for execution control. The returned command result’s code must be inspected and checked against errors.
See also
TKMCommandResult.code
Declaration
Swift
func triggerLockAsync(_ lock: TKMTlcpConnection, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMCommandResult>
Parameters
lock
the TLCP connection to the lock.
cancellationToken
a token to handle cancel events.
Return Value
the result of the trigger lock command.
-
Reserved for internal use.
Declaration
Swift
func syncLockOfflineAsync(_ lock: TKMTlcpConnection, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMCommandResult.TKMCommandResultCode>
-
Synchronizes the lock. Collects log entries and uploads them to the Tapkey Trust Service. Updates the revocation list on the lock with the latest version from the Tapkey Trust Service.
Declaration
Swift
func syncLockOnlineAsync(userId: String, _ lock: TKMTlcpConnection, timeoutMillis: Int32, progress: @escaping (Float?) -> Void, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMSyncLockCommandResult>
Parameters
userId
the user’s ID.
lock
the TLCP connection to the lock.
timeoutMillis
a timeout in milliseconds.
progress
a progress indicator reporting the operation’s progress between 0 and 100.
cancellationToken
a token to handle cancel events.
Return Value
the result of the sync lock command.
-
Reserved for internal use.
Declaration
Swift
func queryPublicStateAsync(_ lock: TKMTlcpConnection, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMPublicStateInfo>
-
Reserved for internal use.
Declaration
Swift
func changeAdminModeAsync(_ lock: TKMTlcpConnection, cryptArtifacts: NetTpkyMcModelCryptArtifacts, lockMode: NetTpkyMcModelTkLockMode, operationType: NetTpkyMcModelAdminModeOperationType, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMCommandResult>
-
Reserved for internal use.
Declaration
Swift
func deactivateAdminModeAsync(_ lock: TKMTlcpConnection, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMCommandResult>
-
Reserved for internal use.
Declaration
Swift
func setLockTimeAsync(_ lock: TKMTlcpConnection, timeOffset: Int64, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMCommandResult>
-
Reserved for internal use.
Declaration
Swift
func unbindLockLocalAsync(_ lock: TKMTlcpConnection, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMCommandResult>
-
Reserved for internal use.
Declaration
Swift
func unbindLockOnlineAsync(_ lock: TKMTlcpConnection, timeoutMillis: Int32, progress: @escaping (Float?) -> Void, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMSyncLockCommandResult>
-
Reserved for internal use.
Declaration
Swift
func bindLockAsync(ownerId: String, userId: String, _ lock: TKMTlcpConnection, force: Bool, timeoutMillis: Int32, progress: @escaping (Float?) -> Void, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMSyncLockCommandResult>
-
Reserved for internal use.
Declaration
Swift
func upgradeFirmware(_ lock: TKMTlcpConnection, firmwarePackage: TKMFirmwarePackage, firstChunkIdx: Int32, progress: @escaping (TKMFirmwareUpgradeProgress) -> Void, cancellationToken: TKMCancellationToken)-> TKMPromise<Void>
-
Reserved for internal use.
Declaration
Swift
func getCustomCommandDescriptorsAsync(_ lock: TKMTlcpConnection, cancellationToken: TKMCancellationToken) -> TKMPromise<NetTpkyMcTlcpModelGetCustomCommandsDescriptorCommand>
-
executeCustomCommandAsync(_:asUnauthenticatedCommand:manufacturerId:customCommandId:data:cancellationToken:)
Reserved for internal use.
Declaration
Swift
func executeCustomCommandAsync(_ lock: TKMTlcpConnection, asUnauthenticatedCommand: Bool, manufacturerId: Int32, customCommandId: Int32, data: IOSByteArray, cancellationToken: TKMCancellationToken) -> TKMPromise<TKMCommandResult>