8

we have bought the ACR122 USB SDK for NFC testing. We would like to build the test desktop application for the ACR122U-A2 NFC reader. We are developing it in Java on the Microsoft Windows 7 platform.

We expected that in order to use PC/SC from Winscard.dll we need to make JNI calls. In order to do that C/C++ wrapper library for JNI calls should be prepared.

I think this should be part of the SDK, because the example application references the JNI wrapper Jacspcsc.dll, but the library is not there. Has anybody similar experience? Are there any JNI wrappers available for Winscard.dll?

Thanks STeN

STeN
  • 6,262
  • 22
  • 80
  • 125

1 Answers1

6

If you installed the PC/SC driver for the reader you can use the java smardcardio package (http://download.oracle.com/javase/6/docs/jre/api/security/smartcardio/spec/javax/smartcardio/package-summary.html) to communicate with the reader.

TerminalFactory terminalFactory = TerminalFactory.getDefault();
CardTerminal terminal = terminalFactory.terminals().list().get(0);
Card card = terminal.connect("T=0");
CardChannel channel = card.getBasicChannel();

// Construct a command and transmit it
CommandAPDU command = new CommandAPDU(new byte[]{(byte)0x01, (byte)0x02, ...})
ResponseAPDU response = channel.transmit(command)
Michael Elias
  • 212
  • 1
  • 4
  • Hi, I already use the java smardcardio package. I received also the library for JNI calls, but I prefer Java native way... Just now I finalized all the initialization, made GUI and I get the ATR. Now I am going to program the tag. Do you know if the CommandAPDU can be used for sending non-APDU commands, i.e. how to proceed with tags (e.g. Mifare Classic 1K), which do not understand APDU, but only proprietary commands? Thx Petr – STeN Jun 15 '11 at 05:18
  • To send tag specific commands to the tag you need to go through some steps to establish a logical connection to the tag; You need to poll for a tag and once you received a response, use the direct transmit command to send commands to the tag. The documentation for the ACR122U reader provides examples on how to do this. – Michael Elias Jun 15 '11 at 07:15
  • You need to wrap commands for the contactless card (as opposed to the internal contact SAM card) inside 'pseudo APDUs'. We've implemented a smartcardio based provider for this over [here](http://scuba.svn.sourceforge.net/viewvc/scuba/acr122provider/src/net/sourceforge/scuba/smartcards/ACR122TerminalFactorySpi.java?revision=161&view=markup). – martijno Jul 10 '12 at 14:37
  • A JNI wrapper around [libnfc](http://www.libnfc.org) might work, and would make your app work with other NXP-PN53x based NFC readers. – martijno Jul 10 '12 at 14:42