Search code examples
androidnfcandroid-4.4-kitkathce

Write NFC-A host-based card emulation for CPR 40.30 reader


HCE was implemented in the Android 4.4, but there is very little information regarding how to write in an emulated card.

  • I have CPR 40.30 reader
  • This reader came along with some sample NFC cards. I read these cards using a NFC card reading app.

NFC card details that are compatible with CPR 40.30

IC manufacturer: NXP Semiconductors

IC type:
MIFARE Ultralight (MF0ICU1)

-- NDEF ------------------------------

NFC data set storage not present:
Maximum NDEF storage size after format: 46 bytes

-- EXTRA ------------------------------

 Memory size:
64 bytes total memory
* 16 pages, with 4 bytes per page
* 48 bytes user memory (12 pages)

-- TECH ------------------------------

 Technologies supported:
ISO/IEC 14443-3 (Type A) compatible
ISO/IEC 14443-2 (Type A) compatible

Android technology information:
Tag description:
* TAG: Tech [android.nfc.tech.NfcA, android.nfc.tech.MifareUltralight, android.nfc.tech.NdefFormatable]
android.nfc.tech.NdefFormatable
android.nfc.tech.MifareUltralight
android.nfc.tech.NfcA
* Maximum transceive length: 253 bytes
* Default maximum transceive time-out: 2000 ms

Detailed protocol information:
ID: 04:AC:91:52:CB:29:80
ATQA: 0x4400
SAK: 0x00

I want to write HCE code and want my Android phone to act like a card which can be read by CPR 40.30 reader. I'm assuming the HCE code should emulate a card with the above mentioned specifications, as the above NFC card can be read by the reader.

The only useful sample code I have found till now for HCE is this, but it uses ISO-DEP. I want to use NFC-A (ISO/IEC 14443 type A) instead.

How can I write code to emulate an NFC-A card?

Referred Links:


Solution

  • Android only supports emulation of ISO/IEC 7816-4 application structures on top of ISO-DEP (ISO/IEC 14443-4). The Android API does not provide any means to access emulation of lower protocol layers.

    From the developer guide:

    Specifically, Android 4.4 supports emulating cards that are based on the NFC-Forum ISO-DEP specification (based on ISO/IEC 14443-4) and process Application Protocol Data Units (APDUs) as defined in the ISO/IEC 7816-4 specification.

    Note that the CPR 40.30 should support ISO-DEP too.