nRF5 SDK v13.0.0
Modules | Data Structures | Macros | Enumerations | Functions
APDU reader/writer

APDU reader/writer for Type 4 Tag communication. More...

Modules

 APDU encoder/decoder for Type 4 Tag configuration
 

Data Structures

struct  nfc_t4t_apdu_data_t
 APDU data field descriptor. More...
 
struct  nfc_t4t_comm_apdu_t
 Command Application Protocol Data Unit (C-APDU) descriptor. More...
 
struct  nfc_t4t_resp_apdu_t
 Response Application Protocol Data Unit (R-APDU) descriptor. More...
 

Macros

#define CLASS_BYTE_NO_SECURE_MSG   0x00
 Class byte indicating no secure messaging, used in C-APDU.
 
#define VERIFY_RAPDU_SUCCESS(P_RAPDU)
 Macro for verifying R-APDU descriptor status. More...
 

Enumerations

enum  nfc_t4t_comm_apdu_ins_type_t {
  NFC_T4T_CAPDU_SELECT_INS = 0xA4,
  NFC_T4T_CAPDU_READ_INS = 0xB0,
  NFC_T4T_CAPDU_UPDATE_INS = 0xD6
}
 Possible instruction codes in C-APDU. More...
 

Functions

__STATIC_INLINE void nfc_t4t_comm_apdu_clear (nfc_t4t_comm_apdu_t *const p_cmd_apdu)
 Function for clearing C-APDU descriptor and restoring its default values. More...
 
__STATIC_INLINE void nfc_t4t_resp_apdu_clear (nfc_t4t_resp_apdu_t *const p_resp_apdu)
 Function for clearing R-APDU descriptor and restoring its default values. More...
 
ret_code_t nfc_t4t_comm_apdu_encode (nfc_t4t_comm_apdu_t const *const p_cmd_apdu, uint8_t *p_raw_data, uint16_t *const p_len)
 Function for encoding C-APDU. More...
 
ret_code_t nfc_t4t_resp_apdu_decode (nfc_t4t_resp_apdu_t *const p_resp_apdu, uint8_t const *const p_raw_data, uint16_t len)
 Function for decoding R-APDU. More...
 
void nfc_t4t_resp_apdu_printout (nfc_t4t_resp_apdu_t *p_resp_apdu)
 Function for printing a R-APDU descriptor. More...
 

Parameters used when selecting instruction code in C-APDU.

#define SELECT_BY_FILE_ID   0x000C
 Select by file identifier, first or only occurence.
 
#define SELECT_BY_NAME   0x0400
 Select by name, first or only occurence.
 

Status codes contained in R-APDU.

#define RAPDU_STATUS_CMD_COMPLETED   0x9000
 Command completed successfully.
 
#define RAPDU_STATUS_SEL_ITEM_NOT_FOUND   0x6A82
 Selected item has not been found.
 

Detailed Description

APDU reader/writer for Type 4 Tag communication.

Macro Definition Documentation

#define VERIFY_RAPDU_SUCCESS (   P_RAPDU)
Value:
if (P_RAPDU->status == RAPDU_STATUS_SEL_ITEM_NOT_FOUND) \
{ \
return NRF_ERROR_NOT_FOUND; \
} \
if (P_RAPDU->status != RAPDU_STATUS_CMD_COMPLETED) \
{ \
return NRF_ERROR_INTERNAL; \
}

Macro for verifying R-APDU descriptor status.

This macro verifies R-APDU descriptor status. It will cause the exterior function to return nrf_error translated from R-APDU status, if the status is not equal to RAPDU_STATUS_CMD_COMPLETED.

Parameters
[in]P_RAPDUPointer to R-APDU descriptor.
Return values
NRF_ERROR_NOT_FOUNDIf C-APDU select command could not find the selected item.
NRF_ERROR_INTERNALUnknown R-APDU error.

Enumeration Type Documentation

Possible instruction codes in C-APDU.

Enumerator
NFC_T4T_CAPDU_SELECT_INS 

Code used for selecting EF or NDEF application.

NFC_T4T_CAPDU_READ_INS 

Code used for selecting EF or NDEF application.

NFC_T4T_CAPDU_UPDATE_INS 

Code used for selecting EF or NDEF application.

Function Documentation

__STATIC_INLINE void nfc_t4t_comm_apdu_clear ( nfc_t4t_comm_apdu_t *const  p_cmd_apdu)

Function for clearing C-APDU descriptor and restoring its default values.

Parameters
[in]p_cmd_apduPointer to C-APDU descriptor.
ret_code_t nfc_t4t_comm_apdu_encode ( nfc_t4t_comm_apdu_t const *const  p_cmd_apdu,
uint8_t *  p_raw_data,
uint16_t *const  p_len 
)

Function for encoding C-APDU.

This function encodes C-APDU according to the provided descriptor.

Parameters
[in]p_cmd_apduPointer to the C-APDU descriptor.
[out]p_raw_dataPointer to the buffer with encoded C-APDU.
[in,out]p_lenSize of the available memory for the C-APDU as input. Size of the generated C-APDU as output.
Return values
NRF_SUCCESSIf C-APDU was encoded successfully.
NRF_ERROR_NO_MEMIf the predicted C-APDU size is bigger than the provided buffer space.
NRF_ERROR_INVALID_PARAMIf C-APDU descriptor is invalid.
NRF_ERROR_NULLIf any passed argument is NULL.
__STATIC_INLINE void nfc_t4t_resp_apdu_clear ( nfc_t4t_resp_apdu_t *const  p_resp_apdu)

Function for clearing R-APDU descriptor and restoring its default values.

Parameters
[in]p_resp_apduPointer to R-APDU descriptor.
ret_code_t nfc_t4t_resp_apdu_decode ( nfc_t4t_resp_apdu_t *const  p_resp_apdu,
uint8_t const *const  p_raw_data,
uint16_t  len 
)

Function for decoding R-APDU.

This function decodes buffer with encoded R-APDU and stores results in the R-APDU descriptor.

Parameters
[out]p_resp_apduPointer to the R-APDU descriptor.
[in]p_raw_dataPointer to the buffer with encoded R-APDU.
[in]lenSize of of the buffer with encoded R-APDU.
Return values
NRF_SUCCESSIf R-APDU was encoded successfully.
NRF_ERROR_INVALID_LENGTHIf the buffer is too small to hold a valid R-APDU.
NRF_ERROR_NULLIf any passed argument is NULL.
void nfc_t4t_resp_apdu_printout ( nfc_t4t_resp_apdu_t p_resp_apdu)

Function for printing a R-APDU descriptor.

This function prints a R-APDU descriptor.

Parameters
[in]p_resp_apduPointer to the R-APDU descriptor.

Documentation feedback | Developer Zone | Subscribe | Updated