在USB-NFC-Reader上访问卡仿真模式 [英] Accessing card-emulation mode on USB-NFC-Reader

查看:249
本文介绍了在USB-NFC-Reader上访问卡仿真模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个配备Android 4.2的Android平板电脑.该平板电脑没有NFC硬件.但是我有一个外部USB阅读器: ACR 1252U ,它带有 Android库.我在此处询问了一些常规设置问题.现在,它变得更具体了,我需要再问一个.在上一个问题中,我发现可以使用 ACS Android库来访问读取器的卡仿真功能.

I have an Android tablet with Android 4.2. This tablet does not have NFC hardware. However I have an external USB reader: ACR 1252U, that came with an Android library. I have asked some general questions of my setup here. Now that it gets more specific, I need to ask another one. In this previous question I found out, that I can use the ACS Android library to access the readers card emulation capabilities.

我的第一个目标是使阅读器模仿包含URL的NFC标签.任何支持NFC的Android手机均应能够扫描此仿真标签并自动打开浏览器.我已经对其进行了测试,并且它可以与真实(物理)标签一起使用.但是很遗憾,我无法正确模拟此标签...

My first goal is to make that reader emulate an NFC tag, that contains a URL. Any NFC-capable Android phone should be able to scan this emulated tag and automatically open the browser. I have tested it, and it works with a real (physical) tag. But unfortunately I am not able to emulate this tag correctly...

现在,我编写了一个Android应用程序,但遇到了麻烦.根据阅读器API(PDF) ,我可以通过发送命令使其进入卡仿真模式

Now I wrote an Android application, but I am stuck. According to the readers API (PDF), I can get it into card emulation mode by sending the command

E0 00 00 40 03 01 00 00

当我这样做时,它会给我答案:

When I do this, it gives me the answer:

E1 00 00 00 03 01 01 01

这确认它处于卡仿真模式.现在,借助Android应用程序,我可以扫描仿真的标签,即该标签被识别为"NXP MIFARE Ultralight"标签.

This confirms, that it is in card emulation mode. With an Android application I now can scan the emulated Tag, which says, that this is recognized as a "NXP MIFARE Ultralight" tag.

我现在的问题是,如何使用URL来填充标签.根据阅读器API(第5.10.3节),我需要发送命令:

My problem now is, how to feed the tag with a URL. According to the reader API (section 5.10.3), I need to send the command:

E0 00 00 60 13 01 01 00 0F D1 01 0B 55 01 67 6F 6F 67 6C 65 2E 63 6F 6D

其中D1 01 0B 55 01 67 6F 6F 67 6C 65 2E 63 6F 6D是NDEF消息,其中包含URL" http://www.google.com ".我使用以下Android Java代码创建了此NDEF消息:

where D1 01 0B 55 01 67 6F 6F 67 6C 65 2E 63 6F 6D is the NDEF message that contains the URL "http://www.google.com". I created this NDEF message using this Android Java code:

String target_url = "http://www.google.com";
Uri uri = Uri.parse(target_url);
NdefRecord recordNFC = NdefRecord.createUri(uri);
NdefMessage message = new NdefMessage(recordNFC);

我的Android手机上的应用程序读取了NFC标签,内容如下:

An application on my Android phone, that reads NFC tag says the following:

如您所见,URL被保存在仿真标记中.

As you can see, the URL is saved on the emulated tag.

  • 那我的手机浏览器为什么不打开URL?
  • 我想念什么吗?我的命令错了吗?
  • 为什么会有一些?"字符?

推荐答案

您正在使用的命令,

E0 00 00 60 <Lc> 01 01 <Byte address> <Length> <Data>

从模拟的NFC论坛2类标记的块3开始写入数据字节.因此,字节地址0x00寻址块3的第一个字节.

writes data bytes starting at block 3 of the emulated NFC Forum Type 2 tag. Thus, the byte address 0x00 addresses the first byte of block 3.

您面临的问题是,您仅从块3(字节0)开始编写NDEF消息本身.但是,NFC论坛2类标签需要更多元数据.具体来说,块3是功能容器块.对于ACR1252U提供的特定内存布局,CC块需要填充值

The problem that you are facing is that you only write the NDEF message itself starting at block 3 (byte 0). However, an NFC Forum Type 2 tag needs further metadata. Specifically, block 3 is the capability container block. For the specific memory layout presented by the ACR1252U, the CC block would need to be filled with the value

  • E1 10 06 00(如果应允许写访问权限)或
  • E1 10 06 0F(如果其他NFC设备应将该标签视为只读标签).
  • E1 10 06 00 (if write access should be allowed) or
  • E1 10 06 0F (if other NFC devices should treat the tag as read-only).

E1是表示这是NFC论坛标签的幻数,10指的是NFC论坛2类标签操作规范定义的数据映射的1.0版(当前版本),而06表示该标签共有12个数据块.

E1 is the magic number indicating that this is an NFC Forum tag, 10 refers to version 1.0 (the current version) of the data mapping defined by the NFC Forum Type 2 Tag Operation specification, and 06 indicates that the tag has a total of 12 data blocks.

此外,您需要将NDEF消息包装到NDEF Message TLV块中. NDEF消息TLV块具有标签0x03.因此,包装的NDEF消息将如下所示:

Further, you need to wrap the NDEF message into an NDEF Message TLV block. The NDEF Message TLV block has the tag 0x03. Thus, the wrapped NDEF message would look like this:

03 0F D1010B5501676F6F676C652E636F6D

您需要编写的标签存储器如下所示:

The tag memory, that you need to write would therefore look like this:

E1 10 06 00
03 0F D1 01
0B 55 01 67
6F 6F 67 6C
65 2E 63 6F
6D         

最后,应通过在结尾处放置一个终结器TLV(标记0xFE,没有长度),然后用零(0x00)填充其余字节,以将标记存储器填满整个块.这也适用于数据已经与完整块对齐,但是在数据末尾还有其他(空)块的情况.

Finally, you should fill the tag memory to full blocks by placing a Terminator TLV (tag 0xFE, no length) at the end and filling the remaining bytes with zeros (0x00). This also applies to the case where the data is already aligned to full blocks but there is further (empty) blocks beyond the end of your data.

E1 10 06 00
03 0F D1 01
0B 55 01 67
6F 6F 67 6C
65 2E 63 6F
6D FE 00 00

因此,您想使用以下write命令将数据存储在模拟的Type 2标签上:

Thus, you would want to use the following write command to store the data on the emulated Type 2 tag:

E0 00 00 60 1C 01 01 00 18 E1 10 06 00 03 0F D1 01 0B 55 01 67 6F 6F 67 6C 65 2E 63 6F 6D FE 00 00

这篇关于在USB-NFC-Reader上访问卡仿真模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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