NfcReadSettings

class NfcReadSettings @JvmOverloads constructor(val linkLoss: LinkLossPolicy = LinkLossPolicy.Resume(DEFAULT_RESTARTS), val settleDelayMillis: Long = DEFAULT_SETTLE_DELAY_MILLIS, val commandTimeoutMillis: Long = DEFAULT_COMMAND_TIMEOUT_MILLIS, val waitForReturnMillis: Long = DEFAULT_WAIT_FOR_RETURN_MILLIS, val waitForDocumentMillis: Long, val telemetry: TelemetrySink? = null, val presenceCheckDelayMillis: Long = DEFAULT_PRESENCE_CHECK_DELAY_MILLIS, val platformSounds: Boolean = true, val observerOn: ObserverThread = ObserverThread.MAIN, val commandTimeoutBeforeAccessMillis: Long = DEFAULT_COMMAND_TIMEOUT_BEFORE_ACCESS_MILLIS, val readTimeoutMillis: Long = DEFAULT_READ_TIMEOUT_MILLIS, val totalTimeLimitMillis: Long = DEFAULT_TOTAL_TIME_LIMIT_MILLIS)

How an NfcChipRead behaves around the radio. Every value has a default that suits an ordinary app: create it with no arguments, or do not pass one at all.

Every time is a Long in milliseconds. linkLoss, settleDelayMillis, commandTimeoutMillis, readTimeoutMillis, commandTimeoutBeforeAccessMillis and observerOn mean the same, with the same defaults, as in the iPhone read's settings (CoreNfcReadSettings). The two waits are Android's own: on iPhone the system session's 60-second limit bounds every wait. presenceCheckDelayMillis and platformSounds set reader mode, which only the Activity-owning NfcChipRead.start(activity, ...) turns on for you.

Kotlin callers use the constructor with named arguments; Java callers can use Builder, which also changes one value of an existing settings object without naming the others (toBuilder).

Experimental: see ExperimentalTesseraChipApi.

Since

1.0.0

Throws

Constructors

Link copied to clipboard
constructor(linkLoss: LinkLossPolicy = LinkLossPolicy.Resume(DEFAULT_RESTARTS), settleDelayMillis: Long = DEFAULT_SETTLE_DELAY_MILLIS, commandTimeoutMillis: Long = DEFAULT_COMMAND_TIMEOUT_MILLIS, waitForReturnMillis: Long = DEFAULT_WAIT_FOR_RETURN_MILLIS, waitForDocumentMillis: Long, telemetry: TelemetrySink? = null, presenceCheckDelayMillis: Long = DEFAULT_PRESENCE_CHECK_DELAY_MILLIS, platformSounds: Boolean = true, observerOn: ObserverThread = ObserverThread.MAIN, commandTimeoutBeforeAccessMillis: Long = DEFAULT_COMMAND_TIMEOUT_BEFORE_ACCESS_MILLIS, readTimeoutMillis: Long = DEFAULT_READ_TIMEOUT_MILLIS, totalTimeLimitMillis: Long = DEFAULT_TOTAL_TIME_LIMIT_MILLIS)

Types

Link copied to clipboard

Builds NfcReadSettings step by step, with the constructor's defaults.

Link copied to clipboard
object Companion

The default values.

Properties

Link copied to clipboard

The longest wait for the chip's answer to one command before access: the commands each attempt sends before the key is used (selecting and reading EF.CardAccess, selecting the application, then BAC's GET CHALLENGE, which only asks for a random number, or PACE's MSE:Set AT, which only chooses the protocol and password). They need no public-key work on the chip and normally answer in milliseconds, so a chip that is found but gets too little power is noticed sooner. Default 1500. From the first command that uses the key on (BAC's EXTERNAL AUTHENTICATE, PACE's first GENERAL AUTHENTICATE), commandTimeoutMillis and readTimeoutMillis apply, so a slow step of the access protocol, chip authentication or a protected read is never cut by this value. When it is longer than commandTimeoutMillis, commandTimeoutMillis applies before access too. A command not answered in time is a try that costs no restart (io.lightine.tessera.emrtd.ChipReadState.NoAnswerYet).

Link copied to clipboard

The longest wait for the chip's answer to one command that makes the chip do public-key or key-agreement work: the steps of BAC and PACE from the first that uses the key (BAC's EXTERNAL AUTHENTICATE, PACE's GENERAL AUTHENTICATE), chip authentication and active authentication; also any extended-length command, whose answer can be up to 64 KB. Every other command has a shorter limit: commandTimeoutBeforeAccessMillis before access, readTimeoutMillis after it. It is the longest limit of the three: a longer value of either of the others is cut to it. Each limit is set on the link as the platform's ISO-DEP time limit, only when the next command needs a different one. When it passes, the platform reports the tag as lost (it cannot tell a slow chip from a document that left), so linkLoss decides what follows. Default 5000: ICAO Doc 9303 Part 10, appendix B.11, lets a chip take up to 5 seconds per block. The SDK's own command time limit counts as a lost link, so the chip may still answer the command after the limit, and that late answer is dropped unread: when the late answer was a refusal of the key, the read does not know it, and linkLoss may start again with the same key, within its restarts.

