open

suspend fun open(tag: Tag, timeoutMillis: Long = DEFAULT_TIMEOUT_MILLIS): IsoDepTransport

Opens an IsoDepTransport for a tag from reader mode: gets its IsoDep, connects it and sets the time limit. Close the result with close when the read ends.

Return

A connected transport. When the caller is cancelled during the connect, or the time limit cannot be set after it, the tag's connection is closed before this throws; when the connect itself fails, nothing is connected and nothing more is sent to the tag.

Parameters

tag

The tag from the NfcAdapter.ReaderCallback.

timeoutMillis

How long to wait for the chip to answer one command, in milliseconds.

Throws

with NfcUnavailable (NOT_SUPPORTED) when the tag does not speak ISO-DEP, or another error from the list in the class description when it cannot be connected.

when timeoutMillis is not in 1 to Int.MAX_VALUE (the platform takes an int).