Trigger Settings Tutorial

RFID SDK for Android 2.0.2.82

Applicable Devices : Fixed Readers

Overview

This Tutorial provides a walk-through of the steps to perform Trigger Settings 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

Triggers are the conditions that should be satisfied in order to start or stop an operation (Inventory or Access Sequence). This information can be specified using TriggerInfo class. The application can also configure the Tag-Report trigger which indicates when to receive ‘n’ unique Tag-Reports from the Reader.

Setting it up

Declarations and API calls to setup configuration

  • GPI based Inventory
  • Start inventory when GPI port ‘n’ changes state to ‘TRUE’ and stop inventory when GPI port ‘n’ changes state to ‘FALSE’.9


TriggerInfo triggerInfo = new TriggerInfo();
// start trigger GPI port 1 changes to true
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_GPI);
triggerInfo.StartTrigger.GPI.setPortNumber(1);
triggerInfo.StartTrigger.GPI.setGPIEvent(true);
// stop trigger GPI port 1 changes to false
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_GPI_WITH_TIMEOUT);
triggerInfo.StopTrigger.GPI.setPortNumber(1);
triggerInfo.StopTrigger.GPI.setGPIEvent(false);
triggerInfo.StopTrigger.GPI.setTimeout(1000); // 1 sec
// report back each tag report as and when it is read by Reader
triggerInfo.setTagReportTrigger(1);

  • Periodic Inventory
  • Start inventory at a specified time for a specified duration repeatedly.


TriggerInfo triggerInfo = new TriggerInfo();
// start inventory on 12th of this month and 12am and runs 200 milliseconds of every 2 seconds
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_PERIODIC);
triggerInfo.StartTrigger.Periodic.setPeriod(2000); // perform inventory for 2 seconds
// start time
SYSTEMTIME startTime = new SYSTEMTIME();
startTime.Day = 6;
startTime.Month = 8;
startTime.Year = 2011;
startTime.Hour = 9;
startTime.Minute = 20;
startTime.Second = 5;
triggerInfo.StartTrigger.Periodic.StartTime = startTime;
// stop trigger 
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_DURATION);
triggerInfo.StopTrigger.setDurationMilliSeconds(200); // stop after 200 milliseconds
// report back all read tags after completion of one round of inventory (i.e. one period)
triggerInfo.setTagReportTrigger(0);
  • Perform ‘n’ Rounds of Inventory with a timeout
  • Start condition could be any; Stop condition is to perform ‘n’ rounds of inventory and then stop or stop inventory after the specified timeout.


TriggerInfo triggerInfo = new TriggerInfo();
// start inventory immediate
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_IMMEDIATE);
// stop trigger
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_N_ATTEMPTS_WITH_TIMEOUT);
triggerInfo.StopTrigger.NumAttempts.setN((short)3); // perform 3 rounds of inventory
triggerInfo.StopTrigger.NumAttempts.setTimeout(3000); // timeout after 3 seconds
// report back all read tags after 3 rounds of inventory
triggerInfo.setTagReportTrigger(0); 

  • Read ‘n’ Tags with a timeout
  • Start condition could be any; Stop condition is to stop after reading ‘n’ tags or stop inventory after the specified timeout.


TriggerInfo triggerInfo = new TriggerInfo();
// start inventory immediate
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_IMMEDIATE);
// stop trigger
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_TAG_OBSERVATION_WITH_TIMEOUT);
triggerInfo.StopTrigger.TagObservation.setN((short)100); // stop inventory after reading 100 tags
triggerInfo.StopTrigger.TagObservation.setTimeout(3000); // timeout after 3 seconds
// report back all read tags after getting 100 unique tags or after 3 seconds
triggerInfo.setTagReportTrigger(0);

  • Periodic Tag Reporting
  • Tags will be periodically reported on a specified timer interval elapsed. ReportTriggers takes precedence over TagReportTrigger property. In order to use setTagReportTrigger function, set the ReportTriggers.setPeriodicReportTrigger with value 0.


TriggerInfo triggerInfo = new TriggerInfo();
// Tags will be periodically reported in every 10 seconds
triggerInfo.ReportTriggers.setPeriodicReportTrigger(10);

Closer look

  • API call Inventory.perform(null,triggerInfo,null) starts operation on reader

What's Next

  • 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