Overview
This Tutorial provides a walk-through of the steps to perform Read 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
Create necessary fields like EPC ID as String
tagId and access parameters TagAccess.ReadAccessParams
// Read user memory bank for the given tag ID
String tagId = "1234ABCD00000000000025B1";
TagAccess tagAccess = new TagAccess();
TagAccess.ReadAccessParams readAccessParams = tagAccess.new ReadAccessParams();
Performing operation
Prepare ReadAccesParams
as per requirement and pass it to readWait
API
// Read user memory bank for the given tag ID
String tagId = "1234ABCD00000000000025B1";
TagAccess tagAccess = new TagAccess();
TagAccess.ReadAccessParams readAccessParams = tagAccess.new ReadAccessParams();
TagData readAccessTag;
readAccessParams.setAccessPassword(0);
// read 4 words
readAccessParams.setCount(4);
// user memory bank
readAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);
// start reading from word offset 0
readAccessParams.setOffset(0);
// read operation
TagData tagData = reader.Actions.TagAccess.readWait(tagId, readAccessParams, null);
Grab the results
readWait
returns result as TagData
if (tagData != null) {
ACCESS_OPERATION_CODE readAccessOperation = tagData.getOpCode();
if (readAccessOperation != null) {
if (tagData.getOpStatus() != null && !tagData.getOpStatus().equals(ACCESS_OPERATION_STATUS.ACCESS_SUCCESS)) {
String strErr = tagData.getOpStatus().toString().replaceAll("_", " ");
Toast.makeText(getActivity(), strErr.toLowerCase(), Toast.LENGTH_SHORT).show();
} else {
if (tagData.getOpCode() == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ) {
Toast.makeText(getActivity(), R.string.msg_read_succeed + " "+tagData.getMemoryBankData(), Toast.LENGTH_SHORT).show();
} else {
}
}
} else {
Toast.makeText(getActivity(), R.string.err_access_op_failed, Toast.LENGTH_SHORT).show();
Constants.logAsMessage(Constants.TYPE_DEBUG, "ACCESS READ", "memoryBankData is null");
}
} else {
Toast.makeText(getActivity(), R.string.err_access_op_failed, Toast.LENGTH_SHORT).show();
}
Closer look
- Configure required memory bank using
readAccessParams.setMemoryBank
tagData.getOpStatus()
returns success or error code asACCESS_OPERATION_STATUS
tagData.getOpCode()
provides type of access operation performed
What's Next
- Change the
setCount
andsetOffset
as per requirement - Use access password
setAccessPassword
to perform operation on protected memorybank