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.0Copyright
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
slotindex (0 based) of the slot from the
slotspropertyReturn Value
a
Readerobject 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
slotname of the slot from the
slotspropertyReturn Value
a
Readerobject or nil if the slot’s name is unknown -
Send a direct command to the device
Declaration
Swift
public func control(command: [UInt8])Parameters
commandThe 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
keepBleActiveif 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 aSecureConnectionParametersobject then the communication mode is considered to be inclearmodeSee also
getAllAdvertisingServices()Precondition
advertisingServicesmust point to the advertising services of a D600 or a PuckDeclaration
Swift
public static func create(peripheral: CBPeripheral, centralManager: CBCentralManager, advertisingServices: [CBUUID], delegate: SCardReaderListDelegate, secureConnectionParameters: SecureConnectionParameters? = nil)Parameters
peripheralThe peripheral the application is connected to
centralManagerThe system Central Manager (must be a singleton)
advertisingServicesarray of CBUUID found during devices scan. This parameter will help to instantiate the good objet
delegatepointer
to the class that implements the callbacks (usuallyself
)secureConnectionParametersObject of type
SecureConnectionParametersused 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() -> IntReturn Value
Int
-
returns the last error message
Declaration
Swift
public func lastErrorMessage() -> StringReturn 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() -> BoolReturn Value
true if there is a connection to a BLE device
-
Is the connection valid?
Declaration
Swift
public func valid() -> BoolReturn Value
Boolean
-
Get a Reader objet from a slot’s name
Declaration
Swift
public func getReader(slot: String) -> SCardReader?Parameters
slotname of the slot from the
slotspropertyReturn Value
a
Readerobject 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
slotindex (0 based) of the slot from the
slotspropertyReturn Value
a
Readerobject 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
SCardReaderList Class Reference