nRF5 SDK v15.3.0
Type 2 Tag parser

In addition to programming the NFC tag that is part of an nRF52 Series IC, you can also use SDK functions to read the content of another NFC tag. Note that an nRF52 Series IC does not provide the hardware that is required for a polling device. If you want to create a polling device, you can use an Adafruit PN532 NFC shield together with an nRF5 Development Kit, for example.

The Type 2 Tag parser module provides functions to parse raw tag data to a Type 2 Tag structure. The API of the module is described in NFC Type 2 Tag parser.

You can use the module to print out the tag content. The output of the parser consists of the following data (as defined in type_2_tag_t):

Use the Adafruit NFC Shield library to read the raw data from a Type 2 Tag. See the Adafruit Tag Reader Example example for more information on how to do this.

The following code example shows how to parse the raw data from a Type 2 Tag:

uint8_t raw_tag_data[] = ...; // Buffer with raw data from a Type 2 Tag (read by the Adafruit PN532 library)
ret_code_t err_code;
// Create a structure for the output of the parser.
// "10" specifies the maximum number of TLV blocks that is expected.
type_2_tag_t * test_type_2_tag = &NFC_TYPE_2_TAG_DESC(nfc_tag);
err_code = type_2_tag_parse(test_type_2_tag, raw_tag_data);
if (err_code == NRF_ERROR_NO_MEM)
{
//Not enough memory to read the whole tag. Printing what has been read.
}
else if (err_code != NRF_SUCCESS)
{
//Error during parsing a tag. Printing what could be read.
}
// Print the tag data.
type_2_tag_printout(test_type_2_tag);

Note that the data that is pointed to by pointers from type_2_tag_t::p_tlv_block_array can be further parsed by the Message and record parser, given that the type of the analyzed TLV block is NDEF TLV.


Documentation feedback | Developer Zone | Subscribe | Updated