How can I contain a file using the NDEF data type for NFC card emulation

187 views Asked by At

In trying to implement some card emulation using NFCPY, I've come across the NDEF data type. I've attached its records along with their comment explanations below.

ndef_data_area = bytearray(64 * 16)
ndef_data_area[0] = 0x10 # NDEF mapping version '1.0'
ndef_data_area[1] = 12 # Number of blocks that may be read at once
ndef_data_area[2] = 8 # Number of blocks that may be written at once
ndef_data_area[4] = 63 # Number of blocks available for NDEF data
ndef_data_area[10] = 1 # NDEF read and write operations are allowed
ndef_data_area[14:16] = struct.pack('>H', sum(ndef_data_area[0:14])) # Checksum

My question is, how can I manually encode a file into these records (NDEF fields)?

I've come across mobile apps that enable the transmission of GPS data, emails, text messages, but I am unsure of how these programs interact with the records of the NDEF data type as they are shown above. As a weaker problem, I tried encoding a string into the NDEF fields, but I am told that only integers are accepted.

1

There are 1 answers

0
Andrew On BEST ANSWER

So some docs on the Ndef standards are available to read at https://github.com/haldean/ndef/tree/master/docs

Some types of data can be handled by "Well Known" types, some types can be handled as "URI" type, e.g. //, email://

A lot of more custom stuff is handled by Mime Type records e.g. "image/png", "application/vcard", etc