4
votes

I'm working on a project which requires an NFC communication between an android phone and a PC. I am using Galaxy S3 as android phone and ACR122 as NFC reader. I have tried the applications at here and here.

I used the sample application which found in android sdk to beam the NDEF message through NFC.

No matter how many times I tried, I couldn't establish a connection between the phone and PC. Android application works fine, since it can push the NDEF message through other phones, but when it comes to connecting with the pc, it doesn't work. Led on the reader changes color from red to blinking green and orange when I touch the phone to the reader, but nothing else happens.

There is the log output from the ismb-npp-java application:

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 of the drivers I could find (Including the latest driver) but the problem persists.

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

3
Does your device work for reading cards, etc? Also tryhttp://www.libnfc.org and code.google.com/p/nfc-tools/source/browse/trunk/libnfc-llcp for P2P.Nikolay Elenkov

3 Answers

0
votes

What version of Android are you running? NPP only works on older versions of Android (pre ICS, I believe).

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

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

0
votes

try this to get NfcAdapter

nfcP2PAdapter = NfcAdapter.getDefaultAdapter(recentContext.getApplicationContext());

// recentContext is activity(this)

It will work for you, it works for me

0
votes

The error you stated is from the transceive method in NppConnection.java. I would suggest that you first place the phone on the reader (let the reader's LED turn to green), then run the application again. See if this works. If not, put a breakpoint in the transceive method and check the values of SW1 and SW2 (if the command is successful, you would expect sw1 = 0x90 and sw2 = 0x00). In case of errors, you would get either sw2 not equal to 0x00 or sw1 = 0x63.

From my understanding, even if you are using a newer version of android and if snep is not supported by either of your devices, they will fall back to NPP.