NDEF file

The NDEF file stores the length and content of the NDEF message. Use this library to encode standardized data for the NFC Type 4 Tag. To generate an NDEF message, you can use the NDEF messages and NDEF records modules.

The following code sample demonstrates how to encode the NDEF file for NFC Type 4 Tag:

int ndef_file_default_message(uint8_t *buff, uint32_t *size)
{
	int err;
	uint32_t ndef_size = nfc_t4t_ndef_file_msg_size_get(*size);

	/* Encode URI message into buffer. */
	err = nfc_ndef_uri_msg_encode(NFC_URI_HTTP_WWW,
				      m_url,
				      sizeof(m_url),
				      nfc_t4t_ndef_file_msg_get(buff),
				      &ndef_size);
	if (err) {
		return err;
	}

	err = nfc_t4t_ndef_file_encode(buff, &ndef_size);
	if (err) {
		return err;
	}

	*size = ndef_size;

	return 0;
}

API documentation

Header file: include/nfc/t4t/ndef_file.h
Source file: subsys/nfc/t4t/ndef_file.c
group nfc_t4t_ndef_file

Generation of NFC NDEF File for the NFC Type 4 Tag.

Defines

NFC_NDEF_FILE_NLEN_FIELD_SIZE

Size of NLEN field, used to encode NDEF message for Type 4 Tag.

nfc_t4t_ndef_file_msg_size_get(_file_buf_size)

Get the available size for the NDEF message into the NDEF File.

Parameters:
  • _file_buf_size[in] Size of the NDEF File buffer.

Returns:

Maximum size of the NDEF Message which can be encoded into the buffer.

nfc_t4t_ndef_file_msg_get(_file_buf)

Get the NDEF Message from NFC NDEF File.

Parameters:
  • _file_buf[in] Pointer to buffer which stores the NDEF file.

Returns:

Pointer to the NDEF Message.

Functions

int nfc_t4t_ndef_file_encode(uint8_t *file_buf, uint32_t *size)

Encode the NFC NDEF File.

Parameters:
  • file_buf[in] Pointer to the NFC NDEF File destination.

  • size[inout] Size of the encoded NDEF Message as input. Size of the generated NDEF file as output.

Return values:

0 – If the operation was successful. Otherwise, a (negative) error code is returned.