简体   繁体   English

Android:卡仿真 - 使用PN532 nfc模块读取ndef消息

[英]Android: card emulation - read ndef message with PN532 nfc module

I have an LG D320n Android phone, elechouse's PN532 nfc module and Stollmann's NFCPlayer with which I can read NFC tags properly. 我有一个LG D320n Android手机,elechouse的PN532 nfc模块和Stollmann的NFCPlayer,我可以正确阅读NFC标签。

I tested a sample from here: https://github.com/grundid/host-card-emulation-sample 我从这里测试了一个样本: https//github.com/grundid/host-card-emulation-sample

It works fine, when I read one Android device as tag with another Android device as reader. 它工作正常,当我读取一个Android设备作为标签与另一个Android设备作为阅读器。 But I can not read the Android device as tag with PN532 reader through NFCPlayer. 但我无法通过NFCPlayer将Android设备作为PN532阅读器的标签阅读。 I want reader to read an NDEF message from the Android device acting as a tag, but NFCPlayer doesn't even recognise the Android device. 我希望读者从Android设备读取NDEF消息作为标签,但NFCPlayer甚至不能识别Android设备。 I think I have to write some modifications on the Android side but I can't figure it out what to do. 我想我必须在Android方面做一些修改,但我无法弄明白该怎么做。 I think I don't have enough knowlege about how NFC communication and HCE work, even though I read this: https://developer.android.com/guide/topics/connectivity/nfc/hce.html 我想我对NFC通信和HCE的工作方式知之甚少,尽管我读过这篇文章: https//developer.android.com/guide/topics/connectivity/nfc/hce.html

I would really appreciate any guideline that could help me understand what am I missing here. 我真的很感激任何可以帮助我理解我在这里缺少什么的指南。

The grundid example app should be discovered by NFCPlayer as a "legacy tag" (tab "R/W: Legacy") as it does not implement the NDEF abstraction layer. NFCPlayer应该将grundid示例应用程序发现为“遗留标记”(标签“R / W:Legacy”),因为它没有实现NDEF抽象层。 On that tab, you can exchange PDUs (APDUs in the case of HCE) with the emulated smartcard. 在该选项卡上,您可以使用模拟智能卡交换PDU(在HCE情况下为APDU)。 A valid APDU for the example app would be 示例应用程序的有效APDU将是

00 A4 04 00 07 F0010203040506 00

You can send this APDU by typing it into the PDU field and clicking on the "Exch. PDU" button. 您可以通过在PDU字段中键入并点击“Exch.PDU”按钮来发送此APDU。 Note that the grundid HCE app does not even implement ISO/IEC 7816-4 response APDUs. 请注意,grundid HCE应用程序甚至不实现ISO / IEC 7816-4响应APDU。 Hence, you may run into troubles with some contactless smartcard readers. 因此,您可能会遇到一些非接触式智能卡读卡器的麻烦。

If you want your emulated smartcard to be discoverabe by NFCPlayer as NFC Forum Type 4 tag containing an NDEF message (tab "R/W: NDEF"), you would need to implement the NFC Forum Type 4 Tag Operation specification (as defined by the NFC Forum . This specification defines how data must be stored on an (emulated) ISO/IEC 14443-4 smartcard to be interpreted as NDEF tag. As a starting point you could use this NDEF on HCE example app (though, the quality and reliability of that code is questionable). This example implements the smartcard filesystem for storing NDEF data. 如果您希望模拟智能卡被NFCPlayer发现为包含NDEF消息的NFC论坛类型4标签(选项卡“R / W:NDEF”),则需要实施NFC论坛类型4标签操作规范(由NFC论坛 。该规范定义了数据必须如何存储在(仿真的)ISO / IEC 14443-4智能卡上才能被解释为NDEF标签。作为起点,您可以在HCE示例应用程序上使用此NDEF (但质量和可靠性)该代码是有问题的。这个例子实现了智能卡文件系统来存储NDEF数据。

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

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