NFC T4T High Level Procedure

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

  1. NDEF Tag Application select procedure.

  2. Capability Container (CC) select procedure.

  3. Capability Container read procedure.

  4. NDEF select procedure.

  5. NDEF read procedure or NDEF update procedure.

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

This module uses three other modules:
  • NFC T4T APDU reader and writer is used to generated APDU commands.

  • ref

    nfc_t4t_cc_file_readme is used to analyzed APDU responses payload and store it within the structure that represents Type 4 Tag content.

  • ref

    nfc_t4t_isodep_readme is used to transfer data over ISO-DEP Protocols

API documentation

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

NFC Type 4 Tag HL Procedure API

group nfc_t4t_hl_procedure

NFC T4T High Level Procedure API.

Enums

enum nfc_t4t_hl_procedure_select

Type of selection procedure.

Values:

NFC_T4T_HL_PROCEDURE_NDEF_APP_SELECT

NDEF App select.

NFC_T4T_HL_PROCEDURE_CC_SELECT

CC file select.

NFC_T4T_HL_PROCEDURE_NDEF_FILE_SELECT

NDEF file select.

Functions

int nfc_t4t_hl_procedure_on_data_received(const u8_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
  • [in] data: Pointer to received data.

  • [in] len: Received data length.

Return Value
  • 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
  • [in] cb: Pointer to callback structure.

Return Value
  • 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 Value
  • 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 Value
  • 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
  • [out] cc: Pointer to the Capability Cointainer descriptor.

Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.

int nfc_t4t_hl_procedure_ndef_file_select(u16_t id)

Perform NDEF file Select Procedure.

Parameters
  • [in] id: File Identifier

Return Value
  • 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, u8_t *ndef_buff, u16_t ndef_len)

Perform NDEF Read Procedure.

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

  • [out] ndef_buff: 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.

  • [in] ndef_len: Length of NDEF file buffer.

Return Value
  • 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, u8_t *ndef_data, u16_t ndef_len)

Perform NDEF Update Procedure.

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

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

  • [in] ndef_len: Length of NDEF file.

Return Value
  • 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 exchenge 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.

Parameters
  • [in] type: 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.

Parameters
  • [in] cc: Pointer to CC file data.

void (*ndef_read)(u16_t file_id, const u8_t *data, size_t len)

HL Procedure NDEF file read callback.

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

Parameters
  • [in] file_id: File Identifier

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

  • [in] len: Received data length.

void (*ndef_updated)(u16_t file_id)

HL Procedure NDEF file updated callback.

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

Parameters
  • [in] file: id File Identifier.