nRF5 SDK v15.3.0
Capability Container file parser

To detect and access 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. The API of the module is described in CC file parser.

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 Type 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 the NDEF file with its payload.
TLV Blocks One or more TLV blocks may be present (optional).

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.

Parsing the CC file

The following code example shows how to parse raw CC file data from a Type 4 Tag:

ret_code_t err_code;
uint8_t cc_file_buff[] = ...; //Buffer with raw CC file data.
NFC_T4T_CC_DESC_DEF(cc_file, MAX_TLV_BLOCKS);
err_code = nfc_t4t_cc_file_parse(p_cc_file, cc_file_buff, sizeof(cc_file_buff));
if (err_code != NRF_SUCCESS)
{
//Error during CC file parsing.
return err_code;
}
// Print the CC file.

Apart from parsing raw CC file data, this module can be used to search for File Control TLVs within a CC file. The following code example shows this functionality:

nfc_t4t_tlv_block_t * p_tlv_block;
p_tlv_block = nfc_t4t_file_control_tlv_get(p_cc_file, 0xE104);
if (p_tlv_block == NULL)
{
// File Control TLV with File Identifier 0xE104 was not found.
}

The following example shows how to use this module to bind a File Control TLV with its file content:

uint8_t ndef_file_buff[] = ...; //Buffer with raw NDEF file data.
nfc_t4t_file_t file = //File descriptor.
{
.p_content = (uint8_t *) ndef_file_buff,
.len = sizeof(ndef_file_buff)
};
err_code = nfc_t4t_file_content_set(p_cc_file, file, 0xE104);
if (err_code != NRF_SUCCESS)
{
//Error during the operation.
return err_code;
}

Note that if you want to store all data from a Type 4 Tag within a CC file structure, you must first parse raw CC file data and then bind all detected files with the tag's TLV blocks.


Documentation feedback | Developer Zone | Subscribe | Updated