waitForCard

suspend fun waitForCard(): Boolean

Suspends until a card is detected.

This function suspends the current coroutine and waits until a card is detected in the reader. It provides a coroutine-friendly alternative to synchronous polling or asynchronous callbacks, and should be called from within a coroutine scope.

Return

true if a card was successfully detected and is present.

Since

1.0.0

Throws

If an I/O error occurs while communicating with the reader.


fun waitForCard(onCardDetected: () -> Unit)

Starts monitoring the reader for card detection events asynchronously.

When a card is detected in the reader, the provided onCardDetected callback is invoked. This function does not block the calling thread and is suitable for use in event-driven or UI-based applications.

Since

1.0.0

Parameters

onCardDetected

The callback function to invoke when a card is detected.

Throws

If an I/O error occurs while communicating with the reader.