Java – P2P NFC communication between Galaxy S3 and ACR122

P2P NFC communication between Galaxy S3 and ACR122… here is a solution to the problem.

P2P NFC communication between Galaxy S3 and ACR122

I’m working on a project that requires NFC communication between an Android phone and a PC. I use the Galaxy S3 as an Android phone and the ACR122 as an NFC reader. I’ve tried the here app and here .

I used the sample application found in the android SDK to send NDEF messages over NFC.

No matter how many times I tried, I couldn’t establish a connection between my phone and PC. The Android app works fine because it can push NDEF messages through other phones, but it doesn’t work when it comes to connecting with a PC. When I touch the card reader with my phone, the LED light color on the card reader changes from red to flashing green and orange, but nothing else happens.

There is log output for ismb-npp-java applications:

Get factory

Get terminals

Terminal name: ACS ACR122 0

T=1

Called rightProcedureTarget..

[DEBUG] {sending [50 bytes]} 0xFF 0x00 0x00 0x00 0x2D 0xD4 0x8C 0x01 0x00 0x00 0x00 0x00 >0x00 0x40 0x01 0xFE 0x0F 0xBB 0xBA 0xA6 0xC9 0x89 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 >0xFF 0xFF 0x01 0xFE 0x0F 0xBB 0xBA 0xA6 0xC9 0x89 0x00 0x00 0x06 0x46 0x66 0x6D 0x01 0x01 >0x10 0x00

it.ismb.npp.IsmbNppException: problem with transmitting data

[DEBUG] {sending [7 bytes]} 0xFF 0x00 0x00 0x00 0x02 0xD4 0x86

[DEBUG] {sending [26 bytes]} 0xFF 0x00 0x00 0x00 0x15 0xD4 0x8E 0x05 0x20 0x06 0x0F 0x63 >0x6F 0x6D 0x2E 0x61 0x6E 0x64 0x72 0x6F 0x69 0x64 0x2E 0x6E 0x70 0x70

at it.ismb.npp.IsmbNppConnection.transceive(IsmbNppConnection.java:281)

at it.ismb.npp.IsmbNppConnection.rightProcedureTarget(IsmbNppConnection.java:301)

at it.ismb.npp.SenderToPhone$ThreadSender.run(SenderToPhone.java:90)

at it.ismb.npp.SenderToPhone$InitiatorTask.run(SenderToPhone.java:75)

at java.util.TimerThread.mainLoop(Unknown Source)

at java.util.TimerThread.run(Unknown Source)

it.ismb.npp.IsmbNppException: problem with transmitting data

at it.ismb.npp.IsmbNppConnection.transceive(IsmbNppConnection.java:281)

at it.ismb.npp.IsmbNppConnection.rightProcedureTarget(IsmbNppConnection.java:306)

at it.ismb.npp.SenderToPhone$ThreadSender.run(SenderToPhone.java:90)

at it.ismb.npp.SenderToPhone$InitiatorTask.run(SenderToPhone.java:75)

at java.util.TimerThread.mainLoop(Unknown Source)

at java.util.TimerThread.run(Unknown Source)

Exception in thread “Timer-0” java.lang.IllegalStateException: Card has been removed

at sun.security.smartcardio.CardImpl.checkState(Unknown Source)

at sun.security.smartcardio.ChannelImpl.checkClosed(Unknown Source)

at sun.security.smartcardio.ChannelImpl.transmit(Unknown Source)

at it.ismb.npp.IsmbNppConnection.transceive(IsmbNppConnection.java:263)

at it.ismb.npp.IsmbNppConnection.rightProcedureTarget(IsmbNppConnection.java:317)

at it.ismb.npp.SenderToPhone$ThreadSender.run(SenderToPhone.java:90)

at it.ismb.npp.SenderToPhone$InitiatorTask.run(SenderToPhone.java:75)

at java.util.TimerThread.mainLoop(Unknown Source)

at java.util.TimerThread.run(Unknown Source)

I’ve used all the drivers I can find (including the latest ones) but the problem persists.

Could it be a problem with the device? Or am I missing something here?

Solution

Which version of Android are you running? NPP only works with older versions of Android (pre-ICS versions I believe).

For ICS and JellyBean, try using the SNEP protocol. The author of the project you are working with has an SNEP version here:

http://code.google.com/p/ismb-snep-java/

Related Problems and Solutions