MdocNfcV2EngagementHelper

class MdocNfcV2EngagementHelper(val eDeviceKey: EcPublicKey, val onHandoverComplete: (connectionMethod: MdocConnectionMethod, encodedDeviceEngagement: ByteString, handover: DataItem) -> Unit, val onMessageReceived: suspend (ByteString) -> Unit, val onError: (error: Exception) -> Unit, val negotiatedHandoverPicker: (connectionMethods: List<MdocConnectionMethod>) -> MdocConnectionMethod, val apduCommandMaxSize: Long = 65536)

Helper used for NFC engagement on the mdoc side.

This implements NFC engagement v2 according to ISO/IEC 18013 Second Edition

APDUs received from the NFC tag reader should be passed to the processApdu method.

The apduCommandMaxSize parameter is used to tell the mdoc reader that it needs to send its commands in APDUs no larger than this size and this value must be smaller or equal to 65536, the maximum size of an Extended APDU. Since this class is usually not used in an environment where a 64 KiB buffer is a showstopper we default to the maximum size.

Parameters

eDeviceKey

EDeviceKey as per ISO/IEC 18013-5:2021.

onHandoverComplete

the function to call when handover is complete.

onMessageReceived

the function to call when a data message has been received over NFC.

onError

the function to call if an error occurs.

negotiatedHandoverPicker

a function to choose one of the connection methods from the mdoc reader. This always contain a MdocConnectionMethodNfcV2 instance and contains others if the mdoc reader is capable of data transfer over e.g. BLE or Wifi Aware. If the mdoc only supports data transfer over NFC, it should return the element for MdocConnectionMethodNfcV2.

apduCommandMaxSize

the maximum length of the command data field.

Constructors

Link copied to clipboard
constructor(eDeviceKey: EcPublicKey, onHandoverComplete: (connectionMethod: MdocConnectionMethod, encodedDeviceEngagement: ByteString, handover: DataItem) -> Unit, onMessageReceived: suspend (ByteString) -> Unit, onError: (error: Exception) -> Unit, negotiatedHandoverPicker: (connectionMethods: List<MdocConnectionMethod>) -> MdocConnectionMethod, apduCommandMaxSize: Long = 65536)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val onError: (error: Exception) -> Unit
Link copied to clipboard
val onHandoverComplete: (connectionMethod: MdocConnectionMethod, encodedDeviceEngagement: ByteString, handover: DataItem) -> Unit
Link copied to clipboard
val onMessageReceived: suspend (ByteString) -> Unit

Functions

Link copied to clipboard
suspend fun processApdu(command: CommandApdu): ResponseApdu

Process APDUs received from the remote NFC tag reader.

Link copied to clipboard
fun processDeactivated(reason: Int)

Must be called when the session is deactivated, e.g. when the NFC tag reader leaves the field.

Link copied to clipboard
suspend fun sendMessage(message: ByteString)

Function for sending data via NFC.