Overview
This Tutorial provides a walk-through of the steps to perform Inventory 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
A Simple continuous Inventory operation reads all tags in the field of view on all antennas of the connected RFID reader. It uses no filters (pre-filters or post-filters) and the start and stop trigger for the inventory is the default - immediate type. for example, start immediately when reader.Actions.Inventory.perform() is called, and stop immediately when reader.Actions.Inventory.stop() is called
Setting it up
Event and Trigger configuration to setup operation
// tag event with tag data
reader.Events.setTagReadEvent(true);
// application will collect tag using getReadTags API
reader.Events.setAttachTagDataWithReadEvent(false);
TriggerInfo triggerInfo = new TriggerInfo();
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_IMMEDIATE);
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_IMMEDIATE);
// set start and stop triggers
reader.Config.setStartTrigger(triggerInfo.StartTrigger);
reader.Config.setStopTrigger(triggerInfo.StopTrigger);
Performing operation
start and stop inventory calls
try {
// perform simple inventory
reader.Actions.Inventory.perform();
// Sleep or wait
Thread.sleep(5000);
// stop the inventory
reader.Actions.Inventory.stop();
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (final OperationFailureException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
Grab the results
Gets results in eventreadnotify when reader starts reporting the read tags
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());
}
}
}
Closer look
- API call
Inventory.perform()
starts operation on reader - API call
Inventory.stop()
stops operation on reader - API call
getReadTags
request to retrieve 100 tags from SDK's internal queue of tags, one can change this number as per tag reading speed or application processing speed
What's Next
- Print various status notification in
eventStatusNotify
to see inventory start and stop events setAttachTagDataWithReadEvent
to true and receive each tag data inRfidReadEvents