Inventory Tutorial

RFID SDK for Xamarin 2.0.1.15

Overview

This Tutorial provides a walk-through of the steps to perform Inventory operation using Xamarin RFID SDK

Create the Project

  • Start by creating a new project in Visual Studio. For help, see the Create Project.
  • 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. forexample, 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.TriggerType = START_TRIGGER_TYPE.StartTriggerTypeImmediate;
triggerInfo.StopTrigger.TriggerType = STOP_TRIGGER_TYPE.StopTriggerTypeImmediate;

// set start and stop triggers
Reader.Config.StartTrigger = triggerInfo.StartTrigger;
Reader.Config.StopTrigger = 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 ( OperationFailureException e) {
    e.PrintStackTrace();
}

Grab the results

Gets results in eventreadnotify when reader starts reporting the read tags


// 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++)
        {
            Console.Out.WriteLine("Tag ID " + myTags[index].TagID);
        }
    }
}

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 in RfidReadEvents