Capability Containers file parser

To detect and access Custom messages NFC Data Exchange Format data, the NFC reader uses the Capability Container (CC) file contained inside the NDEF Tag Application. The CC file is a read-only file with file identifier equal to E103h. It is used to store management data for the Type 4 Tag platform.

The CC file module provides functions to parse raw CC file data to its descriptor structure.

CC file format

You can use the module to print out the tag content. The output of the parser consists of the following data:

Field name

Description

CCLEN

Size of the CC file.

Mapping Version

Tag 4 Tag version number.

MLe

Maximum R-APDU data size.

MLc

Maximum C-APDU data size.

Extended NDEF/NDEF File Control TLV

Management data for NDEF file with its payload

TLV Block

Certain types of TLV blocks are supported by Type 4 Tag:

TLV Block Name

Tag Field Value

Length Field Value

NDEF File Control TLV

04h

06h

Proprietary File Control TLV

05h

06h

Extended NDEF File Control TLV

06h

08h

More detailed information about each TLV block inside Type 4 Tag is also printed out. The output of the parser consists of the following data:

Field name

Description

File identifier

Used for the Select procedure.

Maximum file size

Maximum capacity of the file (in bytes).

Read access condition

Read access level of the file.

Write access condition

Write access level of the file.

Optionally, content of the file (described by the TLV block) can also be printed out. However, in such case you must call an additional function which binds the TLV structure with the described file content.

API documentation

group nfc_t4t_cc_file

Capability Container file parser for Type 4 Tag.

Defines

NFC_T4T_CC_DESC_DEF(_name, _max_blocks)

Macro for creating and initializing a Type 4 Tag Capability Container descriptor.

This macro creates and initializes a static instance of a CC file parser structure and an array of File Control TLV block parser for Type 4 Tag. descriptors.

Use the macro NFC_T4T_CC_DESC to access the Type 4 Tag descriptor instance.

Parameters
  • [in] _name: Name of the created descriptor instance.

  • [in] _max_blocks: Maximum number of File Control TLV block parser for Type 4 Tag. descriptors that can be stored in the array.

NFC_T4T_CC_DESC(_name)

Macro for accessing the CC file parser instance that was created with NFC_T4T_CC_DESC_DEF.

Parameters
  • [in] _name: Name of the created descriptor instance.

Functions

int nfc_t4t_cc_file_parse(struct nfc_t4t_cc_file *t4t_cc_file, const u8_t *raw_data, u16_t len)

Function for parsing raw data of a CC file, read from a Type 4 Tag.

This function parses raw data of a Capability Container file and stores the results in its descriptor.

Parameters
  • [inout] t4t_cc_file: Pointer to the CC file descriptor that will be filled with parsed data.

  • [in] raw_data: Pointer to the buffer with raw data.

  • [in] len: Buffer length.

Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.

struct nfc_t4t_tlv_block *nfc_t4t_cc_file_content_get(struct nfc_t4t_cc_file *t4t_cc_file, u16_t file_id)

Function for finding File Control TLV block within the CC file descriptor.

This function finds File Control TLV block that matches the specified file ID within the CC file descriptor.

Parameters
  • [in] t4t_cc_file: Pointer to the CC file descriptor.

  • [in] file_id: File identifier.

Return Value
  • TLV: Pointer to the File Control TLV.

  • NULL: If TLV with the specified File ID was not found.

int nfc_t4t_cc_file_content_set(struct nfc_t4t_cc_file *t4t_cc_file, const struct nfc_t4t_tlv_block_file *file, u16_t file_id)

Function for binding a file with its File Control TLV block.

This function binds file content with its File Control TLV block, in which maximal file size and access conditions are stored.

Parameters
  • [inout] t4t_cc_file: Pointer to the CC file descriptor.

  • [in] file: Pointer to File descriptor.

  • [in] file_id: File identifier.

Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.

void nfc_t4t_cc_file_printout(const struct nfc_t4t_cc_file *t4t_cc_file)

Function for printing the CC file descriptor.

This function prints the CC file descriptor.

Parameters
  • [in] t4t_cc_file: Pointer to the CC file.

struct nfc_t4t_cc_file
#include <cc_file.h>

Descriptor for the Capability Container (CC) file of Type 4 Tag.

Public Members

struct nfc_t4t_tlv_block *tlv_block_array

Pointer to the array for TLV blocks.

u16_t tlv_count

Number of TLV blocks stored in the Type 4 Tag.

u16_t max_tlv_blocks

Maximum number of TLV blocks.

u16_t len

Size (bytes) of a Capability Container including this field.

u16_t max_rapdu_size

MLe field - maximum R-APDU data size (bytes).

u16_t max_capdu_size

MLc field - maximum C-APDU data size (bytes).

u8_t major_version

Major version of the supported Type 4 Tag specification.

u8_t minor_version

Minor version of the supported Type 4 Tag specification.