Search code examples
androidnfcmifarecontactless-smartcardhce

MIFARE Ultralight emulation on Android


I need to create a simple Android application that emulates a Mifare Ultralight card. It should only "sends" data (to be taken from an editable buffer) when is read and write on the same buffer when it receives data.

But I don't know how to emuate this kind of communication between reader and emulated card. I already read about Android HCE, but I don't know how to implement Mifare Ultralight communication (ISO 14443 type A).

I also read this, this and of course I read about Android HCE.

I really don't know how communication must be implemented. Suppose that I've already registered and correctly setup android service for HCE etc., from the Android Developer Website (with basic application) I can send for the first time data when emulator is read.

But for MIFARE Ultralight card emulation:

1) Should I use the basic NFC methods after get the buffer?

2) How to enable communication between the card emulator and the reader?

3) Where these methods for read and write must be used?

EDIT: Let's imagine a MIFARE wallet.... So, like if I need to store and get data of cards. At mifare4mobile website they told me that SDK is available but anybody know how and where.

Thank you!


Solution

  • It's simply not possible to emulate MIFARE Ultralight on top of Android HCE. Android HCE allows emulation of ISO/IEC 7816-4 APDU based applications on top of the ISO/IEC 14443-4 transport protocol only.

    MIFARE Ultralight uses only lower protocol layers. Specifically, the Ultralight communication protocol sits directly on top of the framing defined in ISO/IEC 14443-3 Type A without the additional transport protocol. As a consequence, it's impossible to emulate that using a HCE service on Android.

    This does not mean that the hardware is incapable of emulating the MIFARE Ultralight protocol. I've verified that at least Broadcom NFC controllers are capable of emulating that protocol. However, implementing that would require quite extensive modifications of the NFC stack and is, consequently, not possible on unmodified, of-the-shelf Android devices.

    Also see Emulate Mifare card with Android 4.4