> For the complete documentation index, see [llms.txt](https://developer.magtek.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.magtek.com/sdks-and-tools/universal-sdk-documentation/.net-windows/idevice.md).

# IDevice

Create an instance of the IDevice from CoreAPI.getDeviceList() or from CoreAPI.createDevice(). Then use the functions described in this chapter.

### cancelTransaction <a href="#id-4.1_canceltransaction" id="id-4.1_canceltransaction"></a>

This function cancels a transaction. A transaction can only be cancelled before a card is presented.

```
bool IDevice.cancelTransaction();
```

Return Value:

Returns true if cancelled. Otherwise, returns false.

### getCapabilities <a href="#id-4.2_getcapabilities" id="id-4.2_getcapabilities"></a>

This function retrieves the capabilities of the device.

```
IDeviceCapabilities IDevice.getCapabilities();
```

Return Value:

Returns IDeviceCapabilities

### getConnectionInfo <a href="#id-4.3_getconnectioninfo" id="id-4.3_getconnectioninfo"></a>

This function retrieves the connection information of the device.

```
ConnectionInfo IDevice.getConnectionInfo();
```

Return Value:

Returns ConnectionInfo

### getConnectionState <a href="#id-4.4_getconnectionstate" id="id-4.4_getconnectionstate"></a>

This function retrieves the connection state of the device.

```
ConnectionState IDevice.getConnectionState();
```

Return Value:

Returns ConnectionState

### getDeviceConfiguration <a href="#id-4.5_getdeviceconfiguration" id="id-4.5_getdeviceconfiguration"></a>

This function allows the host to get an IDeviceConfiguration to configure the device.

```
IDeviceConfiguration IDevice.getDeviceConfiguration();
```

Return Value:

Returns IDeviceConfiguration.

### getDeviceControl <a href="#id-4.6_getdevicecontrol" id="id-4.6_getdevicecontrol"></a>

This function retrieves the device control interface to the device.

```
IDeviceControl IDevice.getDeviceControl();
```

Return Value:

Returns IDeviceControl

### getDeviceInfo <a href="#id-4.7_getdeviceinfo" id="id-4.7_getdeviceinfo"></a>

This function returns an information class of the device.

```
DeviceInfo IDevice.getDeviceInfo();
```

&#x20;eturn Value:

Returns DeviceInfo.

### Name <a href="#id-4.8_name" id="id-4.8_name"></a>

This function returns the name of the device assigned from createDevice().

```
string IDevice.Name();
```

Return Value:

Returns the name of the device.

### requestPAN <a href="#id-4.9_requestpan" id="id-4.9_requestpan"></a>

This function prompts the user to present their card and enter a PIN. A card is presented so that the device can retrieve the PAN, which is used for Format blocks requiring a PAN. The encrypted PIN block (EPB) will be returned in the event OnEvent(). The data byte array may be passed to builder function PANDataBuilder.GetPANData();

For DynaFlex devices, this function starts a PIN session on the first call and shall be called again to send the PIN status to the device for completing the PIN session.

```
bool IDevice.requestPAN(PANRequest panRequest, PINRequest pinRequest);
```

**PANRequest:**

<table data-header-hidden><thead><tr><th width="123.33334350585938" valign="top"></th><th width="167" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">Timeout</td><td valign="top">byte</td><td valign="top">Wait time in seconds.</td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="173.33331298828125" valign="top"></th><th width="199.33331298828125" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">PaymentMethods</td><td valign="top">List of PaymentMethod</td><td valign="top"><p>List of the PaymentMethod enumeration.</p><p> </p><p>MSR         = For magnetic stripe cards.</p><p>Contact     = For EMV chip cards.</p><p>Contactless = For NFC contactless cards. ManualEntry = Manually entry, no card. When set, other payment methods must not be included.</p><p> </p><p>Barcode          = For barcode.</p><p>BarcodeEncrypted = For barcode with encrypted response.</p><p>AppleVAS         = For Apple VAS.</p><p>GoogleVAS        = For Apple VAS.</p><p>NFC              = For NFC tag.</p></td></tr><tr><td valign="top"> </td><td valign="top"> </td><td valign="top"> </td></tr></tbody></table>

**PINRequest:**

<table data-header-hidden><thead><tr><th width="123.99996948242188" valign="top"></th><th width="106.33331298828125" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">Timeout</td><td valign="top">byte</td><td valign="top">Wait time in seconds.</td></tr><tr><td valign="top">PINMode</td><td valign="top">byte</td><td valign="top"><p>PIN mode.</p><p>0x00 = Enter PIN</p><p>0x01 = Enter PIN Amount 0x02 = Reenter PIN Amount 0x03 = Reenter PIN</p><p>0x04 = Verify PIN</p><p> </p><p>For DynaFlex devices this is the User Interface Sequence:</p><p>0x01 = Present Card / Enter PIN (start session)</p><p>0x04 = Present Card / Enter PIN / Enter PIN Again (start session)</p><p> </p><p>On the second call to requestPAN(), send the PIN status:</p><p>0xFD = Cancel PIN Session (end session) 0xFE = PIN Entry Failed (end session) 0xFF = PIN Entry Successful (end session)</p></td></tr><tr><td valign="top">MinLength</td><td valign="top">byte</td><td valign="top">Minimum length of accepted PIN (>= 4).</td></tr><tr><td valign="top">MaxLength</td><td valign="top">byte</td><td valign="top">Maximum length of accepted PIN (=&#x3C; 12).</td></tr><tr><td valign="top">Tone</td><td valign="top">byte</td><td valign="top"><p>Tone to play when prompting for the PIN. Usage:</p><p>0x00 = No sound 0x01 = One beep 0x02 = Two beeps</p></td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="119.33334350585938" valign="top"></th><th width="141" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">Format</td><td valign="top">byte</td><td valign="top"><p>ISO format for the PIN block.</p><p>0x00 = ISO Format 0 0x01 = ISO Format 1 0x03 = ISO Format 3 0x04 = ISO Format 4</p></td></tr><tr><td valign="top">PAN</td><td valign="top">String</td><td valign="top">First 12 digits of the Primary Account Number. Leave blank if not required by the ISO format for the PIN block.</td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

### requestPIN <a href="#id-4.10_requestpin" id="id-4.10_requestpin"></a>

This function prompts the user to enter a PIN. The host must supply the PAN if the Format block selected requires a PAN. The encrypted PIN block (EPB) will be returned in the event OnEvent(). The data byte array may be passed to builder function PINDataBuilder.GetPINData();

For DynaFlex devices, this function starts a PIN session on the first call and shall be called again to send the PIN status to the device for completing the PIN session.

```
bool IDevice.requestPIN(PINRequest pinRequest); PINRequest:
```

<table data-header-hidden><thead><tr><th width="118" valign="top"></th><th width="110" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">Tone</td><td valign="top">byte</td><td valign="top"><p>Tone to play when prompting for the PIN.</p><p>0x00 = No sound 0x01 = One beep 0x02 = Two beeps</p></td></tr><tr><td valign="top">Format</td><td valign="top">byte</td><td valign="top"><p>ISO format for the PIN block.</p><p>0x00 = ISO Format 0 0x01 = ISO Format 1 0x03 = ISO Format 3 0x04 = ISO Format 4</p></td></tr><tr><td valign="top">PAN</td><td valign="top">String</td><td valign="top">First 12 digits of the Primary Account Number. Leave blank if not required by the ISO format for the PIN block.</td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

### requestSignature <a href="#id-4.11_requestsignature" id="id-4.11_requestsignature"></a>

This function prompts the user to enter a signature. The response data will be returned in the event OnEvent.

```
bool IDevice.requestSignature(byte timeout);
```

<table data-header-hidden><thead><tr><th width="153.66668701171875" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top">timeout</td><td valign="top"><p>Time in seconds for the operation to complete.</p><p>0x01 to 0xFF</p></td></tr></tbody></table>

Return Value:

Returns true of success. Otherwise, returns false.

### sendAuthorization <a href="#id-4.12_sendauthorization" id="id-4.12_sendauthorization"></a>

This function sends the Authorization Response Code (ARPC) blob to the device. The response data will be returned in the event OnEvent(). See 15.23C.4 Sample Code for how to process an EMV transaction.

```
bool IDevice.sendAuthorization(IData data);
```

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top">data</td><td valign="top">Contains ARPC blob.</td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

### sendClassicNFCCommand <a href="#id-4.13_sendclassicnfccommand" id="id-4.13_sendclassicnfccommand"></a>

This function sends a command to an NFC Mifare Classic Tag type 2. The NFC tag must first be activated by calling startTransaction() with NFC enabled.

```
bool IDevice.sendClassicNFCCommand(
```

IData data,

bool lastCommand, bool encrypt);

