Card
public protocol Card : AnyObject
A Smart Card with which a connection has been established. Card objects are
obtained by calling CardTerminal.connect(protocolString:)
.
See also
Version
1.0
Date
6 Nov 2017
-
Returns the ATR of this card.
Declaration
Swift
var atr: ATR { get }
-
Returns the protocol in use for this card. For example, “T=0” or “T=1”.
Declaration
Swift
var activeProtocol: String { get }
-
Returns the CardChannel for the basic logical channel. The basic logical channel has a channel number of 0.
Throws
CardError.illegalState
if this card object has been disposed of via thedisconnect(reset:)
method;Declaration
Swift
func basicChannel() throws -> CardChannel
Return Value
the CardChannel for the basic logical channel
-
Opens a new logical channel to the card and returns it. The channel is opened by issuing a
MANAGE CHANNEL
command that should use the format[00 70 00 00 01]
.Throws
CardError.operationFailed
if a new logical channel could not be opened;CardError.illegalState
if this card object has been disposed of via thedisconnect(reset:)
methodDeclaration
Swift
func openLogicalChannel() throws -> CardChannel
-
Requests exclusive access to this card.
Once a thread has invoked
beginExclusive()
, only this thread is allowed to communicate with this card until it callsendExclusive()
. Other threads attempting communication will receive aCardError
.Applications have to ensure that exclusive access is correctly released. This can be achieved by executing the
beginExclusive()
andendExclusive()
calls in adefer
block.Throws
CardError.operationFailed
if exclusive access has already been set or if exclusive access could not be established;CardError.illegalState
if this card object has been disposed of via thedisconnect(reset:)
methodDeclaration
Swift
func beginExclusive() throws
-
Releases the exclusive access previously established using
beginExclusive()
.Throws
CardError.illegalState
if the active Thread does not currently have exclusive access to this card or if this card object has been disposed of via thedisconnect(reset:)
method;CardError.operationFailed
if the card operation failedDeclaration
Swift
func endExclusive() throws
-
Transmits a control command to the terminal device.
This can be used to, for example, control terminal functions like a built-in PIN pad or biometrics.
Throws
CardError.operationFailed
if the card operation failed;CardError.illegalState
if this card object has been disposed of via thedisconnect(reset:)
methodDeclaration
Swift
func transmitControlCommand(controlCode: Int, command: [UInt8]) throws -> [UInt8]
Parameters
controlCode
the control code of the command
command
the command data
Return Value
the response data
-
Disconnects the connection with this card. After this method returns, calling methods on this object or in CardChannels associated with this object that require interaction with the card will raise a
CardError.illegalState
.Throws
CardError.operationFailed
if the card operation failedDeclaration
Swift
func disconnect(reset: Bool) throws
Parameters
reset
whether to reset the card after disconnecting