View Source libnfc_ex

This package provides a NIF binding to libnfc and some Elixir boilerplate for convenient & more idiomatic use.

Status

This library was designed to detect and track the presence of ISO/IEC 14443 Type A passive NFC targets from an Elixir application. Its original use-case was a Raspberry-based music box controlled by cheap passive NFC tags detectable by a PN532 NFC HAT. The adaptation of libnfc functions as well as design of the surrounding Elixir API is so far limited to support this use-case, yet extending the library for other NFC modulations should be relatively straightforward.

  • ✅ Listing & opening NFC devices
  • ✅ ISO 14333 Type A passive target selecting & tracking

Not implemented:

  • Other modulations
  • Initiator API: Polling, writing, transceiving
  • Target API

Dependencies

  • libnfc
  • make
  • working C11 compiler, e.g. gcc

Installing libnfc from source

On Debian and derived Linux systems:

sudo apt-get install build-essentials automake autoconf
sudo apt-get install libusb-dev
git clone https://github.com/nfc-tools/libnfc
cd libnfc
autoreconf -vis
./configure --prefix=/usr --sysconfdir=/etc
make -j4
sudo make install

Visit libnfc for details.

Installation

def deps do
  [
    {:libnfc_ex, "~> 0.1.0"}
  ]
end

Usage

{:ok, device} = LibNFC.open()

{:ok, target_info} =
  LibNFC.initiator_select_passive_target(device)

IO.puts("Target #{LibNFC.Utils.uid_hex(target_info["uid"])} in range")

Alternatives