<table data-header-hidden><thead><tr><th width="182.33331298828125" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top"><p> </p><p> </p><p>data</p></td><td valign="top"><p>Command to send to the NFC tag.</p><p> </p><p>For details of the command see NFC commands table below or <mark style="color:red;"><strong>DynaFlex Family Programmer’s Manual</strong></mark> section <mark style="color:red;"><strong>NFC/Mifare Pass Through Commands</strong></mark></p></td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p>lastCommand</p></td><td valign="top"><p>Determines if this is the last NFC command to complete the operation.</p><p> </p><p>true = This is the last command. Device will provide a single beep after receiving a successful response from the NFC tag. To send subsequent commands, the NFC tag must be activated by calling startTransaction() with NFC enabled.</p><p> </p><p>false = Expect more commands (Default).</p><p> </p><p>Either set to true or false, if the NFC tag command fails, device will provide a double beep.</p></td></tr><tr><td valign="top"><p> </p><p>encrypt</p></td><td valign="top"><p>Determines if data returned is to be encrypted.</p><p>true = Encrypt data</p><p>false = Do not encrypt data (Default)</p></td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

**NFC Classic Commands**

<table data-header-hidden><thead><tr><th width="150.6666259765625" valign="top"></th><th width="103.66668701171875" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Command</td><td valign="top">Length</td><td valign="top">Field Value</td></tr><tr><td valign="top"><p> </p><p> </p><p>Mifare Read</p></td><td valign="top"><p> </p><p> </p><p>11</p></td><td valign="top">Byte 0 – 0x30 – Read Command Byte 1- Sector Number to Read Byte 2 – Start Block Number Byte 3 – End Block Number Byte 4 – Key Type, 0 = A, 1 = B Byte 5 to 10 = 6 Byte Key</td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p>Mifare Write</p></td><td valign="top"><p> </p><p> </p><p> </p><p>var</p></td><td valign="top"><p>Byte 0 – 0xA0 – Write Command Byte 1- Sector Number to Write Byte 2 – Start Block Number Byte 3 – End Block Number</p><p>Byte 4 – Key Type 0 = A, 1 = B Byte 5 to 10 = 6 Byte Key</p><p>Byte 11 to x = Variable length Byte Data (16 bytes per block)</p></td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="166.66668701171875" valign="top"></th><th width="103.6666259765625" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Command</td><td valign="top">Length</td><td valign="top">Field Value</td></tr><tr><td valign="top"><p> </p><p> </p><p>Mifare Increment</p></td><td valign="top"><p> </p><p> </p><p>14</p></td><td valign="top"><p>Byte 0 – 0xC1 – Increment Command Byte 1 – Source Sector Number</p><p>Byte 2- Source Block number Byte 3 – Key Type 0 = A, 1 = B Byte 4 to 9 = 6 Byte Key</p><p>Byte 10 to 13 = 4 Byte Operand</p></td></tr><tr><td valign="top"><p> </p><p> </p><p>Mifare Decrement</p></td><td valign="top"><p> </p><p> </p><p>14</p></td><td valign="top"><p>Byte 0 – 0xC0 – Decrement Command Byte 1 – Source Sector Number</p><p>Byte 2- Source Block number Byte 3 – Key Type 0 = A, 1 = B Byte 4 to 9 = 6 Byte Key</p><p>Byte 10 to 13 = 4 Byte Operand</p></td></tr><tr><td valign="top"><p> </p><p> </p><p>Mifare Restore</p></td><td valign="top"><p> </p><p> </p><p>10</p></td><td valign="top">Byte 0 – 0xC2 – Restore Command Byte 1 – Source Sector Number Byte 2 - Source Block number Byte 3 – Key Type 0 = A, 1 = B Byte 4 to 9 = 6 Byte Key</td></tr><tr><td valign="top"><p> </p><p> </p><p>Mifare Transfer</p></td><td valign="top"><p> </p><p> </p><p>10</p></td><td valign="top"><p>Byte 0 – 0xB0 – Write the value from the Transfer Buffer into destination block number</p><p>Byte 1 – Destination Sector Number Byte 2 - Destination Block number Byte 3 – Key Type 0 = A, 1 = B Byte 4 to 9 = 6 Byte Key</p></td></tr></tbody></table>

