ACS Bluetooth iOS/Mac OS X Library
1.0.0
|
This library provides classes and protocols for communicating with ACS Bluetooth readers on iOS (5.0 or above) and Mac OS X (10.7 or above).
To use the library on iOS, your app must include CoreBluetooth
header file from iOS SDK and ACSBluetooth
header file.
To use the library on Mac OS X, your app must include IOBluetooth
header file from Mac OS X SDK and ACSBluetooth
header file.
Your app must create CBCentralManager
and ABTBluetoothReaderManager objects and then assign a delegate object to them. Therefore, your delegate object will receive the events from central manager and Bluetooth reader manager.
You must implement centralManagerDidUpdateState:
method to check if Bluetooth low energy is supported and available to use.
You can discover peripherals by calling scanForPeripheralsWithServices:options:
method of the CBCentralManager
class.
When the peripheral is discovered, the central manager calls centralManager:didDiscoverPeripheral:advertisementData:RSSI:
method of its delegate object. You need to store the returned CBPeripheral
object.
When you have found the peripheral, you can stop the scanning for other devices to save the power.
After finding the peripheral, you can connect it by calling connectPeripheral:options:
method of the CBCentralManager
class.
If the connection is successful, the central manager will call centralManager:didConnectPeripheral:
method of its delegate object. Otherwise, it will call centralManager:didFailToConnectPeripheral:
method of its delegate object.
After the peripheral is connected, you can detect the Bluetooth reader by calling detectReaderWithPeripheral: (ABTBluetoothReaderManager) method of the ABTBluetoothReaderManager class. The Bluetooth reader manager calls bluetoothReaderManager:didDetectReader:peripheral:error: (ABTBluetoothReaderManagerDelegate-p) method of its delegate object to return the result.
You can attach the peripheral by calling attachPeripheral: (ABTBluetoothReader) method of the ABTBluetoothReader class. The Bluetooth reader calls bluetoothReader:didAttachPeripheral:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the result.
If you have finished the operation with the Bluetooth reader, you can detach the peripheral by calling detach (ABTBluetoothReader) method of the ABTBluetoothReader class.
If your Bluetooth reader is no longer used, you can disconnect the peripheral by calling cancelPeripheralConnection:
method of the CBCentralManager
class.
The central manager calls centralManager:didDisconnectPeripheral:error:
of its delegate object.
You can get the device information by calling getDeviceInfoWithType: (ABTBluetoothReader) method of ABTBluetoothReader class. If the device information is not supported, the method will returns NO
.
The Bluetooth reader calls bluetoothReader:didReturnDeviceInfo:type:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the device information.
If the ACR3901U-S1 reader is detected, the returned ABTBluetoothReader object will be an instance of ABTAcr3901us1Reader class. To invoke the method, you can cast it as ABTAcr3901us1Reader object.
If the battery status is changed, the Bluetooth reader calls bluetoothReader:didChangeBatteryStatus:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the battery status.
If you want to get the battery status again, you can call getBatteryStatus (ABTAcr3901us1Reader) method of ABTAcr3901us1Reader class.
If the ACR1255U-J1 reader is detected, the returned ABTBluetoothReader object will be an instance of ABTAcr1255uj1Reader class. To invoke the method, you can cast it as ABTAcr1255uj1Reader object.
If the battery level is changed, the Bluetooth reader calls bluetoothReader:didChangeBatteryLevel:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the battery level.
If you want to get the battery level again, you can call getBatteryLevel (ABTAcr1255uj1Reader) method of ABTAcr1255uj1Reader class.
Before performing the operation, you must authenticate the Bluetooth reader by calling authenticateWithMasterKey: (ABTBluetoothReader) method of ABTBluetoothReader class with the master key.
The Bluetooth reader calls bluetoothReader:didAuthenticateWithError: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the authentication result.
If the Bluetooth reader is authenticated successfully, you can power on the card by calling powerOnCard (ABTBluetoothReader) method of ABTBluetoothReader class.
The Bluetooth reader calls bluetoothReader:didReturnAtr:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the ATR string.
If the Bluetooth reader is authenticated successfully, you can power off the card by calling powerOffCard (ABTBluetoothReader) method of ABTBluetoothReader class.
The Bluetooth reader calls bluetoothReader:didPowerOffCardWithError: (ABTBluetoothReaderDelegate-p) method of its delegate object to notify the result.
If the Bluetooth reader is authenticated successfully, you can get the card status by calling getCardStatus (ABTBluetoothReader) method of ABTBluetoothReader class.
The Bluetooth reader calls bluetoothReader:didReturnCardStatus:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the card status.
If the card status is changed, the Bluetooth reader calls bluetoothReader:didChangeCardStatus:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the card status.
If the Bluetooth reader is authenticated successfully, you can transmit the APDU to the card by calling transmitApdu: (ABTBluetoothReader) method of ABTBluetoothReader class.
The Bluetooth reader calls bluetoothReader:didReturnResponseApdu:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the response APDU.
If the Bluetooth reader is authenticated successfully, you can transmit the escape command by calling transmitEscapeCommand: (ABTBluetoothReader) method of ABTBluetoothReader class.
The Bluetooth reader calls bluetoothReader:didReturnEscapeResponse:error: (ABTBluetoothReaderDelegate-p) method of its delegate object to return the escape response.