定义 NDEF 消息 [英] Defining a NDEF Message

查看:45
本文介绍了定义 NDEF 消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Raspberry Pi 和 RFID-RC522 板开展 Python 项目.作为 NFC 标签,我使用 NXP NTAG213.我现在的计划是在标签上存储链接.我可以毫无问题地读/写它们.但我不明白如何为标签上存储的数据定义 NDEF 标头.

当我用智能手机在标签上写一个链接并用我的程序读取它时,标签上存储的数据如下所示:

网址http://www.gmx.at"的 NDEF 标头是

[3, 11, 209, 1, 7, 85, 1, ... (数据)]

当我编写另一个链接时,我意识到其中一些参数会发生变化,但有些参数仍然保持不变.

我发现了这个教程它描述了 NDEF 标头的不同字段,但我仍然不知道如何设置它们以存储指向网站的链接.

如果有人能描述我需要如何正确计算/定义链接的参数,我会很高兴.

解决方案

为了了解 NDEF 格式以及 NDEF 格式的数据如何存储在 NFC Forum Type 2 标签(这是由NTAG213),建议您阅读以下NFC论坛规范:

您从标签中读取的数据是一个 NDEF 消息 TLV 对象,其中包含一个 NDEF 消息,该消息由一个 URI 记录组成.

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:

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.

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.

解决方案

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:

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 Message TLV:

    0x03             TLV tag = NDEF Message TLV
      0x0B           TLV length = 11 bytes
      0xD1 ... 0x74  TLV value = NDEF message
    

    This means that the tag contains an NDEF message with a length of 11 bytes. The NDEF message is 0xD1 ... 0x74.

  • NDEF Message:

    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
    

    This means that the NDEF message consists of one URI record (type name urn:nfc:wkt:U) following the URI Record Type Definition.

  • URI record payload:

    0x01             Identifier byte = URI prefix "http://www."
    0x67 ... 0x74    URI field (UTF-8 encoded) = "gmx.at"
    

    This means that the URI record points to the URI "http://www.gmx.at".

这篇关于定义 NDEF 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