**Response Data For NFC Mifare DESFire Light Tag Type 4**

<table data-header-hidden><thead><tr><th width="77.33334350585938" valign="top"></th><th width="92.6666259765625" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Tag</td><td valign="top">Len</td><td valign="top">Value / Description</td></tr><tr><td valign="top"><p> </p><p> </p><p>81</p></td><td valign="top"><p> </p><p> </p><p>var</p></td><td valign="top"><p>Tag Response Code. Byte 0 = 0x00 = Success</p><p>Byte 0 = 0x01 = I/O Failed</p><p>Byte 0 = 0x02 Authentication Failed</p><p> </p><p>Byte 1 = 0x01 = Block that Failed (optional)</p></td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="80.33334350585938" valign="top"></th><th width="71" valign="top"></th><th width="174.6666259765625" valign="top"></th><th width="93.3333740234375"></th><th width="247.99990844726562"></th></tr></thead><tbody><tr><td valign="top">Tag</td><td valign="top">Len</td><td colspan="3" valign="top">Value / Description</td></tr><tr><td rowspan="9" valign="top">82</td><td rowspan="9" valign="top">var</td><td colspan="3" valign="top"><p>Encryption Control Payload tag data.</p><p>·       Data of R-APDU</p><p>If unencrypted:</p></td></tr><tr><td valign="top">Tag</td><td>Len</td><td>Value / Description</td></tr><tr><td valign="top">FC</td><td>var</td><td>NFC Data Container</td></tr><tr><td valign="top">/DF7A</td><td>var</td><td>NFC Data</td></tr><tr><td colspan="3" valign="top"><p> </p><p>If encrypted:</p></td></tr><tr><td valign="top">Tag</td><td>Len</td><td>Value / Description</td></tr><tr><td valign="top">/DFDF59</td><td>var</td><td>Encrypted Data Primitive to be decrypted.</td></tr><tr><td valign="top">/DFDF50</td><td>var</td><td>Encrypted Data KSN</td></tr><tr><td valign="top">/DFDF51</td><td>01</td><td>Encrypted Data Encryption Type</td></tr></tbody></table>

