Android with RFD8500, how to switch from RFID to Barcode Scanner

// Expert user has replied.
L Luca Devincenzi 2 years 11 months ago
374 6 0

Dear Support,
I'm testing your two demo app for RFD8500 (Zebra RFID Mobile and Zebra scanner). Is it possibile, once the RFD8500 is connected in the RFID Mobile, switching to the barcode "mode" ?
I would like to add an activity for barcodes inside the RFID app, but in the sdk I haven't found the command to start reading them.
In the Zebra Scanner App you use a totally different way of cummunication, and set up the communication with the SSI scanner serial port.
The only way to start reading barcode is disconnecting from the RFID and reconnecting with the bar-code port ?
 
 
thank you!

Please register or login to post a reply

6 Replies

C Chris Hallgren

Testing

F Francesco Guerci

solved with code from demo "scan scan write":

private void SetModeBarcode() {
  Command_SetAttr attr = new Command_SetAttr();
  attr.setattnum(1664);
  attr.setatttype("B");
  attr.setattvalue(1);
  sendCommand(attr);
  sendCommand(new Command_GetVersion());
  sendCommand(new Command_GetCapabilities());
}

private void SetModeRFID() {
  Command_SetAttr attr = new Command_SetAttr();
  attr.setattnum(1664);
  attr.setatttype("B");
  attr.setattvalue(0);
  sendCommand(attr);
  sendCommand(new Command_GetVersion());
  sendCommand(new Command_GetCapabilities());
}

V Vedsatx Saddvv

Hi Luca,
     Did you make any progress on this issue?

P Pedro Frau

Hi,
I've been having trouble with this myself. In the end I figured out a way to make it work (even if I don't know if it't the correct way to proceed).
To control the RFD8500 you need to use RFIDAPI3Library (I guess you knew that). Now, to control the scanner, your Android app has to make use of the BarcodeScannerLibrary. Now, you don't need to import this "new" library since it is already included in RFIDAPI3Library. You just need to use it.
Let's say you have a class named ConnectionHandler that "handles the connection" with your RFD8500. This particular class must implement IDCSSdkApiDelegate:

<code>
public class ConnectionHandler implements IDcsSdkApiDelegate {
...
}
</code>

This will force you to implement all the methods in IDcsSdkApiDelegate:

<code>
@Override
public void dcssdkEventScannerAppeared(DCSScannerInfo dcsScannerInfo) {
/***Left blank on purpose***/
}

@Override
public void dcssdkEventScannerDisappeared(int i) {
/***Left blank on purpose***/
}

@Override
public void dcssdkEventCommunicationSessionEstablished(DCSScannerInfo dcsScannerInfo) {
/***Left blank on purpose***/
}

@Override
public void dcssdkEventCommunicationSessionTerminated(int i) {
/***Left blank on purpose***/
}

@Override
public void dcssdkEventBarcode(byte[] barcodeData, int i, int i1) {
String barcodeNum = new String(barcodeData, StandardCharsets.UTF_8);
}

@Override
public void dcssdkEventImage(byte[] bytes, int i) {
/***Left blank on purpose***/
}

@Override
public void dcssdkEventVideo(byte[] bytes, int i) {
/***Left blank on purpose***/
}

@Override
public void dcssdkEventBinaryData(byte[] bytes, int i) {
/***Left blank on purpose***/
}

@Override
public void dcssdkEventFirmwareUpdate(FirmwareUpdateEvent firmwareUpdateEvent) {
/***Left blank on purpose***/
}

@Override
public void dcssdkEventAuxScannerAppeared(DCSScannerInfo dcsScannerInfo, DCSScannerInfo dcsScannerInfo1) {
/***Left blank on purpose***/
}
</code>

Before adding any code to them (their code will be entirely up to you), let's create an instance of the SDKHandler, A list of DCSScannerInfo, a msg Handler, and some constants. Create a new class Application.java which will contain the following:

<code>
public class Application extends android.app.Application {
public static SDKHandler sdkHandler;

//Handler to handle bluetooth events
public static Handler globalMsgHandler;

//Settings for notifications
public static int MOT_SETTING_OPMODE;
public static boolean MOT_SETTING_SCANNER_DETECTION;
public static boolean MOT_SETTING_EVENT_ACTIVE;
public static boolean MOT_SETTING_EVENT_AVAILABLE;
public static boolean MOT_SETTING_EVENT_BARCODE;

//Scanners (both available and active)
public static ArrayList mScannerInfoList = new ArrayList();

@Override
public void onCreate() {
super.onCreate();
//this keyword referring to Context of the sample application
sdkHandler = new SDKHandler(this, true);
}
}
</code>

Ok, now let's say we want to connect to the scanner through our new method connectScanner(). In that method you will set the trigger mode of the RFD8500 to work as a barcode reader, set the stop trigger config to work as a single tag reader, initialize the instance of SDKHandler, Initialize DcsSdk, Set operational modes, get the list of available and active scanners, and establish a session with your scanner.
Step by step, let's first declare some globals on top of your ConnectionHandler:

<code>
public class ConnectionHandler implements IDcsSdkApiDelegate {
private DCSScannerInfo availableScanner;
protected final Handler mHandler = initializeHandler();
private static ArrayList mScannerInfoList;
}
</code>

Then let's create the following methods setSingleTagStopTriggerConfig(), initializeDcsSdkWithAppSettings(), and connectScanner():
setSingleTagStopTriggerConfig():

