[nfc] Use constexpr for compile-time constants

These headers are included by multiple translation units, so
static const causes duplicate copies in each TU's literal pool.
constexpr allows the compiler to use immediate values instead.
This commit is contained in:
J. Nick Koston
2026-02-18 20:58:19 -06:00
parent 565443b710
commit c855e20434
5 changed files with 154 additions and 154 deletions

View File

@@ -8,137 +8,137 @@ namespace esphome {
namespace nfc {
// Header info
static const uint8_t NCI_PKT_HEADER_SIZE = 3; // NCI packet (pkt) headers are always three bytes
static const uint8_t NCI_PKT_MT_GID_OFFSET = 0; // NCI packet (pkt) MT and GID offsets
static const uint8_t NCI_PKT_OID_OFFSET = 1; // NCI packet (pkt) OID offset
static const uint8_t NCI_PKT_LENGTH_OFFSET = 2; // NCI packet (pkt) message length (size) offset
static const uint8_t NCI_PKT_PAYLOAD_OFFSET = 3; // NCI packet (pkt) payload offset
static constexpr uint8_t NCI_PKT_HEADER_SIZE = 3; // NCI packet (pkt) headers are always three bytes
static constexpr uint8_t NCI_PKT_MT_GID_OFFSET = 0; // NCI packet (pkt) MT and GID offsets
static constexpr uint8_t NCI_PKT_OID_OFFSET = 1; // NCI packet (pkt) OID offset
static constexpr uint8_t NCI_PKT_LENGTH_OFFSET = 2; // NCI packet (pkt) message length (size) offset
static constexpr uint8_t NCI_PKT_PAYLOAD_OFFSET = 3; // NCI packet (pkt) payload offset
// Important masks
static const uint8_t NCI_PKT_MT_MASK = 0xE0; // NCI packet (pkt) message type mask
static const uint8_t NCI_PKT_PBF_MASK = 0x10; // packet boundary flag bit
static const uint8_t NCI_PKT_GID_MASK = 0x0F;
static const uint8_t NCI_PKT_OID_MASK = 0x3F;
static constexpr uint8_t NCI_PKT_MT_MASK = 0xE0; // NCI packet (pkt) message type mask
static constexpr uint8_t NCI_PKT_PBF_MASK = 0x10; // packet boundary flag bit
static constexpr uint8_t NCI_PKT_GID_MASK = 0x0F;
static constexpr uint8_t NCI_PKT_OID_MASK = 0x3F;
// Message types
static const uint8_t NCI_PKT_MT_DATA = 0x00; // For sending commands to NFC endpoint (card/tag)
static const uint8_t NCI_PKT_MT_CTRL_COMMAND = 0x20; // For sending commands to NFCC
static const uint8_t NCI_PKT_MT_CTRL_RESPONSE = 0x40; // Response from NFCC to commands
static const uint8_t NCI_PKT_MT_CTRL_NOTIFICATION = 0x60; // Notification from NFCC
static constexpr uint8_t NCI_PKT_MT_DATA = 0x00; // For sending commands to NFC endpoint (card/tag)
static constexpr uint8_t NCI_PKT_MT_CTRL_COMMAND = 0x20; // For sending commands to NFCC
static constexpr uint8_t NCI_PKT_MT_CTRL_RESPONSE = 0x40; // Response from NFCC to commands
static constexpr uint8_t NCI_PKT_MT_CTRL_NOTIFICATION = 0x60; // Notification from NFCC
// GIDs
static const uint8_t NCI_CORE_GID = 0x0;
static const uint8_t RF_GID = 0x1;
static const uint8_t NFCEE_GID = 0x1;
static const uint8_t NCI_PROPRIETARY_GID = 0xF;
static constexpr uint8_t NCI_CORE_GID = 0x0;
static constexpr uint8_t RF_GID = 0x1;
static constexpr uint8_t NFCEE_GID = 0x1;
static constexpr uint8_t NCI_PROPRIETARY_GID = 0xF;
// OIDs
static const uint8_t NCI_CORE_RESET_OID = 0x00;
static const uint8_t NCI_CORE_INIT_OID = 0x01;
static const uint8_t NCI_CORE_SET_CONFIG_OID = 0x02;
static const uint8_t NCI_CORE_GET_CONFIG_OID = 0x03;
static const uint8_t NCI_CORE_CONN_CREATE_OID = 0x04;
static const uint8_t NCI_CORE_CONN_CLOSE_OID = 0x05;
static const uint8_t NCI_CORE_CONN_CREDITS_OID = 0x06;
static const uint8_t NCI_CORE_GENERIC_ERROR_OID = 0x07;
static const uint8_t NCI_CORE_INTERFACE_ERROR_OID = 0x08;
static constexpr uint8_t NCI_CORE_RESET_OID = 0x00;
static constexpr uint8_t NCI_CORE_INIT_OID = 0x01;
static constexpr uint8_t NCI_CORE_SET_CONFIG_OID = 0x02;
static constexpr uint8_t NCI_CORE_GET_CONFIG_OID = 0x03;
static constexpr uint8_t NCI_CORE_CONN_CREATE_OID = 0x04;
static constexpr uint8_t NCI_CORE_CONN_CLOSE_OID = 0x05;
static constexpr uint8_t NCI_CORE_CONN_CREDITS_OID = 0x06;
static constexpr uint8_t NCI_CORE_GENERIC_ERROR_OID = 0x07;
static constexpr uint8_t NCI_CORE_INTERFACE_ERROR_OID = 0x08;
static const uint8_t RF_DISCOVER_MAP_OID = 0x00;
static const uint8_t RF_SET_LISTEN_MODE_ROUTING_OID = 0x01;
static const uint8_t RF_GET_LISTEN_MODE_ROUTING_OID = 0x02;
static const uint8_t RF_DISCOVER_OID = 0x03;
static const uint8_t RF_DISCOVER_SELECT_OID = 0x04;
static const uint8_t RF_INTF_ACTIVATED_OID = 0x05;
static const uint8_t RF_DEACTIVATE_OID = 0x06;
static const uint8_t RF_FIELD_INFO_OID = 0x07;
static const uint8_t RF_T3T_POLLING_OID = 0x08;
static const uint8_t RF_NFCEE_ACTION_OID = 0x09;
static const uint8_t RF_NFCEE_DISCOVERY_REQ_OID = 0x0A;
static const uint8_t RF_PARAMETER_UPDATE_OID = 0x0B;
static constexpr uint8_t RF_DISCOVER_MAP_OID = 0x00;
static constexpr uint8_t RF_SET_LISTEN_MODE_ROUTING_OID = 0x01;
static constexpr uint8_t RF_GET_LISTEN_MODE_ROUTING_OID = 0x02;
static constexpr uint8_t RF_DISCOVER_OID = 0x03;
static constexpr uint8_t RF_DISCOVER_SELECT_OID = 0x04;
static constexpr uint8_t RF_INTF_ACTIVATED_OID = 0x05;
static constexpr uint8_t RF_DEACTIVATE_OID = 0x06;
static constexpr uint8_t RF_FIELD_INFO_OID = 0x07;
static constexpr uint8_t RF_T3T_POLLING_OID = 0x08;
static constexpr uint8_t RF_NFCEE_ACTION_OID = 0x09;
static constexpr uint8_t RF_NFCEE_DISCOVERY_REQ_OID = 0x0A;
static constexpr uint8_t RF_PARAMETER_UPDATE_OID = 0x0B;
static const uint8_t NFCEE_DISCOVER_OID = 0x00;
static const uint8_t NFCEE_MODE_SET_OID = 0x01;
static constexpr uint8_t NFCEE_DISCOVER_OID = 0x00;
static constexpr uint8_t NFCEE_MODE_SET_OID = 0x01;
// Interfaces
static const uint8_t INTF_NFCEE_DIRECT = 0x00;
static const uint8_t INTF_FRAME = 0x01;
static const uint8_t INTF_ISODEP = 0x02;
static const uint8_t INTF_NFCDEP = 0x03;
static const uint8_t INTF_TAGCMD = 0x80; // NXP proprietary
static constexpr uint8_t INTF_NFCEE_DIRECT = 0x00;
static constexpr uint8_t INTF_FRAME = 0x01;
static constexpr uint8_t INTF_ISODEP = 0x02;
static constexpr uint8_t INTF_NFCDEP = 0x03;
static constexpr uint8_t INTF_TAGCMD = 0x80; // NXP proprietary
// Bit rates
static const uint8_t NFC_BIT_RATE_106 = 0x00;
static const uint8_t NFC_BIT_RATE_212 = 0x01;
static const uint8_t NFC_BIT_RATE_424 = 0x02;
static const uint8_t NFC_BIT_RATE_848 = 0x03;
static const uint8_t NFC_BIT_RATE_1695 = 0x04;
static const uint8_t NFC_BIT_RATE_3390 = 0x05;
static const uint8_t NFC_BIT_RATE_6780 = 0x06;
static constexpr uint8_t NFC_BIT_RATE_106 = 0x00;
static constexpr uint8_t NFC_BIT_RATE_212 = 0x01;
static constexpr uint8_t NFC_BIT_RATE_424 = 0x02;
static constexpr uint8_t NFC_BIT_RATE_848 = 0x03;
static constexpr uint8_t NFC_BIT_RATE_1695 = 0x04;
static constexpr uint8_t NFC_BIT_RATE_3390 = 0x05;
static constexpr uint8_t NFC_BIT_RATE_6780 = 0x06;
// Protocols
static const uint8_t PROT_UNDETERMINED = 0x00;
static const uint8_t PROT_T1T = 0x01;
static const uint8_t PROT_T2T = 0x02;
static const uint8_t PROT_T3T = 0x03;
static const uint8_t PROT_ISODEP = 0x04;
static const uint8_t PROT_NFCDEP = 0x05;
static const uint8_t PROT_T5T = 0x06;
static const uint8_t PROT_MIFARE = 0x80;
static constexpr uint8_t PROT_UNDETERMINED = 0x00;
static constexpr uint8_t PROT_T1T = 0x01;
static constexpr uint8_t PROT_T2T = 0x02;
static constexpr uint8_t PROT_T3T = 0x03;
static constexpr uint8_t PROT_ISODEP = 0x04;
static constexpr uint8_t PROT_NFCDEP = 0x05;
static constexpr uint8_t PROT_T5T = 0x06;
static constexpr uint8_t PROT_MIFARE = 0x80;
// RF Technologies
static const uint8_t NFC_RF_TECH_A = 0x00;
static const uint8_t NFC_RF_TECH_B = 0x01;
static const uint8_t NFC_RF_TECH_F = 0x02;
static const uint8_t NFC_RF_TECH_15693 = 0x03;
static constexpr uint8_t NFC_RF_TECH_A = 0x00;
static constexpr uint8_t NFC_RF_TECH_B = 0x01;
static constexpr uint8_t NFC_RF_TECH_F = 0x02;
static constexpr uint8_t NFC_RF_TECH_15693 = 0x03;
// RF Technology & Modes
static const uint8_t MODE_MASK = 0xF0;
static const uint8_t MODE_LISTEN_MASK = 0x80;
static const uint8_t MODE_POLL = 0x00;
static constexpr uint8_t MODE_MASK = 0xF0;
static constexpr uint8_t MODE_LISTEN_MASK = 0x80;
static constexpr uint8_t MODE_POLL = 0x00;
static const uint8_t TECH_PASSIVE_NFCA = 0x00;
static const uint8_t TECH_PASSIVE_NFCB = 0x01;
static const uint8_t TECH_PASSIVE_NFCF = 0x02;
static const uint8_t TECH_ACTIVE_NFCA = 0x03;
static const uint8_t TECH_ACTIVE_NFCF = 0x05;
static const uint8_t TECH_PASSIVE_15693 = 0x06;
static constexpr uint8_t TECH_PASSIVE_NFCA = 0x00;
static constexpr uint8_t TECH_PASSIVE_NFCB = 0x01;
static constexpr uint8_t TECH_PASSIVE_NFCF = 0x02;
static constexpr uint8_t TECH_ACTIVE_NFCA = 0x03;
static constexpr uint8_t TECH_ACTIVE_NFCF = 0x05;
static constexpr uint8_t TECH_PASSIVE_15693 = 0x06;
// Status codes
static const uint8_t STATUS_OK = 0x00;
static const uint8_t STATUS_REJECTED = 0x01;
static const uint8_t STATUS_RF_FRAME_CORRUPTED = 0x02;
static const uint8_t STATUS_FAILED = 0x03;
static const uint8_t STATUS_NOT_INITIALIZED = 0x04;
static const uint8_t STATUS_SYNTAX_ERROR = 0x05;
static const uint8_t STATUS_SEMANTIC_ERROR = 0x06;
static const uint8_t STATUS_INVALID_PARAM = 0x09;
static const uint8_t STATUS_MESSAGE_SIZE_EXCEEDED = 0x0A;
static const uint8_t DISCOVERY_ALREADY_STARTED = 0xA0;
static const uint8_t DISCOVERY_TARGET_ACTIVATION_FAILED = 0xA1;
static const uint8_t DISCOVERY_TEAR_DOWN = 0xA2;
static const uint8_t RF_TRANSMISSION_ERROR = 0xB0;
static const uint8_t RF_PROTOCOL_ERROR = 0xB1;
static const uint8_t RF_TIMEOUT_ERROR = 0xB2;
static const uint8_t NFCEE_INTERFACE_ACTIVATION_FAILED = 0xC0;
static const uint8_t NFCEE_TRANSMISSION_ERROR = 0xC1;
static const uint8_t NFCEE_PROTOCOL_ERROR = 0xC2;
static const uint8_t NFCEE_TIMEOUT_ERROR = 0xC3;
static constexpr uint8_t STATUS_OK = 0x00;
static constexpr uint8_t STATUS_REJECTED = 0x01;
static constexpr uint8_t STATUS_RF_FRAME_CORRUPTED = 0x02;
static constexpr uint8_t STATUS_FAILED = 0x03;
static constexpr uint8_t STATUS_NOT_INITIALIZED = 0x04;
static constexpr uint8_t STATUS_SYNTAX_ERROR = 0x05;
static constexpr uint8_t STATUS_SEMANTIC_ERROR = 0x06;
static constexpr uint8_t STATUS_INVALID_PARAM = 0x09;
static constexpr uint8_t STATUS_MESSAGE_SIZE_EXCEEDED = 0x0A;
static constexpr uint8_t DISCOVERY_ALREADY_STARTED = 0xA0;
static constexpr uint8_t DISCOVERY_TARGET_ACTIVATION_FAILED = 0xA1;
static constexpr uint8_t DISCOVERY_TEAR_DOWN = 0xA2;
static constexpr uint8_t RF_TRANSMISSION_ERROR = 0xB0;
static constexpr uint8_t RF_PROTOCOL_ERROR = 0xB1;
static constexpr uint8_t RF_TIMEOUT_ERROR = 0xB2;
static constexpr uint8_t NFCEE_INTERFACE_ACTIVATION_FAILED = 0xC0;
static constexpr uint8_t NFCEE_TRANSMISSION_ERROR = 0xC1;
static constexpr uint8_t NFCEE_PROTOCOL_ERROR = 0xC2;
static constexpr uint8_t NFCEE_TIMEOUT_ERROR = 0xC3;
// Deactivation types/reasons
static const uint8_t DEACTIVATION_TYPE_IDLE = 0x00;
static const uint8_t DEACTIVATION_TYPE_SLEEP = 0x01;
static const uint8_t DEACTIVATION_TYPE_SLEEP_AF = 0x02;
static const uint8_t DEACTIVATION_TYPE_DISCOVERY = 0x03;
static constexpr uint8_t DEACTIVATION_TYPE_IDLE = 0x00;
static constexpr uint8_t DEACTIVATION_TYPE_SLEEP = 0x01;
static constexpr uint8_t DEACTIVATION_TYPE_SLEEP_AF = 0x02;
static constexpr uint8_t DEACTIVATION_TYPE_DISCOVERY = 0x03;
// RF discover map modes
static const uint8_t RF_DISCOVER_MAP_MODE_POLL = 0x1;
static const uint8_t RF_DISCOVER_MAP_MODE_LISTEN = 0x2;
static constexpr uint8_t RF_DISCOVER_MAP_MODE_POLL = 0x1;
static constexpr uint8_t RF_DISCOVER_MAP_MODE_LISTEN = 0x2;
// RF discover notification types
static const uint8_t RF_DISCOVER_NTF_NT_LAST = 0x00;
static const uint8_t RF_DISCOVER_NTF_NT_LAST_RL = 0x01;
static const uint8_t RF_DISCOVER_NTF_NT_MORE = 0x02;
static constexpr uint8_t RF_DISCOVER_NTF_NT_LAST = 0x00;
static constexpr uint8_t RF_DISCOVER_NTF_NT_LAST_RL = 0x01;
static constexpr uint8_t RF_DISCOVER_NTF_NT_MORE = 0x02;
// Important message offsets
static const uint8_t RF_DISCOVER_NTF_DISCOVERY_ID = 0 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_DISCOVER_NTF_PROTOCOL = 1 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_DISCOVER_NTF_MODE_TECH = 2 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_DISCOVER_NTF_RF_TECH_LENGTH = 3 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_DISCOVER_NTF_RF_TECH_PARAMS = 4 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_INTF_ACTIVATED_NTF_DISCOVERY_ID = 0 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_INTF_ACTIVATED_NTF_INTERFACE = 1 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_INTF_ACTIVATED_NTF_PROTOCOL = 2 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_INTF_ACTIVATED_NTF_MODE_TECH = 3 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_INTF_ACTIVATED_NTF_MAX_SIZE = 4 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_INTF_ACTIVATED_NTF_INIT_CRED = 5 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_INTF_ACTIVATED_NTF_RF_TECH_LENGTH = 6 + NCI_PKT_HEADER_SIZE;
static const uint8_t RF_INTF_ACTIVATED_NTF_RF_TECH_PARAMS = 7 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_DISCOVER_NTF_DISCOVERY_ID = 0 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_DISCOVER_NTF_PROTOCOL = 1 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_DISCOVER_NTF_MODE_TECH = 2 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_DISCOVER_NTF_RF_TECH_LENGTH = 3 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_DISCOVER_NTF_RF_TECH_PARAMS = 4 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_INTF_ACTIVATED_NTF_DISCOVERY_ID = 0 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_INTF_ACTIVATED_NTF_INTERFACE = 1 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_INTF_ACTIVATED_NTF_PROTOCOL = 2 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_INTF_ACTIVATED_NTF_MODE_TECH = 3 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_INTF_ACTIVATED_NTF_MAX_SIZE = 4 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_INTF_ACTIVATED_NTF_INIT_CRED = 5 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_INTF_ACTIVATED_NTF_RF_TECH_LENGTH = 6 + NCI_PKT_HEADER_SIZE;
static constexpr uint8_t RF_INTF_ACTIVATED_NTF_RF_TECH_PARAMS = 7 + NCI_PKT_HEADER_SIZE;
} // namespace nfc
} // namespace esphome