**Example Unencrypted Payload**

```
81	0100 (Tag Respons Code)
82	82036D (Encryption Control)
        FC 820369 (NFC Data Container) 
                DF7A 820364 (NFC Data)
                        031391010F55047777772E6D616774656B2E636F6DFE00. . .
                                www.magtek.com
```

**Example Encrypted Payload**

```
81	0100 (Tag Response code)
82	820389 (Encryption Control)
    DFDF59 820370 (Encrypted Data Primitive) 
            03679DC03B4CA607E3A7D2B52C8E9F1B5CD3D85E7368425. . .
    DFDF50 0A (Encrypted Data KSN) 
            FFFF9876543210200047
        DFDF51 01 (Encrypted Data Type) 
                80
```

### sendDESFireNFCCommand <a href="#id-4.14_senddesfirenfccommand" id="id-4.14_senddesfirenfccommand"></a>

This function sends a command to an NFC Mifare DESFire Light Tag Type 4. The NFC tag must first be activated by calling startTransaction() with NFC enabled.

```
bool IDevice.sendDESFireNFCCommand( 
    IData data,
    bool lastCommand, 
    bool encrypt);
```

<table data-header-hidden><thead><tr><th width="156.3333740234375" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top"><p> </p><p> </p><p>data</p></td><td valign="top"><p>Command to send to the NFC tag. See DESFire Data Sheet (MF2DLHX0). Should follow ISO 7816-4 APDU format.</p><p> </p><p>For details of the command see</p><p><em>D998200383 DynaFlex Family Programmer’s Manual (COMMANDS) section NFC/Mifare Pass Through Commands</em></p></td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p>lastCommand</p></td><td valign="top"><p>Determines if this is the last NFC command to complete the operation.</p><p> </p><p>true = This is the last command. Device will provide a single beep after receiving a successful response from the NFC tag. To send subsequent commands, the NFC tag must be activated by calling startTransaction() with NFC enabled.</p><p> </p><p>false = Expect more commands (Default).</p><p> </p><p>Either set to true or false, if the NFC tag command fails, device will provide a double beep.</p></td></tr><tr><td valign="top"><p> </p><p>encrypt</p></td><td valign="top"><p>Determines if data returned is to be encrypted.</p><p>true = Encrypt data</p><p>false = Do not encrypt data (Default)</p></td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

