M5Unit-NFC 0.0.3 git rev:59f5362
Loading...
Searching...
No Matches
nfca.hpp File Reference

NFC-A definitions. More...

#include "nfc/nfc.hpp"
#include "mifare.hpp"
#include <cstdint>
#include <string>
#include <cstring>

Go to the source code of this file.

Classes

struct  m5::nfc::a::ATS
 Answer to request. More...
 
struct  m5::nfc::a::PICC
 PICC for NFC-A. More...
 
struct  m5::nfc::a::st25ta::SystemFile
 ST25TA series system file. More...
 

Namespaces

namespace  m5
 Top level namespace of M5stack.
 
namespace  a
 NFC-A definitions.
 
namespace  st25ta
 For ST25TA series.
 

Enumerations

enum class  m5::nfc::a::Type : uint8_t {
  Unknown , MIFARE_Classic_Mini , MIFARE_Classic_1K , MIFARE_Classic_2K ,
  MIFARE_Classic_4K , MIFARE_Ultralight , MIFARE_Ultralight_EV1_1 , MIFARE_Ultralight_EV1_2 ,
  MIFARE_Ultralight_Nano , MIFARE_UltralightC , NTAG_203 , NTAG_210u ,
  NTAG_210 , NTAG_212 , NTAG_213 , NTAG_215 ,
  NTAG_216 , ST25TA_512B , ST25TA_2K , ST25TA_16K ,
  ST25TA_64K , ISO_14443_4 , MIFARE_Plus_2K , MIFARE_Plus_4K ,
  MIFARE_Plus_SE , MIFARE_DESFire_2K , MIFARE_DESFire_4K , MIFARE_DESFire_8K ,
  MIFARE_DESFire_Light , NTAG_4XX , ISO_18092
}
 Type of the PICC. More...
 
enum class  m5::nfc::a::SubTypePlus : uint8_t {
  None , EV1 , EV2 , S ,
  X , X_OR_EV
}
 Sub type for MIFARE Plus.
 
enum  m5::nfc::a::SubTypeDESFire : uint8_t { None , EV1 , EV2 , EV3 }
 Sub type for MIFARE DESFire.
 
enum class  m5::nfc::a::Command : uint8_t {
  REQA = 0x26 , WUPA = 0x52 , HLTA = 0x50 , SELECT_CL1 = 0x93 ,
  SELECT_CL2 = 0x95 , SELECT_CL3 = 0x97 , SELCT_CL1_OPT = 0x92 , SELCT_CL2_OPT = 0x94 ,
  SELCT_CL3_OPT = 0x96 , READ = 0x30 , RATS = 0xE0 , DESELECT = 0xC2 ,
  AUTH_WITH_KEY_A = 0x60 , AUTH_WITH_KEY_B = 0x61 , AUTHENTICATE_1 = 0x1A , AUTHENTICATE_2 = 0xAF ,
  WRITE_BLOCK = 0xA0 , DECREMENT = 0xC0 , INCREMENT = 0xC1 , RESTORE = 0xC2 ,
  TRANSFER = 0xB0 , PERSONALIZE_UID_USAGE = 0x40 , SET_MOD_TYPE = 0x43 , WRITE_PERSO = 0xA8 ,
  COMMIT_PERSO = 0xAA , WRITE_PAGE = 0xA2 , GET_VERSION = 0x60 , FAST_READ = 0x3A ,
  READ_CNT = 0x39 , PWD_AUTH = 0x1B , READ_SIG = 0x3C , WRITE_SIG = 0xA9 ,
  LOCK_SIG = 0xAC
}
 ISO-14443-3/4,MIFARE,NTAG commands. More...
 

Functions

m5::nfc::NFCForumTag m5::nfc::a::get_nfc_forum_tag_type (const Type t)
 Get NFC Forum Tag Type from PICC type.
 
bool m5::nfc::a::is_mifare_classic (const Type t)
 Is type MIFARE Classic?
 
bool m5::nfc::a::is_mifare_ultralight (const Type t)
 Is type MIFARE Ultralight series?
 
bool m5::nfc::a::is_ntag2 (const Type t)
 Is type NTAG2xx?
 
bool m5::nfc::a::is_ntag4 (const Type t)
 Is type NTAG4xx?
 
bool m5::nfc::a::is_mifare_plus (const Type t)
 Is type MIFARE Plus?
 
bool m5::nfc::a::is_mifare_classic_compatible (const Type t, const uint8_t sl)
 Is type MIFARE classic compatible? (Plus SL1)
 
bool m5::nfc::a::is_mifare_desfire (const Type t)
 Is type MIFARE DESFire?
 
bool m5::nfc::a::is_mifare (const Type t)
 Is type MIFARE?
 
bool m5::nfc::a::is_st25ta (const Type t)
 Is ST25TA series?
 
bool m5::nfc::a::is_iso14443_4 (const Type t)
 Is ISO 14443-4?
 
