[英]NFC with ACR122U and Android
http://www.acs.com.hk/en/products/3/acr122u-usb-nfc-reader/
我正在使用上面鏈接的Android庫,並且正在嘗試讀取/寫入NFC標簽。 標簽將具有我所知道的格式(可能類似於JSON)。 我可以運行示例應用程序,並看到讀取器正在工作並正在檢測NFC標簽,但是如何實際讀取或編寫它們呢? 該API有點令人困惑。 任何幫助深表感謝。
到目前為止,在我的應用程序中,我已經找到了如何獲取讀取器狀態和讀取器類型/名稱的方法,但是與NFC標簽本身無關。
它也不起作用。 responseLength
始終為0。不應為0。 該命令絕對是正確的讀卡ID命令: {(byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x04
並且在Windows Java示例中使用相同的ACR122 usb閱讀器即可完美運行:
// Transmit APDU
byte[] command = {(byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x04};
byte[] response = new byte[100];
int responseLength = 0;
try {
responseLength = mReader.transmit(0, command, command.length, response, response.length);
} catch (ReaderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView tv = (TextView)findViewById(R.id.main_text_view_response);
tv.setText( "resp: "+Integer.toString(responseLength) + ": "+ Integer.toString( response[0] ) );
除了供應商ACS提供的SDK外,您可以嘗試Libnfc ,它是具有LGPL許可證的開源低級NFC SDK。 您可以在其上構建應用程序。
Libnfc在Linux和Windows上均支持ACR122U。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.