**Response Data For NFC Mifare DESFire Light Tag Type 4**

<table data-header-hidden><thead><tr><th width="94" valign="top"></th><th width="91.3333740234375" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Tag</td><td valign="top">Len</td><td valign="top">Value / Description</td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p>81</p></td><td valign="top"><p> </p><p> </p><p> </p><p>02</p></td><td valign="top"><p>Tag Response (SW1 SW2). See DESFire Data Sheet (MF2DLHX0). Should follow ISO 7816-4 APDU format.</p><p>·       SW1 and SW2 of R-APDU</p><p>If card is not able to respond:</p><p>·       SW1 = 0x64, SW2 = 0x00</p></td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="85" valign="top"></th><th width="76" valign="top"></th><th width="129.66668701171875" valign="top"></th><th width="111"></th><th></th></tr></thead><tbody><tr><td valign="top">Tag</td><td valign="top">Len</td><td colspan="3" valign="top">Value / Description</td></tr><tr><td rowspan="9" valign="top">82</td><td rowspan="9" valign="top">var</td><td colspan="3" valign="top"><p>Encryption Control Payload tag data</p><p>·       Data of R-APDU</p><p>If unencrypted:</p></td></tr><tr><td valign="top">Tag</td><td>Len</td><td>Value / Description</td></tr><tr><td valign="top">FC</td><td>var</td><td>NFC Data Container</td></tr><tr><td valign="top">/DF7A</td><td>var</td><td>NFC Data</td></tr><tr><td colspan="3" valign="top"><p> </p><p>If encrypted:</p></td></tr><tr><td valign="top">Tag</td><td>Len</td><td>Value / Description</td></tr><tr><td valign="top">/DFDF59</td><td>var</td><td>Encrypted Data Primitive to be decrypted.</td></tr><tr><td valign="top">/DFDF50</td><td>var</td><td>Encrypted Data KSN</td></tr><tr><td valign="top">/DFDF51</td><td>01</td><td>Encrypted Data Encryption Type</td></tr></tbody></table>

**Example Unencrypted Payload**

```
81	0100 (Tag Respons Code)
82	82036D (Encryption Control)
    FC 820369 (NFC Data Container) 
    DF7A 820364 (NFC Data)
    031391010F55047777772E6D616774656B2E636F6DFE00. . .
    www.magtek.com
```

**Example Encrypted Payload**

```
81	0100 (Tag Response code)
82	820389 (Encryption Control)
    DFDF59 820370 (Encrypted Data Primitive) 
            03679DC03B4CA607E3A7D2B52C8E9F1B5CD3D85E7368425. . .
    DFDF50 0A (Encrypted Data KSN) 
            FFFF9876543210200047
        DFDF51 01 (Encrypted Data Type) 
        80
```

### sendNFCCommand <a href="#id-4.15_sendnfccommand" id="id-4.15_sendnfccommand"></a>

This function sends a command to an NFC tag type 2. The NFC tag must first be activated by calling startTransaction() with NFC enabled.

