简体   繁体   中英

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

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.

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, eg //, email://

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM