了解 NDEF 记录格式
Understanding NDEF record format
我已经将 NDEF 文本记录 - "poo"(只是测试)写入了 NFC 论坛类型 2 标签,我需要一些帮助来了解具体写入的内容和格式。
发送到标签的命令包含四个数组:
new Uint8Array([162, 4, 3, 10, 209, 1]).buffer
new Uint8Array([162, 5, 6, 84, 2, 101]).buffer
new Uint8Array([162, 6, 110, 112, 111, 111]).buffer <-- 112, 111, 111 is ASCII for "poo"
new Uint8Array([162, 7, 254, 0, 0, 48]).buffer
我理解每个数组的第一个字节(162)是"write"命令。每个数组的第二个字节(4、5、6、7)是整个标签数据中的索引,用于放置后面的字节。它从 4 开始,因为前 16 个字节已经写入,并且包含有关标签的元数据。
我也明白 112、111、111 是我存储的文本。
所以我的问题是:前两个和最后一个数组的用途是什么?
我无法理解它们包含的数据。这是我的 NFC 标签的最终内容(我从末尾截断了所有零)
new Uint8Array([95, 222, 208, 217, 54, 218, 237, 38, 39, 3, 0, 0, 225, 17, 96, 0, 3, 10, 209, 1, 6, 84, 2, 101, 110, 112, 111, 111, 254, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...])
如您所见,前 16 个字节是在创建时写入的;定义标签。接下来是上面的 4 个数组。我目前的理解源于here,它解释了payload带有元数据来解释它是什么数据类型等,但是payload前面有两个数组,后面有一个数组,我不明白。
是NDEF元数据:
您可以将数据与上面的每个字段匹配。
在用头撞墙一段时间后,我发现它 是我怀疑的 元数据,但它的顺序与通常记录的顺序不同。有关以下内容的更多详细信息,请参见 here.
new Uint8Array([162, 4, 3, 10, 209, 1]).buffer
3: "Type length"
10: "Record length"
209: "NDEF record header"
1: "Type Name Field"
new Uint8Array([162, 5, 6, 84, 2, 101]).buffer
6: "Payload Length"
84: "Well known record"
2: "Well known record type" (in this case - the encoding for this text (UTF))
101: "e"
new Uint8Array([162, 6, 110, 112, 111, 111]).buffer
110: "n" - ("en" is locale)
112: "p"
111: "o"
111: "o"
new Uint8Array([162, 7, 254, 0, 0, 48]).buffer
254: Marks the end of the payload
我已经将 NDEF 文本记录 - "poo"(只是测试)写入了 NFC 论坛类型 2 标签,我需要一些帮助来了解具体写入的内容和格式。 发送到标签的命令包含四个数组:
new Uint8Array([162, 4, 3, 10, 209, 1]).buffer
new Uint8Array([162, 5, 6, 84, 2, 101]).buffer
new Uint8Array([162, 6, 110, 112, 111, 111]).buffer <-- 112, 111, 111 is ASCII for "poo"
new Uint8Array([162, 7, 254, 0, 0, 48]).buffer
我理解每个数组的第一个字节(162)是"write"命令。每个数组的第二个字节(4、5、6、7)是整个标签数据中的索引,用于放置后面的字节。它从 4 开始,因为前 16 个字节已经写入,并且包含有关标签的元数据。 我也明白 112、111、111 是我存储的文本。
所以我的问题是:前两个和最后一个数组的用途是什么?
我无法理解它们包含的数据。这是我的 NFC 标签的最终内容(我从末尾截断了所有零)
new Uint8Array([95, 222, 208, 217, 54, 218, 237, 38, 39, 3, 0, 0, 225, 17, 96, 0, 3, 10, 209, 1, 6, 84, 2, 101, 110, 112, 111, 111, 254, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...])
如您所见,前 16 个字节是在创建时写入的;定义标签。接下来是上面的 4 个数组。我目前的理解源于here,它解释了payload带有元数据来解释它是什么数据类型等,但是payload前面有两个数组,后面有一个数组,我不明白。
是NDEF元数据:
您可以将数据与上面的每个字段匹配。
在用头撞墙一段时间后,我发现它 是我怀疑的 元数据,但它的顺序与通常记录的顺序不同。有关以下内容的更多详细信息,请参见 here.
new Uint8Array([162, 4, 3, 10, 209, 1]).buffer
3: "Type length"
10: "Record length"
209: "NDEF record header"
1: "Type Name Field"
new Uint8Array([162, 5, 6, 84, 2, 101]).buffer
6: "Payload Length"
84: "Well known record"
2: "Well known record type" (in this case - the encoding for this text (UTF))
101: "e"
new Uint8Array([162, 6, 110, 112, 111, 111]).buffer
110: "n" - ("en" is locale)
112: "p"
111: "o"
111: "o"
new Uint8Array([162, 7, 254, 0, 0, 48]).buffer
254: Marks the end of the payload