```
bool IDevice.sendNFCCommand( 
        IData data,
        bool lastCommand, 
        bool encrypt);
```

<table data-header-hidden><thead><tr><th width="150.33331298828125" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>data</p></td><td valign="top"><p>Command to send to the NFC tag.</p><ul><li>Get Version</li><li>Read</li><li>Fast Read</li><li>Write</li><li>Compatibility Write</li><li>Read_Cnt</li><li>PWD_Auth</li><li>Read_Sig</li></ul><p> </p><p>For details of the command see the NFC commands table below or <em>D998200383 DynaFlex Family Programmer’s Manual (COMMANDS) section NFC/Mifare Pass Through Commands</em></p></td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p>lastCommand</p></td><td valign="top"><p>Determines if this is the last NFC command to complete the operation.</p><p> </p><p>true = This is the last command. Device will provide a single beep after receiving a successful response from the NFC tag. To send subsequent commands, the NFC tag must be activated by calling startTransaction() with NFC enabled.</p><p> </p><p>false = Expect more commands (Default).</p><p> </p><p>Either set to true or false, if the NFC tag command fails, device will provide a double beep.</p></td></tr><tr><td valign="top"><p> </p><p>encrypt</p></td><td valign="top"><p>Determines if data returned is to be encrypted.</p><p>true = Encrypt data</p><p>false = Do not encrypt data (Default)</p></td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

**NFC Commands**

<table data-header-hidden><thead><tr><th width="124.66665649414062" valign="top"></th><th width="93.3333740234375" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Command</td><td valign="top">Length</td><td valign="top">Field Value</td></tr><tr><td valign="top"><p> </p><p> </p><p>Get Version</p></td><td valign="top"><p> </p><p> </p><p>1</p></td><td valign="top"><p>The GET_VERSION command is used to retrieve information on the NTAG family, the product version, storage size and other product data required to identify the specific NTAG21x.</p><p> </p><p>Byte 0 = 0x60</p></td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="110" valign="top"></th><th width="84.6666259765625" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Command</td><td valign="top">Length</td><td valign="top">Field Value</td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p>Read</p></td><td valign="top"><p> </p><p> </p><p> </p><p> </p><p>2</p></td><td valign="top"><p>The READ command requires a start page address, and returns the 16 bytes of four NTAG21x pages. For example, if address is 03h then pages 03h, 04h, 05h, 06h are returned. Special conditions apply if the READ command address is near the end of the accessible memory area. The special conditions also apply if at least part of the addressed pages is within a password protected area.</p><p> </p><p>Byte 0 = 0x30</p><p>Byte 1 = Start Page Address</p></td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p>Fast Read</p></td><td valign="top"><p> </p><p> </p><p> </p><p>3</p></td><td valign="top"><p>The FAST_READ command requires a start page address and an end page address and returns the all n*4 bytes of the addressed pages. For example, if the start address is 03h and the end address is 07h then pages 03h, 04h, 05h, 06h and 07h are returned.</p><p> </p><p>Byte 0 = 0x3A</p><p>Byte 2 = Start Page Address Byte 3 = End Page Address</p></td></tr><tr><td valign="top"><p> </p><p> </p><p>Write</p></td><td valign="top"><p> </p><p> </p><p>6</p></td><td valign="top"><p>The WRITE command requires a block address, and writes 4 bytes of data into the addressed NTAG21x page.</p><p>Byte 0 = 0xA2</p><p>Byte 1 = Address to Write</p><p>Byte 2 to 5 = 4 Bytes of Data to Write</p></td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>Compatibility Write</p></td><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>18</p></td><td valign="top"><p>The COMPATIBILITY_WRITE command is implemented to guarantee interoperability with the established MIFARE Classic PCD infrastructure, in case of coexistence of ticketing and NFC applications. Even though 16 bytes are transferred to NTAG21x, only the least significant 4 bytes (bytes 0 to 3) are written to the specified address. Set all the remaining bytes, 04h to 0Fh, to logic 00h.</p><p> </p><p>Byte 0 = 0xA0</p><p>Byte 1 = Address to Write</p><p>Byte 2 to 17 = 16 Bytes of Data to Write (only least significant 4 bytes are written)</p><p>Note: This command is sent in 2 steps, which the Firmware will handle</p><p>(1)   &#x3C;CMD>&#x3C;Address to Write>&#x3C;CRCH>&#x3C;CRCL></p><p>(2)   &#x3C;16 Bytes of Data to Write>&#x3C;CRCH>&#x3C;CRCL></p></td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="138.66668701171875" valign="top"></th><th width="79.6666259765625" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Command</td><td valign="top">Length</td><td valign="top">Field Value</td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p>READ_CNT</p></td><td valign="top"><p> </p><p> </p><p> </p><p> </p><p>2</p></td><td valign="top"><p>The READ_CNT command is used to read out the current value of the NFC one-way counter of the NTAG213, NTAG215 and NTAG216. The command has a single argument specifying the counter number and returns the 24-bit counter value of the corresponding counter. If the NFC_CNT_PWD_PROT bit is set to 1b the counter is password protected and can only be read with the READ_CNT command after a previous valid password authentication</p><p>Byte 0 = 0x39</p><p>Byte 1 = 0x02 (NFC Counter Address)</p></td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>PWD_AUTH</p></td><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>5</p></td><td valign="top"><p>A protected memory area can be accessed only after a successful password verification using the PWD_AUTH command. The AUTH0 configuration byte defines the protected area. It specifies the first page that the password mechanism protects. The level of protection can be configured using the PROT bit either for write protection or read/write protection. The PWD_AUTH command takes the password as parameter and, if successful, returns the password authentication acknowledge, PACK. By setting the AUTHLIM configuration bits to a value larger than 000b, the number of unsuccessful password verifications can be limited. Each unsuccessful authentication is then counted in a counter featuring anti-tearing support. After reaching the limit of unsuccessful attempts, the memory access specified in PROT, is no longer possible.</p><p> </p><p>Byte 0 = 0x1B</p><p>Byte 1..4 = password (4 bytes)</p></td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p>READ_SIG</p></td><td valign="top"><p> </p><p> </p><p> </p><p>2</p></td><td valign="top"><p>The READ_SIG command returns an IC specific, 32-byte ECC signature, to verify NXP Semiconductors as the silicon vendor. The signature is programmed at chip production and cannot be changed afterwards.</p><p> </p><p>Byte 0 = 0x3C</p><p>Byte 1 = 0x00, RFU</p></td></tr></tbody></table>

