The MIFARE RFID card allows you to control a public transport ticket, loyalty card, event access (stadiums, exhibitions, leisure parks), an electronic wallet, corporate identification with a personalized card as a badge, and a visitor only as an employee badge.

 

Mifare Ultralight cards

To manage the Mifare Ultralight cards you will need to use the UltralightManagement module class. You can see the class description below:

  try {
            UltralightManagement.getInstance().bind(this, new OnBindListener() {
                @Override
                public void onBindComplete() {

                    try {
                        UltralightManagement.getInstance().open(1000);
                        boolean isDetected = UltralightManagement.getInstance().detect(30_000);
                        if (isDetected) {
                           //TODO: Here you can use the supported functions described below  
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        try {
                            UltralightManagement.getInstance().close(1000);
                        } catch (Exception exception) {
                            exception.printStackTrace();
                        }
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }

 

These are the methods you can use:

 

1. exchangeCmd(byte[] data, long timeOut)

Exchange data with command(use the original command to communicate with the card directly)

 

public byte[] exchangeCmd(byte[] data, long timeOut);


Parameters:

 

Parameter

Description  

data

Command data sent to the card

timeOut

Timeout in milliseconds (Long)



 

Return value:
       Success, return response data
       Failed, return null

 

2. authority (byte [] data, long timeOut)

Block certification.

 

public int authority(byte[] data, long timeOut);


Parameters:

 

Parameter

Description  

data

Password authentication, 16 bytes (hex)

timeOut

Timeout in milliseconds (Long)

 

 

Return value:
       SdkResult.Success - success
       Sdk.Result.Fail - other errors

 

3. readBlock(byte block, long timeOut)

Read block data.

 

public byte[] readBlock(byte block, long timeOut);

 

Parameters:

 

Parameter

Description  

block

block number

timeOut

Timeout in milliseconds (Long)

 

 

Return value:
       Success, return block data
       Failed, return null

 

4. writeBlock(byte block, byte[] data, long timeOut)

Write block data.

 

public int writeBlock(byte block, byte[] data, long timeOut);

 

Parameters:

 

Parameter

Description  

block

block number

data

Write data

timeOut

Timeout in milliseconds (Long)

 

 

Return value:
       SdkResult.Success - success
       Sdk.Result.Fail - other errors

 

For M1 cards:

To manage the M1 cards you will need to use the M1Management class. You can see the class description below:

try {
                    M1Management.getInstance().bind(this, new OnBindListener() {
                        @Override
                        public void onBindComplete() {
                            try {
                                M1Management.getInstance().open(1000);
                                boolean isDetected = M1Management.getInstance().detect(30_000);
                                if (isDetected) {
                                    byte[] blockData = new byte[2048];
                       //TODO: Here you can use the supported functions described below 
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                                try {
                                    M1Management.getInstance().close(1000);
                                } catch (Exception exception) {
                                    exception.printStackTrace();
                                }
                            }
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }

 

These are the methods you can use:

 

1. readUid(long timeOut)

Read card unique id. 

 

public String readUid(long timeOut);

 

Parameters:

 

Parameter

Description  

timeOut

Timeout in milliseconds (Long)

 

Return value:
       card uid

 

2. authority(AuthEntity auth, long timeOut)

Block certification.

 

public int authority(AuthEntity auth, long timeOut);

 

Parameters:

 

Parameter

Description  

auth

AuthEntity, the authentication information class

timeOut

Timeout in milliseconds (Long)

 

AuthEntity

 

Attributes

Description  

int blkNo

Block number

M1KeyTypeEnum keyType

Key type enumeration

byte [] pwd

Password authentication

String m1SN

M1 card uid

 

M1KeyTypeEnum

 

Enumeration Name

Description  

KEYTYPE_A

KEY A

KEYTYPE_B

KEY B

 

Return Value:
       SdkResult.Success - success
       SdkResult.Device_Not_Ready - the device is not ready
       SdkResult.Param_In_InValid - Parameter is not legitimate
       SdkResult.M1Card_Verify_Err - M1 card authentication failure
       SdkResult.Fail - other errors

 

3. readBlock(int blockNo, byte[] dataOut, long timeOut)

Read block data.

 

public int readBlock(int blockNo, byte[] dataOut, long timeOut);


Parameters:

 

Parameter

Description  

blockNo

Block number

dataOut

Output data

timeOut

Timeout in milliseconds (Long)

   

Return Value:
       SdkResult.Success - success
       SdkResult.Device_Not_Ready - the device is not ready
       SdkResult.Param_In_InValid - Parameter is not legitimate
       SdkResult.Fail - other errors

 

4. writeBlock(int blockNo, byte[] data, long timeOut)

Write block data.

 

public int writeBlock(int blockNo, byte[] data, long timeOut);

 

Parameters:

 

Parameter

Description  

blockNo

Block number

data

The data you write in the block

timeOut

Timeout in milliseconds (Long)

  

Return Value:
       SdkResult.Success - success
       SdkResult.Device_Not_Ready - the device is not ready
       SdkResult.Param_In_InValid - Parameter is not legitimate
       SdkResult.Fail - other errors

 

5. readBlockValue(int blockNo, int[] valueReference, long timeOut)

Read block value

 

public int readblockValue(int blockNo, int[] valueReference, long timeOut);


Parameters:

 

Parameter

Description  

blockNo

Block number

valueReference

Output value

timeOut

Timeout in milliseconds (Long)

  

Return Value:
       SdkResult.Success - success
       SdkResult.Device_Not_Ready - the device is not ready
       SdkResult.Param_In_InValid - Parameter is not legitimate
       SdkResult.Fail - other errors

 

6. writeBlockValue(int blockNo, int value, long timeOut)

Write block value

 

public int writeblockValue(int blockNo, int value, long timeOut);

 

Parameters:

 

Parameter

Description  

blockNo

Block number

value

The value you write in the block

timeOut

Timeout in milliseconds (Long)

 

 

Return Value:
       SdkResult.Success - success
       SdkResult.Device_Not_Ready - the device is not ready
       SdkResult.Param_In_InValid - Parameter is not legitimate
       SdkResult.Fail - other errors