Fork for the GitHub

Embed: (wiki syntax)

« Back to documentation index

Type 5 Tag library

This module provides an abstraction layer to the NDEF library for the NFC Forum Type5 Tag. More...

Data Structures

struct  sCCFileInfo
 Type5 Tag Capability Container structure. More...
struct  TT5_TLV_t
 Type5 Tag Type-Length-Value structure as defined by the NFC Forum. More...

Enumerations

enum  TT5_State { TT5_NO_NDEF = 0, TT5_INITIALIZED, TT5_READ_WRITE, TT5_READ }
 

Tag Type 5 State enumeration definition.

More...
enum  TT5_MagicNumber_t { NFCT5_MAGICNUMBER_E1_CCFILE = 0xE1, NFCT5_MAGICNUMBER_E2_CCFILE = 0xE2 }
 

Type5 Tag Capability Container Magic numbers as defined by the NFC Forum.

More...

Functions

uint16_t NfcTag_ReadNDEF (uint8_t *pData, I2C *mi2cChannel)
 This function reads the data stored in the NDEF message.
uint16_t NfcTag_WriteData (uint8_t Type, uint16_t Length, uint8_t *pData, I2C *mi2cChannel)
 This function writes data in the NFC Tag.
uint16_t NfcTag_WriteNDEF (uint16_t Length, uint8_t *pData, I2C *mi2cChannel)
 This function writes a NDEF message in the NFC Tag.
uint16_t NfcTag_WriteProprietary (uint16_t Length, uint8_t *pData, I2C *mi2cChannel)
 This function writes a Proprietary message to the NFC Tag.
uint16_t NfcType5_WriteCCFile (const uint8_t *const pCCBuffer, I2C *mi2cChannel)
 This functions writes the Capability Container in the NFC Tag.
uint16_t NfcType5_ReadCCFile (uint8_t *const pCCBuffer, I2C *mi2cChannel)
 This functions reads the Capability Container from the NFC Tag.
uint16_t NfcType5_TT5Init (I2C *mi2cChannel)
 This function initializes the Capability Container and an empty NDEF message in a NFC Tag.
uint16_t NfcType5_NDEFDetection (I2C *mi2cChannel)
 This function detects a NDEF message in a Type 5 Tag.
uint16_t NfcTag_GetLength (uint16_t *Length, I2C *mi2cChannel)
 This function reads and return the size of the NDEF message in the NFC tag.

Variables

sCCFileInfo CCFileStruct
 Capability Container structure instance (global).
uint8_t Version
 CCfile[1]: Capability container version (b7-b4) and access conditions (b3-b0)
uint8_t MemorySize
 CCfile[2]: Memory size, expressed in 8 bytes blocks, set to 0 if tag size is greater than 16kbits.
uint8_t TT5Tag
 CCfile[3]: Additionnal information on the Type5 Tag:
b0: supports `read multiple block` commands
b1: RFU
b2: RFU
b3: supports `lock block` commands
b4: requires the `special frame` format.
uint8_t rsved1
 RFU.
uint8_t rsved2
 RFU.
uint16_t ExtMemorySize
 CCfile[6],CCfile[7]: Memory size, expressed in 8 bytes blocks, when tag size is greater than 16kbits.
TT5_State State
 Indicates if a NDEF message is present.
uint32_t NDEF_offset
 Indicates the address of a NDEF message in the tag.
uint8_t Length
 Message length if lesser than 255 bytes.
uint16_t Length16
 Message length if greater than or equal to 255 bytes.
sCCFileInfo CCFileStruct
 Capability Container structure instance (global).

Detailed Description

This module provides an abstraction layer to the NDEF library for the NFC Forum Type5 Tag.

These functions manage the specificities of the Type5 Tag accesses.
The NFC Forum defines specific Capability Containers for the Type5 Tags. The Capability Container provides basic information on how a tag can be accessed. Depending on the memory size of the tag, 2 different CC will be used: 1. 4-bytes Capability Container (Memory Size < 16kbits): |Byte0 |Byte1 |Byte2 |Byte3 | |:------------:|:---------------------------:|:-----------:|:--------------:| | Magic Number | Version & Access Conditions | Memory Size | NFC Type 5 Tag | 2. 8-bytes Capability Container (Memory Size > 16kbits): |Byte0 |Byte1 |Byte2|Byte3 |Byte4|Byte5|Byte6 |Byte7 | |:------------:|:---------------------------:|:---:|:--------------:|:---:|:---:|:---------:|:---------:| | Magic Number | Version & Access Conditions | 00h | NFC Type 5 Tag |RFU |RFU |Memory Size|Memory Size|

