ACR122U class
A class representing the ACR122U NFC reader, extending RFIDReader
capabilities.
The ACR122U class provides an interface to interact with the ACR122U NFC reader hardware, facilitating operations such as card reading, authentication, and direct command transmission. It manages the reader's connectivity state, detects card presence, and supports configuring the reader's LED and buzzer behaviors. Callbacks can be registered for significant events such as reader connection/disconnection and card presence/absence, allowing for custom application logic to be executed in response.
Usage involves instantiating the class and optionally setting callback functions to handle specific events. The class also implements methods to authenticate with cards using standard or 3DES encryption, read and write data to cards, and directly transmit APDU commands.
Example
var reader = ACR122U()
..onReaderConnectedCallback = () => print('Reader connected')
..onCardPresentCallback = () => print('Card detected');
await reader.authenticate(blockNumber: 4, key: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]);
This class simplifies the integration of ACR122U reader functionalities into Dart and Flutter applications, abstracting the complexities of direct hardware interaction.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isCardPresent → bool
-
Indicates whether an RFID card is currently present within the reader's detection field.
no setterinherited
- isConnected → bool
-
Indicates whether the RFID reader is currently connected.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addOnCardAbsentCallback(
void callback()) → void -
Adds a callback to be invoked when the RFID reader no longer detects an RFID card.
inherited
-
addOnCardPresentCallback(
void callback()) → void -
Adds a callback to be invoked when an RFID card is detected by the reader.
inherited
-
addOnReaderConnectedCallback(
void callback()) → void -
Adds a callback to be invoked when the RFID reader connects.
inherited
-
addOnReaderDisconnectedCallback(
void callback()) → void -
Adds a callback to be invoked when the RFID reader disconnects.
inherited
-
authenticate(
{required int blockNumber, required List< int> key}) → Future<void> - Authenticates a specified block with a provided key using standard security.
-
authenticate3DES(
{required List< int> key}) → Future<void> - Performs 3DES authentication with a provided key.
-
controlLedBuzzer(
{bool? redFinalState, bool? greenFinalState, required bool redInitialState, required bool greenInitialState, bool redBlinking = false, bool greenBlinking = false, required int t1Duration, required int t2Duration, required int repetitions, bool buzzerT1 = false, bool buzzerT2 = false}) → Future< LedState> - Controls the LED and buzzer behavior on the RFID reader.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
getAtr(
) → Future< List< int> ?> -
Retrieves the Answer to Reset (ATR) from the RFID tag or smart card.
inherited
-
getFirmwareVersion(
) → Future< String> - Retrieves the firmware version of the RFID reader.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
readBlock(
{required int blockNumber, required int length}) → Future< List< int> > - Reads data from a specific block of an RFID tag.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeOnCardAbsentCallback(
void callback()) → void -
Removes a previously registered callback for when an RFID card is no longer present.
inherited
-
removeOnCardPresentCallback(
void callback()) → void -
Removes a callback that was previously added to notify when an RFID card is present.
inherited
-
removeOnReaderConnectedCallback(
void callback()) → void -
Removes a previously registered callback for the RFID reader's connection event.
inherited
-
removeOnReaderDisconnectedCallback(
void callback()) → void -
Removes a previously registered callback for the RFID reader's disconnection event.
inherited
-
setBuzzerOnDetection(
{required bool enabled}) → Future< void> - Enables or disables the buzzer to sound upon card detection.
-
toString(
) → String -
A string representation of this object.
inherited
-
transmitApdu(
ApduHeader header, {List< int> ? data, int? le}) → Future<ApduResponse> -
Transmits an APDU command to the RFID tag or smart card and receives a response.
inherited
-
transmitDirect(
{required List< int> data}) → Future<List< int> > - Transmits a direct command to the RFID reader and returns the response.
-
transmitRaw(
Uint8List data) → Future< Uint8List> -
Transmits raw data to the RFID reader and receives a response.
inherited
-
writeBlock(
{required int blockNumber, required List< int> data}) → Future<void> - Writes data to a specified block on an RFID tag.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited