nfc.tag

nfc.tag.tt1.Type1Tag

class nfc.tag.tt1.Type1Tag
is_present

Returns True if the tag is still within communication range.

read_id()

Read header rom and all static memory bytes (blocks 0-14).

read_all()

Read header rom and all static memory bytes (blocks 0-14).

read_byte(addr)

Read a single byte from static memory area (blocks 0-14).

write_byte(addr, byte, erase=True)

Write a single byte to static memory area (blocks 0-14). The target byte is zero’d first if ‘erase’ is True (default).

read_block(block)

Read an 8-byte data block at address (block * 8).

write_block(block, data, erase=True)

Write an 8-byte data block at address (block * 8). The target bytes are zero’d first if ‘erase’ is True (default).

nfc.tag.tt2.Type2Tag

class nfc.tag.tt2.Type2Tag
is_present

Returns True if the tag is still within communication range.

read(block)

Read 16-byte of data from the tag. The block argument specifies the offset in multiples of 4 bytes (i.e. block number 1 will return bytes 4 to 19). The data returned is a byte array of length 16.

write(block, data)

Write 4-byte of data to the tag. The block argument specifies the offset in multiples of 4 bytes. The data argument must be a string or bytearray of length 4.

nfc.tag.tt3.Type3Tag

class nfc.tag.tt3.Type3Tag
is_present

True if the tag is still within communication range.

poll(system_code)

Send the polling command to recognize a system on the card. The system_code may be specified as a short integer or as a string or bytearray of length 2. The return value is the tuple of the two bytearrays (idm, pmm) if the requested system is present or the tuple (None, None) if not.

read(blocks, service=11)

Read service data blocks from tag. The service argument is the tag type 3 service code to use, 0x000b for reading NDEF. The blocks argument holds a list of integers representing the block numbers to read. The data is returned as a character string.

write(data, blocks, service=9)

Write service data blocks to tag. The service argument is the tag type 3 service code to use, 0x0009 for writing NDEF. The blocks argument holds a list of integers representing the block numbers to write. The data argument must be a character string with length equal to the number of blocks times 16.

nfc.tag.tt4.Type4Tag

class nfc.tag.tt4.Type4Tag
is_present

True if the tag is still within communication range.

select_file(p1, p2, data, expected_response_length=None)

Select a file or directory with parameters defined in ISO/IEC 7816-4

read_binary(offset, count)

Read count bytes from selected file starting at offset

update_binary(offset, data)

Write data bytes to selected file starting at offset