bool m5::nfc::a::is_iso14443_3 (const Type t)
 Is ISO 14443-3?
 
bool m5::nfc::a::supports_NFC (const Type t)
 Does the specified type function as NFC?
 
bool m5::nfc::a::has_fast_read (const Type t)
 Has FAST_READ command?
 
bool m5::nfc::a::has_sak_dependent_bit (const uint8_t sak)
 SAK uncompleted?
 
bool m5::nfc::a::is_sak_completed_14443_4 (const uint8_t sak)
 SAK completed? (Complies with ISO/IEC 14443-4)
 
bool m5::nfc::a::is_sak_completed (const uint8_t sak)
 SAK completed? (Does not comply with ISO/IEC 14443-4)
 
Type m5::nfc::a::sak_to_type (const uint8_t sak)
 Inferring the type from SAK.
 
Type m5::nfc::a::version3_to_type (const uint8_t info[8])
 Inferring the type from GetVersion L3.
 
Type m5::nfc::a::version4_to_type (uint8_t &sub, const uint8_t info[8])
 Inferring the type from GetVersion L4.
 
Type m5::nfc::a::historical_bytes_to_type (uint8_t &sub, const uint16_t atqa, const uint8_t sak, const uint8_t *bytes, const uint8_t len)
 Historical bytes to type.
 
uint16_t m5::nfc::a::get_number_of_blocks (const Type t)
 Gets the number of blocks.
 
uint16_t m5::nfc::a::get_number_of_user_blocks (const Type t)
 Gets the number of user blocks.
 
uint16_t m5::nfc::a::get_user_area_size (const Type t)
 Gets the user area bytes.
 
uint16_t m5::nfc::a::get_unit_size (const Type t)
 Get the unit size of 1 block / 1 page.
 
uint16_t m5::nfc::a::get_number_of_sectors (const Type t)
 Gets the number of sectors.
 
uint16_t m5::nfc::a::get_first_user_block (const Type t)
 Gets the first user area block.
 
uint16_t m5::nfc::a::get_last_user_block (const Type t)
 Gets the last user area block.
 
bool m5::nfc::a::is_user_block (const Type t, const uint16_t block)
 Is block user area?
 
file_system_feature_t m5::nfc::a::get_file_system_feature (const Type t)
 Get file system fearure bits.
 
bool m5::nfc::a::is_file_system_memory (const Type t)
 Memory file system?
 
bool m5::nfc::a::is_file_system_file (const Type t)
 File base file system?
 
uint8_t m5::nfc::a::calculate_bcc8 (const uint8_t *data, const uint32_t len)
 Calculate bcc8.
 
const uint8_t * m5::nfc::a::get_version3_response (const Type t)
 Gets the GET_VERSION(L3) response for emulation.
 
bool m5::nfc::a::operator== (const PICC &a, const PICC &b)
 Equal?
 
bool m5::nfc::a::operator!= (const PICC &a, const PICC &b)
 Not equal?
 
Type m5::nfc::a::st25ta::get_type (const uint8_t ic_ref_or_product_code)
 Gets the type from IC reference or product code.
 

Variables

constexpr uint16_t m5::nfc::a::st25ta::SYSTEM_FILE_ID {0xE101}
 System file for ST25TA.
 
Timeout
constexpr uint32_t m5::nfc::a::TIMEOUT_REQ_WUP {4}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_SELECT {8}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_ANTICOLL {8}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_HALT {2}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_GET_VERSION {5}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_3DES {10}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_AUTH1 {4}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_AUTH2 {16}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_READ {12}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_FAST_READ {2}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_FAST_READ_4PAGE {4}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_FAST_READ_12PAGE {4}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_FAST_READ_32PAGE {12}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_WRITE1 {5}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_WRITE2 {10}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_VALUE_BLOCK {5}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_RATS {5}
 
constexpr uint32_t m5::nfc::a::TIMEOUT_DESELECT {8}
 
4bit ACK
constexpr uint8_t m5::nfc::a::ACK_NIBBLE {0x0A}
 
Identifier
constexpr uint8_t m5::nfc::a::st25ta::IC_REFERENCE_ST25TA512B {0xE5}
 
constexpr uint8_t m5::nfc::a::st25ta::IC_REFERENCE_ST25TA02KB {0xE2}
 
constexpr uint8_t m5::nfc::a::st25ta::IC_REFERENCE_ST25TA02KB_D {0xF2}
 
constexpr uint8_t m5::nfc::a::st25ta::IC_REFERENCE_ST25TA02KB_P {0xA2}
 
constexpr uint8_t m5::nfc::a::st25ta::PRODUCT_CODE_ST25TA16K {0xC5}
 
constexpr uint8_t m5::nfc::a::st25ta::PRODUCT_CODE_ST25TA64K {0xC4}
 

Detailed Description

NFC-A definitions.

Enumeration Type Documentation

◆ Command