**Response Data For NFC Tag Type 2**

<table data-header-hidden><thead><tr><th width="71.66665649414062" valign="top"></th><th width="69.66668701171875" valign="top"></th><th width="95.33331298828125" valign="top"></th><th width="79"></th><th></th></tr></thead><tbody><tr><td valign="top">Tag</td><td valign="top">Len</td><td colspan="3" valign="top">Value / Description</td></tr><tr><td valign="top"><p> </p><p>81</p></td><td valign="top"><p> </p><p>01</p></td><td colspan="3" valign="top">Tag Response Code 0x00 = Success 0x01 = Failed</td></tr><tr><td rowspan="9" valign="top">82</td><td rowspan="9" valign="top">var</td><td colspan="3" valign="top"><p>Encryption Control Payload</p><p> </p><p>If unencrypted:</p></td></tr><tr><td valign="top">Tag</td><td>Len</td><td>Value / Description</td></tr><tr><td valign="top">FC</td><td>var</td><td>NFC Data Container</td></tr><tr><td valign="top">/DF7A</td><td>var</td><td>NFC Data</td></tr><tr><td colspan="3" valign="top"><p> </p><p>If encrypted:</p></td></tr><tr><td valign="top">Tag</td><td>Len</td><td>Value / Description</td></tr><tr><td valign="top">/DFDF59</td><td>var</td><td>Encrypted Data Primitive to be decrypted.</td></tr><tr><td valign="top">/DFDF50</td><td>var</td><td>Encrypted Data KSN</td></tr><tr><td valign="top">/DFDF51</td><td>01</td><td>Encrypted Data Encryption Type</td></tr></tbody></table>

Example Unencrypted Payload

Example Encrypted Payload

