TAG Write Operation Guide

RFID SDK for Android 2.0.2.94

Overview

This guide covers detail walk-through to perform Write operation

General Steps

Following are the general steps for performing write operation successfully

  1. Disable DPO in case of RFD8500 (step not required in case of fixed readers)
  2. Set Power equal or greater than 220dbm
  3. Use Session S0
  4. Isolate the TAG while performing write operation
  5. Use prefilter to singulate the tag
  6. Add retry mechanism and handle partial writes

Setting it up

Following is the generic setup or moving reader to known state suitable for access operation

  1. Set Antenna power to 240dbm
  2. Disable DPO in case of RFD8500
  3. Seting up access operation timeout

// configuration
private void setAntennaPower(int power) {
    Log.d(TAG, "setAntennaPower " + power);
    try {
        // set antenna configurations
        Antennas.AntennaRfConfig config = reader.Config.Antennas.getAntennaRfConfig(1);
        config.setTransmitPowerIndex(power);
        config.setrfModeTableIndex(0);
        config.setTari(0);
        reader.Config.Antennas.setAntennaRfConfig(1, config);
    } catch (InvalidUsageException e) {
        e.printStackTrace();
    } catch (OperationFailureException e) {
        e.printStackTrace();
    }
}

private void setSingulation(SESSION session, INVENTORY_STATE state) {
    Log.d(TAG, "setSingulation " + session);
    try {
        // Set the singulation control
        Antennas.SingulationControl s1_singulationControl = reader.Config.Antennas.getSingulationControl(1);
        s1_singulationControl.setSession(session);
        s1_singulationControl.Action.setInventoryState(state);
        s1_singulationControl.Action.setSLFlag(SL_FLAG.SL_ALL);
        reader.Config.Antennas.setSingulationControl(1, s1_singulationControl);
    } catch (InvalidUsageException e) {
        e.printStackTrace();
    } catch (OperationFailureException e) {
        e.printStackTrace();
    }
}

private void setDPO(boolean bEnable) {
    Log.d(TAG, "setDPO " + bEnable);
    try {
        // control the DPO
        reader.Config.setDPOState(bEnable ? DYNAMIC_POWER_OPTIMIZATION.ENABLE : DYNAMIC_POWER_OPTIMIZATION.DISABLE);
    } catch (InvalidUsageException e) {
        e.printStackTrace();
    } catch (OperationFailureException e) {
        e.printStackTrace();
    }
}

private void setAccessOperationConfiguration() {
    // set required power and profile
    setAntennaPower(240);
    // in case of RFD8500 disable DPO
    if (reader.getHostName().contains("RFD8500"))
        setDPO(false);
    //
    try {
        // set access operation time out value to 1 second, so reader will tries for a second
        // to perform operation before timing out
        reader.Config.setAccessOperationWaitTimeout(1000);
    } catch (InvalidUsageException e) {
        e.printStackTrace();
    } catch (OperationFailureException e) {
        e.printStackTrace();
    }
}

In case of fixed readers

  1. Set Antenna power to 240dbm

// configuration
private void setAntennaPower(int power) {
    Log.d(TAG, "setAntennaPower " + power);
    try {
        // set antenna configurations
        Antennas.AntennaRfConfig config = reader.Config.Antennas.getAntennaRfConfig(1);
        config.setTransmitPowerIndex(power);
        config.setrfModeTableIndex(0);
        config.setTari(0);
        reader.Config.Antennas.setAntennaRfConfig(1, config);
    } catch (InvalidUsageException e) {
        e.printStackTrace();
    } catch (OperationFailureException e) {
        e.printStackTrace();
    }
}

private void setSingulation(SESSION session, INVENTORY_STATE state) {
    Log.d(TAG, "setSingulation " + session);
    try {
        // Set the singulation control
        Antennas.SingulationControl s1_singulationControl = reader.Config.Antennas.getSingulationControl(1);
        s1_singulationControl.setSession(session);
        s1_singulationControl.Action.setInventoryState(state);
        s1_singulationControl.Action.setSLFlag(SL_FLAG.SL_ALL);
        reader.Config.Antennas.setSingulationControl(1, s1_singulationControl);
    } catch (InvalidUsageException e) {
        e.printStackTrace();
    } catch (OperationFailureException e) {
        e.printStackTrace();
    }
}

Perform Write

Following shows usage of write operation with SDK applying prefilter and number of retries internally and thus simplified application