enum class m5::nfc::a::Command : uint8_t
strong

ISO-14443-3/4,MIFARE,NTAG commands.

Enumerator
REQA 

Reequest.

WUPA 

Wake-up.

HLTA 

Halt.

SELECT_CL1 

Anticollison/Select CL1.

SELECT_CL2 

Anticollison/Select CL2.

SELECT_CL3 

Anticollison/Select CL3.

SELCT_CL1_OPT 

Select CL1 and switch bit rate to fc/64 after receive SAK.

SELCT_CL2_OPT 

Select CL2 and switch bit rate to fc/64 after receive SAK.

SELCT_CL3_OPT 

Select CL3 and switch bit rate to fc/64 after receive SAK.

READ 

Read.

RATS 

Request for Answer to Select.

DESELECT 

DESELECT.

AUTH_WITH_KEY_A 

MIFARE Classic. Authentication with Key A.

AUTH_WITH_KEY_B 

MIFARE Classic. Authentication with Key B.

AUTHENTICATE_1 

MIFARE UltralightC. Authentication 1st.

AUTHENTICATE_2 

MIFARE UltralightC. Authentication 2nd.

WRITE_BLOCK 

MIFARE Classic. write.

DECREMENT 

MIFARE Classic. decrement value block.

INCREMENT 

MIFARE Classic. increment value block.

RESTORE 

MIFARE Classic. reads the contents of a value block into the internal Transfer Buffer.

TRANSFER 

MIFARE Classic. writes the contents of the internal Transfer Buffer to a block.

PERSONALIZE_UID_USAGE 

MIFARE Classic Personalize UID Usage.

SET_MOD_TYPE 

MIFARE Classic SET_MOD_TYPE.

WRITE_PERSO 

MIFARE Plus. WritePerso.

COMMIT_PERSO 

MIFARE Plus. CommitPerso.

WRITE_PAGE 

MIFARE Ultralight/C and NTAG write.

GET_VERSION 

NTAG 21x/UL EV1,Nano Gets the version information.

FAST_READ 

NTAG 21x. excluding 210u. Read multiple pages.

READ_CNT 

NTAG 213/5/6. Read counter value.

PWD_AUTH 

NTAG 21x excluding 210u. Authentication for protected area.

READ_SIG 

NTAG 21x Read NXP ECC signature.

WRITE_SIG 

NTAG 210u Write custom signature.

LOCK_SIG 

NTAG 210u Lock/Unlock signature.

◆ Type

enum class m5::nfc::a::Type : uint8_t
strong

Type of the PICC.

Enumerator
Unknown 

Unknown type.

MIFARE_Classic_Mini 

Also known as MIFARE Standard mini.

MIFARE_Classic_1K 

Also known as MIFARE Standard 1K.

MIFARE_Classic_2K 

Also known as MIFARE Standard 2K.

MIFARE_Classic_4K 

Also known as MIFARE Standard 4K.

MIFARE_Ultralight 

MIFARE Ultralight.

MIFARE_Ultralight_EV1_1 

MIFARE Ultralight EV1 MF0UL11.

MIFARE_Ultralight_EV1_2 

MIFARE Ultralight EV1 MF0UL21.

MIFARE_Ultralight_Nano 

MIFARE Ultralight Nano.

MIFARE_UltralightC 

MIFARE UltralightC.

NTAG_203 

NTAG 203.

NTAG_210u 

NTAG 210μ

NTAG_210 

NTAG 210.

NTAG_212 

NTAG 212.

NTAG_213 

NTAG 213.

NTAG_215 

NTAG 215.

NTAG_216 

NTAG 216.

ST25TA_512B 

ST25TA512B.

ST25TA_2K 

ST25TA02K.

ST25TA_16K 

ST25TA16K.

ST25TA_64K 

ST25TA64K.

ISO_14443_4 

PICC compliant with ISO/IEC 14443-4.

MIFARE_Plus_2K 

MIFARE Plus 2K.

MIFARE_Plus_4K 

MIFARE Plus 4K.

MIFARE_Plus_SE 

MIFARE Plus SE 1K.

MIFARE_DESFire_2K 

MIFARE DESFire 2K.

MIFARE_DESFire_4K 

MIFARE DESFire 4K.

MIFARE_DESFire_8K 

MIFARE DESFire 8K.

MIFARE_DESFire_Light 

MIFARE DESFire Light.

NTAG_4XX 

NTAG 4XX.

ISO_18092 

PICC compliant with ISO/IEC 18092.

Function Documentation

◆ get_unit_size()

uint16_t m5::nfc::a::get_unit_size ( const Type t)

Get the unit size of 1 block / 1 page.

Return values
!=0 Unit size
==0 Does not have a unit size

◆ sak_to_type()

Type m5::nfc::a::sak_to_type ( const uint8_t sak)

Inferring the type from SAK.

Returns
Type
Warning
This is a preliminary diagnosis, a more accurate diagnosis is required