### sendPlusNFCCommand <a href="#id-4.16_sendplusnfccommand" id="id-4.16_sendplusnfccommand"></a>

This function sends a command to a Mifare Plus NFC tag. The NFC tag must first be activated by calling startTransaction() with NFC enabled.

```
bool IDevice.sendPlusNFCCommand( 
        IData data,
        bool lastCommand, 
        bool encrypt);
```

<table data-header-hidden><thead><tr><th width="141.66668701171875" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>data</p></td><td valign="top"><p>Command to send to the NFC tag.</p><ul><li>Get Version</li><li>Read</li><li>Fast Read</li><li>Write</li><li>Compatibility Write</li><li>Read_Cnt</li><li>PWD_Auth</li><li>Read_Sig</li></ul><p> </p><p>For details of the command see the NFC commands table below or <em>D998200383 DynaFlex Family Programmer’s Manual (COMMANDS) section NFC/Mifare Pass Through Commands</em></p></td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p>lastCommand</p></td><td valign="top"><p>Determines if this is the last NFC command to complete the operation.</p><p> </p><p>true = This is the last command. Device will provide a single beep after receiving a successful response from the NFC tag. To send subsequent commands, the NFC tag must be activated by calling startTransaction() with NFC enabled.</p><p> </p><p>false = Expect more commands (Default).</p><p> </p><p>Either set to true or false, if the NFC tag command fails, device will provide a double beep.</p></td></tr><tr><td valign="top"><p> </p><p>encrypt</p></td><td valign="top"><p>Determines if data returned is to be encrypted.</p><p>true = Encrypt data</p><p>false = Do not encrypt data (Default)</p></td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

### sendSelection <a href="#id-4.17_sendselection" id="id-4.17_sendselection"></a>

This function sends a user selection to the device. The response data will be returned in the event OnEvent.

```
bool IDevice.sendSelection(IData data);
```

<table data-header-hidden><thead><tr><th width="183" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter for data</td><td valign="top">Description</td></tr><tr><td valign="top"><p> </p><p>Byte 0</p></td><td valign="top"><p>Status of User Selection:</p><p>0x00 = User Selection Request completed, see Selection Result 0x01 = User Selection Request aborted, cancelled by user 0x02 = User Selection Request aborted, timeout</p></td></tr><tr><td valign="top">Byte 1</td><td valign="top">The menu item selected by the user. This is a single byte zero based binary value.</td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

### 1.18    startTransaction <a href="#id-4.18_starttransaction" id="id-4.18_starttransaction"></a>

This function starts a transaction. This function will automatically handle the opening and closing of a device. The transaction will be processed through multiple calls to the event OnEvent(). See 15.23C.4 Sample Code for how to process an EMV transaction.

```
bool IDevice.startTransaction(
```

**ITransaction transaction);**

<table data-header-hidden><thead><tr><th width="135.6666259765625" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top">transaction</td><td valign="top">An interface that contains the parameters for the transaction.</td></tr></tbody></table>

Return Value:

Returns true if the transaction started successfully. Otherwise, returns false.

### subscribeAll <a href="#id-4.19_subscribeall" id="id-4.19_subscribeall"></a>

This function allows the host to be notified of all events sent by the device.

```
bool IDevice.subscribeAll(IEventSubscriber eventCallback);
```

<table data-header-hidden><thead><tr><th width="149.6666259765625" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top">eventCallback</td><td valign="top">Name of a class or structure that implements the IEventSubscriber interface event.</td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.

### unsubscribeAll <a href="#id-4.20_unsubscribeall" id="id-4.20_unsubscribeall"></a>

This function allows the host to no longer receive any events sent by the device.

```
bool IDevice.unsubscribeAll(IEventSubscriber eventCallback);
```

<table data-header-hidden><thead><tr><th width="199.66668701171875" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top">eventCallback</td><td valign="top">Name of a class or structure that implements the IEventSubscriber Delegate interface event.</td></tr></tbody></table>

Return Value:

Returns true if successful. Otherwise, returns false.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.magtek.com/sdks-and-tools/universal-sdk-documentation/.net-windows/idevice.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
