Parser for CC files

To detect and access NDEF data, the NFC reader uses the capability container (CC) file that is contained inside the NDEF tag application. The CC file is a read-only file that contains management data for the Type 4 Tag platform, for example, information about the implemented specification and other capability parameters of the tag. The file identifier of the CC file is E103h.

This library provides functions to parse raw CC file data to its descriptor structure. In this way, you can use it to print out the tag content.

CC file content

The parser outputs 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

(see below)

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:

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, the content of the file that is described by the TLV block can also be printed out. However, to do so, you must call an additional function that binds the TLV structure with the described file content.

API documentation

Header file: include/nfc/t4t/cc_file.h
Source file: subsys/nfc/t4t/cc_file.c
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
  • _name[in] Name of the created descriptor instance.

  • _max_blocks[in] 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
  • _name[in] Name of the created descriptor instance.

Functions

int nfc_t4t_cc_file_parse(struct nfc_t4t_cc_file *t4t_cc_file, const uint8_t *raw_data, uint16_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
  • t4t_cc_file[inout] Pointer to the CC file descriptor that will be filled with parsed data.

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

  • len[in] Buffer length.

Return values

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, uint16_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
  • t4t_cc_file[in] Pointer to the CC file descriptor.

  • file_id[in] File identifier.

Return values
  • 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, uint16_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
  • t4t_cc_file[inout] Pointer to the CC file descriptor.

  • file[in] Pointer to File descriptor.

  • file_id[in] File identifier.

Return values

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
  • t4t_cc_file[in] 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.

uint16_t tlv_count

Number of TLV blocks stored in the Type 4 Tag.

uint16_t max_tlv_blocks

Maximum number of TLV blocks.

uint16_t len

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

uint16_t max_rapdu_size

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

uint16_t max_capdu_size

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

uint8_t major_version

Major version of the supported Type 4 Tag specification.

uint8_t minor_version

Minor version of the supported Type 4 Tag specification.