This video is available to students only

In this lesson, we will deep dive into NDEF.

What is NDEF#

NDEF stands for NFC Data Exchange Format. As the name implies, it is used as the standard way for NFC-enabled devices to exchange data with each other, especially NFC readers and NFC tags.

Recall from the NFC specification overview diagram:

nfc-spec-overview

No matter which operation modes (top part), or Tag types (bottom), everything uses NDEF. For mobile operating systems, NDEF is fully implemented for both iOS and Android.

NdefMessage vs. NdefRecord#

When talking about NDEF, there is a common confusion between two terms: NdefMessage and NdefRecord.

NdefMessage can be considered a container for NdefRecords. From a software developer’s perspective, NdefMessage is an array of NdefRecords.

However, unlike most media containers, such as mp4, which has its own format to decouple from the actual data it contains, NdefMessage is more like a logical concept. NdefRecord itself decides how to group several NdefRecords together to form one NdefMessage. We will see this idea in practice soon.

So, in short, the NdefRecord is the actual building block.

NdefRecord structure#

Here is the structure of a NdefRecord.

ndef-stucture

In this diagram, one row represents 8 bits or 1 byte of data.

A NdefRecord has a fixed-length header (some people might call it flags and TNF, but we will call it header for short). After the fixed-length headers comes variable-length data. Conceptually, the data part of a NdefRecord could be further divided into three kinds: type, payload, and id. The type and payload are pretty self-explanatory. As for the id, it is used to let other NdefRecord identify themselves. Since it is complex but rarely used, we won’t talk too much here.

Start a new discussion. All notification go to the author.