在Zebra RFID Android中执行库存时如何获取存储库用户数据?

时间:2019-07-24 09:47:56

标签: android rfid zebra

尽管RFID API应用程序允许您在选择要访问的存储库之后执行清单,但我似乎在应用程序中不允许任何类似的功能,我想知道如何做到这一点现在,尽管我知道Tag中有数据,但tag.getMemoryBankData()只是返回“ null”

我尝试搜索文档,并尝试使用Zebra Techdocs搜索某种配置选项,以便我也可以访问它。我曾尝试从RFID API .apk中提取代码,以尝试看看它是如何完成的,但是它太模糊了,我找不到它。

这是我的触发器和天线配置,如果有帮助的话。

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
                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);
                reader.Config.setUniqueTagReport(true);

                // power levels are index based so maximum power supported get the last one
                MAX_POWER = reader.ReaderCapabilities.getTransmitPowerLevelValues().length - 1;
                // set antenna configurations
                Antennas.AntennaRfConfig config = reader.Config.Antennas.getAntennaRfConfig(1);
                config.setTransmitPowerIndex(MAX_POWER);
                config.setrfModeTableIndex(0);
                config.setTari(0);
                reader.Config.setDPOState(DYNAMIC_POWER_OPTIMIZATION.DISABLE);
                reader.Config.setAccessOperationWaitTimeout(500);
                reader.Config.Antennas.setAntennaRfConfig(1, config);
                // Set the singulation control
                Antennas.SingulationControl s1_singulationControl = reader.Config.Antennas.getSingulationControl(1);
                s1_singulationControl.setSession(SESSION.SESSION_S0);
                s1_singulationControl.Action.setInventoryState(INVENTORY_STATE.INVENTORY_STATE_A);
                s1_singulationControl.Action.setSLFlag(SL_FLAG.SL_ALL);
                reader.Config.Antennas.setSingulationControl(1, s1_singulationControl);
                // delete any prefilters
                reader.Actions.PreFilters.deleteAll();
                //
            } catch (InvalidUsageException | OperationFailureException e) {
                e.printStackTrace();
            }

我一直期望获得MEMORY_BANK_USER数据,但是它总是返回“ null”,尽管我知道有一种无需执行读取操作就可以获取它的方法,但我似乎找不到方法。如果有人可以帮助您,我将非常感激,谢谢。

1 个答案:

答案 0 :(得分:0)

要读取MEMORY_BANK_USER内容,请使用标签访问模式

rfidreader.Events.setAttachTagDataWithReadEvent(true); 

以及事件处理程序的代码

class EventHandler implements RfidEventsListener {
  // Read Event Notification
  public void eventReadNotify(RfidReadEvents e) {
    TagData tag = e.getReadEventData().tagData;
    if (tag.getOpCode() == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ 
         && tag.getOpStatus() == ACCESS_OPERATION_STATUS.ACCESS_SUCCESS) {
      Log.d(TAG, "eventReadNotify - tag id " + tag.getTagID() + " and mem bank " + tag.getMemoryBankData());
    }
  }
}