51 (edited by nephets 2011-09-01 10:46:11)

Re: P2P communication between android phone and nfc reader

FYI, the NFC Forum has just published the Simple NDEF Exchange Protocol (SNEP) specification which provides a standardized way to exchange NDEF messages on top of LLCP. Every future NFC Forum certified device will have a default SNEP server  running on a well known service access point ("urn:nfc:sn:snep", SAP 2 as per http://www.nfc-forum.org/specs/nfc_foru … s_register). The SNEP specification can be downloaded at http://www.nfc-forum.org/specs/spec_license.

A SNEP implementation and client/server test code is available through nfcpy (https://launchpad.net/nfcpy) and may be useful to either experiment with the protocol or to have a test partner for an own implementation. Same as the LLCP client/server examples, this code was used in cross-vendor plugfests and should be sufficiently correct, although nothing is perfect in the world (issues may be reported on https://bugs.launchpad.net/nfcpy).

Hope it helps the FOSS community and thanks for the work you're doing with libnfc.

Re: P2P communication between android phone and nfc reader

EDevil wrote:

Yes, I can also receive ONE from the phone (which is the first thing that happens when the LLCP link is up), and send multiple to the phone on the same session. I cannot however send multiple NDEF messages from the Android application in the same LLCP session.

Hi, EDevil (hoping you're still there...)

Can you please tell me how you sent messages from the ACR122 to the phone?
I cannot get how to be "on the same session" as you said.

What I did was (my ACR122 side program is in java):

1. on NexusS side, run the ApiDemos and start ndefPush.
2. on ACR122 side, send tgInitAsTarget()
d4 8c 00 00 00 00 00 00 00 01 fe 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 fe 00 00 00 00 00 00 00 00 06 46 66 6d 01 01 10 00
3. tgGetData d4 86
4. get response: llcp type CONNECT with service name parameter
5. tgSetData and send llcp type CONNECTION COMPLETE
6. tgGetData d4 86
7. get response: llcp type INFORMATION followed by NDEF data pushed by the NexusS app.
8. tgSetData and send llcp type CONNECTION COMPLETE
9. send tgSetData with llcp type CONNECT 
10. get response: d5 8f [b]00[/b] 90 00 witch is, I suppose, success
11. and here, I tried to tgSetData with llcp type INFORMATION including npp (and ndef)

but unfortunately, my NexusS' app gives me the log below

09-01 21:11:06.796: DEBUG/NdefPushClient(1958): LLCP connection up and running
09-01 21:11:06.800: DEBUG/NdefPushClient(1958): sending foreground and my tag
09-01 21:11:06.816: DEBUG/NdefPushClient(1958): about to create socket
09-01 21:11:06.820: DEBUG/NdefPushClient(1958): about to connect to service com.android.npp
09-01 21:11:06.855: DEBUG/NdefPushClient(1958): about to send a 44 byte message
09-01 21:11:06.855: DEBUG/NdefPushClient(1958): about to send a 44 byte packet
09-01 21:11:06.906: DEBUG/NdefPushClient(1958): about to close
09-01 21:11:06.968: DEBUG/NdefPushServer(1958): accept returned com.android.internal.nfc.LlcpSocket@4062f1f0
09-01 21:11:06.972: DEBUG/NdefPushServer(1958): about to accept
09-01 21:11:06.976: DEBUG/NdefPushServer(1958): starting connection thread
09-01 21:11:06.984: DEBUG/NdefPushServer(1958): read 33 bytes
09-01 21:11:07.070: INFO/NFC JNI(1958): LLCP Link deactivated
09-01 21:11:07.070: DEBUG/NfcService(1958): LLCP Link Deactivated message. Restart polling loop.
09-01 21:11:07.101: DEBUG/NdefPushServer(1958): connection broken by IOException
09-01 21:11:07.101: DEBUG/NdefPushServer(1958): java.io.IOException
09-01 21:11:07.101: DEBUG/NdefPushServer(1958):     at com.android.internal.nfc.LlcpSocket.receive(LlcpSocket.java:193)
09-01 21:11:07.101: DEBUG/NdefPushServer(1958):     at com.android.nfc.ndefpush.NdefPushServer$ConnectionThread.run(NdefPushServer.java:70)
09-01 21:11:07.101: ERROR/NdefMessage(1958): phFriNfc_NdefRecord_GetRecords(NULL) returned 0x221c
09-01 21:11:07.109: ERROR/NdefPushServer(1958): badly formatted NDEF message, ignoring
09-01 21:11:07.109: ERROR/NdefPushServer(1958): android.nfc.FormatException: Error while parsing NDEF message
09-01 21:11:07.109: ERROR/NdefPushServer(1958):     at android.nfc.NdefMessage.<init>(NdefMessage.java:46)
09-01 21:11:07.109: ERROR/NdefPushServer(1958):     at com.android.nfc.ndefpush.NdefPushProtocol.<init>(NdefPushProtocol.java:131)
09-01 21:11:07.109: ERROR/NdefPushServer(1958):     at com.android.nfc.ndefpush.NdefPushServer$ConnectionThread.run(NdefPushServer.java:86)
09-01 21:11:07.109: DEBUG/NdefPushServer(1958): about to close
09-01 21:11:07.117: DEBUG/NdefPushServer(1958): finished connection thread

My problems are:
1. As nitegate said before, the log says "read 33 bytes" witch is the data sent from ACR122. But I cannot find any way to pick up that data in my android app. Do you know how to get it?

2. The log says "LLCP Link deactivated". Is this because I'm not on the same session? What PDU should I send to keep the same session?

Million Thanx!

Re: P2P communication between android phone and nfc reader

trixter wrote:

What I did was (my ACR122 side program is in java):

1. on NexusS side, run the ApiDemos and start ndefPush.
2. on ACR122 side, send tgInitAsTarget()
d4 8c 00 00 00 00 00 00 00 01 fe 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 fe 00 00 00 00 00 00 00 00 06 46 66 6d 01 01 10 00
3. tgGetData d4 86
4. get response: llcp type CONNECT with service name parameter
5. tgSetData and send llcp type CONNECTION COMPLETE
6. tgGetData d4 86
7. get response: llcp type INFORMATION followed by NDEF data pushed by the NexusS app.
8. tgSetData and send llcp type CONNECTION COMPLETE
9. send tgSetData with llcp type CONNECT 
10. get response: d5 8f [b]00[/b] 90 00 witch is, I suppose, success
11. and here, I tried to tgSetData with llcp type INFORMATION including npp (and ndef)

The response on line 10 doesn't look like a success message. I'm not familiar with the ACR 122 but guess that 90 00 is the checksum trailer in which case you would have gotten a zero length response but an LLCP PDU is at least two octet. If the 90 00 would be an LLCP PDU, then it would be a SYMM PDU from SSAP 0 to DSAP 36 but SYMM PDUs must have both SSAP and DSAP as 0.

Why are you sending CC in line 8 and where is the response to that?
What is the content of the CONNECT PDU you're sending in line 9?

Re: P2P communication between android phone and nfc reader

Hi, nephets. Thank u very much for your reply!

nephets wrote:

The response on line 10 doesn't look like a success message. I'm not familiar with the ACR 122 but guess that 90 00 is the checksum trailer in which case you would have gotten a zero length response but an LLCP PDU is at least two octet. If the 90 00 would be an LLCP PDU, then it would be a SYMM PDU from SSAP 0 to DSAP 36 but SYMM PDUs must have both SSAP and DSAP as 0.

Sorry, my description was not clear...
90 00 is the APDU response code that ACR122 gives back when using PICC commands.
So, all responses have 90 00 at the end of the data.

So, to be precise, I think the response to the tgSetData (with llcp CONNECT) was (at PN532 command level) just d5 8f 00.

nephets wrote:

Why are you sending CC in line 8 and where is the response to that?

EDevil said you need to establish your own connection, so I thought I need to complete the connection once, and then, start connecting from ACR122. But maybe I'm wrong...

nephets wrote:

What is the content of the CONNECT PDU you're sending in line 9?

I sent:

d4 8e 41 01 06 0f 63 6f 6d 2e 61 6e 64 72 6f 69 64 2e 6e 70 70

where, in my understandings, is:

d4 8e: command code for "TgSetData" (of the NXP PN532chip)
41 01: (01000001 00000001 in binary) DSAP, LLCP PDU TYPE (CONNECT), SSAP
06: LLCP Parameter "Service Name"
0f: data length
the rest: "com.android.npp"

I got the LLCP spec from the nfc forum, and I (more or less) understand the meaning of each PDU, but I don't get when, or in what order, I should use them...

And also, I have no idea how to get the NDEF in my android app, because enableForegroundNdefPush() has no listener or any other method to receive data.
I thought about getting intents, but once the push is enabled, android doesn't get any tag intents... (I understand that. Otherwise it's not p2p anymore)

Thank you for you help.

Re: P2P communication between android phone and nfc reader

trixter wrote:
nephets wrote:

Why are you sending CC in line 8 and where is the response to that?

EDevil said you need to establish your own connection, so I thought I need to complete the connection once, and then, start connecting from ACR122. But maybe I'm wrong...

The CC PDU is the answer to CONNECT and says that the connection is accepted (DM would be to reject). To terminate a connection you would use DISC but you don't need to do that for the one set-up by the peer.

trixter wrote:
nephets wrote:

What is the content of the CONNECT PDU you're sending in line 9?

I sent:

d4 8e 41 01 06 0f 63 6f 6d 2e 61 6e 64 72 6f 69 64 2e 6e 70 70

where, in my understandings, is:

d4 8e: command code for "TgSetData" (of the NXP PN532chip)
41 01: (01000001 00000001 in binary) DSAP, LLCP PDU TYPE (CONNECT), SSAP
06: LLCP Parameter "Service Name"
0f: data length
the rest: "com.android.npp"

You need to set DSAP 1 if the CONNECT carries a service name. You should not use SSAP 1, this SAP is for service discovery (you should actually use a value between 32 and 63). Address usage is defined in LLCP section 4.2.1.1.

trixter wrote:

And also, I have no idea how to get the NDEF in my android app, because enableForegroundNdefPush() has no listener or any other method to receive data.

That is unfortunately not my field of experience. I'd recommend http://developer.android.com/resources/ … index.html for this question, the TagViewer descriptions appears to be close to your needs.

Re: P2P communication between android phone and nfc reader

nephets wrote:

The CC PDU is the answer to CONNECT and says that the connection is accepted (DM would be to reject). To terminate a connection you would use DISC but you don't need to do that for the one set-up by the peer.

When I omit the first CC PDU, NexusS gives me the Service Name, but right after, releases ACR122U and I wasn't able to get the response to the 2nd TgGetData (which is supposed to give me the NDEF data).
When I omit the 2nd CC PDU, I get the NDEF, so I think the 2nd one was not necessary...
Thank you for the knowledge.

nephets wrote:

You need to set DSAP 1 if the CONNECT carries a service name. You should not use SSAP 1, this SAP is for service discovery (you should actually use a value between 32 and 63). Address usage is defined in LLCP section 4.2.1.1.

I was misunderstanding the value of the SAP... Thanx.
But when I try with the value below, NexusS gives me error and I still can't get the NDEF...

PDU CONNECT
d4 8e 05 21 06 0f 63 6f 6d 2e 61 6e 64 72 6f 69 64 2e 6e 70 70
PDU INFORMATION
d4 8e 07 21 00 01 00 00 00 01 01 00 00 00 14 d1 01 13 54 02 65 6e 48 69 2c 20 6d 6f 6d 20 20 20 20 20 20 20 20 20

where DSAP/PDU Type/SSAP are respectedly:
05 21 (00000101 00100001 in binary)
07 21 (00000111 00100001 in binary)
Should be better now.

Android log:

09-02 21:49:58.792: DEBUG/NdefPushClient(205): LLCP connection up and running
09-02 21:49:58.796: DEBUG/NdefPushClient(205): sending foreground and my tag
09-02 21:49:58.808: DEBUG/NdefPushClient(205): about to create socket
09-02 21:49:58.820: DEBUG/NdefPushClient(205): about to connect to service com.android.npp
09-02 21:49:58.859: DEBUG/NdefPushClient(205): about to send a 45 byte message
09-02 21:49:58.859: DEBUG/NdefPushClient(205): about to send a 45 byte packet
09-02 21:49:58.917: DEBUG/NdefPushClient(205): about to close
09-02 21:49:58.953: DEBUG/NFC JNI(205): Socket Disconnected
09-02 21:49:58.953: DEBUG/NdefPushServer(205): accept returned com.android.internal.nfc.LlcpSocket@40541b18
09-02 21:49:58.953: DEBUG/NdefPushServer(205): about to accept
09-02 21:49:58.960: DEBUG/NdefPushServer(205): starting connection thread
09-02 21:49:59.050: INFO/NFC JNI(205): LLCP Link deactivated
09-02 21:49:59.050: DEBUG/NfcService(205): LLCP Link Deactivated message. Restart polling loop.
09-02 21:49:59.089: DEBUG/NdefPushServer(205): connection broken by IOException
09-02 21:49:59.089: DEBUG/NdefPushServer(205): java.io.IOException
09-02 21:49:59.089: DEBUG/NdefPushServer(205):     at com.android.internal.nfc.LlcpSocket.receive(LlcpSocket.java:193)
09-02 21:49:59.089: DEBUG/NdefPushServer(205):     at com.android.nfc.ndefpush.NdefPushServer$ConnectionThread.run(NdefPushServer.java:70)
09-02 21:49:59.089: WARN/NdefMessageSet(205): Unable to read version
09-02 21:49:59.097: ERROR/NdefPushServer(205): badly formatted NDEF message, ignoring
09-02 21:49:59.097: ERROR/NdefPushServer(205): android.nfc.FormatException: Unable to read version
09-02 21:49:59.097: ERROR/NdefPushServer(205):     at com.android.nfc.ndefpush.NdefPushProtocol.<init>(NdefPushProtocol.java:76)
09-02 21:49:59.097: ERROR/NdefPushServer(205):     at com.android.nfc.ndefpush.NdefPushServer$ConnectionThread.run(NdefPushServer.java:86)
09-02 21:49:59.097: DEBUG/NdefPushServer(205): about to close
09-02 21:49:59.097: DEBUG/NdefPushServer(205): finished connection thread

Still badly formatted NDEF, but lil' bit different... I got now "Unable to read version"...
So my problem is now in my INFORMATION PDU I think...

nephets wrote:

That is unfortunately not my field of experience. I'd recommend http://developer.android.com/resources/ … index.html for this question, the TagViewer descriptions appears to be close to your needs.

Thank you for your advice! Concerning this, I solved my problem.
I thought that, once in P2P mode (by ndefPush), Android app can't get any tag intents.
But I was wrong, if the LLCP connection is correctly established and NDEF correctly sent, my app is supposed to receive tag intent, and I can pull out my NDEF.
So the last problem I'm facing is (probably) the way I send INFORMATION PDU from ACR122 to NexusS.
Still got problem, but I'm stepping forward. Thank you!

Re: P2P communication between android phone and nfc reader

trixter wrote:

I was misunderstanding the value of the SAP... Thanx.
But when I try with the value below, NexusS gives me error and I still can't get the NDEF...

PDU CONNECT
d4 8e 05 21 06 0f 63 6f 6d 2e 61 6e 64 72 6f 69 64 2e 6e 70 70
PDU INFORMATION
d4 8e 07 21 00 01 00 00 00 01 01 00 00 00 14 d1 01 13 54 02 65 6e 48 69 2c 20 6d 6f 6d 20 20 20 20 20 20 20 20 20

where DSAP/PDU Type/SSAP are respectedly:
05 21 (00000101 00100001 in binary)
07 21 (00000111 00100001 in binary)
Should be better now.

After CONNECT you should have received a CC (else you need to wait for it). Take the SSAP value from the CC PDU and use that as the DSAP value in the I PDU. Generally speaking, the pair of DSAP and SSAP in the CC PDU identifies the established data link connection. CONNECT (without service name) from SAP 32 to SAP 16, for example, could well yield a CC from SAP 33 to SAP 32, again for example. CONNECT with service name to SAP 1 will always produce a CC from an SAP other than 1.

Re: P2P communication between android phone and nfc reader

nephets wrote:

After CONNECT you should have received a CC (else you need to wait for it). Take the SSAP value from the CC PDU and use that as the DSAP value in the I PDU.

I sent TgGetData after the CONNECT PDU and I got CC!!! Thank you!
Then I managed to put a correct SAP.

1. initialize ACR122 as a Target
2. TgGetData -> I receive CONNECT in response
3. TgSetData -> send CC
4. TgGetData -> receive NDEF from NexusS
5. TgSetData -> send CONNECT with DSAP:000001 PDU:0100 SSAP:100001
6. TgGetData -> I receive CC in response with DSAP:100001 PDU:0110 SSAP:010000
7. TgSetData -> send INFO with DSAP:010000 PDU:1100 SSAP:010001
d4 8e 43 11 00 01 00 00 00 01 01 00 00 00 14 d1 01 13 54 02 65 6e 48 69 2c 20 6d 6f 6d 20 20 20 20 20 20 20 20 20
8. response is d5 8f 00

Android still shows errors. now I see "android.nfc.FormatException: Unable to read version".

At line 5 I set 1 for DSAP because it's Service Discovery (as you taught me), and I chose arbitrary SSAP 100001b (dec 33) which is between 32 and 63.
At line 7 I set 16 (that I got from CC) for DSAP, and I set 17 for SSAP that I chose arbitrary between 16 and 31 (because this request doesn't require Service Discovery anymore).

Well, I also tried some other patterns for SAPs, but I'm still trapped...
Is my SAP setting wrong?

My understanding for the Info PDU is like this:
d4 8e: TgSetData
43 11: DSAP/PDU/SSAP
00: seq
01: NPP protocol ver.
00 00 00 01: no. of NDEF entries
01: action code
00 00 00 14: NDEF length
d1: NDEF flags (this one's Short Record, well-known type)
01: type name length
10: data length
54: type value
02: lang code flags
65 6e: lang code
the rest: text value of NDEF

Re: P2P communication between android phone and nfc reader

trixter wrote:

At line 7 I set 16 (that I got from CC) for DSAP, and I set 17 for SSAP that I chose arbitrary between 16 and 31 (because this request doesn't require Service Discovery anymore).

With the CC PDU you've got a data link connection acknowledged between your SAP 33 and Android's SAP 16, so now all your I/RR/RNR PDUs must have SSAP 33 and DSAP 16 and you'll only receive I/RR/RNR PDUs with DSAP 33 and SSAP 16 on that connection.

60 (edited by ismb_h2u 2011-09-07 05:31:16)

Re: P2P communication between android phone and nfc reader

Dear All,
I've solved the communication between ACR 122U and Samsung Nexus S.
Now I can send data from ACR 122 to Nexus S and ViceVersa.

I'd like to publish code and create a simple lib (similar to nfc-ip, http://code.google.com/p/nfcip-java/)
Is anyone interested in contributing? If so please send a mail to lotito@ismb.it - I'll contact you asap

See you soon,
Antonio

61 (edited by ismb_h2u 2011-09-07 05:31:00)

Re: P2P communication between android phone and nfc reader

As Promised, I've uploaded the first part of the code able to send messages from ACR-122 to Samsung Nexus-S.
http://code.google.com/p/ismb-npp-java/

In the following days I'll upload also the code to send messages back and a simple Android App.


If you are interested in contributing to build a stable library, please contact me at lotito@ismb.it

Best Regards,
Antonio

Re: P2P communication between android phone and nfc reader

I have LLCP working with a custom reader and Nexus S but having problems receiving NDEF messages larger than 128 bytes.

The Nexus S's built-in share tag app. is used to push v-card information to our reader. The NDEF message is broken into I-PDU by the Nexus S and ACK-PDUs are sent to ensure both I-PDUs are received. The first I-PDU has most of the information except for last 10 or so bytes are not correct. The second I-PDU seems to be correct but because of the first I-PDU issue, the NDEF message is not properly formatted (it is actually text/v-card MIME type). After the last second ACK-PDU is sent, the Nexus S sends DISC-PDU to terminate the session correctly. From LLCP it looks fine.

Has anyone seen this problem and/or successfully sent messages greater than 128 bytes in a single NPP session?

Re: P2P communication between android phone and nfc reader

miranosys1 wrote:

I have LLCP working with a custom reader and Nexus S but having problems receiving NDEF messages larger than 128 bytes.

The Nexus S's built-in share tag app. is used to push v-card information to our reader. The NDEF message is broken into I-PDU by the Nexus S and ACK-PDUs are sent to ensure both I-PDUs are received. The first I-PDU has most of the information except for last 10 or so bytes are not correct. The second I-PDU seems to be correct but because of the first I-PDU issue, the NDEF message is not properly formatted (it is actually text/v-card MIME type). After the last second ACK-PDU is sent, the Nexus S sends DISC-PDU to terminate the session correctly. From LLCP it looks fine.

Has anyone seen this problem and/or successfully sent messages greater than 128 bytes in a single NPP session?

** Ignore this ** The multiple I-PDU is working! It was a problem on my end with  not having enough buffer for message coming from the reader. It works now. This is a great forum for information.

Re: P2P communication between android phone and nfc reader

Hello,

FYI, the libnfc-llcp does now have a nexus-get-tag example that can read a shared tag for Nexus S.

Romuald Conty

Re: P2P communication between android phone and nfc reader

Hello,

I have little problem with LLCP. I am working on communication between android phone and acr122 on linux (ubuntu 11) and libnfc  v1.5 and libnfc-llcp is the latest svn version. I can send (push) data android to acr122 with no problem but after that i try to send data using llc_connection_send but nothing happen. Program create correct PDU and seems everything is right. i ll send the log4c out of program. 

ps : program base on llcp-test-server

[stderr] 20110929 07:41:45.594 TRACE    libnfc-llcp.llc.link- service 0x1ed4920 bound to SAP 1
[stderr] 20110929 07:41:45.594 TRACE    libnfc-llcp.llc.link- service 0x1ed4330 bound to SAP 16
[stderr] 20110929 07:41:45.594 INFO     libnfc-llcp.mac.link- (ACS ACR122U PICC Interface 00 00 / ACR122U207 - PN532 v1.6 (0x07)) Attempting to activate LLCP Link as target (blocking)
[stderr] 20110929 07:41:46.036 INFO     libnfc-llcp.mac.link- (ACS ACR122U PICC Interface 00 00 / ACR122U207 - PN532 v1.6 (0x07)) LLCP Link activated (target)
[stderr] 20110929 07:41:46.037 TRACE    libnfc-llcp.llc.link- llc_link_configure (0x1ed67c0, 0x7ffff1027754, 10)
[stderr] 20110929 07:41:46.037 DEBUG    libnfc-llcp.llc.link- Version: 1.0 (remote)
[stderr] 20110929 07:41:46.037 DEBUG    libnfc-llcp.llc.link- Version: 1.0 (agreed)
[stderr] 20110929 07:41:46.037 DEBUG    libnfc-llcp.llc.link- WKS: 0x0001
[stderr] 20110929 07:41:46.037 DEBUG    libnfc-llcp.llc.link- LTO: 1500 ms (0x96)
[stderr] 20110929 07:41:46.037 DEBUG    libnfc-llcp.llc.link- mq_open (/libnfc-llcp-10066-0x1ed67c0-up)
[stderr] 20110929 07:41:46.037 DEBUG    libnfc-llcp.llc.link- mq_open (/libnfc-llcp-10066-0x1ed67c0-down)
[stderr] 20110929 07:41:46.037 INFO     libnfc-llcp.llc.link- LLC Link started successfully
[stderr] 20110929 07:41:46.037 INFO     libnfc-llcp.llc.llc- (0x7f1290002700) Link activated
[stderr] 20110929 07:41:46.037 TRACE    libnfc-llcp.mac.link- Waiting for MAC Link PDU exchange thread to exit
[stderr] 20110929 07:41:46.037 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_receive+
[stderr] 20110929 07:41:46.252 TRACE    libnfc-llcp.mac.link- Received 19 bytes
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.mac.link- Received 19 bytes
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Received 19 bytes
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Connect PDU
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Spawning Data Link Connection [33 -> 1] accept routine
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.link- Searching SAP for service 'com.android.npp'
[stderr] 20110929 07:41:46.253 INFO     libnfc-llcp.llc.link- Service 'com.android.npp' is bound to SAP '16'
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Data Link Connection [16 -> 33] accept routine launched (service 16)
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Read -1 bytes from service 16
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_send+
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Nothing to send
[stderr] 20110929 07:41:46.253 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_receive+
[stderr] 20110929 07:41:47.036 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:47.036 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:47.037 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Received 2 bytes
[stderr] 20110929 07:41:47.037 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Symmetry PDU
[stderr] 20110929 07:41:47.037 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Read -1 bytes from service 16
[stderr] 20110929 07:41:47.037 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_send+
[stderr] 20110929 07:41:47.037 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Nothing to send
[stderr] 20110929 07:41:47.037 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_receive+
[stderr] 20110929 07:41:47.037 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:47.037 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:47.253 TRACE    libnfc-llcp.llc.connection- Data Link Connection [16 -> 33] accepted
[stderr] 20110929 07:41:47.820 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:47.820 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:47.820 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Received 2 bytes
[stderr] 20110929 07:41:47.821 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Symmetry PDU
[stderr] 20110929 07:41:47.821 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:47.821 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:47.821 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Read -1 bytes from service 16
[stderr] 20110929 07:41:47.821 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Data Link Connection [16 -> 33] accepted (service 16).  Sending CC
[stderr] 20110929 07:41:47.821 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_send+
[stderr] 20110929 07:41:47.821 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Sent 2 bytes
[stderr] 20110929 07:41:47.821 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_receive+
[stderr] 20110929 07:41:48.604 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:48.604 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:48.604 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:48.604 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:48.604 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Received 2 bytes
[stderr] 20110929 07:41:48.605 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Symmetry PDU
[stderr] 20110929 07:41:48.605 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Read -1 bytes from service 16
[stderr] 20110929 07:41:48.605 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_send+
[stderr] 20110929 07:41:48.605 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Nothing to send
[stderr] 20110929 07:41:48.605 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_receive+
[stderr] 20110929 07:41:48.664 TRACE    libnfc-llcp.mac.link- Received 40 bytes
[stderr] 20110929 07:41:48.664 TRACE    libnfc-llcp.mac.link- Received 40 bytes
[stderr] 20110929 07:41:48.664 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Received 40 bytes
[stderr] 20110929 07:41:48.665 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Information PDU
[stderr] 20110929 07:41:48.665 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
[stderr] 20110929 07:41:48.665 TRACE    libnfc-llcp.mac.link- Sending 2 bytes
pdu information is 'Hello embedded world[stderr] 20110929 07:41:48.665 INFO     libnfc-llcp.llc.llc- (0x7f1290002700) Send 40 bytes to service 16
[stderr] 20110929 07:41:48.665 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Read -1 bytes from service 16
[stderr] 20110929 07:41:48.665 WARN     libnfc-llcp.llc.llc- (0x7f1290002700) Send acknoledgment for received data
'
ERROR: data couldn't send to android device 0 
[stderr] 20110929 07:41:48.665 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_send+
[stderr] 20110929 07:41:48.665 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Sent 3 bytes
[stderr] 20110929 07:41:48.665 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_receive+
[stderr] 20110929 07:41:48.699 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:48.699 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:48.699 TRACE    libnfc-llcp.mac.link- Sending 3 bytes
[stderr] 20110929 07:41:48.699 TRACE    libnfc-llcp.mac.link- Sending 3 bytes
[stderr] 20110929 07:41:48.699 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Received 2 bytes
[stderr] 20110929 07:41:48.700 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Disconnect PDU
[stderr] 20110929 07:41:48.700 TRACE    libnfc-llcp.llc.connection- Stopping Data Link Connection [16 -> 33]
[stderr] 20110929 07:41:48.710 TRACE    libnfc-llcp.llc.connection- Freeing Data Link Connection [16 -> 33]
[stderr] 20110929 07:41:48.710 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_send+
[stderr] 20110929 07:41:48.710 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Nothing to send
[stderr] 20110929 07:41:48.710 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_receive+
[stderr] 20110929 07:41:49.484 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:49.484 TRACE    libnfc-llcp.mac.link- Received 2 bytes
[stderr] 20110929 07:41:49.484 TRACE    libnfc-llcp.mac.link- Sending 3 bytes
[stderr] 20110929 07:41:49.484 TRACE    libnfc-llcp.mac.link- Sending 3 bytes
[stderr] 20110929 07:41:49.484 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Received 2 bytes
[stderr] 20110929 07:41:49.484 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Symmetry PDU
[stderr] 20110929 07:41:49.484 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_send+
[stderr] 20110929 07:41:49.485 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) Nothing to send
[stderr] 20110929 07:41:49.485 TRACE    libnfc-llcp.llc.llc- (0x7f1290002700) mq_receive+
[stderr] 20110929 07:41:50.262 FATAL    libnfc-llcp.mac.link- MAC Level error on PDU reception
[stderr] 20110929 07:41:50.262 WARN     libnfc-llcp.mac.link- pdu_receive returned -1
[stderr] 20110929 07:41:50.262 ERROR    libnfc-llcp.mac.link- NFC error: Target Released
[stderr] 20110929 07:41:50.262 TRACE    libnfc-llcp.mac.link- MAC Link exchange PDU exchange thread terminated (returned 1)
STATUS = 0x1
I was the Target
[stderr] 20110929 07:41:50.262 INFO     libnfc-llcp.llc.link- Freeing service 16
[stderr] 20110929 07:41:50.262 INFO     libnfc-llcp.llc.link- Freeing service 1

Re: P2P communication between android phone and nfc reader

Hi,

ugur wrote:

I can send (push) data android to acr122 with no problem but after that i try to send data using llc_connection_send but nothing happen.

What are you expecting to do ?
What did you mean by "I try to send data", what kind of data do you want to send and what is the expected reaction on Nexus S?

Do you want to send an NDEF from host to Nexus S ?

Romuald Conty

Re: P2P communication between android phone and nfc reader

rconty wrote:

Do you want to send an NDEF from host to Nexus S ?

thanks for reply,

yes exactly that. try to establish a p2p communication and i think nexus to host part okay. i can see the ndef but the problem on the host to nexus s part.

Re: P2P communication between android phone and nfc reader

ugur wrote:
rconty wrote:

Do you want to send an NDEF from host to Nexus S ?

yes exactly that.

Your anwser is already given in this topic: http://www.libnfc.org/community/post/2235/#p2235

EDevil wrote:

In order to have received an NDEF message from the phone you have to have accepted a connection the phone made to the "com.android.npp" service running on your reader side. In order to send a message back you have to establish your own connection to the "com.android.npp" service running on the android side, you can't just reuse the same connection on which you received the message.

Romuald Conty

Re: P2P communication between android phone and nfc reader

ehua329 wrote:

I have working LLCP example code both on the reader side (using acr122+libnfc) and on the phone side (using symbian 3 SDK).

Sry this is not for android devices, but anyone interested just write me an email. Android LLCP stack is still buggy.

Hello ehua329.
Can you share your working example with me as well? Please contact me at sloter11[at]interia.pl

-Pawel

Re: P2P communication between android phone and nfc reader

Hi,

I wonder anybody have any idea about  the average  time consumption for establish a P2P connection between Android and ACR122 ?? Because I think mine is a little bit above my expectation.

71

Re: P2P communication between android phone and nfc reader

Hi ugur - what times are you seeing?   A round trip ACR->send to android then Android->send to ACR seems to be taking about 2.5 seconds for me but I don't think the way I'm doing it is as efficient as it could be.

Re: P2P communication between android phone and nfc reader

Hi,

now ICS is out, and a full AOSP stable port for Nexus S is available : http://forum.xda-developers.com/showthr … ?t=1354263
(or you can use a legit Galaxy Nexus), it should be interesting to try again this P2P communication between ACR122 and Nexus phone as ICS should have a much better NFC stack than the previous 2.3.4 that you tested all at that time.

I am very curious to know if ACR122 can be a receiver of the Android Beam protocol (I am buying one to make test, but until that if someone could try...)

My goal is to use a PN532 and a simple AVR to receive the Android Beam payload (so with a very simplified NFC stack based on libnfc and PN532 driver)

Re: P2P communication between android phone and nfc reader

Android Beam will work if you have LLCP and SNEP implemented. But I wouldn't recommend buying ACR122, SCL3711 RC-S360 are better choices.

Re: P2P communication between android phone and nfc reader

nephets wrote:

But I wouldn't recommend buying ACR122, SCL3711 or RC-S360 are better choices.

+1

Please stop buying ACR122 devices to use them with libnfc... ACR122 is a RFID device that have some almost unusable NFC features (using libnfc).

I don't know what to do:
- I marked it as partial support on libnfc's compatibility page with some explanations¹
- It's written in README file,²
- I created a dedicated topic to this problem³
What's next ?

[1] http://www.libnfc.org/documentation/har … patibility
[2] http://code.google.com/p/libnfc/source/ … unk/README
[3] http://www.libnfc.org/community/topic/5 … th-libnfc/

Romuald Conty

Re: P2P communication between android phone and nfc reader

Hi!

I'm sorry for posting this, but I was able to get a stable communication channel with an Android phone using a ACR122 USB device. I know it is not recommended for libnfc, however I'm working on my own stack in Java. The current version is good enough that I was able to bundle it into a Java Applet that can be launched in a browser.

So now all you need is a ACR 122 plugged in and Java installed and you can play with Android Beam in your browser.
You will find the applet here: http://www.grundid.de/nfc/

There is also a youtube video that demonstrates the applet: http://www.youtube.com/watch?v=I6-YObZNtDg