Link copied to clipboard

What the read does when the link to the chip is lost, usually because the document moved: the default, LinkLossPolicy.Resume with 2 restarts, waits for the document to come back and goes on from where it stopped, at most twice. Each new start opens the chip again with the same key, so a read can make up to 3 authentication attempts with that key, one per start. It never starts again after the chip answered with a refusal of the key. The first refusal in a read, before any try reached the command that uses the key, gets one more try on the same link and no restart; a second refusal ends the read (ChipReadEnding.KeyNotAccepted gives the rule). So a read makes at most one more authentication attempt than its starts. The MRZ and the card access number are not blocked by tries, so the worst a chip may do is answer more slowly. Use LinkLossPolicy.End for one start only.

Link copied to clipboard

The thread the observer is called on: ObserverThread.MAIN by default, so the updates reach a screen without a hop of your own; ObserverThread.CALLER for the read's own threads. Either way the calls come one at a time, in order, with the ending last.

Link copied to clipboard

Whether the platform plays its own sound when a document is found, set when the Activity-owning start turns reader mode on. Default true; false when your app gives its own feedback, because the system sound can make people move the document.

Link copied to clipboard

How often the platform checks that the document is still there, set when the Activity-owning start turns reader mode on. Default 1000: the platform's own 125 ms drops the link of some chips, and a longer delay is a known remedy; whether it helps is for your app to test with its own documents. Not used by the callback form, where your app passes it to NfcReaderMode.enable.

Link copied to clipboard

The longest wait for the chip's answer to one ordinary command after access: selecting a file and reading it with short APDUs, under secure messaging or not, and the other commands that need no public-key work on the chip. Default 2000: on a device a protected read of 223 bytes took 45 to 65 milliseconds, while a chip that went silent in the middle of a file kept the read waiting for the full limit each time. ISO/IEC 14443-4 lets a chip take up to about 4.95 seconds for one frame, so a slow but legal chip may need more: raise it then. A command not answered in time is a lost link, as with commandTimeoutMillis: linkLoss decides what follows. When it is longer than commandTimeoutMillis, commandTimeoutMillis applies.

Link copied to clipboard

How long the read waits after a document is found before the first command, so the hand can settle: frames are often lost in the first moment after detection. Default 400. Cancelling the read cuts it short.

Link copied to clipboard

Where the read's step events go (step, protocol, status word, file id, byte count, time): the sink you give here. With null, the default, the sink registered in TelemetrySinkRegistry when the read starts, which is a sink that drops everything when none is registered. The events never hold document or chip data.

Link copied to clipboard

How long a lost link may still lead to a restart, counted from the first link to the document, not from the start of waiting (waitForDocumentMillis bounds the waiting; before the first link this limit does nothing); the first lost link after it ends the read with ChipReadEnding.Partial or ChipReadEnding.Failed, whatever restarts are left. Under LinkLossPolicy.Resume a lost link after an attempt that read more file bytes than the attempts before it uses no restart, so this limit is what ends a read that keeps making a little progress each time. It does not cut a command or a read that is running: only the next restart. Default 120000 (2 minutes), twice the iPhone system session's 60 seconds, so a read that worked before is not cut; NO_LIMIT turns it off. On iPhone the system session's limit plays this part, so its settings have no such value. Since 1.1.0.

Link copied to clipboard

How long the read may take to find a document and set up the first link to it, counted from the start, across tags whose link could not be set up (on iPhone the system session's 60-second limit plays this part, so its settings have no such value); the default is 120000 (2 minutes) since 1.1.0; it was NO_LIMIT in 1.0.x. A read whose reader mode the app took away, or whose screen was left open, must end by itself and free the one-read-at-a-time slot. Pass NO_LIMIT (or Builder.noLimitForDocument()) to wait without a limit, as before. On iPhone the system session's 60-second limit bounds the wait. When it passes, the read ends with ChipReadEnding.Failed, 0 attempts, and an NfcTimeout with limit NfcTimeout.Limit.WAIT_FOR_DOCUMENT: the limit is in the settings, so the ending is not ChipReadEnding.EndedBySystem. Once a first link is up it no longer applies: waitForReturnMillis bounds the waits after a lost link. This is also the only time bound on a read whose reader mode your app switched off behind the SDK's back: the SDK cannot see that, so with NO_LIMIT such a read waits until the app calls cancel() (or, for an Activity-owning read, the Activity is destroyed). With the 2-minute default it ends by itself; still call cancel() to stop sooner.

Link copied to clipboard

How long the read waits for the document to come back after a lost link, counted from the loss, before it ends with ChipReadEnding.Partial or ChipReadEnding.Failed. Default 15000. It also bounds the tries while a found chip does not answer its first commands (io.lightine.tessera.emrtd.ChipReadState.NoAnswerYet), counted from the first unanswered try: then the read ends with ChipReadEnding.Failed and, when no try got past those first commands, io.lightine.tessera.types.errors.NfcNoAnswer.

Functions

Link copied to clipboard

A builder that starts from these values, so one value can change without naming the others: settings.toBuilder().settleDelayMillis(0).build().

Link copied to clipboard
open override fun toString(): String

The values, never document data.