View File

@@ -12,7 +12,7 @@
namespace esphome {
namespace nfc {
static const uint8_t MAX_NDEF_RECORDS = 4;
static constexpr uint8_t MAX_NDEF_RECORDS = 4;
class NdefMessage {
public:

View File

@@ -8,14 +8,14 @@
namespace esphome {
namespace nfc {
static const uint8_t TNF_EMPTY = 0x00;
static const uint8_t TNF_WELL_KNOWN = 0x01;
static const uint8_t TNF_MIME_MEDIA = 0x02;
static const uint8_t TNF_ABSOLUTE_URI = 0x03;
static const uint8_t TNF_EXTERNAL_TYPE = 0x04;
static const uint8_t TNF_UNKNOWN = 0x05;
static const uint8_t TNF_UNCHANGED = 0x06;
static const uint8_t TNF_RESERVED = 0x07;
static constexpr uint8_t TNF_EMPTY = 0x00;
static constexpr uint8_t TNF_WELL_KNOWN = 0x01;
static constexpr uint8_t TNF_MIME_MEDIA = 0x02;
static constexpr uint8_t TNF_ABSOLUTE_URI = 0x03;
static constexpr uint8_t TNF_EXTERNAL_TYPE = 0x04;
static constexpr uint8_t TNF_UNKNOWN = 0x05;
static constexpr uint8_t TNF_UNCHANGED = 0x06;
static constexpr uint8_t TNF_RESERVED = 0x07;
class NdefRecord {
public:

View File

@@ -9,7 +9,7 @@
namespace esphome {
namespace nfc {
static const uint8_t PAYLOAD_IDENTIFIERS_COUNT = 0x23;
static constexpr uint8_t PAYLOAD_IDENTIFIERS_COUNT = 0x23;
static const char *const PAYLOAD_IDENTIFIERS[] = {"",
"http://www.",
"https://www.",

View File

@@ -12,47 +12,47 @@
namespace esphome {
namespace nfc {
static const uint8_t MIFARE_CLASSIC_BLOCK_SIZE = 16;
static const uint8_t MIFARE_CLASSIC_LONG_TLV_SIZE = 4;
static const uint8_t MIFARE_CLASSIC_SHORT_TLV_SIZE = 2;
static const uint8_t MIFARE_CLASSIC_BLOCKS_PER_SECT_LOW = 4;
static const uint8_t MIFARE_CLASSIC_BLOCKS_PER_SECT_HIGH = 16;
static const uint8_t MIFARE_CLASSIC_16BLOCK_SECT_START = 32;
static constexpr uint8_t MIFARE_CLASSIC_BLOCK_SIZE = 16;
static constexpr uint8_t MIFARE_CLASSIC_LONG_TLV_SIZE = 4;
static constexpr uint8_t MIFARE_CLASSIC_SHORT_TLV_SIZE = 2;
static constexpr uint8_t MIFARE_CLASSIC_BLOCKS_PER_SECT_LOW = 4;
static constexpr uint8_t MIFARE_CLASSIC_BLOCKS_PER_SECT_HIGH = 16;
static constexpr uint8_t MIFARE_CLASSIC_16BLOCK_SECT_START = 32;
static const uint8_t MIFARE_ULTRALIGHT_PAGE_SIZE = 4;
static const uint8_t MIFARE_ULTRALIGHT_READ_SIZE = 4;
static const uint8_t MIFARE_ULTRALIGHT_DATA_START_PAGE = 4;
static const uint8_t MIFARE_ULTRALIGHT_MAX_PAGE = 63;
static constexpr uint8_t MIFARE_ULTRALIGHT_PAGE_SIZE = 4;
static constexpr uint8_t MIFARE_ULTRALIGHT_READ_SIZE = 4;
static constexpr uint8_t MIFARE_ULTRALIGHT_DATA_START_PAGE = 4;
static constexpr uint8_t MIFARE_ULTRALIGHT_MAX_PAGE = 63;
static const uint8_t TAG_TYPE_MIFARE_CLASSIC = 0;
static const uint8_t TAG_TYPE_1 = 1;
static const uint8_t TAG_TYPE_2 = 2;
static const uint8_t TAG_TYPE_3 = 3;
static const uint8_t TAG_TYPE_4 = 4;
static const uint8_t TAG_TYPE_UNKNOWN = 99;
static constexpr uint8_t TAG_TYPE_MIFARE_CLASSIC = 0;
static constexpr uint8_t TAG_TYPE_1 = 1;
static constexpr uint8_t TAG_TYPE_2 = 2;
static constexpr uint8_t TAG_TYPE_3 = 3;
static constexpr uint8_t TAG_TYPE_4 = 4;
static constexpr uint8_t TAG_TYPE_UNKNOWN = 99;
// Mifare Commands
static const uint8_t MIFARE_CMD_AUTH_A = 0x60;
static const uint8_t MIFARE_CMD_AUTH_B = 0x61;
static const uint8_t MIFARE_CMD_HALT = 0x50;
static const uint8_t MIFARE_CMD_READ = 0x30;
static const uint8_t MIFARE_CMD_WRITE = 0xA0;
static const uint8_t MIFARE_CMD_WRITE_ULTRALIGHT = 0xA2;
static constexpr uint8_t MIFARE_CMD_AUTH_A = 0x60;
static constexpr uint8_t MIFARE_CMD_AUTH_B = 0x61;
static constexpr uint8_t MIFARE_CMD_HALT = 0x50;
static constexpr uint8_t MIFARE_CMD_READ = 0x30;
static constexpr uint8_t MIFARE_CMD_WRITE = 0xA0;
static constexpr uint8_t MIFARE_CMD_WRITE_ULTRALIGHT = 0xA2;
// Mifare Ack/Nak
static const uint8_t MIFARE_CMD_ACK = 0x0A;
static const uint8_t MIFARE_CMD_NAK_INVALID_XFER_BUFF_VALID = 0x00;
static const uint8_t MIFARE_CMD_NAK_CRC_ERROR_XFER_BUFF_VALID = 0x01;
static const uint8_t MIFARE_CMD_NAK_INVALID_XFER_BUFF_INVALID = 0x04;
static const uint8_t MIFARE_CMD_NAK_CRC_ERROR_XFER_BUFF_INVALID = 0x05;
static constexpr uint8_t MIFARE_CMD_ACK = 0x0A;
static constexpr uint8_t MIFARE_CMD_NAK_INVALID_XFER_BUFF_VALID = 0x00;
static constexpr uint8_t MIFARE_CMD_NAK_CRC_ERROR_XFER_BUFF_VALID = 0x01;
static constexpr uint8_t MIFARE_CMD_NAK_INVALID_XFER_BUFF_INVALID = 0x04;
static constexpr uint8_t MIFARE_CMD_NAK_CRC_ERROR_XFER_BUFF_INVALID = 0x05;
static const char *const MIFARE_CLASSIC = "Mifare Classic";
static const char *const NFC_FORUM_TYPE_2 = "NFC Forum Type 2";
static const char *const ERROR = "Error";
static const uint8_t DEFAULT_KEY[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
static const uint8_t NDEF_KEY[6] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7};
static const uint8_t MAD_KEY[6] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
static constexpr uint8_t DEFAULT_KEY[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
static constexpr uint8_t NDEF_KEY[6] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7};
static constexpr uint8_t MAD_KEY[6] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
/// Max UID size is 10 bytes, formatted as "XX-XX-XX-XX-XX-XX-XX-XX-XX-XX\0" = 30 chars
static constexpr size_t FORMAT_UID_BUFFER_SIZE = 30;