我目前有以下情况:
我正在尝试编写一个简单String
的UPM Racetrack NFC Tag。我javax.smartcardio
为此使用Java。我为此使用 ACR1252 编写器/阅读器,为此我开发了一个简单的 java 应用程序。
关于卡的信息
- ATR: 3B8F8001804F0CA0000003060300030000000068
- 标准:03 -> ISO14443A 第 3 部分
- 卡名:0003 -> MIFARE ULTRALIGHT
到目前为止,这是我的 util 类代码:
public abstract class NFCUtils {
public static Card connect() throws Exception {
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
//Get the first terminal in the list
CardTerminal terminal = terminals.get(0);
System.out.println("Waiting for card....");
terminal.waitForCardPresent(0);
//Establish a connection
Card card = terminal.connect("*");
System.out.println("Card: " + card);
//Get ATR
byte[] baATR = card.getATR().getBytes();
System.out.println("ATR: " + NFCUtils.toString(baATR));
return card;
}
public static CommandAPDU createCommand(String data) {
int CLA = 0xFF;
int INS = 0xC2;
int P1 = 0x00;
int P2 = 0x01;
int LE = 0x04;
byte[] byteData = data.getBytes();
//APDU: CLA, INS, P1, P2, Data, Offset, DataLenght
CommandAPDU command = new CommandAPDU((byte) CLA, (byte) INS, (byte) P1, (byte) P2, byteData, 0x00, LE);
return command;
}
public static ResponseAPDU writeCommandToTag(Card card, CommandAPDU command) throws CardException {
CardChannel channel = card.getBasicChannel();
ResponseAPDU commandResponse = channel.transmit(command);
return commandResponse;
}
问题是响应总是:C003016300
,这意味着没有错误信息存在。由于缺乏错误信息,我完全坚持这一点。所以我的问题是:我该如何调试它,我的命令是否有明显的问题?
任何帮助是极大的赞赏!