ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::nfc Namespace Reference

Data Structures

class  NciMessage
 One NCI packet, held in a fixed buffer so building and reading messages never allocates. More...
 
class  NdefMessage
 
class  NdefRecord
 
class  NdefRecordText
 
class  NdefRecordUri
 
class  Nfcc
 
class  NfcOnTagTrigger
 Fires with the formatted UID and the tag itself; the tag is passed by reference so no copy is made per trigger. More...
 
class  NfcTag
 
class  NfcTagBinarySensor
 
class  NfcTagListener
 

Typedefs

using NdefRecords = StaticVector<std::unique_ptr<NdefRecord>, MAX_NDEF_RECORDS>
 The records of one message, owned in place so parsing a message allocates only the records themselves.
 
using NfcTagUid = StaticVector<uint8_t, NFC_UID_MAX_LENGTH>
 

Functions

 ESPHOME_LOG_TAG (TAG, "nfc.binary_sensor")
 
 ESPHOME_LOG_TAG (TAG, "nfc.ndef_message")
 
 ESPHOME_LOG_TAG (TAG, "nfc.ndef_record")
 
 ESPHOME_LOG_TAG (TAG, "nfc.ndef_record_text")
 
 ESPHOME_LOG_TAG (TAG, "nfc.ndef_record_uri")
 
 ESPHOME_LOG_TAG (TAG, "nfc")
 
char * format_uid_to (char *buffer, std::span< const uint8_t > uid)
 Format UID to buffer with '-' separator (e.g., "04-11-22-33"). Returns buffer for inline use.
 
char * format_bytes_to (char *buffer, std::span< const uint8_t > bytes)
 Format bytes to buffer with ' ' separator (e.g., "04 11 22 33"). Returns buffer for inline use.
 
uint8_t guess_tag_type (uint8_t uid_length)
 
int8_t get_mifare_classic_ndef_start_index (const std::span< const uint8_t > data)
 
bool decode_mifare_classic_tlv (const std::span< const uint8_t > data, uint32_t &message_length, uint8_t &message_start_index)
 
uint32_t get_mifare_ultralight_buffer_size (uint32_t message_length)
 
void fill_ndef_tlv (std::span< const uint8_t > message, uint32_t buffer_length, FixedVector< uint8_t > &buffer)
 Fills buffer with the NDEF TLV (type, length, message, terminator) padded with zeros to buffer_length
 
uint32_t get_mifare_classic_buffer_size (uint32_t message_length)
 
bool mifare_classic_is_first_block (uint8_t block_num)
 
bool mifare_classic_is_trailer_block (uint8_t block_num)
 
 ESPHOME_LOG_TAG (TAG, "nfc.helpers")
 
bool has_ha_tag_ndef (const NfcTag &tag)
 
std::string get_ha_tag_ndef (const NfcTag &tag)
 
std::string get_random_ha_tag_ndef ()
 
 ESPHOME_LOG_TAG (TAG, "nfc.tag")
 

Typedef Documentation

◆ NdefRecords

using esphome::nfc::NdefRecords = StaticVector<std::unique_ptr<NdefRecord>, MAX_NDEF_RECORDS>

The records of one message, owned in place so parsing a message allocates only the records themselves.

Definition at line 17 of file ndef_message.h.

◆ NfcTagUid

using esphome::nfc::NfcTagUid = StaticVector<uint8_t, NFC_UID_MAX_LENGTH>

Definition at line 14 of file nfc_tag.h.

Function Documentation

◆ decode_mifare_classic_tlv()

bool esphome::nfc::decode_mifare_classic_tlv ( const std::span< const uint8_t > data,
uint32_t & message_length,
uint8_t & message_start_index )

Definition at line 39 of file nfc.cpp.

◆ ESPHOME_LOG_TAG() [1/8]

esphome::nfc::ESPHOME_LOG_TAG ( TAG ,
"nfc"  )

◆ ESPHOME_LOG_TAG() [2/8]

esphome::nfc::ESPHOME_LOG_TAG ( TAG ,
"nfc.binary_sensor"  )

◆ ESPHOME_LOG_TAG() [3/8]

esphome::nfc::ESPHOME_LOG_TAG ( TAG ,
"nfc.helpers"  )

◆ ESPHOME_LOG_TAG() [4/8]

esphome::nfc::ESPHOME_LOG_TAG ( TAG ,
"nfc.ndef_message"  )

◆ ESPHOME_LOG_TAG() [5/8]

esphome::nfc::ESPHOME_LOG_TAG ( TAG ,
"nfc.ndef_record"  )

◆ ESPHOME_LOG_TAG() [6/8]

esphome::nfc::ESPHOME_LOG_TAG ( TAG ,
"nfc.ndef_record_text"  )

◆ ESPHOME_LOG_TAG() [7/8]

esphome::nfc::ESPHOME_LOG_TAG ( TAG ,
"nfc.ndef_record_uri"  )

◆ ESPHOME_LOG_TAG() [8/8]

esphome::nfc::ESPHOME_LOG_TAG ( TAG ,
"nfc.tag"  )

◆ fill_ndef_tlv()

void esphome::nfc::fill_ndef_tlv ( const std::span< const uint8_t > message,
const uint32_t buffer_length,
FixedVector< uint8_t > & buffer )

Fills buffer with the NDEF TLV (type, length, message, terminator) padded with zeros to buffer_length

Definition at line 72 of file nfc.cpp.

◆ format_bytes_to()

char * esphome::nfc::format_bytes_to ( char * buffer,
std::span< const uint8_t > bytes )

Format bytes to buffer with ' ' separator (e.g., "04 11 22 33"). Returns buffer for inline use.

Definition at line 14 of file nfc.cpp.

◆ format_uid_to()

char * esphome::nfc::format_uid_to ( char * buffer,
std::span< const uint8_t > uid )

Format UID to buffer with '-' separator (e.g., "04-11-22-33"). Returns buffer for inline use.

Definition at line 10 of file nfc.cpp.

◆ get_ha_tag_ndef()

std::string esphome::nfc::get_ha_tag_ndef ( const NfcTag & tag)

Definition at line 9 of file nfc_helpers.cpp.

◆ get_mifare_classic_buffer_size()

uint32_t esphome::nfc::get_mifare_classic_buffer_size ( uint32_t message_length)

Definition at line 91 of file nfc.cpp.

◆ get_mifare_classic_ndef_start_index()

int8_t esphome::nfc::get_mifare_classic_ndef_start_index ( const std::span< const uint8_t > data)

Definition at line 26 of file nfc.cpp.

◆ get_mifare_ultralight_buffer_size()

uint32_t esphome::nfc::get_mifare_ultralight_buffer_size ( uint32_t message_length)

Definition at line 64 of file nfc.cpp.

◆ get_random_ha_tag_ndef()

std::string esphome::nfc::get_random_ha_tag_ndef ( )

Definition at line 25 of file nfc_helpers.cpp.

◆ guess_tag_type()

uint8_t esphome::nfc::guess_tag_type ( uint8_t uid_length)

Definition at line 18 of file nfc.cpp.

◆ has_ha_tag_ndef()

bool esphome::nfc::has_ha_tag_ndef ( const NfcTag & tag)

Definition at line 7 of file nfc_helpers.cpp.

◆ mifare_classic_is_first_block()

bool esphome::nfc::mifare_classic_is_first_block ( uint8_t block_num)

Definition at line 104 of file nfc.cpp.

◆ mifare_classic_is_trailer_block()

bool esphome::nfc::mifare_classic_is_trailer_block ( uint8_t block_num)

Definition at line 112 of file nfc.cpp.