SDK For Android DG en
SDK For Android DG en
SDK For Android DG en
SDK FOR
ANDROID
Developer Guide
MN-003158-05 Rev. A
Copyright
ZEBRA and the stylized Zebra head are trademarks of Zebra Technologies Corporation, registered in many
jurisdictions worldwide. All other trademarks are the property of their respective owners. ©2019 Zebra
Technologies Corporation and/or its affiliates. All rights reserved.
Zebra Technologies Corporation Australia’s limited warranty above is in addition to any rights and remedies you
may have under the Australian Consumer Law. If you have any queries, please call Zebra Technologies
Corporation at +65 6858 0722. You may also visit our website: www.zebra.com for the most updated warranty
terms.
Terms of Use
• Proprietary Statement
This manual contains proprietary information of Zebra Technologies Corporation and its subsidiaries
(“Zebra Technologies”). It is intended solely for the information and use of parties operating and
maintaining the equipment described herein. Such proprietary information may not be used, reproduced,
or disclosed to any other parties for any other purpose without the express, written permission of Zebra
Technologies.
• Product Improvements
Continuous improvement of products is a policy of Zebra Technologies. All specifications and designs are
subject to change without notice.
• Liability Disclaimer
Zebra Technologies takes steps to ensure that its published Engineering specifications and manuals are
correct; however, errors do occur. Zebra Technologies reserves the right to correct any such errors and
disclaims liability resulting therefrom.
• Limitation of Liability
In no event shall Zebra Technologies or anyone else involved in the creation, production, or delivery of the
accompanying product (including hardware and software) be liable for any damages whatsoever
(including, without limitation, consequential damages including loss of business profits, business
interruption, or loss of business information) arising out of the use of, the results of use of, or inability to
use such product, even if Zebra Technologies has been advised of the possibility of such damages. Some
jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so the above
limitation or exclusion may not apply to you.
2
Revision History
Changes to the original manual are listed below:
Added:
- Set Default Configuration.
- RFD8500 information.
3
Table of Contents
Copyright ........................................................................................................................................... 2
For Australia Only ....................................................................................................................... 2
Terms of Use .................................................................................................................................... 2
Revision History ................................................................................................................................ 3
About
Introduction ....................................................................................................................................... 7
Supported RFID Readers ................................................................................................................. 7
Chapter Descriptions ........................................................................................................................ 7
Notational Conventions ..................................................................................................................... 8
Related Documents and Software .................................................................................................... 8
Service Information ........................................................................................................................... 9
Provide Documentation Feedback .................................................................................................... 9
Getting Started
Introduction ..................................................................................................................................... 10
Installing Android Studio ................................................................................................................. 10
Importing the 123RFID Mobile Application Project ......................................................................... 11
Building and Running Projects ........................................................................................................ 13
RFID API3 Android SDK ................................................................................................................. 16
Creating an Android Project ...................................................................................................... 16
Installing Xamarin ........................................................................................................................... 18
4
Table of Contents
5
Table of Contents
6
About
Introduction
The Zebra RFID SDK for Android Developer Guide provides installation and programming information for the
Software Developer Kit (SDK) that allows RFID application development for the Zebra Android devices.
NOTE: This guide provides details and references to SDK using both Java and Xamarin.
• Android Application development using Android Studio IDE and Java programming language.
• Android Application development using Xamarin - Visual Studio IDE and C# programming language.
• RFD2000
• RFD8500
• MC3300R
Chapter Descriptions
Topics covered in this guide are as follows:
• Getting Started provides an overview of the RFID SDK and sample mobile application usage, build, and
operation.
• ZEBRA RFID SDK for Android provides detailed information about how to use various basic and advanced
functionality to develop an Android application using the Zebra RFID SDK for Android.
• ZEBRA RFID SDK for Xamarin Android provides detailed information about how to use various basic and
advanced functionality to develop an Xamarin Android application using the Zebra RFID SDK for Xamarin
Android.
• Migrating to a Combined RFD8500/RFD2000 RFID SDK provides the information necessary to update
existing applications and develop new applications for use with the combined RFID SDK.
7
About
Notational Conventions
The following conventions are used in this document:
• Bold text is used to highlight the following:
• Key names on a keypad
• Button names on a screen
• Bullets (•) indicate:
• Action items
• Lists of alternatives
• Lists of required steps that are not necessarily sequential
• Sequential lists (e.g., those that describe step-by-step procedures) appear as numbered lists.
8
About
Service Information
If you have a problem using the equipment, contact your facility's technical or systems support. If there is a
problem with the equipment, they will contact the Zebra Global Customer Support Center at:
www.zebra.com/support.
When contacting Zebra support, please have the following information available:
• Serial number of the unit
• Model number or product name
• Software type and version number.
Zebra responds to calls by e-mail, telephone or fax within the time limits set forth in support agreements.
If your problem cannot be solved by Zebra support, you may need to return your equipment for servicing and will
be given specific directions. Zebra is not responsible for any damages incurred during shipment if the approved
shipping container is not used. Shipping the units improperly can possibly void the warranty.
If you purchased your business product from a Zebra business partner, contact that business partner for support.
9
Getting Started
Introduction
This chapter provides instruction on importing and running the 123RFID Mobile Application code and instructions.
NOTE: RFID API3 Android SDK depends upon android.support-v4 or v7 to run. If the Android application is
created without ‘appcompat’ support, add ‘com.android.support:support-v4’ or v7 in the gradle file ‘dependencies’
section. If the application is created with the application compatibility option, dependencies are automatically
added.
The latest SDK tools packaged with Android Studio are acceptable. To use the SDK manager to download the
required Android SDK packages go to Menu Tools > Android > SDK Manager.
10
Getting Started
11
Getting Started
12
Getting Started
1. Android Studio may start downloading required Gradle/SDK packages first. Define proxy information in
Android Studio and gradle properties as required and Android Studio starts to build the project.
13
Getting Started
2. After completion of a successful compilation, run the application using the Run App button. Android studio
prompts for the deployment target. Install the built application on the required device by choosing a device from
the Connected Devices list.
14
Getting Started
3. Figure 5 is the captured image of the demo application running on an Android device.
15
Getting Started
2. Navigate to File > New > Import Module to import the RFID API3 module.
16
Getting Started
3. Browse the RFIDAPI3Library folder (after source directory selection, the module name displays as
RFIDAPI3Library).
4. Add the module under dependencies in the application gradle file. The dependencies section shows
'appcompat' and RFIDAPI3 module as follows:
dependencies {
//.... other dependencies
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation project(':RFIDAPI3Library')
//....
}
Figure 9 Application Gradle Modification for Module
17
Getting Started
Installing Xamarin
To install Xamarin Android, click on Xamarin and follow the procedure. The guide and project uses the following
configurations:
• Minimum SDK Version - API 19: Android 4.4 (KitKat)
• Target SDK Version - API 25: Android 7.1.1 (Nougat)
• .NET Framework 4.6.1 Development environment
• Visual Studio 2017
• Xamarin Version: Xamarin.Android 7.0
NOTE: RFID API3 Xamarin SDK depends upon android AppCompatSupport library. AppCompatSupportV4 or
V7 library is mandatory for integrating the dll into the application. Applications created with standard templates
have Xamarin.Android.Support.v4 and Xamarin.Android.Support.v7.AppCompat automatically added as part of
assembly reference in the Solution project.
18
Getting Started
5. Add a XamarinZebraRFID.dll reference in to the project reference from the RfidSdk folder.
19
Getting Started
20
Getting Started
21
ZEBRA RFID SDK for
Android
Introduction
This chapter provides detailed information about how to use various basic and advanced functionality to develop
an Android application using the Zebra RFID SDK for Android.
The Zebra RFID SDK for Android allows applications to communicate with RFID readers connected to a mobile
device.
The Zebra RFID SDK for Android provides the API that can be used by external applications to manage connection
of the RFID readers, and to control connected RFID reader.
Basics
NOTE: Detailed API documentation can be found in Java Class Reference Guide distributed with the Zebra
RFID SDK for Android (see Related Documents and Software on page 8).
The Zebra RFID SDK for Android provides the ability to manage RFID readers’ connections, perform various
operations with connected RFID readers, configure connected RFID readers and knowing other information related
to connected RFID readers.
Zebra RFID Android SDK consists of a static android library in ‘aar’ format that is supposed to be linked with an
external Android application. Step-by-step instructions for configuring the Android application project to enable
utilization of Zebra RFID Android SDK are provided in Getting Started: Installing Android Studio on page 10,
Building and Running Projects on page 13, and RFID API3 Android SDK on page 16.
All available APIs are defined under the com.zebra.rfid.api3 package. RFIDReader is the root Java class in the
SDK. The application uses a single instance of an RFIDReader object to interact with a particular reader.
Use available readers and the RFIDReader object to register for events, connect with readers, and after successful
connection, perform required operations such as inventory, access and locate.
It is recommended that all API calls should be made using Android ‘AsyncTask’ so that operations are performed in
the background thread keeping the UI thread free.
If the API call fails, the API throws an exception. The application should call all APIs in try-catch block for handling
exceptions.
22
ZEBRA RFID SDK for Android
Connection Management
Connect to an RFID Reader
Connection is the first step to talk to an RFID reader. Importing package is the first step to use any API. Import the
package as follows:
import com.zebra.rfid.api3.*;
As first step create instance of Readers class with passing activity context as first parameter and enum value
SERVICE_SERIAL as second parameter
The Readers class instance gives a list of all available/paired RFID readers with an Android device. Readers list is
in the form of ReaderDevice class.
ReaderDevice class includes instance of RFIDReader class; which is root class to interface and performing all
operations with RFID reader.
In addition, the application can implement Readers.RFIDReaderEventHandler in the following way to get notified
for RFID reader getting attached (added) / detached (removal).
23
ZEBRA RFID SDK for Android
The following example demonstrates the connection is handled under try-catch block and OperationFailure
exception is thrown by connection API is stored and used for further analysis.
if (ex.getResults() == RFIDResults.RFID_READER_REGION_NOT_CONFIGURED) {
// Get and Set regulatory configuration settings
// RegulatoryConfig regulatoryConfig = rfidReader.Config.getRegulatoryConfig();
// RegionInfo regionInfo =
rfidReader.ReaderCapabilities.SupportedRegions.getRegionInfo(1);
// regulatoryConfig.setRegion(regionInfo.getRegionCode());
// rfidReader.Config.setRegulatoryConfig(regulatoryConfig);
}
if (ex.getResults() == RFIDResults.RFID_CONNECTION_PASSWORD_ERROR) {
// get password showPasswordDialog();
rfidReader.setPassword(password);
rfidReader.connect();
}
if (ex.getResults() == RFIDResults.RFID_BATCHMODE_IN_PROGRESS) {
// handle batch mode related stuff
}
24
ZEBRA RFID SDK for Android
Note that as the batch operation runs on the reader, the reader related information cannot be autonomously
retrieved by the SDK. It is the responsibility of the application to retrieve/update reader related information using
the following API once the BATCH operation is stopped before any other use.
rfidReader.PostConnectReaderUpdate();
Disconnect
When the application is done with the connection and operations on the RFID reader, it calls the following API to
close the connection, and to release and clean up the resources.
rfidReader.disconnect();
NOTE: If a reader disconnection occurs, the reader.isConnected() flag may return the value false. If the
application calls reader.connect(), the application should call reader.disconnect() regardless of the flag
status.
rfidReader.reconnect();
NOTE: When a reader reconnection occurs, it is advisable to retrieve the configuration again and registration of
events, etc. It is also possible that the reader may have gone into batch mode if the reader was
configured for that mode.
Dispose
When the application main activity is destroyed, it is required to dispose the SDK instance so that it can cleanly exit
(unregistration and unbind by SDK as required).
readers.Dispose();
25
ZEBRA RFID SDK for Android
General Capabilities
• Model Name
• Number of antennas supported.
• Tag Event Reporting Supported - Indicates the reader’s ability to report tag visibility state changes (New
Tag, Tag Invisible, or Tag Visibility Changed).
• RSSI Filter Supported - Indicates the reader’s ability to report tags based on the signal strength of the
back-scattered signal from the tag.
• NXP Commands Supported - Indicates whether the reader supports NXP commands such as Change
EAS, set Quiet, Reset Quiet, Calibrate.
• Tag LocationingSupported - Indicates the reader’s ability to locate a tag.
• DutyCycleValues - List of DutyCycle percentages supported by the reader.
Gen2 Capabilities
• Block Erase - supported
• Block Write - supported
• State Aware Singulation - supported
• Maximum Number of Operation in Access Sequence
• Maximum Pre-filters allowable per antenna
• RF Modes.
Regulatory Capabilities
• Country Code
• Communication Standard.
26
ZEBRA RFID SDK for Android
Reader Identification
Reader ID and Reader ID Type (the reader identification can be MAC or EPC).
System.out.println("\nNumAntennaSupported: " +
reader.ReaderCapabilities.getNumAntennaSupported())
27
ZEBRA RFID SDK for Android
Antenna Configuration
The AntennaProperties is used to set the antenna configuration to individual antenna or all the antennas.
The antenna configuration (SetAntennaConfig function) is comprised of Antenna ID, Receive Sensitivity
Index, Transmit Power Index, and Transmit Frequency Index. These indexes refer to the Receive Sensitivity table,
Transmit Power table, Frequency Hop table, or Fixed Frequency table, respectively. These tables are available in
Reader capabilities. getAntennaConfig function gets the antenna configuration for the given antenna ID.
28
ZEBRA RFID SDK for Android
RF Configuration
The function SetAntennaRFConfig is added to configure antenna RF configuration to individual antenna. This
function is similar to SetAntennaConfig but includes additional parameters specific pertaining to the antenna.
The configuration includes Receive Sensitivity Index, Transmit Power Index, Transmit Frequency Index, and RF
Mode Table Index. These indexes are refers to the Receive Sensitivity table, Transmit Power table, Frequency
Hop table, Fixed Frequency table, or RF Mode table, respectively. These tables are available in Reader
capabilities. Also, includes tari, transmit port, receive port and Antenna Stop trigger condition. The stop condition
can be 'n' number of attempts, duration based.
The function getAntennaRFConfig gets the antenna RF configuration for the given antenna ID.
Singulation Control
The function getSingulationControl retrieves the current settings of the singulation control from the reader for the
given Antenna ID.
To set the singulation control settings, the setSingulationControll method is used. The following settings can be
configured:
29
ZEBRA RFID SDK for Android
• PC value
• RSSI value
• Phase value
• Channel index
• Tag seen count.
The function getTagStorageSettings retrieves the tag report parameters from the reader for the given Antenna
ID.
To set the Tag report parameters, the setTagStorageSettings method is used. The following settings can be
configured:
Regulatory Configuration
The SDK supports managing of regulatory related parameters of a specific active RFID reader.
A set of enabled channels includes only such channels that are supported in the selected region. If hopping
configuration is not allowed for the selected regions, a set of enabled channels is not specified.
Regulatory parameters could be retrieved and set via getRegulatoryConfig and setRegulatoryConfig API
functions accordingly. The region information is retrieved using getRegionInfo API. The following example
demonstrates retrieving of current regulatory settings and configuring the RFID reader to operate in one of
supported regions.
Saving Configuration
Various parameters of a specific RFID reader configured via SDK are lost after the next power down. The SDK
provides an ability to save a persistent configuration of RFID reader. The saveConfig API function can be used to
make the current configuration persistent over power down and power up cycles. The following example
demonstrates utilization of mentioned API functions.
30
ZEBRA RFID SDK for Android
Managing Events
The Application can register for one or more events so as to be notified of the same when it occurs. There are two
main events.
• eventReadNotify - Notifies whenever read tag event occurs with read tag data as argument. By default,
the event comes with tag data. If not required, disable using function setAttachTagDataWithReadEvent.
• eventStatusNotify - Notifies whenever status event occurs with status event data as argument.
Table 1 Events
Android Events Description
BUFFER_FULL_WARNING_EVENT When the internal buffers are 90% full, this event is signaled
DISCONNECTION_EVENT Event notifying disconnection from the Reader. The Application can
call reconnect method periodically to attempt reconnection or call
disconnect method to cleanup and exit.
BUFFER_FULL_EVENT When the internal buffers are 100% full, this event is signaled and
tags are discarded in FIFO manner.
READER_EXCEPTION_EVENT Event notifying that an exception has occurred in the Reader. When
this event is signaled,
StatusEventData. ReaderExceptionEventData.
ReaderExceptionEventType can be called to know the reason for
the exception which is coming as part of Events.StatusEventArgs.
The Application can continue to use the connection if the reader
renders is usable.
31
ZEBRA RFID SDK for Android
Table 1 Events
Android Events Description
BATCH_MODE_EVENT The batch mode event notification when the reader indicates
(RFD8500 only) whether batch mode is in progress.
POWER_EVENT Events which notify the different power states of the reader device.
The event data contains cause, voltage, current and power.
32
ZEBRA RFID SDK for Android
reader.Events.removeEventsListener(eventHandler);
33
ZEBRA RFID SDK for Android
Response to the above API comes as battery event, power event, and temperature event according to the set
boolean value in the respective parameters.
try {
if (reader != null)
reader.Config.getDeviceStatus(true, false, false);
else
stopTimer();
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (OperationFailureException e) {
e.printStackTrace();
}
Basic Operations
Tag Storage Settings
This section covers the basic operations that an application needs to perform on an RFID reader which includes
inventory and single tag access operations.
The application needs to get the tags from the dll which are reported by the reader. Tags can be reported as part of
an Inventory operation (reader.Actions.Inventory.perform) or a Read Access operation
(reader.Actions.TagAccess.readEvent or reader.Actions.TagAccess.readWait).
Applications can also configure to receive tag reports that indicate the results of access operations as shown
below.
Each tag has a set of associated information along with it. During the Inventory operation, the reader reports
theEPC-ID of the tag, where as during the Read-Access operation the requested Memory Bank Data is also
reportedapart from EPC-ID. In either case, there is additional information such as PC-bits, RSSI, last time seen,
tag seen count, etc. that is available for each tag. This information is reported to the application as TagData for
each tagreported by the reader.
Applications can also choose to enable/disable reporting certain fields in TAG_DATA. Disabling certain fields
cansometimes improve the performance as the reader and the sdk are not processing that information. It can also
resultin specific behavior. For example, disabling reporting an Antenna Id can result in the application receiving a
single unique tag even though they were multiple entries of the same tag reported from different antennas. The
34
ZEBRA RFID SDK for Android
following demonstrates enabling the reporting of PeakRSSI, Tag Seen Count, PC and CRC only and disabling
other fields such as Antenna ID, Time Stamps, and XPC.
A Simple Continuous Inventory operation reads all tags in the field of view of 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 (for
example, start immediately when reader.Actions.Inventory.perform is called, and stop immediately when
reader.Actions.Inventory.stop is called).
Tag Access operations are performed on a specific tag or applied on tags that match a specific Access-Filter. If no
Access-Filter is specified, the Access Operation is performed on all tags in the field of view of chosen antennas.
This section covers the Simple Tag Access operation on a specific tag which is in the field of view of any of the
antennas of the connected RFID reader.
dpo should be disabled before any access operation for the RFD8500 reader.
Read
The application calls method reader.Actions.TagAccess.readWait to read data from a specific memory bank.
35
ZEBRA RFID SDK for Android
Write
The application calls method reader.Actions.TagAccess.writeWait or reader. Actions.
TagAccess. blockWriteWait to write data to a specific memory bank. The response is returned as a Tagdata from
where a number of words can be retrieved.
Block-Write
The following shows usage of block write:
NOTE: The same write access parameters are passed as used above to easily switch between two APIs.
Lock
The application calls method reader.Actions.TagAccess.lockWait to perform a lock operation on one or more
memory banks with specific privileges.
36
ZEBRA RFID SDK for Android
Kill
Block Erase
The application calls RFID_BlockErase to erase the contents of a tag.
// Block Erase
TagData tagData = new TagData ();
String tagId = "1234ABCD00000000000025B1";
TagAccess.BlockEraseAccessParams blockEraseAccessParams = tagAccess.new
BlockEraseAccessParams();
blockEraseAccessParams.setAccessPassword(0);
blockEraseAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER); // user memory bank
blockEraseAccessParams.setOffset(0); // start erasing from word offset 0
blockEraseAccessParams.setCount(8); // number of words to erase
mConnectedReader.Actions.TagAccess.blockEraseWait(tagId,
blockEraseAccessParams, null,tagData);
Block-Permalock
The application calls method Reader.Actions.TagAccess.blockPermalockWait to block a permalock tag. Tags
reported as part of Block-Permalock access operation have TagData.getOpCode as
ACCESS_OPERATION_BLOCK_PERMALOCK and TagData.getOpStatus indicating the result of the operation; if
TagData.OpStatus is ACCESS_SUCCESS, TagData.getMemoryBankData contains the Block-Permalock Mask
Data.
37
ZEBRA RFID SDK for Android
All synchronous access operation APIs have been overloaded with new parameters for prefilter support.
Example:
reader.Actions.TagAccess.readWait("2F2203447334C3100002EA55", readAccessParams,
null,true);
writeWait and blockWriteWait APIs have additional parameter for specifying whether to use TID memory bank as
prefilter.
writeWait(java.lang.String tagID,
TagAccess.WriteAccessParams writeAccessParams,
AntennaInfo antennaInfo,
TagData tagData,
boolean bPrefilter, boolean bTIDPrefilter)
Example:
Provision of TID memory bank as prefilter and giving number of retries will help doing retries on partial writes of
EPC memory bank.
Note - Using TID memory bank as prefilter will result in longer time of write, as SDK internally retrieves TID
memory bank of tag.
Note - When prefilter is enabled, SDK does access operation in session S0 and uses
INV_B_NOT_INV_A_OR_DSRT_SL_NOT_ASRT_SL with INV_B inventory state
TagAccess.WriteAccessParams have additional parameter to define number of retries.
38
ZEBRA RFID SDK for Android
Earlier version of SDK has hardcoded timeout of five seconds which results in longer wait for operation result to
come if tag is not found in FOV or other reasons (not singulated).
By this application can shorten wait time and quickly retry in failure cases.
Method to set access operation timeout for all synchronous tag access operations APIs.
Example:
reader.Config.setAccessOperationWaitTimeout(1000);
Advanced Operations
Using Pre-Filters
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
Singulation refers to the method of identifying an individual Tag in a multiple-Tag environment. RFID readers
support State-Aware or State-Unaware pre-filtering (or singulation) which is indicated by the boolean flag
IsTagInventoryStateAwareSingulationSupported in the ReaderCapabilities class.
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/ Reader.Config.Antennas.SingulationControl) or
not participate in the inventory based on their states.
Selected Flag
Tags provide a selected flag, SL, which is asserted or deasserted based on match criteria using method
Reader.Actions.PreFilters.Add.
State-Aware Singulation
In state-aware singulation, the application specifies detailed controls for singulation: Action and Target. Action
indicates whether matching Tags assert or de-assert 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.
39
ZEBRA RFID SDK for Android
Applying Pre-Filters
The following are the steps to use pre-filters:
1. Add pre-filters.
2. Set appropriate singulation controls.
3. Perform Inventory or Access operation.
Add Pre-filters
Each RFID reader supports a maximum number of pre-filters per antenna as indicated by
ReaderCapabilities.getMaxNumPreFilters which is known using the ReaderCapabilities.
The application sets pre-filters using reader.Actions.PreFilters.add and removes using
reader.Actions.PreFilters.delete.
State-Aware Settings
filter.StateAwareAction.setStateAwareAction(STATE_AWARE_ACTION.STATE_AWARE_ACTION_INV_B;
// not to select tags that match the criteria
reader.Actions.PreFilters.add(filter);
// It is also required to set appropriate singulation control not to
// get tags with inventoried flag B for session 1
40
ZEBRA RFID SDK for Android
State-Aware Singulation
Using Triggers
Triggers are the conditions that are 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.
We have to use Config.setStartTrigger and Config.setStopTrigge APIs to set triggers on the reader.
• Periodic Inventory: Start inventory at a specified time for a specified duration repeatedly.
• Perform ‘n’ Rounds of Inventory with a timeout: Start condition can be any; Stop condition is to perform ‘n’
rounds of inventory and then stop or stop inventory after the specified timeout.
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_IMMEDIATE);
// stop trigger
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_N_ATTEMPTS_WIT
H_TIMEOUT);
triggerInfo.StopTrigger.NumAttempts.setN((short)3); // perform 3 rounds of
inventory
triggerInfo.StopTrigger.NumAttempts.setTimeout(3000); // timeout after 3
seconds //
41
ZEBRA RFID SDK for Android
• 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.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_IMMEDIATE);
// stop trigger
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_TAG_OBSERVATIO
N_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
• Inventory based on hand-held trigger: Start inventory when the hand-held gun/button trigger is pulled, and
stop inventory when the hand-held gun/button trigger is released or subject to timeout.
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_HANDHELD);
// Start Inventory when the Handheld trigger is pressed
triggerInfo.StartTrigger.Handheld.setHandheldTriggerEvent(HANDHELD_TRIGGER_EVENT_TYPE.
HANDHELD_TRIGGER_PRESSED);
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_HANDHELD_WITH_
TIMEOUT);
// Stop Inventory when the Handheld trigger is released
triggerInfo.StopTrigger.Handheld.setHandheldTriggerEvent(HANDHELD_TRIGGER_EVENT_TYPE.
HANDHELD_TRIGGER_RELEASED);
triggerInfo.StopTrigger.Handheld.setHandheldTriggerTimeout(0);
• Set the trigger using the following APIs, perform inventory and other operations which are using above set
start and stop triggers.
reader.Config.setStartTrigger(triggerInfo.StartTrigger);
reader.Config.setStopTrigger(triggerInfo.StopTrigger);
reader.Actions.Inventory.perform();
Access
Using Access-Filters
In order to perform an access operation on multiple tags, the application can set ACCESS_FILTER to filter the
required tags. If ACCESS_FILTER is not specified, the operation is performed on all tags. In any case, the
PRE_FILTER(s) (if any is set) applies prior to ACCESS_FILTER.
42
ZEBRA RFID SDK for Android
The following access-filter gets all tags that have zeroed reserved memory bank.
reader.Events.setInventoryStartEvent(true);
reader.Events.setInventoryStopEvent(true); // Data Read Notification from the
reader
class EventHandler implements RfidEventsListener {
// Read Event Notification
public void eventReadNotify(RfidReadEvents e){
TagData tag = e.getReadEventData().tagData;
System.out.println("Tag ID " + tag.getTagID());
if (tag.getOpCode() == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ &&
tag.getOpStatus() == ACCESS_OPERATION_STATUS.ACCESS_SUCCESS) {
if (tag.getMemoryBankData().length() > 0) {
System.out.println(" Mem Bank Data " + tag.getMemoryBankData());
}
}
}
// Status Event Notification
public void eventStatusNotify(RfidStatusEvents e) {
if (e.StatusEventData.getStatusEventType() ==
STATUS_EVENT_TYPE.INVENTORY_START_EVENT) {
// Access operation started
} else if(e.StatusEventData.getStatusEventType() ==
STATUS_EVENT_TYPE.INVENTORY_STOP_EVENT) {
// Access operation stopped - Can be used to signal waiting thread
}
}
}
43
ZEBRA RFID SDK for Android
44
ZEBRA RFID SDK for Android
The operations are performed in the same order in which it is added to it sequence. An operation can be removed
from the sequence using reader.Actions.TagAccess.OperationSequence.delete and finally de-initialized if
no longer needed by calling the function.
reader.Actions.TagAccess.OperationSequence.deleteAll();
// add Write Access operation - Write to User memory
TagAccess tagAccess = new TagAccess();
TagAccess.Sequence opSequence = tagAccess.new Sequence(tagAccess);
TagAccess.Sequence.Operation op1 = opSequence.new Operation();
op1.setAccessOperationCode(ACCESS_OPERATION_CODE.ACCESS_OPERATION_WRITE);
op1.WriteAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);
op1.WriteAccessParams.setAccessPassword(0);
op1.WriteAccessParams.setOffset(0);
op1.WriteAccessParams.setWriteData("55667788");
op1.WriteAccessParams.setWriteDataLength(4);
reader.Actions.TagAccess.OperationSequence.add(op1);
// add Write Access operation - Write to Reserved memory bank
TagAccess.Sequence.Operation op2 = opSequence.new Operation();
op2.setAccessOperationCode(ACCESS_OPERATION_CODE.ACCESS_OPERATION_WRITE);
op2.WriteAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);
op2.WriteAccessParams.setAccessPassword(0);
op2.WriteAccessParams.setOffset(0);
op2.WriteAccessParams.setWriteData("BBBBCCCC");
op2.WriteAccessParams.setWriteDataLength(4);
reader.Actions.TagAccess.OperationSequence.add(op2);
// perform access sequence
reader.Actions.TagAccess.OperationSequence.performSequence();
// if the access operation is to be terminated without meeting stop trigger (ifspecified),
// stopSequence method can be called
reader.Actions.TagAccess.OperationSequence.stopSequence();
Gen2v2 Operations
This section covers the Gen2V2 operations that an application needs to performed on a RFID Reader which
supports Gen2v2 commands such as authenticate, untraceable, and readbuffer.
Authenticate
Authenticate operation takes in the message data and message length with few of the options such as decision on
including the response length, sending the response, etc.
The AuthenticateParams contain the message data, message length and other settings to be sent to the reader.
The accessfilter parameter contains the tag pattern on which the operation occurs.
// authenticate
// Tag Pattern A
accessFilter.TagPatternA.setMemoryBank(MEMORY_BANK.MEMORY_BANK_EPC);
accessFilter.TagPatternA.setTagPattern(new byte[]{(byte)0xe2, (byte)0xc0 });
accessFilter.TagPatternA.setTagPatternBitCount(16);
accessFilter.TagPatternA.setBitOffset(32);
accessFilter.TagPatternA.setTagMask(tagMask);
accessFilter.TagPatternA.setTagMaskBitCount(tagMask.length*8);
accessFilter.setAccessFilterMatchPattern(FILTER_MATCH_PATTERN.A);
45
ZEBRA RFID SDK for Android
// G2V2 authenticate
// Gen2V2 gen2V2 - new Gen2v2 ();
Gen2v2.AuthenticateParams AuthenticateParams = gen2V2.new AuthenticateParams();
AuthenticateParams.setMsgData("2001FD5D8048F48DD09AAD22000111");
AuthenticateParams.setMsgLen(120);
AuthenticateParams.setIncrespLen(true);
AuthenticateParams.setStoreResp(false);
AuthenticateParams.setSentResp(true);
try {
reader.Actions.gen2v2Access.authenticate(AuthenticateParams, accessFilter, null);
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (OperationFailureException e) {
e.printStackTrace();
}
The response and result in the Tagdata will contain the information obtained from the operation.
46
ZEBRA RFID SDK for Android
Untraceable
Untraceable operation lets the user decide which memory bank to show and what length of the memory bank to
show. Here the UntraceableParams contain the settings and password. The accessfilter parameter contains the
tag pattern on which the operation occurs.
// untraceable
AccessFilter accessFilter = new AccessFilter();
byte[] tagMask = new byte[]{(byte) 0xff, (byte) 0xff, };
// Tag Pattern A
accessFilter.TagPatternA.setMemoryBank(MEMORY_BANK.MEMORY_BANK_EPC);
accessFilter.TagPatternA.setTagPattern("2f22");
accessFilter.TagPatternA.setTagPatternBitCount(32);
accessFilter.TagPatternA.setBitOffset(32);
accessFilter.TagPatternA.setTagMask(tagMask);
accessFilter.TagPatternA.setTagMaskBitCount(tagMask.length*8);
accessFilter.setAccessFilterMatchPattern(FILTER_MATCH_PATTERN.A);
Gen2v2 gen2V2 = new Gen2v2();
Gen2v2.UntraceableParams UntraceableParams = gen2V2.new
UntraceableParams();
UntraceableParams.setPassword(0);
UntraceableParams.setShowEpc(true);
UntraceableParams.setHideEpc(false);
UntraceableParams.setShowUser(false);
UntraceableParams.setEpcLen(6);
UntraceableParams.setTid(UNTRACEABLE_TID.HIDE_ALL_TID);
try{
reader.Actions.gen2v2Access.untraceable(UntraceableParams, accessFilter,
null);
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (OperationFailureException e) {
e.printStackTrace(); }
After this, when inventory is run, the effects of the settings sent are seen in untraceable operation.
Tag Locationing
Readers that support the Tag Locationing feature report the same in the field isTagLocationingSupported of
ReaderCapabilities as true. This feature is supported only on hand-held readers and is useful to locate a specific
tag in the field of view of the reader’s antenna. The default locationing algorithm supported on the reader can
perform locationing only on a single antenna. reader.Actions.TagLocationing.Perform can be used to start locating
a tag, and reader.Actions.TagLocationing.Stop to stop the locationing operation. The result of locationing of a tag is
reported as LocationInfo in TagData and is present in TagData if tagData isContainsLocationInfo is true.
tagData.LocationInfo.getRelativeDistance gives the relative distance of the tag from the reader antenna.
47
ZEBRA RFID SDK for Android
reader.Actions.TagLocationing.Perform("E2002849491502421020B330",null);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
reader.Actions.Inventory.stop();
//The response of the tag locationing comes through eventReadNotify in the following
Event Handler.
public class EventHandler implements RfidEventsListener {
// 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++) {
System.out.println("Tag ID " + myTags[index].getTagID());
if (myTags[index].isContainsLocationInfo()) {
int tag = index;
System.out.println("Tag locationing distance " +
myTags[tag].LocationInfo.getRelativeDistance());
}
}
}
}
}
rfidReader.Config.setTriggerMode(ENUM_TRIGGER_MODE.RFID_MODE, true);
First parameter is mode enum value and second parameter indicates whether SDK should take care of disabling
scanner plugin. When second parameter is true; SDK executes code to disable scanner plugin.
NOTE: It is recommended that Application handle scanner plugin enable/disable in pause and resume activity
respectively to avoid cross triggering to functionality not required.
48
ZEBRA RFID SDK for Android
techdocs.zebra.com/datawedge/6-5/guide/api/scannerinputplugin/
techdocs.zebra.com/datawedge/6-5/guide/api/resultinfo/
49
ZEBRA RFID SDK for Android
Set Attribute
The RFID SDK supports setting RFID parameters through attributes. Please refer to the respective reader model
integrator guide for information about various types of supported attributes and details.
The following code demonstrates ways to set reader LED Mode indication.
reader.Config.setLedBlinkEnable(true);
• Antenna configuration
• Singulation settings
• Tag storage settings
• Delete all pre-filters (select record) on device
• Dynamic power setting (DPO enable/disable)
• Any five attributes passed as array of attributes
50
ZEBRA RFID SDK for Android
// antenna power
Antennas.AntennaRfConfig antennaRfConfig =
mConnectedReader.Config.Antennas.getAntennaRfConfig(1);
//mConnectedReader.Config.Antennas.new AntennaRfConfig();
antennaRfConfig.setTransmitPowerIndex(270);
// singulation control
Antennas.SingulationControl singulationControl =
mConnectedReader.Config.Antennas.getSingulationControl(1);
singulationControl.Action.setInventoryState(INVENTORY_STATE.INVENTORY_STATE_A);
singulationControl.Action.setPerformStateAwareSingulationAction(false);
// Tag storage settings
// API call
mConnectedReader.Config.setDefaultConfigurations(antennaRfConfig, singulationControl,
tagStorageSettings, true, true, setAttributeArray);
Exceptions
The Zebra RFID Android SDK throws two types of exceptions as a given:
• InvalidUsageException: This exception is thrown when the user passes an invalid parameter, calling
getInfo() gives detail error message.
• OperationFailureException: This exception is thrown when the requested operation is failed. The
Exception contains the Operation RFIDResults, status description, time stamp & vendor specific message
for the operation failure.
51
ZEBRA RFID SDK for Android
Exception Handling
All API should be called under try-catch block to catch the exception thrown while performing API by SDK.
try {
reader.connect();
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (OperationFailureException e) {
e.printStackTrace();
}
General Guidelines
Synchronization
Use synchronization method to cover connection, configuration, and disconnection blocks.
synchronized (lock) {
readers.GetAvailableRFIDReaderList();
reader.Connect();
// Code related to configuration and initial setup after connection
ConfigureRfidReader();
}
synchronized (lock) {
reader.disconnect();
readers.Dispose();
}
Threading
The following APIs must be called from background thread:
• GetAvailableRFIDReaderList
• connect
• disconnect
• Dispose
52
ZEBRA RFID SDK for Android
import com.zebra.rfid.api3.ACCESS_OPERATION_CODE;
import com.zebra.rfid.api3.ACCESS_OPERATION_STATUS;
import com.zebra.rfid.api3.ENUM_TRANSPORT;
import com.zebra.rfid.api3.ENUM_TRIGGER_MODE;
import com.zebra.rfid.api3.HANDHELD_TRIGGER_EVENT_TYPE;
import com.zebra.rfid.api3.InvalidUsageException;
import com.zebra.rfid.api3.OperationFailureException;
import com.zebra.rfid.api3.RFIDReader;
import com.zebra.rfid.api3.ReaderDevice;
import com.zebra.rfid.api3.Readers;
import com.zebra.rfid.api3.RfidEventsListener;
import com.zebra.rfid.api3.RfidReadEvents;
import com.zebra.rfid.api3.RfidStatusEvents;
import com.zebra.rfid.api3.START_TRIGGER_TYPE;
import com.zebra.rfid.api3.STATUS_EVENT_TYPE;
import com.zebra.rfid.api3.STOP_TRIGGER_TYPE;
import com.zebra.rfid.api3.TagData;
import com.zebra.rfid.api3.TriggerInfo;
import java.util.ArrayList;
53
ZEBRA RFID SDK for Android
@Override
protected Boolean doInBackground(Void... voids) {
try {
if (readers != null) {
if (readers.GetAvailableRFIDReaderList() != null) {
availableRFIDReaderList =
readers.GetAvailableRFIDReaderList();
if (availableRFIDReaderList.size() != 0) {
// get first reader from list
readerDevice = availableRFIDReaderList.get(0);
reader = readerDevice.getRFIDReader();
if (!reader.isConnected()) {
// Establish connection to the RFID Reader
reader.connect();
ConfigureReader();
return true;
}
}
}
}
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (OperationFailureException e) {
e.printStackTrace();
Log.d(TAG, "OperationFailureException " + e.getVendorMessage());
}
return false;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
if (aBoolean) {
Toast.makeText(getApplicationContext(), "Reader Connected",
Toast.LENGTH_LONG).show();
//textView.setText("Reader connected");
}
}
}.execute();
}
private void ConfigureReader() {
if (reader.isConnected()) {
TriggerInfo triggerInfo = new TriggerInfo();
triggerInfo.StartTrigger.setTriggerType(START_TRIGGER_TYPE.START_TRIGGER_TYPE_IMMEDIATE);
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_IMMEDIATE);
try {
// receive events from reader
if (eventHandler == null)
eventHandler = new EventHandler();
reader.Events.addEventsListener(eventHandler);
// HH event
reader.Events.setHandheldEvent(true);
// tag event with tag data
54
ZEBRA RFID SDK for Android
reader.Events.setTagReadEvent(true);
reader.Events.setAttachTagDataWithReadEvent(false);
// set trigger mode as rfid so scanner beam will not come
reader.Config.setTriggerMode(ENUM_TRIGGER_MODE.RFID_MODE, true);
// set start and stop triggers
reader.Config.setStartTrigger(triggerInfo.StartTrigger);
reader.Config.setStopTrigger(triggerInfo.StopTrigger);
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (OperationFailureException e) {
e.printStackTrace();
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
if (reader != null) {
reader.Events.removeEventsListener(eventHandler);
reader.disconnect();
Toast.makeText(getApplicationContext(), "Disconnecting reader",
Toast.LENGTH_LONG).show();
reader = null;
readers.Dispose();
readers = null;
}
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (OperationFailureException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
55
ZEBRA RFID SDK for Android
}
}
}
}
}
56
ZEBRA RFID SDK for
Xamarin Android
Introduction
This chapter provides detailed information about how to use various basic and advanced functionality to develop
an Xamarin Android application using the Zebra RFID SDK for Xamarin Android.
The Zebra RFID SDK for Xamarin allows applications to communicate with RFID readers connected to a mobile
device.
The Zebra RFID SDK for Android provides the API that can be used by external applications to manage connection
of the RFID readers, and to control connected RFID reader.
Basics
Zebra RFID Xamarin consists of library in dll format that should be linked with an external Xamarin application. All
available APIs are defined under the Com.Zebra.Rfid.Api3 namespace. RFIDReader is the root class in the SDK.
The application uses a single instance of an RFIDReader object to interact with a particular reader. Use available
readers and the RFIDReader object to register for events, connect with readers, and after successful connection,
perform required operations such as inventory, access, and locate. It is recommended that all API calls are made
using Xamarin ThreadPool.QueueUserWorkItem so that operations are performed in the background thread
keeping the UI thread free. If the API call fails, the API throws an exception. The application calls all APIs in
try-catch block for handling exceptions.
57
ZEBRA RFID SDK for Xamarin Android
Connection Management
Connect to an RFID Reader
Connection is the first step to talk to an RFID reader. Importing package is the first step to use any API. Import the
package as follows:
using Com.Zebra.Rfid.Api3;
As first step create instance of Readers class with passing activity context as first parameter and enum value
ServiceSerial as second parameter
The Readers class instance gives a list of all available/paired RFID readers with an Android device. Readers list is
in the form of ReaderDevice class.
ReaderDevice class includes instance of RFIDReader class; which is root class to interface and performing all
operations with RFID reader.
rfidReader.Connect();
In addition, the application can implement Readers.IRFIDReaderEventHandler in the following way to get
notified for RFID reader getting attached (added) / detached (removal).
58
ZEBRA RFID SDK for Xamarin Android
The following example demonstrates the connection is handled under try-catch block and OperationFailure
exception is thrown by connection API is stored and used for further analysis.
if (ex.Results == RFIDResults.RfidReaderRegionNotConfigured) {
// Get and Set regulatory configuration settings
// RegulatoryConfig regulatoryConfig = rfidReader.Config.RegulatoryConfig;
// RegionInfo regionInfo =
rfidReader.ReaderCapabilities.SupportedRegions.GetRegionInfo(1);
// regulatoryConfig.Region=regionInfo.RegionCode;
// rfidReader.Config.RegulatoryConfig=regulatoryConfig;
}
Disconnect
When the application is done with the connection and operations on the RFID reader, it calls the following API to
close the connection, and to release and clean up the resources.
RfidReader.Disconnect();
NOTE: If a reader disconnection occurs, the reader.isConnected() flag may return the value false. If the
application calls reader.connect(), the application should call reader.disconnect() regardless of the flag
status.
Dispose
When the application main activity is destroyed, it is required to dispose the SDK instance so that it can cleanly exit
(unregistration and unbind by SDK as required).
Readers.Dispose();
59
ZEBRA RFID SDK for Xamarin Android
General Capabilities
• Model Name
• Number of antennas supported.
• Tag Event Reporting Supported - Indicates the reader’s ability to report tag visibility state changes (New
Tag, Tag Invisible, or Tag Visibility Changed).
• RSSI Filter Supported - Indicates the reader’s ability to report tags based on the signal strength of the
back-scattered signal from the tag.
• NXP Commands Supported - Indicates whether the reader supports NXP commands such as Change
EAS, set Quiet, Reset Quiet, Calibrate.
• Tag LocationingSupported - Indicates the reader’s ability to locate a tag.
• DutyCycleValues - List of DutyCycle percentages supported by the reader.
Gen2 Capabilities
• Block Erase - supported
• Block Write - supported
• State Aware Singulation - supported
• Maximum Number of Operation in Access Sequence
• Maximum Pre-filters allowable per antenna
• RF Modes.
Regulatory Capabilities
• Country Code
• Communication Standard.
60
ZEBRA RFID SDK for Xamarin Android
Reader Identification
Reader ID and Reader ID Type (the reader identification can be MAC or EPC).
61
ZEBRA RFID SDK for Xamarin Android
The API GetRFModeTableInfo in reader capabilities.RFModes gets the RF Mode table from the
reader. The getLinkedProfiles function described below populates the RFModeTable into an
List.
Antenna Configuration
The AntennaProperties is used to set the antenna configuration to individual antenna or all the antennas.
The antenna configuration (SetAntennaConfig function) is comprised of Antenna ID, Receive Sensitivity
Index, Transmit Power Index, and Transmit Frequency Index. These indexes refer to the Receive Sensitivity table,
Transmit Power table, Frequency Hop table, or Fixed Frequency table, respectively. These tables are available in
Reader capabilities. getAntennaConfig function gets the antenna configuration for the given antenna ID.
62
ZEBRA RFID SDK for Xamarin Android
RF Configuration
The function SetAntennaRFConfig is added to configure antenna RF configuration to individual antenna. This
function is similar to SetAntennaConfig but includes additional parameters specific pertaining to the antenna.
The configuration includes Receive Sensitivity Index, Transmit Power Index, Transmit Frequency Index, and RF
Mode Table Index. These indexes are refers to the Receive Sensitivity table, Transmit Power table, Frequency
Hop table, Fixed Frequency table, or RF Mode table, respectively. These tables are available in Reader
capabilities. Also, includes tari, transmit port, receive port and Antenna Stop trigger condition. The stop condition
can be 'n' number of attempts, duration based.
The function GetAntennaRfConfig gets the antenna RF configuration for the given antenna ID.
Singulation Control
The function getSingulationControl retrieves the current settings of the singulation control from the reader for
the given Antenna ID.
To set the singulation control settings, the setSingulationControll method is used. The following settings can
be configured:
The SDK provides an ability to configure a set of fields to be reported in a response to an operation by a specific
active RFID reader.
63
ZEBRA RFID SDK for Xamarin Android
The function getTagStorageSettings retrieves the tag report parameters from the reader for the given Antenna
ID.
To set the Tag report parameters, the setTagStorageSettings method is used. The following settings can be
configured:
Regulatory Configuration
The SDK supports managing of regulatory related parameters of a specific active RFID reader.
A set of enabled channels includes only such channels that are supported in the selected region. If hopping
configuration is not allowed for the selected regions, a set of enabled channels is not specified.
Regulatory parameters could be retrieved and set via getRegulatoryConfig and setRegulatoryConfig API
functions accordingly. The region information is retrieved using getRegionInfo API. The following example
demonstrates retrieving of current regulatory settings and configuring the RFID reader to operate in one of
supported regions.
64
ZEBRA RFID SDK for Xamarin Android
Saving Configuration
Various parameters of a specific RFID reader configured via SDK are lost after the next power down. The SDK
provides an ability to save a persistent configuration of RFID reader. The saveConfig API function can be used to
make the current configuration persistent over power down and power up cycles. The following example
demonstrates utilization of mentioned API functions.
Saving the configuration
Reader.Config.SaveConfig();
Reader.Config.SaveConfig();
Managing Events
The Application can register for one or more events so as to be notified of the same when it occurs. There are two
main events.
• eventReadNotify - Notifies whenever read tag event occurs with read tag data as argument. By default,
the event comes with tag data. If not required, disable using function setAttachTagDataWithReadEvent.
• eventStatusNotify - Notifies whenever status event occurs with status event data as argument.
Table 2 Events
Xamarin Events Description
BufferFullWarningEvent When the internal buffers are 90% full, this event is signaled
InventoryStopEvent Inventory Operation has stopped. In case of periodic trigger this event is
triggered for each period.
DisconnectionEvent Event notifying disconnection from the Reader. The Application can call
reconnect method periodically to attempt reconnection or call
disconnect method to cleanup and exit.
65
ZEBRA RFID SDK for Xamarin Android
Table 2 Events
Xamarin Events Description
BufferFullEvent When the internal buffers are 100% full, this event is signaled and tags are
discarded in FIFO manner.
ReaderExceptionEvent Event notifying that an exception has occurred in the Reader. When this
event is signaled,
StatusEventData. ReaderExceptionEventData.
ReaderExceptionEventType can be called to know the reason for the
exception which is coming as part of Events.StatusEventArgs. The
Application can continue to use the connection if the reader renders is
usable.
TemperatureAlarmEvent When Temperature reaches Threshold level, this event is generated. The
event data contains source name (PA/Ambient),current Temperature and
alarm Level (Low, High or Critical)
BatteryEvent Events notifying different levels of battery, state of the battery, if charging or
discharging.
OperationEndSummaryEvent Event generated when operation end summary has been generated. The
data associated with the event contains total rounds, total number of tags
and total time in micro secs.
PowerEvent Events which notify the different power states of the reader device. The
event data contains cause, voltage, current and power.
66
ZEBRA RFID SDK for Xamarin Android
Reader.Events.RemoveEventsListener(eventHandler);
Response to the above API comes as battery event, power event, and temperature event according to the set
boolean value in the respective parameters.
67
ZEBRA RFID SDK for Xamarin Android
try
{
if (Reader != null)
Reader.Config.GetDeviceStatus(true, false, false);
else
StopTimer();
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
}
Basic Operations
Tag Storage Settings
This section covers the basic operations that an application needs to perform on an RFID reader which includes
inventory and single tag access operations.
The application needs to get the tags from the dll which are reported by the reader. Tags can be reported as part of
an Inventory operation (Reader.Actions.Inventory.Perform) or a Read Access operation
(Reader.Actions.TagAccess.ReadEvent or Reader.Actions.TagAccess.ReadWait).
Applications can also configure to receive tag reports that indicate the results of access operations as shown
below.
Each tag has a set of associated information along with it. During the Inventory operation, the reader reports
theEPC-ID of the tag, where as during the Read-Access operation the requested Memory Bank Data is also
reportedapart from EPC-ID. In either case, there is additional information such as PC-bits, RSSI, last time seen,
tag seen count, etc. that is available for each tag. This information is reported to the application as TagData for
each tagreported by the reader.
Applications can also choose to enable/disable reporting certain fields in TAG_DATA. Disabling certain fields
cansometimes improve the performance as the reader and the sdk are not processing that information. It can also
resultin specific behavior. For example, disabling reporting an Antenna Id can result in the application receiving a
single unique tag even though they were multiple entries of the same tag reported from different antennas. The
68
ZEBRA RFID SDK for Xamarin Android
following demonstrates enabling the reporting of PeakRSSI, Tag Seen Count, PC and CRC only and disabling
other fields such as Antenna ID, Time Stamps, and XPC.
A Simple Continuous Inventory operation reads all tags in the field of view of 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 (for
example, start immediately when reader.Actions.Inventory.perform is called, and stop immediately when
reader.Actions.Inventory.stop is called).
Tag Access operations are performed on a specific tag or applied on tags that match a specific Access-Filter. If no
Access-Filter is specified, the Access Operation is performed on all tags in the field of view of chosen antennas.
This section covers the Simple Tag Access operation on a specific tag which is in the field of view of any of the
antennas of the connected RFID reader.
// dpo should be disabled before any access operation
Reader.Config.DPOState=DYNAMIC_POWER_OPTIMIZATION.Disable;
69
ZEBRA RFID SDK for Xamarin Android
Read
The application calls method reader.Actions.TagAccess.ReadWait to read data from a specific memory bank.
Write, Block-Write
NOTE: The same write access parameters are passed as used above to easily switch between two APIs.
70
ZEBRA RFID SDK for Xamarin Android
Lock
The application calls method reader.Actions.TagAccess.lockWait to perform a lock operation on one or more
memory banks with specific privileges.
Kill
Block Erase
// Block Erase
TagData tagData = new TagData();
String tagId = "1234ABCD00000000000025B1";
TagAccess.BlockEraseAccessParams blockEraseAccessParams = new
TagAccess.BlockEraseAccessParams(tagAccess);
blockEraseAccessParams.AccessPassword=0;
blockEraseAccessParams.MemoryBank=(MEMORY_BANK.MemoryBankUser); // user memory bank
blockEraseAccessParams.Offset=0; // start erasing from word offset 0
blockEraseAccessParams.Count=8; // number of words to erase
MConnectedReader.Actions.TagAccess.BlockEraseWait(tagId, blockEraseAccessParams,
null,
tagData);
71
ZEBRA RFID SDK for Xamarin Android
Block-Permalock
72
ZEBRA RFID SDK for Xamarin Android
All synchronous access operation APIs have been overloaded with new parameters for prefilter support.
Example:
writeWait and blockWriteWait APIs have additional parameter for specifying whether to use
TID memory bank as prefilter.
WriteWait(Java.Lang.String tagID,
TagAccess.WriteAccessParams writeAccessParams,
AntennaInfo antennaInfo,
TagData tagData,
Example:
Apply EPC memory bank as prefilter:
Provision of TID memory bank as prefilter and giving number of retries will help doing retries on partial writes of
EPC memory bank.
NOTE: Using TID memory bank as prefilter will result in longer time of write, as SDK internally retrieves TID
memory bank of tag.
NOTE: When prefilter is enabled, SDK does access operation in session S0 and uses
InvBNotInvAOrDsrtSlNotAsrtSl with InvB inventory state
WriteRetries=int writeRetries;
73
ZEBRA RFID SDK for Xamarin Android
Earlier version of SDK has hardcoded timeout of five seconds which results in longer wait for operation result to
come if tag is not found in FOV or other reasons (not singulated). By this application can shorten wait time and
quickly retry in failure cases.
AccessOperationWaitTimeout=int timeout
Method to set access operation timeout for all synchronous tag access operations APIs.
Example:
Reader.Config.AccessOperationWaitTimeout=1000;
Advanced Operations
Using Pre-Filters
Pre-filters are the same as the Select command of C1G2 specification. Once applied, pre-filters are applied prior to
Inventory and Access operations.
Introduction
Singulation
Singulation refers to the method of identifying an individual Tag in a multiple-Tag environment. RFID readers
support State-Aware or State-Unaware pre-filtering (or singulation) which is indicated by the boolean flag
IsTagInventoryStateAwareSingulationSupported in the ReaderCapabilities class.
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.SingulationControl) or
not participate in the inventory based on their states.
Selected Flag
Tags provide a selected flag, SL, which is asserted or deasserted based on match criteria using method
Reader.Actions.PreFilters.Add.
State-Aware Singulation
In state-aware singulation, the application specifies detailed controls for singulation: Action and Target. Action
indicates whether matching Tags assert or de-assert 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.
74
ZEBRA RFID SDK for Xamarin Android
Applying Pre-Filters
The following are the steps to use pre-filters:
1. Add pre-filters.
2. Set appropriate singulation controls.
3. Perform Inventory or Access operation.
Add Pre-filters
Each RFID reader supports a maximum number of pre-filters per antenna as indicated by
ReaderCapabilities.MaxNumPreFilters which is known using the ReaderCapabilities.
The application sets pre-filters using reader.Actions.PreFilters.add and removes using
Reader.Actions.PreFilters.Delete.
State-Aware Settings
filter.StateAwareAction.StateAwareAction=STATE_AWARE_ACTION.StateAwareActionInvB;
// not to select tags that match the criteria
Reader.Actions.PreFilters.Add(filter);
// It is also required to set appropriate singulation control not to
// get tags with inventoried flag B for session 1
75
ZEBRA RFID SDK for Xamarin Android
State-Aware Singulation
Set the singulation control
Antennas.SingulationControl s1_singulationControl =
rfidReader.Config.Antennas.GetSingulationControl(1);
s1_singulationControl.Session=SESSION.SessionS1;
s1_singulationControl.Action.InventoryState=INVENTORY_STATE.InventoryStateB;
s1_singulationControl.Action.SLFlag=SL_FLAG.SlFlagDeasserted;
s1_singulationControl.Action.SetPerformStateAwareSingulationAction(true);
rfidReader.Config.Antennas.SetSingulationControl(1,
s1_singulationControl);
Inventory or Access operation when performed after setting pre-filters, use the tags filtered out of pre-filters for their
operation.
Using Triggers
Triggers are the conditions that are 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.
We have to use Config.StartTrigger and Config.StopTrigger APIs to set triggers on the reader.
• Periodic Inventory: Start inventory at a specified time for a specified duration repeatedly.
76
ZEBRA RFID SDK for Xamarin Android
• Perform ‘n’ Rounds of Inventory with a timeout: Start condition can be any; Stop condition is to perform ‘n’
rounds of inventory and then stop or stop inventory after the specified timeout.
• 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.
• Inventory based on hand-held trigger: Start inventory when the hand-held gun/button trigger is pulled, and
stop inventory when the hand-held gun/button trigger is released or subject to timeout.
77
ZEBRA RFID SDK for Xamarin Android
• Set the trigger using the following APIs, perform inventory and other operations which are using above set
start and stop triggers.
Reader.Config.StartTrigger=triggerInfo.StartTrigger;
Reader.Config.StopTrigger=triggerInfo.StopTrigger;
Reader.Actions.Inventory.Perform();
Access
Using Access-Filters
In order to perform an access operation on multiple tags, the application can set ACCESS_FILTER to filter the
required tags. If ACCESS_FILTER is not specified, the operation is performed on all tags. In any case, the
PRE_FILTER(s) (if any is set) applies prior to ACCESS_FILTER.
The following access-filter gets all tags that have zeroed reserved memory bank.
78
ZEBRA RFID SDK for Xamarin Android
Reader.Events.SetInventoryStartEvent(true);
Reader.Events.SetInventoryStopEvent(true); // Data Read Notification from the
reader
class EventHandler : Java.Lang.Object, IRfidEventsListener
{
// Read Event Notification
public void EventReadNotify(RfidReadEvents e)
{
TagData tag = e.ReadEventData.TagData;
Console.Out.WriteLine("Tag ID " + tag.TagID);
if (tag.OpCode == ACCESS_OPERATION_CODE.AccessOperationRead &&
tag.OpStatus == ACCESS_OPERATION_STATUS.AccessSuccess)
{
if (tag.MemoryBankData.Length > 0)
{
Console.Out.WriteLine(" Mem Bank Data " + tag.MemoryBankData);
}
}
}
// Status Event Notification
public void EventStatusNotify(RfidStatusEvents e){
if (e.StatusEventData.StatusEventType ==
STATUS_EVENT_TYPE.InventoryStartEvent)
{
// Access operation started
}
else if (e.StatusEventData.StatusEventType ==
STATUS_EVENT_TYPE.InventoryStopEvent)
{
// Access operation stopped - Can be used to signal waiting thread
}
}
}
79
ZEBRA RFID SDK for Xamarin Android
80
ZEBRA RFID SDK for Xamarin Android
Reader.Actions.TagAccess.OperationSequence.DeleteAll();
// add Write Access operation - Write to User memory
TagAccess tagAccess = new TagAccess();
TagAccess.Sequence opSequence = new TagAccess.Sequence(tagAccess, tagAccess);
TagAccess.Sequence.Operation op1 = new
TagAccess.Sequence.Operation(opSequence);
op1.AccessOperationCode=ACCESS_OPERATION_CODE.AccessOperationWrite;
op1.WriteAccessParams.MemoryBank=MEMORY_BANK.MemoryBankUser;
op1.WriteAccessParams.AccessPassword=0;
op1.WriteAccessParams.Offset=0;
op1.WriteAccessParams.SetWriteData("55667788" );
op1.WriteAccessParams.WriteDataLength=4;
Reader.Actions.TagAccess.OperationSequence.Add(op1);
// add Write Access operation - Write to Reserved memory bank
TagAccess.Sequence.Operation op2 = new TagAccess.Sequence.Operation(opSequence);
op2.AccessOperationCode=ACCESS_OPERATION_CODE.AccessOperationWrite;
op2.WriteAccessParams.MemoryBank=MEMORY_BANK.MemoryBankUser;
op2.WriteAccessParams.AccessPassword=0;
op2.WriteAccessParams.Offset=0;
op2.WriteAccessParams.SetWriteData("BBBBCCCC");
op2.WriteAccessParams.WriteDataLength=4;
Reader.Actions.TagAccess.OperationSequence.Add(op2);
// perform access sequence
Reader.Actions.TagAccess.OperationSequence.PerformSequence();
// if the access operation is to be terminated without meeting stop trigger (if
specified),
// stopSequence method can be called
Reader.Actions.TagAccess.OperationSequence.StopSequence();
Gen2v2 Operations
This section covers the Gen2V2 operations that an application needs to performed on a RFID Reader which
supports Gen2v2 commands such as authenticate, untraceable, and readbuffer.
Authenticate
Authenticate operation takes in the message data and message length with few of the options such as decision on
including the response length, sending the response, etc.
The AuthenticateParams contain the message data, message length and other settings to be sent to the reader.
The accessfilter parameter contains the tag pattern on which the operation occurs.
// authenticate
// Tag Pattern A
AccessFilter accessFilter = null;
accessFilter.TagPatternA.MemoryBank=MEMORY_BANK.MemoryBankEpc;
accessFilter.TagPatternA.SetTagPattern(new byte[] { (byte)0xe2, (byte)0xc0 });
accessFilter.TagPatternA.TagPatternBitCount=16;
accessFilter.TagPatternA.BitOffset=32;
accessFilter.TagPatternA.SetTagMask(tagMask);
accessFilter.TagPatternA.TagMaskBitCount=tagMask.Length * 8;
accessFilter.AccessFilterMatchPattern=(FILTER_MATCH_PATTERN.A);
81
ZEBRA RFID SDK for Xamarin Android
// G2V2 authenticate
// Gen2V2 gen2V2 - new Gen2v2 ();
Gen2v2.AuthenticateParams AuthenticateParams = new Gen2v2.AuthenticateParams(gen2V2);
AuthenticateParams.MsgData="2001FD5D8048F48DD09AAD22000111";
AuthenticateParams.MsgLen=120;
AuthenticateParams.IncrespLen=true;
AuthenticateParams.StoreResp=false;
AuthenticateParams.SentResp=true;
try
{
Reader.Actions.Gen2v2Access.Authenticate(AuthenticateParams, accessFilter,
null);
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
}
// Keep getting response in the eventReadNotify event if registered
82
ZEBRA RFID SDK for Xamarin Android
The response and result in the Tagdata will contain the information obtained from the operation.
83
ZEBRA RFID SDK for Xamarin Android
Untraceable
Untraceable operation lets the user decide which memory bank to show and what length of the memory bank to
show. Here the UntraceableParams contain the settings and password. The accessfilter parameter contains the
tag pattern on which the operation occurs.
// untraceable
AccessFilter accessFilter = new AccessFilter();
byte[] tagMask = new byte[] { (byte)0xff, (byte)0xff, };
// Tag Pattern A
accessFilter.TagPatternA.MemoryBank=MEMORY_BANK.MemoryBankEpc;
accessFilter.TagPatternA.SetTagPattern("2f22");
accessFilter.TagPatternA.TagPatternBitCount=32;
accessFilter.TagPatternA.BitOffset=32;
accessFilter.TagPatternA.SetTagMask(tagMask);
accessFilter.TagPatternA.TagMaskBitCount=tagMask.Length * 8;
accessFilter.AccessFilterMatchPattern=FILTER_MATCH_PATTERN.A;
Gen2v2 gen2V2 = new Gen2v2();
Gen2v2.UntraceableParams UntraceableParams = new
Gen2v2.UntraceableParams(gen2V2);
UntraceableParams.Password=0;
UntraceableParams.ShowEpc=true;
UntraceableParams.HideEpc=false;
UntraceableParams.ShowUser=false;
UntraceableParams.EpcLen=6;
UntraceableParams.Tid=UNTRACEABLE_TID.HideAllTid;
try
{
Reader.Actions.Gen2v2Access.Untraceable(UntraceableParams, accessFilter,
null);
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
}
After this, when inventory is run, the effects of the settings sent are seen in untraceable operation.
84
ZEBRA RFID SDK for Xamarin Android
Tag Locationing
Readers that support the Tag Locationing feature report the same in the field isTagLocationingSupported of
ReaderCapabilities as true. This feature is supported only on hand-held readers and is useful to locate a specific
tag in the field of view of the reader’s antenna. The default locationing algorithm supported on the reader can
perform locationing only on a single antenna. reader.Actions.TagLocationing.Perform can be used to start locating
a tag, and reader.Actions.TagLocationing.Stop to stop the locationing operation. The result of locationing of a tag is
reported as LocationInfo in TagData and is present in TagData if tagData isContainsLocationInfo is true.
tagData.LocationInfo.getRelativeDistance gives the relative distance of the tag from the reader antenna.
rfidReader.Config.TriggerMode=(ENUM_TRIGGER_MODE.RfidMode, true);
85
ZEBRA RFID SDK for Xamarin Android
First parameter is mode enum value and second parameter indicates whether SDK should take care of disabling
scanner plugin. When second parameter is true; SDK executes code to disable scanner plugin.
NOTE: It is recommended that Application handle scanner plugin enable/disable in pause and resume activity
respectively to avoid cross triggering to functionality not required.
techdocs.zebra.com/datawedge/6-5/guide/api/scannerinputplugin/
techdocs.zebra.com/datawedge/6-5/guide/api/resultinfo/
86
ZEBRA RFID SDK for Xamarin Android
87
ZEBRA RFID SDK for Xamarin Android
Set Attribute
The RFID SDK supports setting RFID parameters through attributes.
The following code demonstrates ways to set reader LED Mode indication.
Reader.Config.SetLedBlinkEnable(true);
• Antenna configuration
• Singulation settings
• Tag storage settings
• Delete all pre-filters (select record) on device
• Dynamic power setting (DPO enable/disable)
• Any five attributes passed as array of attributes
88
ZEBRA RFID SDK for Xamarin Android
// antenna power
Antennas.AntennaRfConfig antennaRfConfig =
mConnectedReader.Config.Antennas.GetAntennaRfConfig(1);
//mConnectedReader.Config.Antennas.new AntennaRfConfig();
antennaRfConfig.TransmitPowerIndex=270;
// singulation control
Antennas.SingulationControl singulationControl =
mConnectedReader.Config.Antennas.GetSingulationControl(1);
singulationControl.Action.InventoryState=INVENTORY_STATE.InventoryStateA;
singulationControl.Action.SetPerformStateAwareSingulationAction(false);
// API call
mConnectedReader.Config.SetDefaultConfigurations(antennaRfConfig, singulationControl,
tagStorageSettings, true, true, setAttributeArray);
Exceptions
The Zebra RFID Android SDK throws two types of exceptions as a given:
• InvalidUsageException: This exception is thrown when the user passes an invalid parameter, calling
getInfo() gives detail error message.
• OperationFailureException: This exception is thrown when the requested operation is failed. The
Exception contains the Operation RFIDResults, status description, time stamp & vendor specific message
for the operation failure.
Exception Handling
All API should be called under try-catch block to catch the exception thrown while performing API by SDK.
89
ZEBRA RFID SDK for Xamarin Android
try
{
Reader.Connect();
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
}
General Guidelines
Synchronization
Use synchronization method to cover connection, configuration, and disconnection blocks.
lock (monitor)
{
readers.AvailableRFIDReaderList;
Reader.Connect();
// Code related to configuration and initial setup after connection
ConfigureRfidReader();
}
lock (monitor)
{
Reader.Disconnect();
Readers.Dispose();
}
Threading
The following APIs must be called from background thread:
• GetAvailableRFIDReaderList
• connect
• disconnect
• Dispose
90
ZEBRA RFID SDK for Xamarin Android
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.V7.App;
using Android.Views;
using Android.Widget;
using Android.Util;
using Com.Zebra.Rfid.Api3;
using Java.Util;
using System.Threading;
namespace XamarinApiAutomation
{
[Activity(Label = "MainActivity", MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
private static Readers readers;
private static IList<ReaderDevice> availableRFIDReaderList;
private static ReaderDevice readerDevice;
private static RFIDReader Reader;
private static String TAG = "DEMO";
TextView textView;
private EventHandler eventHandler;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.list_testcases);
// Create your application here
// textView = (TextView)FindViewById(Resource.Id.TagText);
// SDK
if (readers == null)
{
readers = new Readers(this, ENUM_TRANSPORT.ServiceSerial);
}
ThreadPool.QueueUserWorkItem(o =>
{
try
91
ZEBRA RFID SDK for Xamarin Android
{
if (readers != null && readers.AvailableRFIDReaderList != null)
{
availableRFIDReaderList =
readers.AvailableRFIDReaderList;
if (availableRFIDReaderList.Count > 0)
{
if (Reader == null)
{
// get first reader from list
readerDevice = availableRFIDReaderList[0];
Reader = readerDevice.RFIDReader;
// Establish connection to the RFID Reader
Reader.Connect();
if (Reader.IsConnected)
{
Console.Out.WriteLine("Readers connected");
ConfigureReader();
}
}
}
}
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
Log.Debug(TAG, "OperationFailureException " + e.VendorMessage);
}
});
}
private void ConfigureReader()
{
if (Reader.IsConnected)
{
TriggerInfo triggerInfo = new TriggerInfo();
triggerInfo.StartTrigger.TriggerType =
START_TRIGGER_TYPE.StartTriggerTypeImmediate;
triggerInfo.StopTrigger.TriggerType =
STOP_TRIGGER_TYPE.StopTriggerTypeImmediate;
try
{
// receive events from reader
92
ZEBRA RFID SDK for Xamarin Android
if (eventHandler == null)
eventHandler = new EventHandler(Reader);
Reader.Events.AddEventsListener(eventHandler);
// HH event
Reader.Events.SetHandheldEvent(true);
// tag event with tag data
Reader.Events.SetTagReadEvent(true);
Reader.Events.SetAttachTagDataWithReadEvent(false);
// set trigger mode as rfid so scanner beam will not come
Reader.Config.SetTriggerMode(ENUM_TRIGGER_MODE.RfidMode, true);
// set start and stop triggers
Reader.Config.StartTrigger = triggerInfo.StartTrigger;
Reader.Config.StopTrigger = triggerInfo.StopTrigger;
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
}
}
}
protected override void OnDestroy()
{
try
{
if (Reader != null)
{
Reader.Events.RemoveEventsListener(eventHandler);
Reader.Disconnect();
Toast.MakeText(ApplicationContext, "Disconnecting reader",
ToastLength.Long).Show();
Reader = null;
readers.Dispose();
readers = null;
}
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
}
93
ZEBRA RFID SDK for Xamarin Android
catch (Exception e)
{
e.StackTrace.ToString();
}
}
}
// Read Event Notification
public void EventReadNotify(RfidReadEvents e)
{
// Recommended to use new method getReadTagsEx for better performance in case
of large tag population
94
ZEBRA RFID SDK for Xamarin Android
if
(rfidStatusEvents.StatusEventData.HandheldTriggerEventData.HandheldEvent ==
HANDHELD_TRIGGER_EVENT_TYPE.HandheldTriggerPressed)
{
ThreadPool.QueueUserWorkItem(o =>
{
try
{
Reader.Actions.Inventory.Perform();
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
}
});
}
if
(rfidStatusEvents.StatusEventData.HandheldTriggerEventData.HandheldEvent ==
HANDHELD_TRIGGER_EVENT_TYPE.HandheldTriggerReleased)
{
ThreadPool.QueueUserWorkItem(o =>
{
try
{
Reader.Actions.Inventory.Stop();
}
catch (InvalidUsageException e)
{
e.PrintStackTrace();
}
catch (OperationFailureException e)
{
e.PrintStackTrace();
}
});
}
}
}
}
}
}
95
Migrating to a Combined
RFD8500/RFD2000 RFID
SDK
Introduction
The new RFID SDK library can be used with both RFD8500 and RFD2000 devices. This chapter provides the
information necessary to update existing applications and develop new applications for use with the combined
RFID SDK.
Access operations offset and Change word based Use the following: Minor
count APIs: API. setCount
setByteCount setOffset
setByteOffset
96
Migrating to a Combined RFD8500/RFD2000 RFID SDK
NOTE: Current RFD8500 users should review the API differences below when porting applications from the
RFD2000.
97
Migrating to a Combined RFD8500/RFD2000 RFID SDK
Table 7 Model Specific APIs
RFD8500 RFD2000 Notes
Config.setBeeperVolume Not supported by reader. set/get Beeper on RFD8500.
Config.getBeeperVolume
NOTE: The following bullets assume that the application has prior knowledge of the type of reader model it is
working with and acts accordingly.
Examples
The following example shows getting a reader list for both reader models based on the device. The application can
create an instance of reader by checking the device type.
if (readers == null) {
if (Build.DEVICE.contains("TC20"))
readers = new Readers(this, ENUM_TRANSPORT.SERVICE_SERIAL);
else
readers = new Readers();
}
The following example shows model specific API inclusion and getting beeper volume for the RFD8500. The
application can check the connected reader model name to exercise the supported API on a particular model to
avoid conflict.
98
Migrating to a Combined RFD8500/RFD2000 RFID SDK
if(Application.mConnectedReader.ReaderCapabilities.getModelName().contains("RFD8500")) {
Application.beeperVolume = Application.mConnectedReader.Config.getBeeperVolume();
Application.batchMode =
Application.mConnectedReader.Config.getBatchModeConfig().getValue();
}
99
www.zebra.com