Package-level declarations

Types

Link copied to clipboard
data class AlternativeCarrierRecord(val cps: Int = CPS_ACTIVE, val carrierDataReference: String, val auxiliaryDataReferences: List<String> = emptyList())

Alternative Carrier record ("ac").

Link copied to clipboard
class CcidException(message: String) : IOException

Custom exception class for CCID-specific errors. This exception is thrown when an error occurs during communication with the smart card, such as an invalid response or a command failure.

Link copied to clipboard
data class CollisionResolutionRecord(val randomNumber: Int)

Collision Resolution record ("cr").

Link copied to clipboard
data class CommandApdu(val cla: Int, val ins: Int, val p1: Int, val p2: Int, val payload: ByteString, val le: Int)

A Command APDU according to ISO/IEC 7816.

Link copied to clipboard
sealed class ExternalNfcReader(val id: String, val addedAt: Instant, val displayName: String, val userDisplayName: String? = null)

Base class for external NFC readers.

Link copied to clipboard
class ExternalNfcReaderStore(storage: Storage, partitionId: String)

A persistent store for externally connected NFC readers.

Link copied to clipboard
data class ExternalNfcReaderUsb(val id: String, val addedAt: Instant, val displayName: String, val userDisplayName: String? = null, val vendorId: Int, val productId: Int, val interfaceIndex: Int) : ExternalNfcReader

An external NFC reader connected via USB.

Link copied to clipboard
data class HandoverCarrierRecords(val carrierRecord: NdefRecord, val alternativeCarrierRecord: AlternativeCarrierRecord, val auxiliaryRecords: List<NdefRecord> = emptyList())

NDEF records representing a single alternative carrier in NFC Forum Connection Handover.

Link copied to clipboard
data class HandoverRequestRecord(val version: Int, val embeddedMessage: NdefMessage)

Handover Request record.

Link copied to clipboard
data class HandoverSelectRecord(val version: Int, val embeddedMessage: NdefMessage)

Handover Select record.

Link copied to clipboard
data class NdefMessage(val records: List<NdefRecord>)

An immutable NDEF message.

Link copied to clipboard
data class NdefRecord(val tnf: NdefRecord.Tnf, val type: ByteString = ByteString(), val id: ByteString = ByteString(), val payload: ByteString = ByteString())

An immutable NDEF Record.

Link copied to clipboard
object Nfc

Constants and utilities related to NFC.

Link copied to clipboard

A router which routes incoming NFC CommandApdus by ISO/IEC 7816-4 Application ID (AID) to multiple NfcApduService instances.

Link copied to clipboard

Backend interface for routing APDUs to and from an NfcApduRouter on platforms without OS-level Host Card Emulation (such as Desktop/Linux JVM with an NCI controller).

Link copied to clipboard
actual abstract class NfcApduRouterBase : HostApduService

Android actual for NfcApduRouterBase extending HostApduService.

expect abstract class NfcApduRouterBase

Platform base class for NfcApduRouter.

actual abstract class NfcApduRouterBase

iOS actual for NfcApduRouterBase.

actual abstract class NfcApduRouterBase

JVM actual for NfcApduRouterBase.

actual abstract class NfcApduRouterBase

Web actual for NfcApduRouterBase.

Link copied to clipboard
abstract class NfcApduService

Base class for NFC APDU services orchestrated by NfcApduRouter.

Link copied to clipboard
class NfcCommandFailedException(message: String, val status: Int) : Exception

Exception thrown if an NFC command doesn't return success.

Link copied to clipboard

Reason why an NFC link was deactivated.

Link copied to clipboard
abstract class NfcIsoTag

Class representing a ISO/IEC 14443-4 tag.

Link copied to clipboard
class NfcIsoTagAndroid(tag: IsoDep, context: CoroutineContext, updateMessage: (message: String) -> Unit) : NfcIsoTag
Link copied to clipboard
data class NfcScanOptions(val pollingFrameData: ByteString? = null)

Options used to influence NFC scanning.

Link copied to clipboard

Exception thrown if a NfcIsoTag is removed while trying to communicate with it.

Link copied to clipboard
interface NfcTagReader

An interface for reading NFC tags.

Link copied to clipboard

An NfcTagReader backed by an external USB CCID (Chip Card Interface Device) contactless smart card / NFC reader.

Link copied to clipboard
data class ResponseApdu(val status: Int, val payload: ByteString = ByteString())

A response APDU according to ISO/IEC 7816-4.

Link copied to clipboard
data class ServiceParameterRecord(val tnepVersion: Int, val serviceNameUri: String, val tnepCommunicationMode: Int, val wtInt: Int, val nWait: Int, val maxNdefSize: Int)

Service Parameter Record.

Link copied to clipboard
data class ServiceSelectRecord(val serviceName: String)
Link copied to clipboard
data class TnepStatusRecord(val status: Int)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
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.

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.

Link copied to clipboard
fun NfcTagReaderUsb.Companion.createFromFileDescriptor(fileDescriptor: Int, interfaceIndex: Int? = null, disconnectDelay: Duration = 5.seconds): NfcTagReaderUsb

Creates a USB CCID NfcTagReaderUsb wrapping an already-opened OS file descriptor for a /dev/bus/usb/BBB/DDD device node via libusb_wrap_sys_device() (requires libusb>= 1.0.23).

Link copied to clipboard

Converts Minimum Waiting Time to a duration.

Link copied to clipboard

Adds a USB device to the ExternalNfcReaderStore if it doesn't exist already.

Link copied to clipboard
suspend fun ExternalNfcReaderStore.observeUsbDevices(pollInterval: Duration = 1.seconds)

Monitors attached USB devices on Desktop JVM and automatically adds newly attached USB CCID (bInterfaceClass == 0x0B) NFC readers to this ExternalNfcReaderStore.

Link copied to clipboard
suspend fun <T : Any> scanNfcWithPromptDialog(message: String?, block: suspend (updateMessage: (String) -> Unit, resetMessage: () -> Unit) -> T): T

Runs an NFC tag scanning block while managing the ScanNfcPromptDialogModel prompt UI (if message is non-null and a PromptModel with bound UI is present in the coroutine context) and platform haptic feedback.