简体   繁体   English

如何在NFC 4类标签仿真上组织大数据文件

[英]how to organize large data file on a NFC type 4 tag emulation

I'm working on an application where I store data on a 4Mbit dataflash and read it out with a smartphone via NFC. 我正在开发一个将数据存储在4Mbit数据闪存上并通过NFC用智能手机读出的应用程序。 To do this I use a NFC frontent (AS3953) and a microcontroller to emulate a Type 4 tag. 为此,我使用NFC前端(AS3953)和微控制器来模拟Type 4标签。 It would be convenient to split the data into 264 bytes chunks (page-size of flash) and read them out sequentially. 将数据拆分为264字节的块(闪存的页面大小)并顺序读取它们会很方便。

What is then the better structure: one big NDEF file with many records of 264 bytes each, or many single elementary files under one dedicated file? 那么更好的结构是什么:一个大的NDEF文件,每个记录有264个字节的许多记录,或者一个专用文件下的许多单个基本文件?

Thanks for inputs, Andreas 感谢您的投入,Andreas

This heavily depends on what you want to achieve with your solution and what platforms you target: 这在很大程度上取决于您要通过解决方案实现的目标以及目标平台:

  1. You can build an NFC tag that follows the NFC Forum Type 4 tag specification and uses only the NDEF data abstraction layer. 您可以构建遵循NFC论坛4类标签规范并仅使用NDEF数据抽象层的NFC标签。

    • Your application will be interoperable with all devices that support reading and writing NDEF messages on NFC Forum Type 4 tags. 您的应用程序将与支持在NFC论坛4类标签上读写NDEF消息的所有设备互操作。 This includes all current major mobile OS platforms that support NFC and the NFC Web API. 这包括支持NFC和NFC Web API的当前所有主要的移动OS平台。
    • You are limited to 65534 bytes of NDEF data (including record headers). NDEF数据(包括记录头)限制为65534字节。
    • You cannot really control how a device reads or writes data from/to the NDEF file. 您实际上无法控制设备如何从NDEF文件读取数据或将数据写入NDEF文件。 Specifically, even if you segment the file into several NDEF records, there is no means to control in what segments the file will be read/written. 特别是,即使将文件分段为多个NDEF记录,也无法控制将文件读/写为哪些分段。 (Note that you can control the maximum data field size of APDUs, but there is nothing that prevents an NFC device to read/write even smaller chunks.) (请注意,您可以控制APDU的最大数据字段大小,但是没有什么可以阻止NFC设备读取/写入甚至更小的块。)
    • An NFC device (eg Android does this) will typically read the whole NDEF message upon scanning the tag in order to perform automatic actions (eg start an app). NFC设备(例如Android这样做)通常会在扫描标签后读取整个 NDEF消息,以执行自动操作(例如启动应用程序)。
  2. You can build an NFC tag that follows the NFC Forum Type 4 tag specification and uses a combination of the NDEF data abstraction layer (eg to store information that permits your app to be started automatically and to identify the prorietary protocol) and proprietary data files (as specified in the NFC Forum Type 4 Tag Operation specification). 您可以构建遵循NFC论坛4类标签规范并结合使用NDEF数据抽象层(例如,存储允许您的应用自动启动并标识专有协议的信息)和专有数据文件的NFC标签( (如NFC论坛4型标签操作规范中所指定)。

    • Proprietary data files are not accessible on several platforms (eg Windows Phone 8, NFC Web API). 在多个平台(例如Windows Phone 8,NFC Web API)上无法访问专有数据文件。 They can be accessed on Android and BlackBerry devices though. 但是,可以在Android和BlackBerry设备上访问它们。
    • Besides the automatic NDEF abstraction that is typically handled by the operating system, you will need to manually implement commands to identify and access the prorietary data files (eg on Android using the IsoDep class). 除了通常由操作系统处理的自动NDEF抽象外,您还需要手动实施命令以识别和访问所有权数据文件(例如,在使用IsoDep类的Android上)。
    • Using those prorietary data files, you could structure your memory to use eg one file per page. 使用这些专有数据文件,您可以构建内存结构,例如每页使用一个文件。
    • You are not limited to 65534 bytes but instead can have several files that have up to 65534 bytes each. 您不限于65534个字节,而是可以有多个文件,每个文件最多65535个字节。
    • An NFC device will typically only read the NDEF file by default when scanning the tag in order to perform automatic actions. 默认情况下,NFC设备通常在扫描标签时默认情况下仅读取NDEF文件以执行自动操作。 Proprietary files will usually be ignored. 专有文件通常将被忽略。
    • Instead of using the proprietary files feature of the NFC Forum Type 4 Tag Operation specification, you could just as well create a separate application (under a different DF name/AID) that permits you to access your data memory (either through ISO 7816-4 standardized commands our through custom commands). 除了使用NFC论坛4型标签操作规范的专有文件功能外,您还可以创建一个单独的应用程序(使用不同的DF名称/ AID),该应用程序允许您(通过ISO 7816-4)访问数据存储器通过自定义命令标准化命令)。
  3. You can create a completely custom protocol based on ISO 14443/ISO 7816-4. 您可以基于ISO 14443 / ISO 7816-4创建完全自定义的协议。

    • You won't (or only partially) have the capabilities of an NDEF tag (eg triggering of automatic actions, like starting a specific app). 您将(或仅部分地)具有NDEF标签的功能(例如,触发自动操作,例如启动特定应用程序)。
    • Your app will not be compatible to Windows Phone 8 (or any other platform that only permits high-level access to tags through NDEF abstraction). 您的应用程序将与Windows Phone 8(或仅允许通过NDEF抽象高层访问标签的任何其他平台)不兼容。
    • You don't have the protocol overhead introduced by implementing the NFC Forum Type 4 Tag Operation specification. 您没有实现NFC论坛4类标签操作规范所引入的协议开销。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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