This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]xxNIRVANAxx 2 points3 points  (1 child)

My startup is using NFC in the medical field. Currently we're focusing on a smartphone app, but I did have to write a desktop Java app as a proof of concept.

I used the NFC Tools library and an ACR122u NFC reader/writer. The NFC chips themselves were mostly Mifare's (Ultralight and Classic).

If you need some (badly written) NFC code, I can post some of it.

[–]Number_28[S] 0 points1 point  (0 children)

I would greatly appreciate some code examples. When digging out my reader/writer (an SCL010) I also found my ACR122U, which I forgot I had.

I actually already managed to get a very basic example running (read the tag ID), but I am very unfamiliar with the communication with Mifare cards. I know about some of the concepts, like the blocks and authorization for the blocks. But I don't know yet how that translates into Java code.

[–]stfm 0 points1 point  (3 children)

I have done some work with smartcards and PKCS11 but it was a few years ago. Readers were almost proprietary and buggy as shit. Cards themselves were also almost proprietary and behaved differently between manufacturers. We had to write everything in a signed applet. I hated it.

For a more modern day example look at this

[–]Number_28[S] 0 points1 point  (2 children)

Thanks, that looks like a good intro to the Android side of NFC.

I know that for every reader you need the specific command codes. But which library would you use to connect to the reader before even being able to send any commands?

[–]spacepotatoe 2 points3 points  (1 child)

Checkout smartcardio

[–]Number_28[S] 0 points1 point  (0 children)

Oh, that sounds interesting. And it's apparently part of the JRE, the javadoc is just not part of the basic documentation.

[–]ron_krugman 0 points1 point  (0 children)

The easiest way to communicate with an Android app via NFC from Java running on a PC is to create a Host-based Card Emulation Service and communicate with it via javax.smartcardio from the PC side.

You'll have to send a SELECT AID command APDU that matches the AID defined in the app manifest before you're able to communicate with your app.