Android 4.4.2, NFC reader PN532 and NFC card emulation

I developed a system that can read the NFC tag using a reader with a PN532 chip . It is working fine. I can read the Mifare Classic and Mifare Ultralight tags.

Now I would like to use a Nexus tablet with Android 4.4.2 to emulate a tag. I have no experience developing Android, but I think it is possible.

I have established an NFC connection in a Nexus tablet, but I think I need to download or write some application for emulating a tag and sharing NDEF.

What is the easiest way?

+1
source share
1 answer

It depends on which Nexus tablet you have:

  • Nexus 7 (first generation version / 2012): This device uses an NXP PN544 NFC controller. It seems that currently on these devices it is not possible to perform host-based emulation with Android 4.4+ (see this question and my answer here ).

  • Nexus 7 (Second Generation / 2013) and Nexus 10: These devices use the Broadcom NFC controller. Thus, you can use the Android 4.4 HCE API to emulate a contactless smart card.

With the Android HCE API, you emulate an ISO 14443-4 smart card, and you can only communicate using the application selection and APDU format defined in ISO 7816-4. First you create and register an HCE service (see API Guide). You can then handle the incoming APDUs using the processCommandApdu() service method (see this answer ).

If your reader-side application currently only handles MIFARE Classic and Ultralight, you will have to expand it to also communicate with smart cards based on ISO 14443-4 / APDU. (Emulation of non-APDU-based cards such as MIFARE Classic and Ultralight is not possible on top of the ANDroid HCE API.) PN532 usually handles most of this for you, so as soon as you find such a smart card (for example, using InListPassiveTarget ) it should automatically process the ISO 14443-4 transport protocol, and you can directly send APDU commands using the InDataExchange .

If you want to exchange NDEF messages through HCE as soon as you connect to the APDU-based network, you can implement the NFC Forum Type 4 tag operations specification (get it from the NFC Forum website ) in the Android HCE service to emulate a Type 4 NDEF tag.

+3
source

Source: https://habr.com/ru/post/1269599/


All Articles