Package com.tapkey.mobile.manager
Interface CommandExecutionFacade
-
public interface CommandExecutionFacade
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(TlcpConnection, CancellationToken)
. In the present example, the required TLCP connection is established using theBleLockCommunicator
.// 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 -> { // Now, with the TlcpConnection to the lock available, the CommandExecutionFacade // asynchronously executes the trigger lock command. return commandExecutionFacade.triggerLockAsync(tlcpConnection, ct); }, ct).continueOnUi(commandResult -> { switch (commandResult.getCommandResultCode()) { case Ok: return true; // Handle error results. ... } return false; }).catchOnUi(e -> { 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; });
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CommandExecutionFacade.FirmwareUpgradeProgress
Returns information on a firmware upgrade progress.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Promise<SyncLockCommandResult>
bindLockAsync(String userId, String ownerId, TlcpConnection lock, boolean force, Integer timeoutMillis, Action1<Float,RuntimeException> progress, CancellationToken cancellationToken)
Reserved for internal use.Promise<net.tpky.mc.tlcp.model.RebindCommand.ResponseData>
bindLockLocalAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.Promise<CommandResult>
changeAdminModeAsync(TlcpConnection lock, net.tpky.mc.model.CryptArtifacts cryptArtifacts, net.tpky.mc.model.TkLockMode lockMode, net.tpky.mc.model.AdminModeOperationType operationType, CancellationToken cancellationToken)
Reserved for internal use.Promise<CommandResult>
deactivateAdminModeAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.Promise<CommandResult>
executeCustomCommandAsync(TlcpConnection lock, boolean asUnauthenticatedCommand, int manufacturerId, int customCommandId, byte[] data, CancellationToken cancellationToken)
Reserved for internal use.Promise<CommandResult>
executeCustomCommandSignedAsync(TlcpConnection lock, int manufacturerId, int customCommandId, byte[] data, CancellationToken cancellationToken)
Reserved for internal use.Promise<Void>
executeCustomCommandSimpleAsync(TlcpConnection lock, boolean asUnauthenticatedCommand, int manufacturerId, int customCommandId, byte[] data, CancellationToken cancellationToken)
Reserved for internal use.Promise<CommandResult>
executeStandardCommandAsync(TlcpConnection lock, DynamicCommand command, CancellationToken cancellationToken)
Executes a dynamic standard command.Promise<CommandResult>
executeStandardCommandAsync(TlcpConnection lock, net.tpky.mc.tlcp.model.Command command, CancellationToken cancellationToken)
Executes a standard command like a TriggerLockCommand.Promise<net.tpky.mc.tlcp.model.GetCustomCommandsDescriptorCommand.ResponseData>
getCustomCommandDescriptorsAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.Promise<GroupInfos>
queryGroupInfosAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.Promise<PublicStateInfo>
queryPublicStateAsync(TlcpConnection lock, CancellationToken cancellationToken)
Returns the public state of the lock.Promise<CommandResult>
setLockTimeAsync(TlcpConnection lock, long timeOffset, CancellationToken cancellationToken)
Reserved for internal use.Promise<CommandResult.CommandResultCode>
syncLockOfflineAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.Promise<SyncLockCommandResult>
syncLockOnlineAsync(String userId, TlcpConnection lock, Integer timeoutMillis, Action1<Float,RuntimeException> progress, CancellationToken cancellationToken)
Synchronizes the lock.Promise<CommandResult>
triggerLockAsync(TlcpConnection lock, CancellationToken cancellationToken)
Triggers the lock.Promise<CommandResult>
unbindLockLocalAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.Promise<SyncLockCommandResult>
unbindLockOnlineAsync(TlcpConnection lock, Integer timeoutMillis, Action1<Float,RuntimeException> progress, CancellationToken cancellationToken)
Reserved for internal use.Promise<Void>
upgradeFirmware(TlcpConnection lock, FirmwarePackage firmwarePackage, int firstChunkIdx, Action1<CommandExecutionFacade.FirmwareUpgradeProgress,RuntimeException> progress, CancellationToken cancellationToken)
Installs the specified firmware package on the lock.Promise<Void>
uploadFirmware(TlcpConnection lock, FirmwarePackage firmwarePackage, int firstChunkIdx, Action1<CommandExecutionFacade.FirmwareUpgradeProgress,RuntimeException> progress, CancellationToken cancellationToken)
Reserved for internal use.Promise<Void>
waitForTagLost(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.Promise<Void>
waitForTagLost(net.tpky.nfc.NdefConnection tag, CancellationToken cancellationToken)
Reserved for internal use.
-
-
-
Method Detail
-
executeStandardCommandAsync
Promise<CommandResult> executeStandardCommandAsync(TlcpConnection lock, net.tpky.mc.tlcp.model.Command command, CancellationToken cancellationToken)
Executes a standard command like a TriggerLockCommand. Standard commands are signed using the signed in user's keys.- Parameters:
lock
- the TLCP connection to the lock.command
- The command to be executed.cancellationToken
- a token to handle cancel events.- Returns:
- the result of the command.
- See Also:
CommandResult.getCommandResultCode()
,CommandResult.CommandResultCode
-
executeStandardCommandAsync
Promise<CommandResult> executeStandardCommandAsync(TlcpConnection lock, DynamicCommand command, CancellationToken cancellationToken)
Executes a dynamic standard command. Dynamic commands resolve to a concrete command only at execution time. Standard commands are signed using the signed in user's keys.- Parameters:
lock
- the TLCP connection to the lock.command
- The command to be executed.cancellationToken
- a token to handle cancel events.- Returns:
- the result of the command.
- See Also:
CommandResult.getCommandResultCode()
,CommandResult.CommandResultCode
-
triggerLockAsync
Promise<CommandResult> triggerLockAsync(TlcpConnection lock, CancellationToken cancellationToken)
Triggers the lock. The method internally uses the `CompatTriggerLockCommandBuilder`, which derives the action to be taken from the user's permissions. 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.- Parameters:
lock
- the TLCP connection to the lock.cancellationToken
- a token to handle cancel events.- Returns:
- the result of the trigger lock command.
- See Also:
CommandResult.getCommandResultCode()
,CommandResult.CommandResultCode
-
syncLockOfflineAsync
Promise<CommandResult.CommandResultCode> syncLockOfflineAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.
-
syncLockOnlineAsync
Promise<SyncLockCommandResult> syncLockOnlineAsync(String userId, TlcpConnection lock, Integer timeoutMillis, Action1<Float,RuntimeException> progress, CancellationToken cancellationToken)
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.- 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.- Returns:
- the result of the sync lock command.
-
queryPublicStateAsync
Promise<PublicStateInfo> queryPublicStateAsync(TlcpConnection lock, CancellationToken cancellationToken)
Returns the public state of the lock.- Parameters:
lock
- the TLCP connection to the lock.cancellationToken
- a token to handle cancel events.- Returns:
- the lock's public state.
-
queryGroupInfosAsync
Promise<GroupInfos> queryGroupInfosAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.
-
changeAdminModeAsync
Promise<CommandResult> changeAdminModeAsync(TlcpConnection lock, net.tpky.mc.model.CryptArtifacts cryptArtifacts, net.tpky.mc.model.TkLockMode lockMode, net.tpky.mc.model.AdminModeOperationType operationType, CancellationToken cancellationToken)
Reserved for internal use.
-
deactivateAdminModeAsync
Promise<CommandResult> deactivateAdminModeAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.
-
setLockTimeAsync
Promise<CommandResult> setLockTimeAsync(TlcpConnection lock, long timeOffset, CancellationToken cancellationToken)
Reserved for internal use.
-
unbindLockLocalAsync
Promise<CommandResult> unbindLockLocalAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.
-
unbindLockOnlineAsync
Promise<SyncLockCommandResult> unbindLockOnlineAsync(TlcpConnection lock, Integer timeoutMillis, Action1<Float,RuntimeException> progress, CancellationToken cancellationToken)
Reserved for internal use.
-
bindLockAsync
Promise<SyncLockCommandResult> bindLockAsync(String userId, String ownerId, TlcpConnection lock, boolean force, Integer timeoutMillis, Action1<Float,RuntimeException> progress, CancellationToken cancellationToken)
Reserved for internal use.
-
bindLockLocalAsync
Promise<net.tpky.mc.tlcp.model.RebindCommand.ResponseData> bindLockLocalAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.
-
upgradeFirmware
Promise<Void> upgradeFirmware(TlcpConnection lock, FirmwarePackage firmwarePackage, int firstChunkIdx, Action1<CommandExecutionFacade.FirmwareUpgradeProgress,RuntimeException> progress, CancellationToken cancellationToken)
Installs the specified firmware package on the lock. A firmware package built specifically for the present lock has to be retrieved using the Tapkey Access Management Web API's POST /Firmwares/{id} operation. After the installation is finished,queryPublicStateAsync(TlcpConnection, CancellationToken)
can be used to verify that the firmware version actually installed on the lock matches the version of the firmware package passed to this method.- Parameters:
lock
- the TLCP connection to the lock.firmwarePackage
- the firmware package to be installed on the lock.firstChunkIdx
- the index of the first chunk. Can be used to continue an interrupted installation process.progress
- returns the progress of the firmware upgrade process.cancellationToken
- a token to handle cancel events.- See Also:
queryPublicStateAsync(TlcpConnection, CancellationToken)
, POST /Firmwares/{id}
-
uploadFirmware
Promise<Void> uploadFirmware(TlcpConnection lock, FirmwarePackage firmwarePackage, int firstChunkIdx, Action1<CommandExecutionFacade.FirmwareUpgradeProgress,RuntimeException> progress, CancellationToken cancellationToken)
Reserved for internal use.
-
getCustomCommandDescriptorsAsync
Promise<net.tpky.mc.tlcp.model.GetCustomCommandsDescriptorCommand.ResponseData> getCustomCommandDescriptorsAsync(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.
-
executeCustomCommandAsync
Promise<CommandResult> executeCustomCommandAsync(TlcpConnection lock, boolean asUnauthenticatedCommand, int manufacturerId, int customCommandId, byte[] data, CancellationToken cancellationToken)
Reserved for internal use.
-
executeCustomCommandSignedAsync
Promise<CommandResult> executeCustomCommandSignedAsync(TlcpConnection lock, int manufacturerId, int customCommandId, byte[] data, CancellationToken cancellationToken)
Reserved for internal use.
-
executeCustomCommandSimpleAsync
Promise<Void> executeCustomCommandSimpleAsync(TlcpConnection lock, boolean asUnauthenticatedCommand, int manufacturerId, int customCommandId, byte[] data, CancellationToken cancellationToken)
Reserved for internal use.
-
waitForTagLost
Promise<Void> waitForTagLost(net.tpky.nfc.NdefConnection tag, CancellationToken cancellationToken)
Reserved for internal use.
-
waitForTagLost
Promise<Void> waitForTagLost(TlcpConnection lock, CancellationToken cancellationToken)
Reserved for internal use.
-
-