SCardReaderList

public class SCardReaderList : NSObject, CBCentralManagerDelegate, CBPeripheralDelegate

Main class, instanciate a reader list, manage slots, enable sending APDUs in transmit and control mode, etc

Version

Version 1.0

Author

SpringCard
  • Represent the vendor’s name

    Declaration

    Swift

    public var vendorName: String
  • Product’s name

    Declaration

    Swift

    public var productName: String
  • Device serial number, expressed in hex

    Declaration

    Swift

    public var serialNumber: String
  • Device serial number of the BLE device

    Declaration

    Swift

    public var serialNumberRaw: [UInt8]?
  • Firmware’s version

    Declaration

    Swift

    public var firmwareVersion: String
  • Hardware version

    Declaration

    Swift

    public var hardwareVersion: String
  • Software version

    Declaration

    Swift

    public var softwareVersion: String
  • Declaration

    Swift

    public var pnpId: String
  • Battery level in percentage

    Declaration

    Swift

    public var batteryLevel: Int
  • Slots count (0 = device is not authentic)

    Declaration

    Swift

    public var slotCount: Int
  • Name of each slot, if names are equal to an empty string then there was an error

    Declaration

    Swift

    public var slots: [String]
  • Transmit Power Level

    Declaration

    Swift

    public var powerLevel: Int
  • Battery Power State

    Declaration

    Swift

    public var powerState: Int
  • Is the reader in low power mode?

    Declaration

    Swift

    public var isInLowPowerMode: Bool
  • Declaration

    Swift

    public static let libraryName: String
  • Declaration

    Swift

    public static let LibrarySpecial: String
  • Declaration

    Swift

    public static let libraryDebug: Bool
  • Declaration

    Swift

    public static let libraryVersion: String
  • Declaration

    Swift

    public static let libraryVersionMajor: String
  • Declaration

    Swift

    public static let libraryVersionMinor: String
  • Declaration

    Swift

    public static let LibraryVersionBuild: String
  • Get a Reader objet from a slot’s index

    Declaration

    Swift

    public subscript(slot: Int) -> SCardReader? { get }

    Parameters

    slot

    index (0 based) of the slot from the slots property

    Return Value

    a Reader object or nil if the index is out of bounds

  • Get a Reader objet from a slot’s name

    Declaration

    Swift

    public subscript(slot: String) -> SCardReader? { get }

    Parameters

    slot

    name of the slot from the slots property

    Return Value

    a Reader object or nil if the slot’s name is unknown

  • Send a direct command to the device

    Declaration

    Swift

    public func control(command: [UInt8])

    Parameters

    command

    The command to send to the reader

    Return Value

    Nothing, answer is available in the onControlDidResponse() callback

  • Close connection with the product

    Declaration

    Swift

    public func close(keepBleActive: Bool = false)

    Parameters

    keepBleActive

    if true then the Bluetooth connection remains active, when false the Bluetooth connection is also closed

  • Request for the creation of a PC/SC product over BLE

    Remark

    If this method is called with an unknow device, an error will be triggered. If you don’t pass a SecureConnectionParameters object then the communication mode is considered to be in clearmode

    Precondition

    advertisingServices must point to the advertising services of a D600 or a Puck

    Declaration

    Swift

    public static func create(peripheral: CBPeripheral, centralManager: CBCentralManager, advertisingServices: [CBUUID], delegate: SCardReaderListDelegate, secureConnectionParameters: SecureConnectionParameters? = nil)

    Parameters

    peripheral

    The peripheral the application is connected to

    centralManager

    The system Central Manager (must be a singleton)

    advertisingServices

    array of CBUUID found during devices scan. This parameter will help to instantiate the good objet

    delegate

    pointer to the class that implements the callbacks (usually self)

    secureConnectionParameters

    Object of type SecureConnectionParameters used to pass secure communication parameters (optional)

    Return Value

    As the code is asynchronous, the onReaderListDidCreate() callback of the delegate will be called in case of success or failure (i.e you need to verify the error parameter)

  • Get the list of services UUID to filter scan

    Declaration

    Swift

    public static func getAllAdvertisingServices() -> [CBUUID]

    Return Value

    array of services UUIDs

  • Get the last error code

    Declaration

    Swift

    public func lastError() -> Int

    Return Value

    Int

  • returns the last error message

    Declaration

    Swift

    public func lastErrorMessage() -> String

    Return Value

    a string describing the problem, can be a message from the system or a message specific to the SpringCard library

  • Returns the connection status

    Declaration

    Swift

    public func connected() -> Bool

    Return Value

    true if there is a connection to a BLE device

  • Is the connection valid?

    Declaration

    Swift

    public func valid() -> Bool

    Return Value

    Boolean

  • Get a Reader objet from a slot’s name

    Declaration

    Swift

    public func getReader(slot: String) -> SCardReader?

    Parameters

    slot

    name of the slot from the slots property

    Return Value

    a Reader object or nil if the slot’s name is unknown

  • Get a Reader object from a slot’s index

    Declaration

    Swift

    public func getReader(slot: Int) -> SCardReader?

    Parameters

    slot

    index (0 based) of the slot from the slots property

    Return Value

    a Reader object or nil if the index is out of bounds

  • Wake-up the reader, if it is in low power mode.

    See also

    onReaderListState()

    Declaration

    Swift

    public func wakeUp()
  • Ask the device to enter full power-down mode

    Remark

    Not all hardware support a full power-down mode. For devices without such capabilities, this instruction is equivalent to a warm reset.

    Declaration

    Swift

    public func shutdown()
  • Read device power state & battery level

    Declaration

    Swift

    public func getPowerInfo()

    Return Value

    Nothing, answer is available in the onPowerInfo() callback