Nexus S NPP for 2-way exchange

Asked by Vic Lortz

I have been experimenting NPP on a Nexus S (Android 2.3.4) with an SCL3711 reader. I want to do a fast 2-way exchange. If I configure the phone to be the NPP client, I can receive and process the NDEF record fairly quickly. However, if I next try to turn around the channel and send an NDEF message back to the phone I'm seeing a rather large delay (typically 2-4 seconds). Since I'm using NPP, it seems that I have to tear down the LLCP connection in the middle for this to work.

I first start up the python code (based on a modified npp-test-server.py) as an NPP server. I tap the phone, and I receive the NDEF message from the client right away. I then call nfc.llcp.deactivate() or nfc.llcp.shutdown() [I've tried both, with no discernable difference]. I next call llcp_connect(clf,nfc.llcp.startup(llcp_config)) to establish a new connection in client mode. The delay occurs in the call to llcp_connect(). Once that call returns, I can send data back to the phone in about 500msec. This direction isn't as responsive as the phone-to-PC direction, but it is okay for my purposes. The problem is in how long it takes llcp_connect() to return.

I would appreciate some guidance as to the best way to break the connection and re-establish it in the other direction. Are there any tricks to speeding up this process? Is there any better way to do 2-way NFC with a Nexus S? NPP works fine to transfer NDEF in one direction, but it's annoying to have to tear down and reestablish the LLCP connection to send data in the other direction. Am I missing something?

Thanks very much,
Vic

Question information

Language:
English Edit question
Status:
Solved
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Solved by:
Stephen Tiedemann
Solved:
Last query:
Last reply:
Revision history for this message
Best Stephen Tiedemann (stephen-tiedemann) said :
#1

Vic,

there is no need to tear down the LLCP link for a two way exchange, you can just connect to the NPP server in the same touch and send it an NDEF message. For a simple NPP echo server it's very few lines of code and I'll check in an example npp-echo-server.py in a minute. As the name says, whatever NDEF message the Nexus S sends to the npp-echo-server will immediately be sent back. Ihope that helps.

/Stephen

Revision history for this message
Vic Lortz (victor-lortz) said :
#2

Thanks for the quick clarification, Stephen. I had misunderstood this part of the NPP spec:

"Upon the establishment of an NFC-DEP connection, the NPP client MUST immediately attempt the NPP push procedure if it has valid NDEF message(s) available. The procedure is:
1. Connect to LLCP socket with service name com.android.npp
2. Send the NPP Header following by NDEF Entries as defined in the Data Format section
3. Disconnect the LLCP socket"

Apparently the disconnect step doesn't have to take place right away.

-Vic