1

I have my ACR122U in card emulation mode and an Android application which has to start when the emulated tag is detected and send a message, for example: "Hello".

When emulate the tag and scan it with my phone it successfully opens the application by catching it with the android.nfc.action.TAG_DISCOVERED intent filter.

I have three questions about this situation.

Question 1

I read that the TAG_DISCOVERED has the lowest priority and you can't be sure your application will be selected after a tag discovery. Using card emulation, is the only way to catch an intent by using the android.nfc.action.TAG_DISCOVERED intent filter, or is there an other (better) way?

Question 2

I think this question is related to question 1. When i use the tgSetData command on the PN532 i gues i just send plain text to the android device. For example: FF 00 00 00 08 D4 8E 61 73 64 61 73 64 sends the string "asdasd". Is it also possible in card emulation to send a NDEF message or something similar? I suppose if that's possible Question 1 is answered to because you can use the NDEF intent filter.

Question 3

This question is about the application select part. From the first tgGetData i recieve the bytes 00 a4 04 00 07 d2 76 00 00 85 01 00. I read that this is the application select. I also noticed that won't get this procedure when the Android application is opened. I gues that's probably because the application is opened in the front. But how do i interact with this response when my application isn't in the front? My current interaction is this:

  • getData D4 86
  • Response = D5 87 00 00 A4 04 00 07 D2 76 00 00 85 01 01 00
  • setData D4 8E 61 73 64 61 73 64 (just a random string)
  • Response = D5 8F 00 90 00
  • Use send- / getData to transmit data.

This doesn't work when the application isn't openend. Is this because this procedure is wrong or maybe my handling in Android is wrong?

Any information is welcome related to the questions.

Many thanks!

Regards.

4

1 回答 1

2

问题 1

与前台调度一起使用TAG_DISCOVERED非常好。在这种情况下,您的活动优先于其他应用程序,并且TAG_DISCOVERED是一个简单的包罗万象的机制。

但是,您通常不应TAG_DISCOVERED在清单中用作意图过滤器。在这种情况下TAG_DISCOVERED,作为一个后备,只捕获未被任何其他应用程序的意图过滤器处理的标签。(实际上TAG_DISCOVERED是为了向后兼容非常有限的第一代 Android NFC API。)

在这种情况下,您可以将意图过滤器与or/andTECH_DISCOVERED的技术过滤器文件结合使用。(ACR122U 将在 IOS/IEC 14443 Type A (= ) 之上模拟 ISO/IEC 14443-4 卡 ( = )。)NfcAIsoDepIsoDepNfcA

问题2

发送 NDEF 消息并不容易,但可以使用您的模拟标签作为 NFC 标签(包含 NDEF 消息)。ACR122U 模拟 ISO/IEC 14443-4 标签。因此,您需要在标签端实现 NFC Forum Type 4 标签操作规范,以便将模拟标签用作包含 NDEF 消息的 NFC Forum Type 4 标签。有关详细信息,请参阅NFC 论坛免费提供的规范。您可能还想查看 ISO/IEC 7816-4,它定义了基于 APDU 的协议以及通过 ISO-DEP 传输协议使用的应用程序结构。

一旦你实现了这样一个标签,你当然可以使用NDEF_DISCOVERED意图过滤器。

问题 3

有关 APDU 和智能卡应用程序结构如何工作的信息,请参见 ISO/IEC 7816-4。您从 Android 设备收到的命令

00 A4 04 00 07 D2 76 00 00 85 01 01 00

是 NFC Forum Type 4 Tag 应用程序(1.1 版)的 SELECT 命令。Android 设备将自动发出该命令(通常还有一些进一步的命令,请参阅 NFC 论坛 Type 4 标签操作规范),以检查标签是否包含 NDEF 消息。当您收到这样的命令时,您应该根据 ISO/IEC 7816-4 使用适当的状态代码来回答(例如6A82,这意味着未找到文件或应用程序)。

虽然通过 ISO-DEP 传输非标准(即非 ISO/IEC 7816-4)帧(如您的情况下的纯 ASCII 文本)有效,但我强烈建议遵守 ISO/IEC 7816-4 以便与 Android 顺利工作设备。

于 2014-08-21T07:40:45.060 回答