nfctools
nfctools copied to clipboard
Mifare Classic ISO 14443-3A with 7 byte UID returning only 4 bytes
When calling
byte[] tagId = ndefOperations.getTagInfo().getId();
I only get a 4-byte UID, but not as expected a 7-byte-UID
For Example I get the UID 04 BC D4 C2
instead of the full UID 04 BC D4 C2 E0 5C 80
I use this method to extract the TAG-ID:
byte[] tagId = ndefOperations.getTagInfo().getId();
String cardUid = "";
for(int i = 0; i < tagId.length; i++ ){
cardUid += String.format("%02X ", tagId [i]);
}
I get the correct UID using the APU-Command:
System.out.println("Job ID " + jobId + " GET UID THE OLD Common way....");
CardTerminal terminal2 = terminals.get(0);
javax.smartcardio.Card card2 = terminal2.connect("*");
CardChannel channel2 = card2.getBasicChannel();
byte[] cmdApduGetCardUid = new byte[]{
(byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x00};
ResponseAPDU respApdu = channel2.transmit(
new CommandAPDU(cmdApduGetCardUid));
String cardId = "";
if(respApdu.getSW1() == 0x90 && respApdu.getSW2() == 0x00){
byte[] baCardUid = respApdu.getData();
for(int i = 0; i < baCardUid.length; i++ ){
cardId += String.format("%02X ", baCardUid [i]);
}
}
System.out.println("Card ID is "+cardId);