PN532-RFID-NFC-Format-NDEF

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

NDEF

NDEF est l'acronyme de NFC Data Exchange Format signifiant "format d'échange de donnée NFC".

Le format d'échange de donnée NFC (NDEF) est un format de donnée normalisé qui peut être utilisé pour échanger des informations entre n'importe quel périphériques compatible NFC et un autre périphérique NFC (ou tag). Le format de donnée est composé de NDEF Messages (messages NDEF) et NDEF Records (enregistrement NDEF). Le standard est maintenu par le Forum NFC et librement consultable mais nécessite que vous acceptiez un accord de licence à télécharger.

Le format NDEF est utilisé pour stocker et échanger des informations tels que URIs, du texte, etc., en utilisant un format facilement compréhensible. Les tags NFC comme les cartes Mifare Classic peuvent être configurées comme tags NDEF et les données écrites sur celles-ci par un périphérique NFC (des NDEF Records) peuvent être comprises/interprétées et être accédées par un autre périphérique compatible NDEF. Les messages NDEF peuvent également être utilisés pour échanger des informations entre deux périphériques NFC actifs en mode "peer-to-peer". En adhérent au format d'échange de données NDEF durant la communication, des périphériques qui ne connaissent absolument rien l'un de l'autre deviennent alors capable de partager des données de façon organisée et de se comprendre mutuellement. Voici une liste de quelques notes applicatives et documents de référence concernant NDEF:

Messages NDEF

Les messages NDEF (dit NDEF Messages en anglais) sont des mécanismes de base concernant le "transport" d'enregistrements NDEF (le NDEF records). Chaque messahe peut contenir un ou plusieurs enregistrement NDEF.

Enregistrements NDEF

Les enregistrements NDEF (dit "NDEF Records") contiennent une quantité spécifique de donnée (dite "payload" dans la documentation anglaise. PayLoad cela correspond à la charge utile... comprenez la charge utile de donnée).

Un enregistrement NDEF à la structure suivante qui permet d'identifier le contenu et la taille de l'enregistrement:

    Bit 7     6       5       4       3       2       1       0
    ------  ------  ------  ------  ------  ------  ------  ------ 
    [ MB ]  [ ME ]  [ CF ]  [ SR ]  [ IL ]  [        TNF         ]  
     
    [                         TYPE LENGTH                        ] -- longueur du champ type (record type)
     
    [                       PAYLOAD LENGTH                       ] -- longueur de la charge utile (des données)
     
    [                          ID LENGTH                         ] -- longueur du champ d'identification (ID)
     
    [                         RECORD TYPE                        ] -- champ: Type d'enregistrement 
     
    [                              ID                            ] -- champ: identification
     
    [                           PAYLOAD                          ] -- champ: charge utile (les données)

L'entête (octet 0)

Aussi appelé "record header" contains a number of important fields, including a 3-bit field that identifies the type of record that follows (the Type Name Format or TNF que nous traduirons par "le nom du type de format"):

Le champs TNF

The Type Name Format or TNF Field of an NDEF record is a 3-bit value that describes the record type, and sets the expectation for the structure and content of the rest of the record. Possible record type names include:

      TNF Value    Record Type
      ---------    -----------------------------------------
      0x00         Empty Record
                   Indicates no type, id, or payload is associated with this NDEF Record.
                   This record type is useful on newly formatted cards since every NDEF tag
                   must have at least one NDEF Record.
                   
      0x01         Well-Known Record
                   Indicates the type field uses the RTD type name format.  This type name is used
                   to stored any record defined by a Record Type Definition (RTD), such as storing
                   RTD Text, RTD URIs, etc., and is one of the mostly frequently used and useful
                   record types.
                   
      0x02         MIME Media Record
                   Indicates the payload is an intermediate or final chunk of a chunked NDEF Record
                   
      0x03         Absolute URI Record
                   Indicates the type field contains a value that follows the absolute-URI BNF
                   construct defined by RFC 3986
                   
      0x04         External Record
                   Indicates the type field contains a value that follows the RTD external
                   name specification
                   
      0x05         Unknown Record
                   Indicates the payload type is unknown
                   
      0x06         Unchanged Record
                   Indicates the payload is an intermediate or final chunk of a chunked NDEF Record

IL: champ ID LENGTH

IL est l'acronyme de ID Length, c'est un flag (drapeau) indiquant si le champ "ID Length Field" est présent ou non.

If this is set to 0, then the ID Length Field is ommitted in the record.

SR: Short Record Bit

The SR flag is set to one if the PAYLOAD LENGTH field is 1 byte (8 bits/0-255) or less. This allows for more compact records.

CF: Chunk Flag ==== The CF flag indicates if this is the first record chunk or a middle record chunk.

ME: Message End

