ACS Audio Jack iOS Library
1.0.0
|
This library provides classes and protocols for communicating with ACS audio jack readers on iOS 5.0 or above.
Your application should include a header file AudioJack.h
in order to use the classes and protocols provided by the library.
To use ACRAudioJackReader
class, you should assign a delegate to your reader. Your delegate object is responsibe for receiving the data from the reader and should conform to the ACRAudioJackReaderDelegate
protocol.
The sleep mode of reader is enabled by default. To use the reader, your application should call reset (ACRAudioJackReader) method. If your delegate object implements ACRAudioJackReaderDelegate::readerDidReset: method, it will receive a notification after the operation is completed.
You can enable the sleep mode by calling sleep (ACRAudioJackReader) method. If your delegate object implements ACRAudioJackReaderDelegate::reader:didNotifyResult: method, it will receive a notification after the operation is completed.
You can set the sleep timeout by calling ACRAudioJackReader::setSleepTimeout method. If your delegate object implements ACRAudioJackReaderDelegate::reader:didNotifyResult: method, it will receive a notification after the operation is completed.
To get the firmware version, your application should call getFirmwareVersion (ACRAudioJackReader) method. Your delegate object should implement ACRAudioJackReaderDelegate::reader:didSendFirmwareVersion: method in order to receive the firmware version.
To get the status, your application should call getStatus (ACRAudioJackReader) method. Your delegate object should implement ACRAudioJackReaderDelegate::reader:didSendStatus: method in order to receive the status.
When you swipe a card, the reader notifies a track data and sends it through an audio channel to your iOS device. To receive the notification and the track data, your delegate object should implement ACRAudioJackReaderDelegate::readerDidNotifyTrackData: and ACRAudioJackReaderDelegate::reader:didSendTrackData: method. You can check the track error using ACRTrackData::track1ErrorCode and ACRTrackData::track2ErrorCode properties. Note that the received ACRTrackData object will be the instance of ACRAesTrackData or ACRDukptTrackData according to the settings. You must check the type of instance before accessing the object.
You can get the track data using ACRAesTrackData::trackData, ACRDukptTrackData::track1Data and ACRDukptTrackData::track2Data properties. Note that the track data of ACRAesTrackData object is encrypted by AES while the track data of ACRDukptTrackData object is encrypted by Triple DES. You must decrypt it before accessing the original track data.
After decrypting the track data of ACRAesTrackData object, you can use initWithBytes:length: (ACRTrack1Data) and initWithBytes:length: (ACRTrack2Data) methods to decode the track data into fields. For the track data or masked track data of ACRDukptTrackData object, you can use initWithString: (ACRTrack1Data) and initWithString: (ACRTrack2Data) methods.
If you want to access a raw data of a response, your delegate object should implement ACRAudioJackReaderDelegate::reader:didSendRawData:length: method. Note that the raw data is not verified by CRC16 checksum and you can call verifyData:length: (ACRAudioJackReader) method to verify it.
If your reader came with the ICC interface, you can operate the card using the following methods:
Before transmitting the APDU, you need to reset the card using powerCardWithAction:slotNum:timeout:error: (ACRAudioJackReader) method. The ATR string will be returned if the card is operated normally. Otherwise, it will return the error code.
After resetting the card, the card state is changed to ACRCardNegotiable or ACRCardSpecific. You cannot transmit the APDU if the card state is not equal to ACRCardSpecific. To select the protocol, invoke setProtocol:slotNum:timeout:error: (ACRAudioJackReader) method with the preferred protocols.
After selecting the protocol, you can transmit the command APDU using transmitApdu:slotNum:timeout:error: (ACRAudioJackReader) or transmitApdu:length:slotNum:timeout:error: (ACRAudioJackReader) method.
You can transmit the control command to the reader using transmitControlCommand:controlCode:slotNum:timeout:error: (ACRAudioJackReader) or transmitControlCommand:length:controlCode:slotNum:timeout:error: (ACRAudioJackReader) method if the reader supports a set of escape commands.
If your reader came with the PICC interface, you can operate the card using the following methods:
Before transmitting the APDU, you need to power on the card using piccPowerOnWithTimeout:cardType: (ACRAudioJackReader) method. If your delegate object implements ACRAudioJackReaderDelegate::reader:didSendPiccAtr:length method, it will receive the ATR string from the card.
To transmit the APDU, you can use piccTransmitWithTimeout:commandApdu:length: (ACRAudioJackReader) method. If your delegate object implements ACRAudioJackReaderDelegate::reader:didSendPiccResponseApdu:length method, it will receive the response APDU from the card.
After using the card, you can pwoer off the card using piccPowerOff (ACRAudioJackReader) method. If your delegate object implements ACRAudioJackReaderDelegate::reader:didNotifyResult: method, it will receive a notification after the operation is completed.