NFC NDEF message formatting : payload size (ISO 15693 header, NfcV)

6.3k views Asked by At

"Hey bro, what's up ?"

I'm in trouble with NDEF message formatting.

I went through the NFC forum to know how to build a NDEF message with a single NDEF record (text RTD) with a payload, so I can program my tag (M24LR16E) through I2c.

In addition to this, I programmed my tag with an external writer to have an example of a well formatted record.

Then I programmed my tag through I2C with the exact same value, and everything worked well. Changing the payload characters gave me the proof of my success =)

"But you didn't come here to show us that anything worked well, no?"

You're right, know I'm trying to change the payload length and I get troubles. As soon as I change the PAYLOAD_LENGTH of the NDEF record it is no more recognized anymore as one. I changed the PAYLOAD_LENGTH from 10 down to 5, so it's not a problem of overflowing the config field.

"Great story, show me some code/config"

Here is my record configuration :

  • "Header" (MB ME CF SR IL TNF) : 0xD1
  • PAYLOAD_LENGTH : 0x0A
  • TYPE LENGTH : 0x01
  • TYPE : 0x54
  • PAYLOAD :
    • 0x02 ; UTF-8, 2 byte language code
    • 0x65 ; e
    • 0x6E ; n
    • 7 Other boring bytes

Also, I noticed that if I override the 6 bytes before my NDEF message, the NDEF message isn't recognized anymore. I have no idea on what could be this data as the NFC specification doesn't talk about this, neither the tag datasheet.

"You're supposed to ask a question..."

Uh, well...

  • Is there anything else than the PAYLOAD_LENGTH field of the NDEF record that I should change?
  • What are those essential data before my NDEF message?

My reader: Nexus 4 with NXP's "TagInfo" app

1

There are 1 answers

2
Michael Roland On BEST ANSWER

Unfortunately, you won't find much information on how to use that tag to store NDEF messages on the NFC Forum website. The reason for this is that there is currently no Tag Type specifiction for ISO 15693 tags (though standardization is ongoing).

I assume the memory contents of the tag looks like this (including the bytes you did not understand):

E1 4x yy 00
03 0E <YOUR NDEF MESSAGE> FE

If that's the case, the first 4 bytes are the capability container (indicated by the magic byte 0xE1 and the version nibble 0x4). x shoud be 0x0 indicating (application level!) read & write access. yy should be the overall size of your available data memory (excluding capability container) divided by 8. So far you should be able to keep those values...

But then there is the NDEF message TLV structure which embeds your NDEF message: 0x03 is the tag indicating an NDEF message. 0x0E is the length field. So that's what you need to change in addition to the payload length of your record. Android is quite picky when it comes to that length field. If this does not match the exact length of your NDEF message, most Android versions will ignore the message. The last byte, 0xFE is the (optional) terminator TLV. This should immediately follow the last data byte on your tag to tell the NDEF tag parser to stop parsing.