Module acr122u

A pcsc_apdu_transform implementation which handles proprietary APDU formats used by the ACR122(U) and compatible NFC readers.

Behaviours: pcsc_apdu_transform.

Description

A pcsc_apdu_transform implementation which handles proprietary APDU formats used by the ACR122(U) and compatible NFC readers.

This includes control commands which can manage the buzzer and LEDs and change parameters which are relevant with or without a card present. To use these commands without requiring a card, use the direct share mode (with empty protocols list).

To use direct control commands you may need to enable PCSC/CCID "escape" commands in the relevant driver configuration on your system.

This module is based on documentation from ACS available online at: https://www.acs.com.hk/en/download-manual/419/API-ACR122U-2.04.pdf

Data Types

command()

command() = get_firmware_version_command() | get_ats_command() | get_uid_command() | set_auto_buzzer_command() | led_buzzer_command() | iso7816:apdu_cmd()

felica_subtype()

felica_subtype() = felica212k | felica424k

get_ats_command()

get_ats_command() = get_ats

Retrieve an NFC card's Answer to Select (ATS) value.

get_ats_reply()

get_ats_reply() = {ok, binary()} | {error, term()}

get_firmware_version_command()

get_firmware_version_command() = get_firmware_version

Retrieves the firmware version.

get_firmware_version_reply()

get_firmware_version_reply() = {ok, binary()} | {error, term()}

Binary will contain an ASCII string like "ACR122U201".

get_uid_command()

get_uid_command() = get_uid

Retrieve an NFC card's UID or serial number.

get_uid_reply()

get_uid_reply() = {ok, binary()} | {error, term()}

led_buzzer_command()

led_buzzer_command() = {led_buzzer, Repeats::integer(), Initial::led_buzzer_state(), Final::led_buzzer_state()}

Control the LEDs and buzzer on the reader. This command will induce a repeating, alternating pattern between two states (initial and final), and then leave the LED and buzzer in the "final" state.

For example, to make the red LED turn on and stay on, use:
    {led_buzzer, 1, #{}, #{red => on}}
  
To make the red LED blink on and off 3 times at 200ms intervals, and then stay off at the end, use:
    {led_buzzer, 3, #{red => on, for => 200}, #{red => off, for => 200}}
  
To make the green LED flash once for 200ms and sound the buzzer, then turn off and stay off, use:
    {led_buzzer, 1, #{green => on, buzz => true, for => 200}, #{green => off}}
  

led_buzzer_reply()

led_buzzer_reply() = ok | {error, term()}

led_buzzer_state()

led_buzzer_state() = #{red => on | off, green => on | off, for => msec(), buzz => boolean()}

mifare_subtype()

mifare_subtype() = mifare1k | mifare4k | ultralight | mini

msec()

msec() = integer()

reply()

reply() = get_firmware_version_reply() | get_ats_reply() | get_uid_reply() | set_auto_buzzer_reply() | led_buzzer_reply() | iso7816:apdu_reply()

set_auto_buzzer_command()

set_auto_buzzer_command() = {set_auto_buzzer, on | off}

Set whether the reader will sound its buzzer automatically when an NFC card is detected.

set_auto_buzzer_reply()

set_auto_buzzer_reply() = ok | {error, term()}

Function Index

classify_emulated_atr/1Takes a decoded ATR and classifies whether it is one of the "emulated" card types which does not accept ISO7816 APDUs (but the ACR122U will translate certain APDUs for us).

Function Details

classify_emulated_atr/1

classify_emulated_atr(X1::iso7816:atr_info()) -> not_emulated | unknown | {mifare, mifare_subtype()} | topaz_jewel | {felica, felica_subtype()}

Takes a decoded ATR and classifies whether it is one of the "emulated" card types which does not accept ISO7816 APDUs (but the ACR122U will translate certain APDUs for us).


Generated by EDoc