0
votes

I've been using the ACR122 card reader for a while which had no trouble reading either Mifare 1K or Mifare Ultralight NFC cards.

After upgrading the card reader to the newest version (ACR1251), my program can't read the UID from the Mifare 1K cards.

This is the snippet I use for reading:

CardTerminal terminal = terminalWithCardPresent.get(0);
terminal.waitForCardPresent(0);
Card card = terminal.connect("T=1");
if (card != null) {
    CommandAPDU command = new CommandAPDU((byte) 0xFF, (byte) 0xCA, (byte) 0x00, (byte) 0x00, (byte) 0x07);
    CardChannel channel = card.getBasicChannel();
    ResponseAPDU response = channel.transmit(command);
    StringBuilder sb = new StringBuilder();
    if (response.getSW1() == 0x90 && response.getSW2() == 0x00) {
        byte[] data = response.getData();
        String code = decoder.apply(data);
        sb.append(code);
    }
    cardIdRead.recieve(sb.toString());
}
terminal.waitForCardAbsent(0);

With the new version of the rad reader:

  • the ResponseAPDU.getSW1() function returns 98
  • while getSW2() returns 130

I've tried searching both the web and the card readers documentation for an explanation for the response codes with no luck. Anyone else had simular problems, and know how to read the UID from a card returnon sw1 sw2 98 130?

2

2 Answers

0
votes

Converting the SW 98 130 into hex gave ‘6282’. From this table, it means "Fewer bytes than specified by the Le parameter could be read, since the end of the file was encountered first."

The 'FF CA' is documentated in ACR122U reader documentation, but is not found in ACR1251U documentation. From the ACR122U documentation, the Le should be '00' instead of '07'.

I suggest trying to send APDU 'FFCA000000', and if it failed, try to send 'FFCA0000XX' (with XX from '01' to '06').

0
votes

For JAVASE purpose (Ultralight nfc Card) you can follow this Links and bellow code.

For Read UID , Command is :

 baReadUID = new byte[] { (byte) 0xFF, (byte) 0xCA, (byte) 0x00,
            (byte) 0x00, (byte) 0x00 };

For Read from Specefic Block (Here read page 04 to page 07) Command is:

read_four_to_seven = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0x00,
                     (byte) 0x00, (byte) 0x05, (byte) 0x0D4, (byte) 0x40, (byte) 0x01,
                     (byte) 0x30, (byte) 0x04, (byte) 0x07 };

For Writing into Page 04:

Write_Page_Four = new byte[] { (byte) 0xFF, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x15, (byte) 0xD4, (byte) 0x40,
(byte) 0x01, (byte) 0xA0, (byte) 0x04, (byte) 0x4D,
(byte) 0x65, (byte) 0x73, (byte) 0x75, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00 };

All Complete code is here...