create

fun NfcTagReaderUsb.Companion.create(vendorId: Int, productId: Int, interfaceIndex: Int? = null, disconnectDelay: Duration = 5.seconds): NfcTagReaderUsb

Creates a USB CCID NfcTagReaderUsb targeting an attached USB reader matching vendorId and productId.

The USB device is opened lazily when NfcTagReaderUsb.scan is called, so the returned NfcTagReaderUsb automatically survives USB resets and hotplug re-enumeration between scans. Call NfcTagReaderUsb.close when the reader is no longer needed.

Return

a closeable NfcTagReaderUsb ready to scan tags via NfcTagReaderUsb.scan.

Parameters

vendorId

the 16-bit USB vendor ID (0x0000..0xFFFF), for example 0x072F (ACS).

productId

the 16-bit USB product ID (0x0000..0xFFFF), for example 0x223B (ACR1252U).

interfaceIndex

the USB bInterfaceNumber of the CCID interface to claim, or null (the default) to automatically select the first contactless NFC CCID interface (skipping SAM/SIM and mechanical contact card slots).

disconnectDelay

how long to keep the USB interface claimed after a completed scan and tag removal before releasing it (defaults to 5.seconds).

Throws


fun NfcTagReaderUsb.Companion.create(devicePath: String, interfaceIndex: Int? = null, disconnectDelay: Duration = 5.seconds): NfcTagReaderUsb

Creates a USB CCID NfcTagReaderUsb targeting a specific Linux USB device node, udev symlink, or physical sysfs USB port path.

Supported devicePath formats (resolved freshly each time NfcTagReaderUsb.scan opens the underlying USB transport, so udev symlinks and sysfs port paths survive USB hotplugs and re-enumeration):

  • A usbfs device node path, such as "/dev/bus/usb/001/004".

  • A udev symlink pointing to a /dev/bus/usb/BBB/DDD node or sysfs USB device directory, such as "/dev/nfc-reader-front" (resolved via Path.toRealPath()).

  • A Linux sysfs USB port directory path or bare port name, such as "/sys/bus/usb/devices/1-1.2" or "1-1.2", which pins the reader to a physical USB socket even when multiple attached readers share identical VID:PID values and lack serial numbers.

Call NfcTagReaderUsb.close when the reader is no longer needed.

Return

a closeable NfcTagReaderUsb ready to scan tags via NfcTagReaderUsb.scan.

Parameters

devicePath

the Linux usbfs device node path, udev symlink path, or sysfs USB port path/name.

interfaceIndex

the USB bInterfaceNumber of the CCID interface to claim, or null (the default) to automatically select the first contactless NFC CCID interface (skipping SAM/SIM and mechanical contact card slots).

disconnectDelay

how long to keep the USB interface claimed after a completed scan and tag removal before releasing it (defaults to 5.seconds).

Throws