public class SmartcardReader
extends java.lang.Object
smartcardReader = SmartcardReader.getInstance();
smartcardReader.openReader();
smartcardReader.powerOn();
smartcardReader.sendApdu(apdu1);
smartcardReader.sendApdu(apdu2);
smartcardReader.sendApdu(apdu3);
...
smartcardReader.powerOff();
smartcardReader.closeReader();
The session with UICC card is opened after powerOn, it is closed after powerOff.
If it is used in an android Activity,
it's advised to call openReader()
and poweredOn
in onCreate,
and call powerOff()
and closeReader()
in onDestroy.
Modifier and Type | Field and Description |
---|---|
static int |
TDA8029_SERIALPORT_BAUDRATE_115200 |
static int |
TDA8029_SERIALPORT_BAUDRATE_38400 |
static java.lang.String |
VERSION |
Modifier and Type | Method and Description |
---|---|
void |
closeReader()
Closes smart card reader
|
byte[] |
getCardParam()
Get card parameters
|
java.lang.String |
getFirmwareVersion()
Get smart card reader firmware version
|
static SmartcardReader |
getInstance()
Get SmartcardReader singleton instance
|
static SmartcardReader |
GetInstance()
Deprecated.
Use
getInstance() instead |
byte |
getReaderStatus()
Get reader status
|
void |
ifsdRequest(int size)
This command is used to send a S(IFS request) block to the card
indicating the maximum length of information field of blocks
which can be received by the interface device in T=1 protocol.
|
boolean |
isAutoNegotiate()
is auto negotiate set during powerOn
|
boolean |
isCardPresent()
Is a card present in the smartcard reader
|
static boolean |
isDebuggingEnabled() |
void |
negotiate()
This command is used to make a PPS (Protocol and Parameter Selection) to the card.
|
void |
negotiate(byte protocol,
byte FiDi)
This command is used to make a PPS (Protocol and Parameter Selection) to the card
|
boolean |
openReader()
Opens smart card reader with default baud rate 38400
|
boolean |
openReader(int baudrate)
Opens smart card reader with specified baud rate
|
void |
powerOff()
Power off the smart card
|
byte[] |
powerOn_1_8V_EMV(boolean autoNegotiate) |
byte[] |
powerOn_1_8V_ISO(boolean autoNegotiate) |
byte[] |
powerOn_3V_EMV(boolean autoNegotiate) |
byte[] |
powerOn_3V_ISO() |
byte[] |
powerOn_5V_EMV()
5V is known to have stability issues on current hardware
|
byte[] |
powerOn_5V_ISO()
5V is known to have stability issues on current hardware
|
byte[] |
powerOn_ISO() |
byte[] |
powerOn()
Power on the smart card, and optionally perform negotiate if auto negotiate is set
|
byte[] |
processT1Command(byte[] apdu)
Deprecated.
Use
sendApdu(byte[]) instead |
void |
send_T1_IFSRequest(int size)
Send an IFS(information field size) request to indicate a new IFSD it can support.
|
byte[] |
sendApdu(byte[] apdu)
Send APDU via T=0 or T=1 depending on the protocol negotiated and get the response APDU
|
byte[] |
sendRawCommand(byte command,
byte[] data)
Send raw ALPAR command frame
|
void |
setAutoNegotiate(boolean auto)
Set auto negotiate during powerOn
Setting it to true will cause
powerOn() and its variants to perform auto negotiate based on the card's ATR. |
void |
setCardBaudRate(byte FiDi,
byte CKU)
This command is used to set the card baud rate
|
void |
setClockCard(byte frequency)
Change the card clock frequency
|
static void |
setDebuggingEnabled(boolean debug) |
public static final java.lang.String VERSION
public static final int TDA8029_SERIALPORT_BAUDRATE_38400
public static final int TDA8029_SERIALPORT_BAUDRATE_115200
public static SmartcardReader getInstance()
public boolean openReader()
true
the reader is opened successfully, {code}false{code} otherwise.public boolean openReader(int baudrate)
Possible baud rates are: 4800, 9600, 19200, 38400, 57600, 115200
public void closeReader()
public void setAutoNegotiate(boolean auto)
powerOn()
and its variants to perform auto negotiate based on the card's ATR.auto,
- set it true if negotiate is wanted and false to suppress negotiate during power onpublic boolean isAutoNegotiate()
public byte[] powerOn()
public byte[] powerOn_ISO()
public byte[] powerOn_5V_ISO()
public byte[] powerOn_5V_EMV()
public byte[] powerOn_3V_ISO()
public byte[] powerOn_3V_EMV(boolean autoNegotiate)
public byte[] powerOn_1_8V_ISO(boolean autoNegotiate)
public byte[] powerOn_1_8V_EMV(boolean autoNegotiate)
public void negotiate(byte protocol, byte FiDi)
protocol
- the protocol to be used.
Possible values are:
ALPARProtocol.PARAM_PROTOCOL_T0
,
ALPARProtocol.PARAM_PROTOCOL_T1
FiDi
- the ratio Fi/Di given by TA1 parameter of the ATRpublic void negotiate()
public void setCardBaudRate(byte FiDi, byte CKU)
FiDi
- the ratio Fi/Di given by TA1 parameter of the ATRCKU
- if CKU=ALPARProtocol.PARAM_FIDI_CKU
,
the baud rate is defined by FiDi.
if CKU=ALPARProtocol.PARAM_TWICE_FIDI_CKU
,
the baud rate is 2 * the baud rate is defined by FiDi.public byte[] sendRawCommand(byte command, byte[] data)
refer to document AN10207.pdf from NXP
command
- the command bytedata
- the datapublic void powerOff()
public byte getReaderStatus()
refer to document AN10207.pdf from NXP
public byte[] getCardParam()
refer to document AN10207.pdf from NXP
public void setClockCard(byte frequency)
frequency
- Possible values are:
ALPARProtocol.PARAM_CLOCK_FREQUENCY_14_745MHz
,
ALPARProtocol.PARAM_CLOCK_FREQUENCY_7_37MHz
,
ALPARProtocol.PARAM_CLOCK_FREQUENCY_3_68MHz
,
ALPARProtocol.PARAM_CLOCK_FREQUENCY_1_84MHz
public java.lang.String getFirmwareVersion()
public boolean isCardPresent()
public byte[] sendApdu(byte[] apdu)
apdu
- the command APDU@Deprecated public byte[] processT1Command(byte[] apdu)
sendApdu(byte[])
insteadapdu
- the command APDUpublic void ifsdRequest(int size)
The initial size following the answer to reset is 32 bytes and this size shall be used throughout the rest of the card session or until a new value is negotiated by the terminal by sending a S(IFS request) block to the card.
In E.M.V. mode, the IFSD size is automatically negotiated to 254 just after the ATR has been received.
size
- IFSD size in T=1 protocolpublic void send_T1_IFSRequest(int size)
size
- @Deprecated public static SmartcardReader GetInstance()
getInstance()
insteadpublic static void setDebuggingEnabled(boolean debug)
public static boolean isDebuggingEnabled()