dxNfcCard
1. Overview
This module is part of the official system module library of dejaOS, used for interacting with NFC (Near Field Communication) cards. It provides a comprehensive singleton interface for detecting, reading, and writing various NFC card types.
Key Features:
- Multi-Card Support: Handles various basic NFC card types, including M1, CPU, and NTAG cards.
- eID Functionality: Integrates functionality for reading Chinese 2nd Generation ID cards (eID). Note: This feature requires a network connection.
- Event-Driven: Uses an asynchronous, event-driven model to handle card detection.
- Configuration: Allows for detailed configuration of the underlying NFC hardware parameters.
2. Files
dxNfcCard.jslibvbar-m-dxnfccard.so
Ensure these two files are included in the
dxmodulessubdirectory under your project root directory.
3. Dependencies
dxLogger(for logging, optional)
4. Compatible Devices
Compatible with all devices running dejaOS 2.0+ that are equipped with NFC hardware.
5. Usage
Basic Usage (Standard NFC Cards)
import { dxNfcCard } from "./dxmodules/dxNfcCard.js";
import logger from "./dxmodules/dxLogger.js";
// 1. Initialize the module
dxNfcCard.init();
// 2. Set callbacks for card detection
dxNfcCard.setCallbacks({
onCardDetected: (cardInfo) => {
logger.info("NFC Card Detected:", cardInfo);
// cardInfo contains { card_type, id, id_len, type, sak, ... }
},
});
// 3. Poll for events in a timer
setInterval(() => {
try {
dxNfcCard.loop();
} catch (e) {
logger.error("Error in NFC loop:", e);
}
}, 100); // Process events every 100ms