Type 4 Tag procedures

This module provides functions to perform the NDEF detection procedure, which is used to retrieve the NDEF message from the data of a tag.

The full NDEF detection procedure consists of the following procedures:

  1. NDEF tag application select.

  2. Capability container (CC) select.

  3. Capability container read.

  4. NDEF select.

  5. NDEF read or NDEF update.

After a successful NDEF detection procedure, you can also write data to the NDEF file. To do this, you must perform an NDEF update procedure.

This module uses three other modules:

API documentation

Header file: include/nfc/t4t/hl_procedure.h
Source file: subsys/nfc/t4t/hl_procedure.c
group nfc_t4t_hl_procedure

NFC T4T High Level Procedure API.

Enums

enum nfc_t4t_hl_procedure_select

Type of selection procedure.

Values:

enumerator NFC_T4T_HL_PROCEDURE_NDEF_APP_SELECT

NDEF App select.

enumerator NFC_T4T_HL_PROCEDURE_CC_SELECT

CC file select.

enumerator NFC_T4T_HL_PROCEDURE_NDEF_FILE_SELECT

NDEF file select.

Functions

int nfc_t4t_hl_procedure_on_data_received(const uint8_t *data, size_t len)

Handle High Level Procedure received data.

Function for handling the received data. It should be called immediately upon receiving the ISO-DEP data.

Parameters:
  • data[in] Pointer to received data.

  • len[in] Received data length.

Return values:

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

int nfc_t4t_hl_procedure_cb_register(const struct nfc_t4t_hl_procedure_cb *cb)

Register High Level Procedure callback.

Function for register callback. It should be used to provides synchronization between NFC T4T operation.

Parameters:
  • cb[in] Pointer to callback structure.

Return values:

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

int nfc_t4t_hl_procedure_ndef_tag_app_select(void)

Perform NDEF Tag Application Select Procedure.

Return values:

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

int nfc_t4t_hl_procedure_cc_select(void)

Perform NDEF Tag Capability Container Select Procedure.

Return values:

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

int nfc_t4t_hl_procedure_cc_read(struct nfc_t4t_cc_file *cc)

Perform Capability Container Read Procedure.

Parameters:
  • cc[out] Pointer to the Capability Container descriptor.

Return values:

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

int nfc_t4t_hl_procedure_ndef_file_select(uint16_t id)

Perform NDEF file Select Procedure.

Parameters:
  • id[in] File Identifier

Return values:

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

int nfc_t4t_hl_procedure_ndef_read(struct nfc_t4t_cc_file *cc, uint8_t *ndef_buff, uint16_t ndef_len)

Perform NDEF Read Procedure.

Parameters:
  • cc[inout] Pointer to Capability Containers descriptor.

  • ndef_buff[out] Pointer to buffer where the NDEF file will be stored. The NDEF Read procedure is an asynchronous operation, the data buffer have to be keep until this procedure will be finished.

  • ndef_len[in] Length of NDEF file buffer.

Return values:

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

int nfc_t4t_hl_procedure_ndef_update(struct nfc_t4t_cc_file *cc, uint8_t *ndef_data, uint16_t ndef_len)

Perform NDEF Update Procedure.

Parameters:
  • cc[in] Pointer to Capability Containers descriptor.

  • ndef_data[in] Pointer to the NDEF file data. The NDEF Read procedure is an asynchronous operation, the data buffer have to be keep until this procedure will be finished.

  • ndef_len[in] Length of NDEF file.

Return values:

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

struct nfc_t4t_hl_procedure_cb
#include <hl_procedure.h>

NFC T4T High Level Procedure callback structure.

This structure is used to control command exchange with NFC Type 4 Tag.

Public Members

void (*selected)(enum nfc_t4t_hl_procedure_select type)

HL Procedure selected callback.

The selection of applications or files is completed.

Param type:

[in] Type of selection command.

void (*cc_read)(struct nfc_t4t_cc_file *cc)

HL Procedure CC file read callback.

The CC file of Type 4 Tag read operation is completed successfully.

Param cc:

[in] Pointer to CC file data.

void (*ndef_read)(uint16_t file_id, const uint8_t *data, size_t len)

HL Procedure NDEF file read callback.

The NDEF file of Type 4 Tag read operation is completed successfully.

Param file_id:

[in] File Identifier

Param data:

[in] Pointer to received NDEF file data. The data buffer is assigned by nfc_t4t_hl_procedure_ndef_read function.

Param len:

[in] Received data length.

void (*ndef_updated)(uint16_t file_id)

HL Procedure NDEF file updated callback.

The NDEF file of Type 4 Tag update operation is completed successfully.

Param file:

[in] id File Identifier.