Pre-Filter Configurations Tutorial

RFID SDK for Android 2.0.2.82

Applicable Devices : ALL

Overview

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

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 = filters.new PreFilter();
        filter.setAntennaID((short) 1);// Set this filter for Antenna ID 1
        filter.setTagPattern(tag);// Tags which starts with passed pattern
        filter.setTagPatternBitCount(tag.length() * 4);
        filter.setBitOffset(32); // skip PC bits (always it should be in bit length)
        filter.setMemoryBank(MEMORY_BANK.MEMORY_BANK_EPC);
        filter.setFilterAction(FILTER_ACTION.FILTER_ACTION_STATE_AWARE); // use state aware singulation
        filter.StateAwareAction.setTarget(TARGET.TARGET_INVENTORIED_STATE_S1); // inventoried flag of session S1 of matching tags to B
        filter.StateAwareAction.setStateAwareAction(STATE_AWARE_ACTION.STATE_AWARE_ACTION_INV_B);
        // 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 {
            Antennas.SingulationControl s1_singulationControl = reader.Config.Antennas.getSingulationControl(1);
            s1_singulationControl.setSession(SESSION.SESSION_S1);
            s1_singulationControl.Action.setInventoryState(INVENTORY_STATE.INVENTORY_STATE_B);
            s1_singulationControl.Action.setPerformStateAwareSingulationAction(true);
            reader.Config.Antennas.setSingulationControl(1, s1_singulationControl);
        } catch (InvalidUsageException e) {
            e.printStackTrace();
        } catch (OperationFailureException e) {
            e.printStackTrace();
        }
    }

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();
} catch (InterruptedException 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
  • setStateAwareAction 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.setInventoryState(INVENTORY_STATE.INVENTORY_STATE_B) with INVENTORY_STATE.INVENTORY_STATE_A to select non matching tags