定义NDEF消息 [英] Defining a NDEF Message
问题描述
我正在使用Raspberry Pi和RFID-RC522板进行Python项目.作为NFC标签,我使用NXP NTAG213.我现在的计划是在标签上存储链接.我可以毫无问题地对其进行读写.但是我不明白如何为标签上存储的数据定义NDEF标头.
I am working on a Python project with my Raspberry Pi and the RFID-RC522 board. As NFC tags I use NXP NTAG213. My plan now is to store links on the tags. I can read/write on them without a problem. But I don't understand how to define the NDEF header for the stored data on the tags.
当我用智能手机在标签上写链接并用程序阅读时,标签上存储的数据如下:
When I write a link on the tags with my smartphone and read it with my program the stored data on the tag looks like this:
URL" http://www.gmx.at "的NDEF标头是
The NDEF header for the URL "http://www.gmx.at" is
[3, 11, 209, 1, 7, 85, 1, ... (Data)]
我认识到当我编写另一个链接时,其中一些参数会发生变化,但有些仍然保持不变.
I recognized that some of these parameters change when I write another link, but some still stay the same.
我找到了这个教程其中描述了NDEF标头的不同字段,但我仍然不知道如何设置它们以存储指向网站的链接.
I found this tutorial which describes the different fields of the NDEF header but I still don't get how I need to set them to store a link to a website.
如果有人能够描述我需要如何正确计算/定义链接参数,我将感到非常高兴.
I would be very happy if someone can describe how I need to calculate/define the parameters for a link correctly.
推荐答案
为了了解NDEF格式以及NDEF格式的数据如何存储在NFC Forum Type 2标签(该标签平台是由NTAG213),建议您阅读以下NFC论坛规范:
In order to understand the NDEF format and the way how NDEF formatted data is stored on an NFC Forum Type 2 tag (which is the tag platform that is implemented by the NTAG213), I suggest that you read the following NFC Forum specifications:
- Type 2 Tag Operation Specification
- NFC Data Exchange Format (NDEF)
- URI Record Type Definition
您从标记读取的数据是一个NDEF消息TLV对象,其中包含由一个URI记录组成的NDEF消息.
The data that you read from the tag is an NDEF Message TLV object containing an NDEF message that consists of one URI record.
-
NDEF消息TLV:
NDEF Message TLV:
0x03 TLV tag = NDEF Message TLV
0x0B TLV length = 11 bytes
0xD1 ... 0x74 TLV value = NDEF message
这意味着标签包含长度为11个字节的NDEF消息. NDEF消息为0xD1 ... 0x74
.
This means that the tag contains an NDEF message with a length of 11 bytes. The NDEF message is 0xD1 ... 0x74
.
NDEF消息:
0xD1 Record header
Bit 7 = MB = 1: first record of NDEF message
Bit 6 = ME = 1: last record of NDEF message
Bit 5 = CF = 0: last or only record of chain
Bit 4 = SR = 1: short record length field
Bit 3 = IL = 0: no ID/ID length fields
Bit 2..0 = TNF = 0x1: Type field represents an NFC Forum
well-known type name
0x01 Type length = 1 byte
0x07 Payload length = 7 bytes
0x55 Type field = "U" (in US-ASCII) = binary form of type name urn:nfc:wkt:U
0x01 ... 0x74 Payload field = URI record payload
这意味着NDEF消息由一个URI记录类型定义之后的URI记录(类型名称urn:nfc:wkt:U)组成.
This means that the NDEF message consists of one URI record (type name urn:nfc:wkt:U) following the URI Record Type Definition.
URI记录有效载荷:
URI record payload:
0x01 Identifier byte = URI prefix "http://www."
0x67 ... 0x74 URI field (UTF-8 encoded) = "gmx.at"
这意味着URI记录指向URI" http://www.gmx.at ".
This means that the URI record points to the URI "http://www.gmx.at".
这篇关于定义NDEF消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!