<code>
/***This method makes the trigger config work as a single tag reader***/
public void setSingleTagStopTriggerConfig(){
Long tagObservation;
triggerInfo.StopTrigger.setTriggerType(STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_TAG_OBSERVATION_WITH_TIMEOUT);
tagObservation = Long.parseLong("1");
// set tag observation
triggerInfo.StopTrigger.TagObservation.setN(tagObservation.shortValue());
triggerInfo.StopTrigger.TagObservation.setTimeout(3000);
}

/***Here we make sure our application subscribes to scanner events. In particular, Scanner availability and barcode events***/
public void initializeDcsSdkWithAppSettings() {
// Restore preferences
Application.MOT_SETTING_OPMODE = DCSSDK_CONNTYPE_BT_NORMAL.value;

Application.MOT_SETTING_SCANNER_DETECTION = true;

Application.MOT_SETTING_EVENT_ACTIVE = true;
Application.MOT_SETTING_EVENT_AVAILABLE = true;
Application.MOT_SETTING_EVENT_BARCODE = true;

int notifications_mask = 0;
if (Application.MOT_SETTING_EVENT_AVAILABLE) {
notifications_mask |= (DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_SCANNER_APPEARANCE.value | DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_SCANNER_DISAPPEARANCE.value);
}
if (Application.MOT_SETTING_EVENT_ACTIVE) {
notifications_mask |= (DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_SESSION_ESTABLISHMENT.value | DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_SESSION_TERMINATION.value);
}
if (Application.MOT_SETTING_EVENT_BARCODE) {
notifications_mask |= (DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value);
}

Application.sdkHandler.dcssdkSubsribeForEvents(notifications_mask);
}

/***This method is used to configure the RFD8500 to work as a barcode scanner***/
public void connectScanner(){
try {
rfidReader.Config.setTriggerMode(ENUM_TRIGGER_MODE.BARCODE_MODE, true);
setSingleTagStopTriggerConfig();
} catch (InvalidUsageException e) {
e.printStackTrace();
} catch (OperationFailureException e) {
e.printStackTrace();
}
mScannerInfoList=Application.mScannerInfoList;
if (Application.sdkHandler == null) {
Application.sdkHandler = new SDKHandler(mainContext, true);
}

Application.sdkHandler.dcssdkSetDelegate(this);
initializeDcsSdkWithAppSettings();

Application.sdkHandler.dcssdkEnableAvailableScannersDetection(true);
Application.sdkHandler.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_BT_NORMAL);
Application.sdkHandler.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_SNAPI);
Application.sdkHandler.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_BT_LE);
Application.sdkHandler.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_USB_CDC);

if (Application.sdkHandler != null) {
mScannerInfoList.clear();
ArrayList scannerTreeList = new ArrayList();
Application.sdkHandler.dcssdkGetAvailableScannersList(scannerTreeList);
Application.sdkHandler.dcssdkGetActiveScannersList(scannerTreeList);

for (DCSScannerInfo s :
scannerTreeList) {
addToScannerList(s);
}
}

Application.sdkHandler.dcssdkEstablishCommunicationSession(availableScanner.getScannerID());
</code>

Finally, let's add some auxiliary methods:

<code>
private void addToScannerList(DCSScannerInfo s) {
mScannerInfoList.add(s);
if (s.getAuxiliaryScanners() != null) {
for (DCSScannerInfo aux :
s.getAuxiliaryScanners().values()) {
addToScannerList(aux);
}
}
}

private Handler initializeHandler() {
if (Application.globalMsgHandler != null)
return Application.globalMsgHandler;
return null;
}
</code>

Once initializeDcsSdkWithAppSettings() has been executed you should start receiving events, first event you should receive is dcssdkEventScannerAppeared() where you will see the list of paired devices (even if they are not readers), so you could implement the method for instance as follows:

<code>
if(dcsScannerInfo.getScannerName().equals(readerName)){
canConnectScanner = true;
availableScanner = dcsScannerInfo;
}
</code>

Where you establish the device you want to connect with through its name.
**canConnectScanner and readerName are just variables I created that make sense in my code's logic, here you should implement your own logic.

Then, once connection with your reader has been established, you should start receiving information as you pull the trigger on the dcssdkEventBarcode() method.
**remember tha barcode data here comes as a byte array, you can convert it to the actual barcode number using
<code>
String barcodeNum = new String(yourByteArray, StandardCharsets.UTF_8);
</code>

So now you just how to figure out the logic you want to use to switch from one to another. For instance, a button in your frontend that calls a method switchGunMode(String gunMode /*Let's say "barcode"*/) from where you can call connectScanner().

Now this is an extract from my code, so it might not be plug and play, but you shouldn't have to make too much of an effort to make it work. Zebra documentation is a mess and as I see in the forum the only answer you get when you ask for good documentation is "Go to our demo apps and figure it out yourself". What I shared here is a code I built after several ours scrapping documentation, forums, sample codes, etc. and testing. But I really think Zebra should make an effort on trying to keep the documentation updated, complete and correct (because there are a lot of errors in sample codes.
But that's my personal opinion.

Kind regards.

M Mugileeshwaran Sugumar

Hi 

Do you have any sample solution for the above code which you gave?

Regards

S Sean Kennedy

Hi Mugileeshwaran
Refer to the 123RFID Mobile application and it correspondent Source Code (Android Studio / Java)
https://www.zebra.com/us/en/support-downloads/software/demo/123rfid-mobile.html
The downloadable .ZIP contains both the sideloadable apl, as well as the Source code.

CONTACT
Can’t find what you’re looking for?