• Stars
    star
    171
  • Rank 222,266 (Top 5 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interaction with external NFC readers in Android

External NFC Service (native style) for Android

Library for interaction with ACS NFC readers over USB; external NFC support Android devices.

Features:

  • External NFC reader management and interaction
  • Parallell use of external and/or internal NFC (i.e. in the same activity, both enabled at the same time)
  • Support for both tags and Android devices (Host Card Emulation), simultaneously
  • Use of forked android.nfc classes (Ndef, MifareUltralight, IsoDep, etc) for Android 10+ support.

As this project very much simplifies implementation for use-cases requiring external NFC readers, it saves a lot of development time (2-8 weeks depending on use-case and previous knowledge).

Alternative

Most of the code within this repository has been refined into Entur's android-nfc-lib. This does not include

  • NDEF handling
  • Bluetooth reader

License

Apache 2.0

Usage

This repository contains source code for

There is also a Host Card Emulation client app for use with the Basic client app as well as Android-to-Android communication.

External NFC reader API

The API defines

  • broadcast actions
    • service start / stop and status
    • reader open / close and status
    • tag connect / disconnect
  • extras objects for interaction with readers
    • disable beeps
    • display text
    • configure NFC tech types (PICC)
    • enable/disable LEDs
    • run custom commands
    • and more..
  • abstract activities for interaction with built-in and external NFC (simultaneously)
  • these currently depend on the NDEF Tools for Android project.
  • Programmatically start and stop the service (see methods startService() and stopService() in the NfcExternalDetectorActivity class in for an example).

Supported readers

Currently the ACS readers

are supported and must be connected to your Android device via an On-The-Go (OTG) USB cable.

Additional ACR readers might work depending on their command set, however custom reader commands will (like LED, beep etc) will not be available.

Supported tag technology

The following tags are supported by the service

  • Mifare Ultralight familiy
    • Mifare Ultralight
    • NTAG 21x with FAST READ
  • Mifare Classic and friends
    • Not recommended due to security and compatibility issues
  • Desfire EV1 tags
  • Host Card Emulation - interaction with Android devices.

The readers can for the most part can be enabled for all tag types at the same time, including Host Card Emulation.

Please note:

  • Some readers only support a subset of the above tags
  • For ACR 122U the Mifare Classic does not work well.
  • No built-in NDEF support for Desfire EV1 cards

Configuration options

  • assume all NTAG21x Mifare Ultralight targets. This improves read speed, particullary for the tags which have legacy equivalents, like NTAG 210 and 213
  • read only tag UIDs, ignore other tag data. This improves read speed.
  • read NDEF data automatically
  • read UID for Desfire EV1 targets automatically

Reader connection

Note that not all Android devices actually have an USB hub, in which case no USB devices work.

Does the ACR reader not light up when connected to your device, even after the service asks for USB permissions? The ACR reader shuts down if there is not enough battery, so try charging your battery more, or connect external power.

If you are using external power, be aware that the connection order (device, reader, power) might be important. Known symptom:

  • Seeing an USB permissions window that disappears rather quickly.

Tag detection

There is quite a few types of tags out there, and if your tag type is not recognized, please let me know. If the tag does not register at all, make sure that auto polling is configured, and that the right protocols are enabled. Use the below utility apps for tweaking your reader settings.

Reader setting utility apps

You might be interested in

for configuration of your reader. Approximately the same configuration options are available using this API.

See also

This project contains adapted code from

  • NFC Tools for Java
  • SMARTRAC SDK for Android NFC NTAG

History

  • 2.1.0: Improve bluetooth handling, various bug fixes and a few improvements.
  • 2.0.0: Moved to wrapped android.nfc NFC android classes + various refactorings.
  • 1.0.0: Library using native NFC android classes

More Repositories

1

3d-bin-container-packing

A variant of the Largest Area Fit First (LAFF) algorithm + brute force algorithm
Java
391
star
2

ndef-tools-for-android

NDEF Tools for Android
Java
139
star
3

desfire-tools-for-android

Open source MIFARE DESFire EV1 NFC library for Android
Java
75
star
4

mockito-soap-cxf

Test SOAP services using JUnit and Mockito
Java
49
star
5

xswi

The simple, standalone XML Stream Writer for iOS
Objective-C
30
star
6

Fagmote

Java
28
star
7

aotc-gradle-plugin

Ahead-of-Time Compilation in Gradle projects.
Java
16
star
8

nfc-tags

15
star
9

nfc-eclipse-plugin

Eclipse plugin for working with NDEF in NFC tags
Java
14
star
10

java-jwt-benchmark

Project for benchmarking popular Json Web Token (JWT) frameworks for Java using JMH.
Java
10
star
11

maven-cache-github-action

Github Action for caching of the Maven repository (at ~/.m2)
TypeScript
10
star
12

sesseltjonna-csv

World's fastest CSV parser / databinding for Java
Java
10
star
13

json-log-filter

World's fastest JSON filter for the JVM
Java
7
star
14

mockito-rest-spring

REST web-service mocking utility for Spring
Java
6
star
15

android-nfc-lifecycle-wrapper

Library for NFC on Android using androidx lifecycle extensions and functional interfaces.
Java
6
star
16

json-log-domain

Library supporting JSON-logging with Logback and Stackdriver
Java
6
star
17

jackson-syntax-highlight

Syntax highlighting (via ANSI) for JSON output using Jackson
Java
6
star
18

logback-logstash-syntax-highlighting-decorators

Syntax highlighting JSON decorator for logstash-logback-encoder
Java
6
star
19

google

This is my working repository for Google APIs.
HTML
4
star
20

async-stax-utils

Asynchronous StAX-utils
Java
4
star
21

xml-log-filter

High-performance filtering of to-be-logged XML
Java
4
star
22

mule-module-dxpath

Dynamic XPath module for Mule ESB
Java
3
star
23

gtfs-neo4j-import

GTFS Neo4j import
Java
3
star
24

gtfs-databinding

High-performance reading of zipped GTFS files
Java
3
star
25

gradle-jfrog-artifactory-multimodule-library-example

Pattern for multimodule open-source library using gradle and JFrog Artifactory
Java
2
star
26

MIFAREClassicRefactor

Java
2
star
27

csv-benchmark

Benchmarking high-performance open source CSV parsers using JMH
Java
2
star
28

unzip-csv

High-performance (i.e. multi-threaded) unpacking and processing of CSV files directly from ZIP archives.
Java
1
star
29

inline-histogram

Inline text histogram
Java
1
star
30

spring-boot-maven3-jdk8-centos

Openshift docker image with s2i file and descriptor.
Shell
1
star
31

gradle-cache-cleaner

Removed unused dependencies from Gradle cache
Java
1
star
32

datasets-json-benchmark

Json parser benchmarks for specific datasets
Java
1
star
33

skjolber.github.io

Thomas
JavaScript
1
star