Overview
This Tutorial provides a walk-through of the steps to perform Smart Periodic 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 Smart Periodic Inventory operation reads all tags in the field of view on all antennas of the connected RFID reader. By default the start trigger is set to START_TRIGGER_TYPE_SMART_PERIODIC_INVENTORY
and stop trigger is set to STOP_TRIGGER_TYPE_DURATION
Below is the table for supported Strat Trigger type.
Start Trigger Type | Mandatory | OFF |
---|---|---|
START_TRIGGER_TYPE_IMMEDIATE | NA | YES |
START_TRIGGER_TYPE_PERIODIC | YES | NA |
START_TRIGGER_TYPE_GPI | NA | NA |
START_TRIGGER_TYPE_SMART_PERIODIC_INVENTORY | YES | NA |
Below is the table for supported Stop Trigger type.
Stop Trigger Type | Mandatory | OFF |
---|---|---|
STOP_TRIGGER_TYPE_IMMEDIATE | NA | YES |
STOP_TRIGGER_TYPE_DURATION | YES | YES |
STOP_TRIGGER_TYPE_GPI_WITH_TIMEOUT | NA | NA |
STOP_TRIGGER_TYPE_TAG_OBSERVATION_WITH_TIMEOUT | NA | YES |
STOP_TRIGGER_TYPE_N_ATTEMPTS_WITH_TIMEOUT | NA | YES |
STOP_TRIGGER_TYPE_HANDHELD_WITH_TIMEOUT | NA | NA |
STOP_TRIGGER_TYPE_ACCESS_N_ATTEMPTS_WITH_TIMEOUT | NA | NA |
Setting it up
Event configuration to setup operation
// tag event with tag data
reader.Events.setTagReadEvent(true);
// application will collect tag using getReadTags API
reader.Events.setAttachTagDataWithReadEvent(false);
Performing Smart Periodic Inventory 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();
}
Overriding the default time(milliseconds) for Period and RF On time. Here is an example for Smart Periodic Inventory with 30% Duty cycle (Period: 500, RF On time: 150)
Duty cycle = (RF On Time)/Period.The minimum duty cycle can be set to 20% and maximum duty cycle can be set to 50%.
try {
triggerInfo = new TriggerInfo();
triggerInfo.StartTrigger = new StartTrigger();
triggerInfo.StopTrigger = new StopTrigger();
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE_SMART_PERIODIC_INVENTORY);
triggerInfo.StartTrigger.Periodic.setPeriod(500);
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_DURATION);
triggerInfo.StopTrigger.setDurationMilliSeconds(150);
return reader.Actions.Inventory.perform(null, triggerInfo, null);
} catch (Exception e) {
}
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