//
// method to write data
//
private void writeTag(String sourceEPC, String Password, MEMORY_BANK memory_bank, String targetData, int offset) {
    Log.d(TAG, "WriteTag " + targetData);
    try {
        TagData tagData = null;
        String tagId = sourceEPC;
        TagAccess tagAccess = new TagAccess();
        TagAccess.WriteAccessParams writeAccessParams = tagAccess.new WriteAccessParams();
        String writeData = targetData; //write data in string
        writeAccessParams.setAccessPassword(Long.parseLong(Password,16));
        writeAccessParams.setMemoryBank(memory_bank);
        writeAccessParams.setOffset(offset); // start writing from word offset 0
        writeAccessParams.setWriteData(writeData);
        // set retries in case of partial write happens
        writeAccessParams.setWriteRetries(3);
        // data length in words
        writeAccessParams.setWriteDataLength(writeData.length() / 4);
        // 5th parameter bPrefilter flag is true which means API will apply pre filter internally
        // 6th parameter should be true in case of changing EPC ID it self i.e. source and target both is EPC
        boolean useTIDfilter = memory_bank == MEMORY_BANK.MEMORY_BANK_EPC;
        reader.Actions.TagAccess.writeWait(tagId, writeAccessParams, null, tagData, true, useTIDfilter);
    } catch (InvalidUsageException e) {
        e.printStackTrace();
    } catch (OperationFailureException e) {
        e.printStackTrace();
    }
}

Incase of Fixed readers


//
// method to write data
//
private void writeTag(String sourceEPC, String Password, MEMORY_BANK memory_bank, String targetData, int offset) {
    Log.d(TAG, "WriteTag " + targetData);
    try {
        TagData tagData = null;
        String tagId = sourceEPC;
        TagAccess tagAccess = new TagAccess();
        TagAccess.WriteAccessParams writeAccessParams = tagAccess.new WriteAccessParams();
        String writeData = targetData; //write data in string
        writeAccessParams.setAccessPassword(Long.parseLong(Password,16));
        writeAccessParams.setMemoryBank(memory_bank);
        writeAccessParams.setOffset(offset); // start writing from word offset 0
        writeAccessParams.setWriteData(writeData);
        // set retries in case of partial write happens
        writeAccessParams.setWriteRetries(3);
        // data length in words
        writeAccessParams.setWriteDataLength(writeData.length());
        // 5th parameter bPrefilter flag is true which means API will apply pre filter internally
        // 6th parameter should be true in case of changing EPC ID it self i.e. source and target both is EPC
        boolean useTIDfilter = memory_bank == MEMORY_BANK.MEMORY_BANK_EPC;
        reader.Actions.TagAccess.writeWait(tagId, writeAccessParams, null, tagData, true, useTIDfilter);
    } catch (InvalidUsageException e) {
        e.printStackTrace();
    } catch (OperationFailureException e) {
        e.printStackTrace();
    }
}

Write User data

Following shows storing data in tag USER memory bank - it uses methods defined above


private void WriteUser() {
    // one time setup to suite the access operation, if reader is already in that state it can be avoided
    setAccessOperationConfiguration();
    // all are hex strings
    String EPC = "3005FB63AC1F3681EC880468";
    String data = "437573746F6D204461746120696E2055736572206D656D6F72792062616E6B0D";
    String password = "0";//"5A454252";
    // perform write
    writeTag(EPC, password, MEMORY_BANK.MEMORY_BANK_USER, data, 0);
}                                              

Write access password

Following shows setting up access operation password


private void WritePassword() {
    // one time setup to suite the access operation, if reader is already in that state it can be avoided
    //setAccessOperationConfiguration();
    //
    String EPC = "3005FB63AC1F3681EC880468";
    String data = "5A454252"; // new password
    String password = "0"; // no existing password
    // perform write, offset is two for access password
    writeTag(EPC, password, MEMORY_BANK.MEMORY_BANK_RESERVED, data, 2);
}

Change EPC ID

Following shows changing EPC ID


private void WriteEPC() {
    // one time setup to suite the access operation, if reader is already in that state it can be avoided
    //setAccessOperationConfiguration();
    //
    String EPC = "3005FB63AC1F3681EC880468";
    String data = "3005FB63AC1F3681EC880468";
    String password = "0";
    // perform write, offset is two for EPC ID
    writeTag(EPC, password, MEMORY_BANK.MEMORY_BANK_EPC, data, 2);
}