Skip to content

NFC Type A Emulator is an Android application for emulating NFC Type A cards (ISO 14443-3A / ISO 14443-4A) using compatible devices. It lets developers, researchers, and hobbyists test NFC readers without requiring the original physical card.

Notifications You must be signed in to change notification settings

Lankow/nfc-emulator

Repository files navigation

NFC Type A Emulator – Android App

About

NFC Type A Emulator is an Android application for emulating NFC Type A cards (ISO 14443-3A / ISO 14443-4A) using compatible devices. It lets developers, researchers, and hobbyists test NFC readers without requiring the original physical card. The app exposes an HTTP API that can be driven from the device itself or from the included Node.js external server, and both accept a single request containing multiple command groups.

Prerequisites

  • Android device with NFC capability (Android 5.0 or higher).
  • Android Studio or the Android SDK with Java 11+.

Building

./gradlew assembleDebug

The generated APK will be located in app/build/outputs/apk/debug/.

You can also open the project in Android Studio and run it directly on a connected device.

Usage

  1. Install the app on an NFC-capable Android device.
  2. Enter up to two Application Identifiers (AIDs) in the provided fields.
  3. Tap Save AIDs and hold the device near an NFC reader.
  4. The communication log at the bottom shows APDU requests (red) and responses (green), along with scenario state changes and NFC activation or deactivation events.

HTTP Control API

The app exposes a lightweight HTTP API that allows remote control over AIDs, logging and scenarios. Enable the server from the Server screen and note the device's IP address and chosen port. Commands are sent as POST requests with a JSON body to http://<DEVICE_IP>:<PORT>/.

The current application status can be queried with GET /STATUS, which returns one of IDLE, READY, RUNNING, FINISHED, STOPPED, SILENCED or ERROR.

Command structure

Commands are grouped by top-level keys. A request may include any combination of the following objects: Aid, Comm, Scenarios, Filters, and Reset. Each object mirrors the fields described below. For compatibility, older payloads that use a single Type field are still accepted.

Example combining AID registration and log clearing:

curl -X POST http://<DEVICE_IP>:<PORT>/ -H "Content-Type: application/json" \
  -d '{"Aid":{"Add":"A0000002471001"},"Comm":{"Clear":true}}'

For a broader example that registers AIDs, adds a scenario, applies a filter and clears the log in one request, see example-server/multi-command-request.json and post it with:

curl -X POST http://<DEVICE_IP>:<PORT>/ -H "Content-Type: application/json" \
  -d @example-server/multi-command-request.json

Aid

Manage registered Application Identifiers.

{
  "Aid": {
    "Add": ["A0000002471001", "A0000002471002"],   // optional AIDs to add
    "Remove": ["A0000002471003"],                  // optional AIDs to remove
    "Clear": false                                 // set true to unregister all AIDs
  }
}

Add and Remove accept either a single string or an array of strings.

Comm

Control the communication log and scenarios.

{
  "Comm": {
    "Clear": false,            // clear the log when true
    "Save": true,              // save log to file when true
    "Mute": false,             // mute/unmute communication
    "CurrentScenario": "Start" // "Start", "Stop" or "Clear"
  }
}

Requests receive a simple 200 OK response. Additional command types may be introduced in future versions.

Scenarios

Create or manage scenarios. Steps may be of type Select, which waits for an AID selection, or RequestResponse, which returns a predefined response when a matching APDU request is received. Use needsSelection to require that a Select step has completed before the request is matched.

{
  "Scenarios": {
    "Add": [
      {
        "name": "MyScenario",
        "steps": [
        {
          "name": "Select",
          "type": "Select",
          "aid": "F0010203040506",
          "singleSelect": false
        },
        {
          "name": "Ping",
          "type": "RequestResponse",
          "request": "00B0950000",
          "response": "6A82",
          "needsSelection": true
        }
      ]
    }
    ],
    "Remove": ["OldScenario"],    // optional names to remove
    "Clear": false,                // clear all scenarios when true
    "Current": "MyScenario"       // set current scenario
  }
}

Add and Remove accept arrays; Add may also be a single scenario object and Remove a single name.

Example external server

A minimal Node.js implementation of this HTTP API is provided in example-server/. POST / requests queue command payloads and the app retrieves them by polling GET /. The server logs each request to stdout so you can see when commands are queued and dispatched.

Code Structure

  • MainActivity – Compose UI and AID configuration.
  • TypeAEmulatorService – Handles APDU commands from the NFC reader.
  • CommunicationLog – Stores APDU exchanges for display.

Debugging

Verbose debug logs are written to Logcat using tags like AidManager, ScenarioManager, ServerConnMgr, InternalServer, ServerJsonHandler, TypeAEmulatorService, CommunicationLog, and MainActivity. Use adb logcat to observe AID registration, scenario execution, server traffic, and NFC APDU flow in real time.

About

NFC Type A Emulator is an Android application for emulating NFC Type A cards (ISO 14443-3A / ISO 14443-4A) using compatible devices. It lets developers, researchers, and hobbyists test NFC readers without requiring the original physical card.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published