Managing Events Guide

RFID SDK for Android 2.0.2.94

Overview

This Guide provides a walk-through of the steps to perform Managing Events operation using RFID3 API

Details

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

# Reader Events Detail HandHeld Readers Fixed Readers
1 HANDHELD_TRIGGER_EVENT A hand-held Gun/Button event Pull/Release has occurred. Applicable NA
2 INVENTORY_START_EVENT Inventory Operation started. In case of periodic trigger, this event is triggered for each period Applicable Applicable
3 INVENTORY_STOP_EVENT Inventory Operation has stopped. In case of periodic trigger this event is triggered for each period Applicable Applicable
4 OPERATION_END_SUMMARY_EVENT 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 Applicable NA
5 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. Applicable Applicable
6 BUFFER_FULL_WARNING_EVENT When the internal buffers are 90% full, this event is signaled Applicable Applicable
7 BUFFER_FULL_EVENT When the internal buffers are 100% full, this event is signaled and tags are discarded in FIFO manner Applicable Applicable
8 TEMPERATURE_ALARM_EVENT 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) Applicable NA
9 BATTERY_EVENT Events notifying different levels of battery, state of the battery, if charging or discharging. Applicable NA
10 POWER_EVENT Events which notify the different power states of the reader device. The event data contains cause, voltage, current and power Applicable NA
6 ANTENNA_EVENT A particular Antenna has been Connected/Disconnected. When this event is signaled, StatusEventData contains Antenna and the Connection Status that has occurred. NA Applicable
7 GPI_EVENT A GPI event (state change from high to low, or low to high) has occurred on a GPI port. When this event is signaled, StatusEventData contains GPI Port and GPI Event that has occurred. NA Applicable
8 TAG_READ_EVENT A tag read event occurs when tag is read. Applicable Applicable

Setting it up

Registering for read tag data notification


EventHandler eventHandler = new EventHandler();
reader.Events.addEventsListener(eventHandler);
// Subscribe required status notification
reader.Events.setInventoryStartEvent(true);
myReader.Events.setInventoryStopEvent(true);
// enables tag read notification. if this is set to false, no tag read notification is send
myReader.Events.setTagReadEvent(true);
myReader.Events.setReaderDisconnectEvent(true);
myReader.Events.setBatteryEvent(true);

Event class

Implement the RfidEventsLister class to receive event notifications


class EventHandler implements RfidEventsListener {
    // Read Event Notification
    public void eventReadNotify(RfidReadEvents e){
        // Recommended to use new method getReadTagsEx for better performance in case of large
        // tag population
        TagData[] myTags = myReader.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].getOpCode() == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ
                    && myTags[index].getOpStatus() == ACCESS_OPERATION_STATUS.ACCESS_SUCCESS)
                {
                    if (myTags[index].getMemoryBankData().length() > 0) {
                        System.out.println(" Mem Bank Data " +
                        myTags[index].getMemoryBankData());
                    }
                }
            }
        }
    }
    // Status Event Notification
    public void eventStatusNotify(RfidStatusEvents e) {
        System.out.println("Status Notification: " +
        e.StatusEventData.getStatusEventType());
    }
}

Unregistration

Unregistering for read tag data notification


reader.Events.removeEventsListener(eventHandler);

Device Status Related Events

Device status, such as battery, power, and temperature, is obtained through events after initiating the following API


reader.Config.getDeviceStatus(battery, power, temperature)

Response to the above API comes as battery event, power event, and temperature event according to the set boolean value in the respective parameters. The following is an example of how to get these events


try {
    if (reader != null)
        reader.Config.getDeviceStatus(true, false, false);
    else
        // do something
} catch (InvalidUsageException e) {
    e.printStackTrace();
} catch (OperationFailureException e) {
    e.printStackTrace();
}