java.lang.Objectandroid.device.PiccManager
public class PiccManager
The PiccManager class is used to initialize and control RF Card reader. Including data transmission, storage, read-write and other operation interfaces.
To read RF Card with this class, according to the following steps,
open to initialize the RF card reader.
request.
antisel.
activate.
apduTransmit.
deactivate to stop.
close.
For more information about the RF card reader, read PiccManager sample.
| Constructor Summary | |
|---|---|
PiccManager()
The PiccManager class is used to initialize and control RF Card reader. |
|
| Method Summary | |
|---|---|
int |
open()
Open the RF card reader. |
int |
close()
Close the RF card reader. |
int |
activate()
Activate card to start sending APDU. |
int |
deactivate(byte mode)
Deactivate a card. |
int |
activateEx(byte[] art)
Activate card to start sending APDU. |
int |
antisel(byte[] sn,
byte[] sak)
Anti-collision and select card and returns the serial number of the card. |
int |
apduTransmit(byte[] sent,
int sentLen,
byte[] rsp)
Transmit APDU exchange commands. |
int |
apduTransmit(byte[] cmd,
int cmdLen,
byte[] rsp,
byte[] sw)
Transmit APDU commands. |
int |
apduTransmit(byte[] cmd,
int cmdLen,
byte[] rsp,
int crc,
int speed)
Transmit APDU exchange commands. |
int |
apduTransmit(int cmd,
int num,
byte[] sent,
int sentLen,
byte[] rsp)
Transmit APDU commands for RF Card. |
int |
apduTransmitFelica(byte[] cmd,
int cmdLen,
byte[] rsp)
Transfer APDU instruction to felica card. |
void |
SetTimeOutFelica(int timeOut)
Set the felica APDU instruction timeout. Default is no timeout. |
int |
enableRATS(byte value)
Request for answer to select. |
int |
idcard_apduTransmit(byte[] sent,
int sentLen,
byte[] rsp)
Transmit APDU commands. |
int |
idcard_init()
Init the ID card. |
int |
m1_amount(int blkNo)
Read the amount for the block number. |
int |
m1_decrement(int blkNO,
int iMoney)
Decrement the value block by iMoney amount. |
int |
m1_increment(int blkNo,
int iMoney)
Increment the value block by iMoney amount. |
int |
m1_init(int blkNo,
int value)
Init the value block by value. |
int |
m1_keyAuth(int keyType,
int blnNo,
int keyLen,
byte[] keyBuf,
int iSeriNumLen,
byte[] seriNum)
Authenticate a key. |
int |
m1_readBlock(int blkNo,
byte[] pReadBuf)
Read a block. |
int |
m1_restore(int blkNo)
Move the content of a block into temporary data register. |
int |
m1_transfer(int blkNo)
Transfer from temporary internal data register to value block. |
int |
m1_writeBlock(int blkNo,
int iLenWriteBuf,
byte[] pWriteBuf)
Write a block into the card. |
int |
mifareUlIncrCnt(byte bCntNum,
int iCntValue)
Write the Mifare UltraLight counter. |
int |
mifareUlPageRead(int sectorNum,
byte[] rsp)
Read the Mifare UltraLight data. |
int |
mifareUlPageWrite(int sectorNum,
byte[] sent)
Write the Mifare UltraLight data. |
int |
mifareUlReadCnt(byte bCntNum,
int[] pCntValue)
Read Mifare UltraLight counter. |
int |
primeCard_apduTransmit(byte[] sent,
int sentLen,
byte[] rsp)
Transmit APDU commands for type B. |
int |
primeCard_init()
Init for type B prime protocol. |
int |
request_norats(byte[] mode,
byte[] atq)
Request card and without RATS. |
int |
request_type(byte pollType,
byte[] mode,
byte[] atq)
Request Specify card type. |
int |
request(byte[] mode,
byte[] atq)
Request card. |
int |
transactionData(byte bProtocol,
byte[] pSendBuf,
int bSendLen,
byte[] pRecvBuf,
int[] pRecvLen)
Transaction command. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
public PiccManager()
public int open()
PiccManager piccManager = new PiccManager();
int ret = piccManager.open();
if (ret != 0) {
//open failed
}public int enableRATS(byte value)
value - Enabled value. 1 is enable; 0 is disable.
public int primeCard_init()
public int primeCard_apduTransmit(byte[] sent,
int sentLen,
byte[] rsp)
sent - APDU command to be sent, the command format with ISO7816 transmission protocol.
sentLen - APDU length.
rsp - Response from card.
public int request(byte[] mode,
byte[] atq)
mode - The card type, could be 'A', 'B', 'F' or 'V'.
atq - The ATQ.
public int request_norats(byte[] mode,
byte[] atq)
mode - The card type, could be 'A', 'B', 'F' or 'V'.
atq - The ATQ.
public int request_type(byte pollType,
byte[] mode,
byte[] atq)
pollType - Value:
mode - The card type:
atq - The ATQ.
public int antisel(byte[] sn,
byte[] sak)
sn - Serial number.
sak - SAK.
public int activate()
piccManager.open();
int ret = piccManager.activate();
if (ret != 0) {
//activate failed
}public int activateEx(byte[] art)
art - Store the returned data.
piccManager.open();
byte atr[] = new byte[32];
int ret = piccManager.activateEx(atr);
if (ret != 0) {
//activateEx failed
}
public int apduTransmit(byte[] cmd,
int cmdLen,
byte[] rsp,
byte[] sw)
cmd - APDU command to be sent, the command format with ISO7816 transmission protocol.
cmdLen - APDU length.
rsp - Response from card.
sw - Status bytes.
public int apduTransmit(byte[] sent,
int sentLen,
byte[] rsp)
sent - APDU command to be sent.
sentLen - APDU length.
rsp - Response from card.
public int apduTransmit(byte[] cmd,
int cmdLen,
byte[] rsp,
int crc,
int speed)
cmd - APDU command to be sent.
cmdLen - APDU length.
rsp - Response from card.
crc - APDU CRC.
speed - APDU speed.
public int apduTransmitFelica(byte[] cmd, int cmdLen, byte[] rsp)
cmd - The BCD code of the APDU instruction to be sent to the card is required, and the command format conforms to the 7816 specification.
cmdLen - APDU length.
rsp - Response data returned by card, BCD code.
public void SetTimeOutFelica(int timeOut)
timeOut - Timeout, in MS.
public int deactivate(byte mode)
mode - value:
piccManager.activate();
public static final byte MODE = 0x00;
int ret = piccManager.deactivate(MODE);
if(ret != 0) {
//deactivate failed
}public int close()
int ret = piccManager.open();
if(ret == 0) {
piccManager.close();
}
public int m1_keyAuth(int keyType,
int blnNo,
int keyLen,
byte[] keyBuf,
int iSeriNumLen,
byte[] seriNum)
keyType - Key type:
blnNo - Block number.
keyLen - key length.
keyBuf - The key.
iSeriNumLen - Serial number length.
seriNum - Serial number.
public int m1_readBlock(int blkNo,
byte[] pReadBuf)
blkNo - Block number.
pReadBuf - To store the read data.
public int m1_writeBlock(int blkNo,
int iLenWriteBuf,
byte[] pWriteBuf)
blkNo - The block number.
iLenWriteBuf - Length of buffer to be written.
pWriteBuf - The buffer to be written.
public int m1_increment(int blkNo,
int iMoney)
blkNo - The value block number.
iMoney - The amount to be decremented.
public int m1_decrement(int blkNO,
int iMoney)
blkNO - The value block number.
iMoney - The amount to be decremented.
public int m1_restore(int blkNo)
blkNo - The block number to be operated on.
public int m1_transfer(int blkNo)
blkNo - The block number to be operated on.
public int m1_init(int blkNo,
int value)
blkNo - The value block number.
value - The amount to be init.
public int m1_amount(int blkNo)
blkNo - The value block number.
public int idcard_init()
public int idcard_apduTransmit(byte[] sent,
int sentLen,
byte[] rsp)
sent - APDU command to be sent.
sentLen - APDU length.
rsp - Response from IDCard.
public int apduTransmit(int cmd,
int num,
byte[] sent,
int sentLen,
byte[] rsp)
cmd - Transmitted commands.
num - Counter.
sent - APDU command to be sent.
sendLen - APDU length.
rsp - Response from RF Card.
public int mifareUlPageRead(int sectorNum,
byte[] rsp)
sectorNum - Read the sector number.
rsp - Output, 4 byte data from card.
public int mifareUlPageWrite(int sectorNum,
byte[] sent)
sectorNum - Write the sector number.
sent - 4 byte data to write.
public int mifareUlReadCnt(byte bCntNum,
int[] pCntValue)
bCntNum - Counter number 0 to 2.
pCntValue - Output, the counter value.
public int mifareUlIncrCnt(byte bCntNum,
int iCntValue)
bCntNum - Counter number 0 to 2.
iCntValue - Count value to write.
public int transactionData(byte bProtocol,
byte[] pSendBuf,
int bSendLen,
byte[] pRecvBuf,
int[] pRecvLen)
bProtocol - Card Type:
pSendBuf - Send the command.
bSendLen - Send command's length.
pRecvBuf - Response data from the card.
pRecvLen - Out data's length.