Write Access Operations Tutorial

RFID SDK for Android 2.0.2.124

Applicable Devices : ALL

Overview

This Tutorial provides a walk-through of the steps to perform Write Access operation using RFID3 API

Create The Project

  • Start by creating a new project in Android Studio. For help, see the Android Studio tutorial.
  • Refer Hello RFID to prepare basic setup to work with RFID Reader and then follow this guide

Details

Tag Access operations are performed on a specific tag or applied on tags that match a specific Access-Filter. If no Access-Filter is specified, the Access Operation is performed on all tags in the field of view of chosen antennas. This section covers the Simple Tag Access operation on a specific tag which is in the field of view of any of the antennas of the connected RFID reader.

Setting it up

The application can call method reader.Actions.TagAccess.writeWait or reader.Actions.TagAccess.blockWriteWait to write data to a specific memory bank. The response is returned as a Tagdata from where number of words can be retrieved.

Performing Write operation

The application can call method reader.Actions.TagAccess.writeWait or reader.Actions.TagAccess.blockWriteWait to write data to a specific memory bank. The response is returned as a Tagdata from where number of words can be retrieved.


// Write user memory bank data
TagData tagData = null;
String tagId = "1234ABCD00000000000025B1";
TagAccess tagAccess = new TagAccess();
TagAccess.WriteAccessParams writeAccessParams = tagAccess.new WriteAccessParams();
String writeData = "11223344"; //write data in string
writeAccessParams.setAccessPassword(0);
writeAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);
writeAccessParams.setOffset(0); // start writing from word offset 0
writeAccessParams.setWriteData(writeData);
// data length in words
writeAccessParams.setWriteDataLength(writeData.length() / 4);
// antenna Info is null – performs on all antenna
reader.Actions.TagAccess.writeWait(tagId, writeAccessParams, null, tagData);

Block Write

Following shows usage of block write, note that same write access parameters are passed as used above So it becomes easy to switch between two APIs


reader.Actions.TagAccess.blockWriteWait(tagId, writeAccessParams, null, tagData); 

Grab the results

writeWait returns result in parameter passed as TagData


Log.d(TAG, " Number of words written " + tagData.getNumberOfWords());

Closer look

  • tagData.getNumberOfWords() provides number of words written. This can be useful in case of partial writes
  • tagData.getOpStatus() returns success or error code as ACCESS_OPERATION_STATUS
  • tagData.getOpCode() provides type of access operation performed

What's Next

  • Change the setCount and setOffset as per requirement
  • Use access password setAccessPassword to perform operation on protected memorybank