Utilize the NFC tag Data on the MC9300 Device

Article ID: 08906895

Issue / Question

How to utilize the NFC tag Data on the Device?

Applicable To

MC9300

Resolution / Answer

Concept
The MC93 has an embedded NFC tag inside battery well.


By using NFC enabled device (host device), it is possible to add more content of the embedded tag.

The NFC function should be enabled on the host device via Android settings (i.e. “Connected Devices” – NFC). The RF field of the device must point to the back of the battery compartment (as shown below) to establish the NFC communication.



The tag type is NXP ICODE SLIX2. The memory of 320 bytes is divided in two pages:
 

1. Page L: Zebra protected page is used to record P/N, S/N and MFD. Data is formatted as NFC NDEF text record. It cannot be changed. Limit block is 20 (0x14). Page size is 80 bytes.
 
2. Page H: The custom page is free to be used. There are 236 bytes which can be written for your application. This white paper explains how to access to this part.



How to implement reading/writing on Android application
The Android application should use TapLink AAR library from NXP. Download File>>

Follow TapLink integration documentation / Javadoc for more details.

It will be needed to register the TapLink library by following this procedure. Read More>>

It is a matter of register to mifare website and register package/application name. It generates a key to write on source code, replace the mKey with the value.

private NxpNfcLib mNxpNfcLib; // Taplink library instance
private String mKey = "b400574e1bebf5cfd90e389637828045";

private static final byte FLAGS_DEFAULT = 0x02;



Library has to be initialized

private void initializeLibrary() {
    mNxpNfcLib = NxpNfcLib.getInstance();
    mNxpNfcLib.registerActivity(this, mKey);
}



NXP NFC library should start/stop foreground dispatch NFC events onResume/onPause
 

@Override
protected void onResume() {
    super.onResume();
    mNxpNfcLib.startForeGroundDispatch();
}

@Override
protected void onPause() {
    super.onPause();
    mNxpNfcLib.stopForeGroundDispatch();
}



On each new card, it will raise onNewIntent. At this point, the card logic can be implemented
 

@Override
protected void onNewIntent(Intent intent) {
    cardLogic(intent);
}

private void cardLogic(Intent intent) {
    CardType cardType = mNxpNfcLib.getCardType(intent);
    displayMessage("Card type found: " + cardType.getTagName());
    if(cardType == CardType.ICodeSLIX2){
        try {
            iCodeSLIX2CardLogic(ICodeFactory.getInstance().getICodeSLIX2(
                    mNxpNfcLib.getCustomModules()));
        } catch (Throwable t) {
            toastMessage("Unknown error tap again");
        }
    }
}

private void iCodeSLIX2CardLogic(IICodeSLIX2 iCodeSLIX2) {
	// Add your code here
	// example: write 4 bytes (random data) on block 25
	writeData(iCodeSLIX2, (byte) 25);
}



Example of write data with reading check
 

private boolean writeData (IICodeSLIX2 iCodeSLIX2, byte blockNb){
    displayMessage("-- Write data on block# " + blockNb);
    byte[] dataNew = new byte[]{(byte) mRandom.nextInt(),(byte) mRandom.nextInt(),(byte) mRandom.nextInt(),(byte) mRandom.nextInt()};
    displayMessage(" Data to write: " + Utilities.bytesToString(dataNew));
    iCodeSLIX2.writeSingleBlock(FLAGS_DEFAULT, blockNb, dataNew);
    byte[] data = iCodeSLIX2.readSingleBlock(FLAGS_DEFAULT, blockNb);
    displayMessage(" Read data: " + Utilities.bytesToString(data));
    return Arrays.equals(data, dataNew);
}

+ Applicable Products

  • MC9300 Mobile Computer