×
Namespaces

Variants
Actions
(Difference between revisions)

Understanding NFC Data Exchange Format (NDEF) messages

From Nokia Developer Wiki
Jump to: navigation, search
mahbub_s60 (Talk | contribs)
(Mahbub s60 -)
lpvalente (Talk | contribs)
m (Lpvalente - broken links)
Line 6: Line 6:
 
The NFC Data Exchange Format (NDEF) specification defines a message encapsulation format to exchange information, e.g. between an NFC Forum Device and another NFC Forum Device or an NFC Forum Tag. NDEF is a lightweight, binary message format that can be used to encapsulate one or more application-defined payloads of arbitrary type and size into a single message.  
 
The NFC Data Exchange Format (NDEF) specification defines a message encapsulation format to exchange information, e.g. between an NFC Forum Device and another NFC Forum Device or an NFC Forum Tag. NDEF is a lightweight, binary message format that can be used to encapsulate one or more application-defined payloads of arbitrary type and size into a single message.  
 
An NDEF message is composed of one or more NDEF records. There can be multiple records in a NDEF message.  Basically NDEF message is array of NDEF records. How many records we can encapsulate in a NDEF message that depends on our application and the tag type. For our analysis purposes we use only one NDEF records. This NDEF record stores   
 
An NDEF message is composed of one or more NDEF records. There can be multiple records in a NDEF message.  Basically NDEF message is array of NDEF records. How many records we can encapsulate in a NDEF message that depends on our application and the tag type. For our analysis purposes we use only one NDEF records. This NDEF record stores   
http://nokia.com. Following figure shows the general view of NDEF message [1]. <br>
+
<nowiki>http://nokia.com</nowiki>. Following figure shows the general view of NDEF message [1]. <br>
 
[[Image:ndefrecod.png]]
 
[[Image:ndefrecod.png]]
 
<br>
 
<br>
Line 43: Line 43:
 
<br>
 
<br>
 
03
 
03
0x03  URI identifier (“http://”) <br>
+
0x03  URI identifier <nowiki>(“http://”)</nowiki> <br>
 
<br>
 
<br>
 
Pay Load <br>
 
Pay Load <br>

Revision as of 17:01, 9 August 2011

Contents

Introduction

Most NFC tags are passive elements those store data for reader (for NFC enabled mobile phones) in NDEF (NFC Data Exchange Format) format. When we touch our phones with any NFC forum enabled tags, actually we read the NDEF message by our application. Those happen via NFC application to protocol stack then low level driver and finally the radio frequency (RF) parts to retrieve data from tags. In this article, we try to explain the structure of NDEF message with simple uniform resource identifier (URI) to describe web page address. We provide an example Qt mobility application that can be used to test it.

NDEF message and NDEF record

The NFC Data Exchange Format (NDEF) specification defines a message encapsulation format to exchange information, e.g. between an NFC Forum Device and another NFC Forum Device or an NFC Forum Tag. NDEF is a lightweight, binary message format that can be used to encapsulate one or more application-defined payloads of arbitrary type and size into a single message. An NDEF message is composed of one or more NDEF records. There can be multiple records in a NDEF message. Basically NDEF message is array of NDEF records. How many records we can encapsulate in a NDEF message that depends on our application and the tag type. For our analysis purposes we use only one NDEF records. This NDEF record stores http://nokia.com. Following figure shows the general view of NDEF message [1].
Ndefrecod.png
When we communicate with our NFC reader devices (mobile phones) to read or write data to NFC tag we read basically (for example http: //nokia . com) the following hexa code.
03 0e d1 01 0a 55 03 6e 6f 6b 69 61 2e 63 6f 6d fe
03
This is one byte that defines the type of record this is. An NDEF record is represented by the hex byte 03, with Qt mobility API we don’t provide this, those are added for us.
0e
This is one byte that tells the reader how many bytes are in the payload. With Qt mobility API we don’t provide this, those are added for us by platform.
d1
NDEF records are variable length records with a common format illustrated in the figure below.
d1 is binary code (11010001)
Ndeftnf.png


In our case:
MB = 1 (message Begin is true means this is first record in the NDEF message)
ME = 1 (Message end, means it is last record in the NDEF message, if it is 0 that tells application that more records are ahead)
CF = 0 (means this is not chunked message, An NDEF message can contain zero or more chunked payloads. Each chunked payload is encoded as an initial record chunk followed by zero or more middle record chunks and finally by a terminating record chunk, in our case we simplify our record as not chunked)
SR = 1 (SR stands for short record, if set, that the payload length field is a single octet.This short record layout is intended for compact encapsulation of small payloads which will fit within PAYLOAD fields of size ranging between 0 to 255 octets.)
IL = 0(IL stands for identification length, if set, that the ID_LENGTH field is present in the header as a single octet. If the IL flag is zero, the ID_LENGTH field is omitted from the record header and the ID field is also omitted from the record)
TNF = 001(The TNF field value indicates the structure of the value of the TYPE field. The value 0x01 (NFC Forum well-known type) indicates that the TYPE field contains a value that follows the RTD type name format defined in the NFC Forum RTD specification )

Ndeffullrecod.png


01 (Type Length)
The TYPE_LENGTH field is an unsigned 8-bit integer that specifies the length in octets of the TYPE field. The TYPE_LENGTH field is always zero for certain values of the TNF field.
0A (Pay load Length)
The PAYLOAD_LENGTH field is an unsigned integer that specifies the length in octets of the PAYLOAD field (the application payload). The size of the PAYLOAD_LENGTH field is determined by the value of the SR flag
55 (type The value of the TYPE field is an identifier describing the type of the payload, The URI record type (“U”) )
03 0x03 URI identifier (“http://”)

Pay Load
Rest string in UTF-8 (nokia.com)
FE Terminator byte. This is final byte added by platform.

Qt Mobility TestApplication

File:Qttestapp.zip
Modified example from Qt mobility example, address and corresponding NDEF messages are shown in the edit box
Screenshot
Ndefscreenshot.png

References

1. http://www.developer.nokia.com/info/sw.nokia.com/id/bdaa4a0f-fcf3-4a4b-b800-c664387d6894/Introduction_to_NFC.html
2. http://www.nfc-forum.org/specs/

2213 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×