Mock EEPROM

class wscodec.encoder.pyencoder.eeprom.Eeprom(sizeblocks: int)[source]

A mock of the NT3H2111 EEPROM, based on a bytearray. There are methods to read and write from this in 16-byte blocks. Helper methods parse the entire EEPROM contents as an NDEF message. This mimics what a phone will do when it reads the NT3H2111 using NFC.

The EEPROM will normally contain the output of the cupl Encoder: an NDEF message containing one NDEF record. This itself will contain a URL. One of the parameters in the query string is ‘q’, which contains the circular buffer of temperature and relative humidity samples.

decode_ndef() ndef.record.Record[source]

Decode the NDEF message.

Returns

First NDEF record in the message

display_block(block: int) bytearray[source]

Display one EEPROM block.

Parameters

block – Address of the block to display.

Returns

Block data as a list of 16 bytes.

get_message() bytearray[source]

Extract the NDEF message bytes from EEPROM.

Returns

NDEF message bytearray

get_qdemis() list[source]
Returns

The value of URL parameter ‘q’ as a list of 8-byte demis.

get_qparam() str[source]
Returns

The value of URL parameter ‘q’ as a string.

get_url() str[source]

Obtain URL from the NDEF record stored in EEPROM.

Returns

URL string

get_url_parsed() urllib.parse.ParseResult[source]

Parse URL in the EEPROM NDEF record.

Returns

Parsed URL

get_url_parsedqs() dict[source]

Parse parameters in the query string

Returns

A dictionary of URL parameters.

read_block(block: int, blkdata: ctypes.c_char_p)[source]

Read one block into a pointer.

Parameters
  • block – Address if the block to read.

  • blkdata – Pointer to an array of 16 bytes that the block will be read into.

Returns

None

write_block(block: int, blkdata: ctypes.c_char_p)[source]

Write one block from a pointer.

Parameters
  • block – Address of the block to write

  • blkdata – Pointer to an array of 16 bytes that will be written to the block.

Returns

None