How to write a Type5 Tag Capability Container

1. Initialize the Capacity Container structure with the Tag compliant values:

  • Example for a 4kbits memory tag:

CCFileStruct.MagicNumber = NFCT5_MAGICNUMBER_E1_CCFILE; CCFileStruct.Version = NFCT5_VERSION_V1_0; CCFileStruct.MemorySize = 0x40; CCFileStruct.TT5Tag = 0x0;

  • Example for a 64kbits memory tag:

CCFileStruct.MagicNumber = NFCT5_MAGICNUMBER_E2_CCFILE; CCFileStruct.Version = NFCT5_VERSION_V1_0; CCFileStruct.MemorySize = NFCT5_EXTENDED_CCFILE; CCFileStruct.ExtMemorySize = 0x400; CCFileStruct.TT5Tag = 0x1;

2. Call the `NfcType5_TT5Init` function to write the Capability Container to the Tag:

NfcType5_TT5Init();


Enumeration Type Documentation

Type5 Tag Capability Container Magic numbers as defined by the NFC Forum.

Enumerator:
NFCT5_MAGICNUMBER_E1_CCFILE 

Complete data area can be read by 1-byte block adrdess commands.

NFCT5_MAGICNUMBER_E2_CCFILE 

Last part of the data area can be only read by 2-bytes block address commands.


The first 256 blocks can be read by 1-byte block address commands.

Definition at line 54 of file tagtype5_wrapper.h.

enum TT5_State

Tag Type 5 State enumeration definition.

Enumerator:
TT5_NO_NDEF 

No data detected in the tag.

TT5_INITIALIZED 

Capability container detected.

TT5_READ_WRITE 

Read-Write data detected.

TT5_READ 

Read-Only data message detected.

Definition at line 45 of file tagtype5_wrapper.h.


Function Documentation

uint16_t NfcTag_GetLength ( uint16_t *  Length,
I2C *  mi2cChannel 
)

This function reads and return the size of the NDEF message in the NFC tag.

Parameters:
LengthPointer on the NDEF size to be returned.
Return values:
NDEF_ERROR_NOT_FORMATEDDevice is not a NFC Tag Type 5 Tag.
NDEF_ERRORThe NDEF message size has not been read.
NDEF_OKThe NDEF message size has been retrieved.

Definition at line 481 of file tagtype5_wrapper.cpp.

uint16_t NfcTag_ReadNDEF ( uint8_t *  pData,
I2C *  mi2cChannel 
)

This function reads the data stored in the NDEF message.

Parameters:
pDataPointer on the buffer used to store the read data.
Return values:
NDEF_ERROR_MEMORY_INTERNALThe buffer is too small for the NDEF message.
NDEF_ERROR_NOT_FORMATEDNo Capability Container detected.
NDEF_ERRORError when reading the NDEF message.
NDEF_OKNDEF message successfully read.

Definition at line 95 of file tagtype5_wrapper.cpp.

uint16_t NfcTag_WriteData ( uint8_t  Type,
uint16_t  Length,
uint8_t *  pData,
I2C *  mi2cChannel 
)

This function writes data in the NFC Tag.

Parameters:
TypeType of the data: NDEF or Proprietary
LengthNumber of bytes to write.
pDataPointer on the buffer to copy.
Return values:
NDEF_ERROR_MEMORY_INTERNALMemory size is too small for the data.
NDEF_ERROR_NOT_FORMATEDNo Capability Container detected.
NDEF_ERRORError when writing the Tag.
NDEF_OKThe data has been successfully written.

Definition at line 162 of file tagtype5_wrapper.cpp.

uint16_t NfcTag_WriteNDEF ( uint16_t  Length,
uint8_t *  pData,
I2C *  mi2cChannel 
)

This function writes a NDEF message in the NFC Tag.

Parameters:
LengthNumber of bytes to write.
pDataPointer on the buffer to copy.
Return values:
NDEF_ERROR_MEMORY_INTERNALMemory size is too small for the data.
NDEF_ERROR_NOT_FORMATEDNo Capability Container detected.
NDEF_ERRORError when writing the Tag.
NDEF_OKThe data has been successfully written.

