NDEF data is structured in messages. Each message consists of one or more records, which are made up of a header and the record payload. The Record header contains metadata about, amongst others, the payload type and length. The Record payload constitutes the actual content of the record.
The NDEF record header consists of the following fields:
Field | Length | Required | Description |
---|---|---|---|
Flags and TNF | 1 byte | yes | See Flags and TNF. |
Type Length | 1 byte | yes | Specifies the length of the payload type field. Required, but may be zero. |
Payload Length | 1 or 4 bytes | yes | Specifies the length of the payload. Either 1 byte or 4 byte long, depending on the SR flag. Required, but may be zero. |
ID Length | 1 byte | no | Required if the IL flag is set. Specifies the size of the Payload ID field. |
Payload Type | variable | no | Required if the Type Length is > 0. Specifies the type of the NDEF record payload. |
Payload ID | variable | no | Required if the IL flag is set and the ID Length is > 0. Specifies the ID of the NDEF record payload. |
The Flags and TNF byte contains the following flags:
Value | Type Name Format |
---|---|
0x00 | Empty |
0x01 | NFC Forum well-known type [NFC RTD] |
0x02 | Media-type [RFC 2046] |
0x03 | Absolute URI [RFC 3986] |
0x04 | NFC Forum external type [NFC RTD] |
0x05 | Unknown |
0x06 | Unchanged |
0x07 | Reserved |
The content of the payload is application-specific and related to the type of the record. For example, in Connection Handover LE and EP records, the payload is composed of data required by BLE for successful pairing. In URI records, the payload contains a web address of the page that the polling device should open. In launch app records, it contains the ID of the application that should be launched.
Note that the payload of an NDEF record can contain a nested NDEF message. This nested message must be a full NDEF message, consisting of one or multiple NDEF records with the appropriate setting of MB and ME flags.