Overview
This Tutorial provides a walk-through of the steps to perform Locate operation using RFID API3
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
The Tag locationing (reffered as Locate) feature is supported only on hand-held readers and is useful to locate a specific tag in the field of view of the reader’s antenna.
Setting it up
No specific setup is required. Only Tag ID is enough to perform locate operation
Performing Operation
reader.Actions.TagLocationing.Perform can be used to start locating a tag, and reader.Actions.TagLocationing.Stop to stop the locationing operation.
// Performing Tag Locationing on a particular tag ID.
reader.Actions.TagLocationing.Perform("E2002849491502421020B330", null, null);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
reader.Actions.TagLocationing.stop();
Grab the results
The result of locationing of a tag is reported as LocationInfo in TagData and is present in TagData if tagData isContainsLocationInfo is true. tagData.LocationInfo.getRelativeDistance gives the relative distance of the tag from the reader antenna.
//The response of the tag locationing comes through eventReadNotify in the following Event Handler.
public class EventHandler implements RfidEventsListener {
// Read Event Notification
public void eventReadNotify(RfidReadEvents e) {
TagData[] myTags = reader.Actions.getReadTags(100);
if (myTags != null) {
for (int index = 0; index < myTags.length; index++) {
Log.d(TAG,"Tag ID " + myTags[index].getTagID());
if (myTags[index].isContainsLocationInfo()) {
int tag = index;
Log.d(TAG,"Tag locationing distance " + myTags[tag].LocationInfo.getRelativeDistance());
}
}
}
}
}
Closer look
LocationInfo.getRelativeDistance()
gives relative distance i.e. from 0% to 100% where tag being tag very far to very close respectively
What's Next
reader.Actions.TagLocationing.Perform
API's third parameter is EPC mask. When looking for non-specific item from group, use EPC mask to filter matching tags