CardTerminal
@objcMembers
public class CardTerminal : BaseClass
SmartCardIO - CardTerminal class
A Smart Card terminal, sometimes refered to as a Smart Card Reader. A CardTerminal object can be obtained by calling CardTerminals.list() or CardTerminals.getTerminal(). Note that physical card readers with slots for multiple cards are represented by one CardTerminal object per such slot.
-
Establishes a connection to the card using the entered protocol. If a connection has previously established using the specified protocol, this method returns the same Card object as the previous call.
Throws
Status.StatusCode on failure (see enum Status.StatusCode for possible values)
Declaration
Swift
public func connect(protocolString: String) throws -> Card
Parameters
protocolString
the protocol to use (“T=0”, “T=1”), or “*” to connect using any available protocol.
Return Value
Card instance
-
Returns the unique name of this terminal.
Declaration
Swift
public func getName() -> String
Return Value
String holding the name
-
Returns whether a card is present in this terminal.
Declaration
Swift
public func isCardPresent() -> Bool
Return Value
True if a card is present, else false
-
Waits until a card is absent in this terminal or the timeout expires. If the method returns due to an expired timeout, it returns false. Otherwise it return true. If no card is present in this terminal when this method is called, it returns immediately.
Throws
Status.StatusCode on failure (see enum Status.StatusCode for possible values)
Declaration
Swift
public func waitForCardAbsent(timeout: Int) throws -> Bool
Parameters
timeout
if positive, block for up to timeout milliseconds; if zero, block indefinitely; must not be negative
Return Value
False if the method returns due to an expired timeout, true otherwise
-
Waits until a card is present in this terminal or the timeout expires. If the method returns due to an expired timeout, it returns false. Otherwise it return true. If a card is present in this terminal when this method is called, it returns immediately.
Throws
Status.StatusCode on failure (see enum Status.StatusCode for possible values)
Declaration
Swift
public func waitForCardPresent(timeout: Int) -> Bool
Parameters
timeout
if positive, block for up to timeout milliseconds; if zero, block indefinitely; must not be negative
Return Value
False if the method returns due to an expired timeout, true otherwise.
-
Returns the current battery level of the terminal in hexadecimal format. Note: returns 0xFF when charging.
Throws
Status.StatusCode on failure (see enum Status.StatusCode for possible values)Declaration
Swift
public func getBatteryLevel() throws -> UInt8
Return Value
Current battery level in hexadecimal format (0x00 till 0x64) or 0xFF when charging
-
Returns the firmware version of the cardterminal as ascii string
Throws
Status.StatusCode on failure (see enum Status.StatusCode for possible values)Declaration
Swift
public func getFirmwareVersion() throws -> String
Return Value
firmware version of the cardterminal as ascii string
-
Returns the serial number of the cardterminal as ascii string
Throws
Status.StatusCode on failure (see enum Status.StatusCode for possible values)Declaration
Swift
public func getSerialNumber() throws -> String
Return Value
serial number of the cardterminal as ascii string
-
Returns flag indicating if the ACK protocol is enabled for the cardterminal (Note: the ACK protocol is only supported for terminals with firmware version 109.00 or above)
Throws
Status.StatusCode on failure (see enum Status.StatusCode for possible values)Declaration
Swift
public func isACKProtocolEnabled() throws -> Bool
Return Value
True if enabled else false
-
Enables or disables the ACK protocol used for communication. The ACK protocol uses ACK and NACK packets to try to further stabilise communication and enables the possibility to recover communication errors in most cases. Set to true to enable the setting or false to disable it.
Notes:
- The ACK protocol is only supported for cardterminals with firmware version 109.00 or above
Default is disabled (false)
Declaration
Swift
public func setACKProtocol(protocolOnOrOff: Bool) -> StatusCode
Parameters
protocolOnOrOff
True to enable the ACK protocol, else False to disable
Return Value
Status.StatusCode; .success if command executed successful, else an error status (see enum Status.StatusCode for possible values).