Pre-Filter Configurations Tutorial

RFID SDK for Xamarin 2.0.1.15

Overview

This Tutorial provides a walk-through of the steps to perform Pre-Filter configuration 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

Pre-filters are the same as the Select command of C1G2 specification. Once applied, pre-filters are applied prior to Inventory and Access operations.

Singulation

Refer Singulation for details. In order to filter tags that match a specific condition, it is necessary to use the tag-sessions and their states (setting the tags to different states based on match criteria - reader.Actions.PreFilters.add) so that while performing inventory, tags can be instructed to participate (singulation - reader.Config.Antennas.setSingulationControl) or not participate in the inventory based on their states.

State-Aware Singulation

In state-aware singulation the application can specify detailed controls for singulation: Action and Target. Action indicates whether matching Tags assert or deassert SL (Selected Flag), or set their inventoried flag to A or to B. Tags conforming to the match criteria specified using the method reader.Actions.PreFilters.Add are considered matching and the remaining are non-matching. Target indicates whether to modify a tag’s SL flag or its inventoried flag, and in the case of inventoried it further specifies one of four sessions.

Setting it up

The following are the steps to use pre-filters

  • Add pre-filters
  • Set appropriate singulation controls
  • Perform Inventory or Access operation

Each RFID reader supports a maximum number of pre-filters per antenna as indicated by reader.ReaderCapabilites.getMaxNumPreFilters which can be known using the ReaderCapabilities. The application can set pre-filters using reader.Actions.PreFilters.add and remove using reader.Actions.PreFilters.delete.


// Add state aware pre-filter for given EPC or Tag ID
private void addfilters(String tag)
{
    // Add state aware pre-filter
    PreFilters filters = new PreFilters();
    PreFilters.PreFilter filter = new PreFilters.PreFilter(filters);
    filter.AntennaID = 1;// Set this filter for Antenna ID 1
    filter.SetTagPattern(tag);// Tags which starts with passed pattern
    filter.TagPatternBitCount = tag.Length * 4;
    filter.BitOffset = 32; // skip PC bits (always it should be in bit length)
    filter.MemoryBank = MEMORY_BANK.MemoryBankEpc;
    filter.FilterAction = FILTER_ACTION.FilterActionStateAware; // use state aware singulation
    filter.StateAwareAction.Target = TARGET.TargetInventoriedStateS1; // inventoried flag of session S1 of matching tags to B
    filter.StateAwareAction.StateAwareAction = STATE_AWARE_ACTION.StateAwareActionInvB;
    // not to select tags that match the criteria
    try
    {
        Reader.Actions.PreFilters.Add(filter);
    }
    catch (InvalidUsageException e)
    {
        e.PrintStackTrace();
    }
    catch (OperationFailureException e)
    {
        e.PrintStackTrace();
    }
}

Set singulation control

Now that the pre-filters are set (i.e., tags are classified into matching or non-matching criteria), the application needs to specify which tags should participate in the inventory using reader.Config.Antennas.setSingulationControl(). Singulation Control must be specified with respect to each antenna like pre-filters.


// Set the singulation control matching with prefilter
private void setSingulationForFilter()
{
    try
    {
        // Get Singulation Control for the antenna 1 
        Antennas.SingulationControl singulationControl;
        singulationControl = Reader.Config.Antennas.GetSingulationControl(1);

        // Set Singulation Control for the antenna 1 
        singulationControl.Session = SESSION.SessionS1;
        singulationControl.Action.InventoryState = INVENTORY_STATE.InventoryStateB;
        singulationControl.Action.SetPerformStateAwareSingulationAction(true);
        Reader.Config.Antennas.SetSingulationControl(1, singulationControl);
    }
    catch (OperationFailureException ex)
    {
        Console.WriteLine(" Singulation configuration failed " + ex.VendorMessage);
    }
}

Performing operation

Inventory or Access operation when performed after setting pre-filters, use the tags filtered out of pre-filters for their operation.


try
{
    Reader.Actions.Inventory.Perform();
    Thread.Sleep(5000);
    Reader.Actions.Inventory.Stop();
}
catch (InvalidUsageException e)
{
    e.PrintStackTrace();
}
catch (OperationFailureException e)
{
    e.PrintStackTrace();
}

Closer look

  • Pre-Filter i.e. select command moves matching tags to given state and then applying matching singulation results in interested tags getting inventoried
  • StateAwareAction has various conditions set to matching and non matching group of tags
  • After pre-filter application tag moves its state if matching and then it participates in inventory irrespective to SESSION behaviour - given session is also matching

What's Next

  • Alter singulationControl.Action.InventoryState = INVENTORY_STATE.InventoryStateB; with INVENTORY_STATE.InventoryStateA to select non matching tags