Definition at line 233 of file tagtype5_wrapper.cpp.

uint16_t NfcTag_WriteProprietary ( uint16_t  Length,
uint8_t *  pData,
I2C *  mi2cChannel 
)

This function writes a Proprietary message to the NFC Tag.

Parameters:
LengthNumber of byte to write.
pDataPointer on the buffer to copy.
Return values:
NDEF_ERROR_MEMORY_INTERNALMemory size is too small for the data.
NDEF_ERROR_NOT_FORMATEDNo Capability Container detected.
NDEF_ERRORError when writing the Tag.
NDEF_OKThe data has been successfully written.

Definition at line 247 of file tagtype5_wrapper.cpp.

uint16_t NfcType5_NDEFDetection ( I2C *  mi2cChannel )

This function detects a NDEF message in a Type 5 Tag.

It first detects the Capability Container and then look for the NDEF TLV. The `CCfileStruct` global variable is updated accordingly with what is detected.

Return values:
NDEF_OKNDEF message Tag Type 5 detected.
NDEF_ERROR_NOT_FORMATEDDevice is not a NFC Tag Type 5 Tag.

Definition at line 371 of file tagtype5_wrapper.cpp.

uint16_t NfcType5_ReadCCFile ( uint8_t *const   pCCBuffer,
I2C *  mi2cChannel 
)

This functions reads the Capability Container from the NFC Tag.

Parameters:
pCCBufferPointer on the buffer used to store the CC.
Return values:
NDEF_ERRORError when reading the Tag.
NDEF_OKThe CC has been successfully read.

Definition at line 286 of file tagtype5_wrapper.cpp.

uint16_t NfcType5_TT5Init ( I2C *  mi2cChannel )

This function initializes the Capability Container and an empty NDEF message in a NFC Tag.

The Capability Container content is defined by the global variable `CCFileStruct`.

Return values:
NDEF_ERRORThe Tag has not been initialized.
NDEF_OKThe Tag has been successfully initialized.

Definition at line 313 of file tagtype5_wrapper.cpp.

uint16_t NfcType5_WriteCCFile ( const uint8_t *const   pCCBuffer,
I2C *  mi2cChannel 
)

This functions writes the Capability Container in the NFC Tag.

Parameters:
pCCBufferPointer on the buffer containnig the Capability Container.
Return values:
NDEF_ERRORError when writing the Tag.
NDEF_OKThe CC has been successfully written.

Definition at line 259 of file tagtype5_wrapper.cpp.


Variable Documentation

Capability Container structure instance (global).

Definition at line 85 of file tagtype5_wrapper.cpp.

Capability Container structure instance (global).

Definition at line 85 of file tagtype5_wrapper.cpp.

uint16_t ExtMemorySize [inherited]

CCfile[6],CCfile[7]: Memory size, expressed in 8 bytes blocks, when tag size is greater than 16kbits.

Definition at line 77 of file tagtype5_wrapper.h.

uint8_t Length [inherited]

Message length if lesser than 255 bytes.

Definition at line 86 of file tagtype5_wrapper.h.

uint16_t Length16 [inherited]

Message length if greater than or equal to 255 bytes.

Definition at line 87 of file tagtype5_wrapper.h.

uint8_t MemorySize [inherited]

CCfile[2]: Memory size, expressed in 8 bytes blocks, set to 0 if tag size is greater than 16kbits.

Definition at line 67 of file tagtype5_wrapper.h.

uint32_t NDEF_offset [inherited]

Indicates the address of a NDEF message in the tag.

Definition at line 79 of file tagtype5_wrapper.h.

uint8_t rsved1 [inherited]

RFU.

Definition at line 75 of file tagtype5_wrapper.h.

uint8_t rsved2 [inherited]

RFU.

Definition at line 76 of file tagtype5_wrapper.h.

TT5_State State [inherited]

Indicates if a NDEF message is present.

Definition at line 78 of file tagtype5_wrapper.h.

uint8_t TT5Tag [inherited]

CCfile[3]: Additionnal information on the Type5 Tag:
b0: supports `read multiple block` commands
b1: RFU
b2: RFU
b3: supports `lock block` commands
b4: requires the `special frame` format.

Definition at line 68 of file tagtype5_wrapper.h.

uint8_t Version [inherited]

CCfile[1]: Capability container version (b7-b4) and access conditions (b3-b0)

Definition at line 66 of file tagtype5_wrapper.h.