androidnfcndefacr122pn532

NFC - Android device can't read Type 4 NDEF tag content emulated from ACR122U (PN532)


I'm writing C# application to emulate NFC tag via ACR122U, which uses PN532 internally. I want Android to read simple URI NDEF Tag.

I'm able to communicate with Android using NFC Forum Type 4 Tag protocol, Android detects the tag, but is not able to read the NDEF file - checked with NFC Tools app.

The communication looks like this:

tgInitAsTarget:
> FF-00-00-00-27-D4-8C-05-04-00-12-34-56-20-01-FE-05-01-86-04-02-02-03-00-4B-02-4F-49-8A-00-FF-FF-01-01-66-6D-01-01-10-02-00-00-00-00
< D5-8D-08-E0-80-90-00

> FF-00-00-00-02-D4-86 // tgGetData
< D5-87-00-00-A4-04-00-07-D2-76-00-00-85-01-01-00-90-00 // NDEF Tag applcation select
> FF-00-00-00-04-D4-8E-90-00 // optional File Control Information not provided
< D5-87-00-00-A4-00-0C-02-E1-03-90-00 // Capability Container select
> FF-00-00-00-04-D4-8E-90-00 // OK
< D5-87-00-00-B0-00-00-0F-90-00 // ReadBinary data from CC file
> FF-00-00-00-13-D4-8E-00-0F-20-00-FF-00-FF-04-06-E1-04-00-14-00-00-90-00 // CC content as per protocol
< D5-87-00-00-A4-00-0C-02-E1-04-90-00 // NDEF Select command
> FF-00-00-00-04-D4-8E-90-00 // OK
< D5-87-00-00-B0-00-00-02-90-00 // ReadBinary NLEN field from NDEF file
> FF-00-00-00-06-D4-8E-00-12-90-00 // NDEF will have 18 (12h) bytes
< D5-87-00-00-B0-00-02-12-90-00 // ReadBinary NDEF file
> FF-00-00-00-16-D4-8E-00-10-D1-01-0C-55-01-67-6F-6F-67-6C-65-2E-63-6F-6D-2F-90-00 // NDEF content - Well known URI type: google.com/

Some helpful tips:

It looks like I must be doing something wrong at the very last step of the communication. Is the NDEF file formatted correctly?


Solution

  • The problem is indeed in the last message. Just before that Android was asking for NDEF content from offset 02: < D5-87-00-00-B0-00-02-12-90-00

    Last message included the whole NDEF content including the size on first 2 bytes: 00-10. This must be removed:

    FF-00-00-00-14-D4-8E-D1-01-0C-55-01-67-6F-6F-67-6C-65-2E-63-6F-6D-2F-90-00

    This worked and Android open google.com.