ACR122 - 安卓/如何提取UIDUID

2023-09-03 21:51:20 作者:《噩性欲望》

我尝试将ACR122集成到我的Andr​​oid应用程序。我使用了Android库(的http:// www.acs.com.hk/en/products/3/acr122u-usb-nfc-reader/ )可从ACS。

I try to integrate an ACR122 to my android app. I'm using the ANDROID Library (http://www.acs.com.hk/en/products/3/acr122u-usb-nfc-reader/) available from ACS.

一切工作,我可检测卡的presence,但我想提取卡的UID / ID。有人知道函数来做到这一点?

Everything work, I can detect the presence of a card but I want to extract the UID/ID of the card. Someone know the function to do that?

你有这种类型的集成的例子吗?

Do you have an example of this type of integration?

推荐答案

在情况Mifare卡,你需要发送这个APDU字节数组卡:(字节)0xFF的,(字节)0xCA,(字节)为0x00,(字节)为0x00,(字节)×00。我不知道有关ACR122的API,但可能你需要用这个APDU到特定的API方法类似发射()

In case of Mifare card you need to send this APDU byte array to the card: (byte) 0xFF, (byte) 0xCA, (byte) 0x00, (byte) 0x00, (byte) 0x00 . I'm not sure about ACR122 API but probably you need to wrap this APDU into specific API method like transmit()

更新

样品code:

 byte[] command = { (byte) 0xFF, (byte) 0xCA, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
 byte[] response = new byte[300];
 int responseLength;
 responseLength = reader.transmit(slotNum, command, command.length, response,response.length);
 System.out.println(new String(response));

Reader是com.acs.smartcard.Reader对象 和slotNum是一个插槽号。我不知道如何找到它,因为我没有ACR测试。但是,如果你说,你是能够建立与读者基本的沟通也许你知道slotNum。

Reader is com.acs.smartcard.Reader object and slotNum is a the slot number. I’m not sure how to find it because I don’t have ACR to test. But if you told that you was able to establish basic communication with reader probably you know slotNum.

 
精彩推荐
图片推荐