The ME flag indicates if this is the last record in the message.MB: Message BeginThe MB flag indicates if this is the start of an NDEF message.

Type Length

Indicates the length (in bytes) of the Record Type field. This value is always zero for certain types of records defined with the TNF Field described above.

Payload Length

Indicates the length (in bytes) of the record payload. If the SR field (described above) is set to 1 in the record header, this value will be one byte long (for a payload length from 0-255 bytes). If the SR field is set to 0, this value will be a 32-bit value occupying 4 bytes.

ID Length

Indicates the length in bytes of the ID field. This field is present only if the IL flag (described above) is set to 1 in the record header.

Record Type

This value describes the 'type' of record that follows. The values of the type field must corresponse to the value entered in the TNF bits of the record header.

Record ID

The value of the ID field if an ID is included (the IL bit in the record header is set to 1). If the IL bit is set to 0, this field is ommitted.

Payload

The record payload, which will be exactly the number of bytes described in the Payload Length field earlier.

Well-Known Records (TNF Record Type 0x01)

Probably the most useful record type is the "NFC Forum Well-Known Type" (TNF Type 0x01). Record types that adhere to the "Well-Defined" type are each described by something called an RTD or Record Type Definition. Some of the current Well-Defined RTDs are:

URI Records (0x55/'U')

The "Well Known Type" for a URI record is 0x55 ('U'), and this record type can be used to store a variety of useful information such as telephone numbers (tel:), website addresses, links to FTP file locations, etc.

URI Records are defined in the document "URI Record Type Definition" from the NFC Forum, and it has the following structure:

    Name            Offset   Size      Description
    ----            ------   ----      -----------
    Identifier Code 0        1 byte    See table below
    URI Field       1        N bytes   The rest of the URI (depending on byte 0 above)

The URI Identifier Code is use to shorten the URI length, and can have any of the following values:

    Value    Protocol
    -----    --------
    0x00     No prepending is done ... the entire URI is contained in the URI Field
    0x01     http://www.
    0x02     https://www.
    0x03     http://
    0x04     https://
    0x05     tel:
    0x06     mailto:
    0x07     ftp://anonymous:anonymous@
    0x08     ftp://ftp.
    0x09     ftps://
    0x0A     sftp://
    0x0B     smb://
    0x0C     nfs://
    0x0D     ftp://
    0x0E     dav://
    0x0F     news:
    0x10     telnet://
    0x11     imap:
    0x12     rtsp://
    0x13     urn:
    0x14     pop:
    0x15     sip:
    0x16     sips:
    0x17     tftp:
    0x18     btspp://
    0x19     btl2cap://
    0x1A     btgoep://
    0x1B     tcpobex://
    0x1C     irdaobex://
    0x1D     file://
    0x1E     urn:epc:id:
    0x1F     urn:epc:tag:
    0x20     urn:epc:pat:
    0x21     urn:epc:raw:
    0x22     urn:epc:
    0x23     urn:nfc:

Following the URI Identifier Code is the URI Field. This field provides the URI as per RFC 3987 and contains the rest of the URI after the value corresponding to the URI Identifier is prepended (unless the URI ID is 0x00, in which case the complete URI will be contained in the URI Field).

Test Records

A faire...

Smart Poster Records

A faire...

Exemple d'enregistrement NDEF

Well Known Records

URI Record

An example of a URI record is shown in "Memory Dump of a Mifare Classic 1K Card with an NDEF Record" below. A faire...

Text Record

A faire...

Smartposter Record

A faire...

Absolute URI Record

A faire...

Using Mifare Classic Cards as an NDEF Tag

Mifare Classic 1K and 4K cards can be configured as NFC Forum compatible NDEF tags, but they must be organised in a certain manner to do so. The requirements to make a Mifare Classic card "NFC Forum compliant" are described in the following App Note from NXP:

AN1304 - NFC Type MIFARE Classic Tag Operation

While the App Note above is the authoritative source on the matter, the following notes may also offer a quick overview of the key concepts involved in using Mifare Classic cards as NFC Forum compatible 'NDEF' tags:

== Mifare Application Directory (MAD) In order to form a relationship between the sector-based memory of a Mifare Classic card and the individual NDEF records, the Mifare Application Directory (MAD) structure is used. The MAD indicates which sector(s) contains which NDEF record. The definitive source of information on the Mifare Application Directory is the following application note:

AN10787 - MIFARE Application Directory (MAD)

For reference sake, the two types of MADs (depending on the size of the card in question) are defined below:

Mifare Application Directory 1 (MAD1)



Source: PN532 RFID/NFC Breakout and Shield créé par LadyAda pour AdaFruit Industries. Crédit [www.adafruit.com AdaFruit Industries]

Traduit par Meurisse D. pour MCHobby.be

Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.