DataWedge Interaction

I'd like to be able to broadcast to Datawedge to turn scanner on or off. For example, once a user scans a product, I'd request the scanner to be turned off until a quantity has been entered.

Here's a link from Zebra on how to do it. It just needs to be programmed into retool as command that can be executed after an activity.

Enable / Disable:

Enable / Disable can be called at any time

Intent dwIntent = new Intent();
dwIntent.setAction("com.symbol.datawedge.api.ACTION");
//  Enable
dwIntent.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "ENABLE_PLUGIN");
//  or Disable
dwIntent.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "DISABLE_PLUGIN");
sendBroadcast(dwIntent);

Resume / Suspend:

Resume / Suspend is much quicker but Suspend can only be called when the scanner is in the SCANNING or WAITING state

Intent dwIntent = new Intent();
dwIntent.setAction("com.symbol.datawedge.api.ACTION");
//  Resume
dwIntent.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "RESUME_PLUGIN");
//  or Suspend
if (okToSuspend)
    dwIntent.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "SUSPEND_PLUGIN");
sendBroadcast(dwIntent);

You can determine the scanner state using the GetScannerStatus or RegisterForNotification APIs:

//  RegisterForNotification
@Override
protected void onResume()
{
    super.onResume();
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.symbol.datawedge.api.NOTIFICATION_ACTION");
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    registerReceiver(myBroadcastReceiver, filter);
}

private BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals("com.symbol.datawedge.api.NOTIFICATION_ACTION"))
        {
            if (intent.hasExtra("com.symbol.datawedge.api.NOTIFICATION"))
            {
                Bundle extras = intent.getBundleExtra("com.symbol.datawedge.api.NOTIFICATION");
                String notificationType = extras.getString("NOTIFICATION_TYPE");
                if (notificationType != null && notificationType.equals("SCANNER_STATUS"))
                {
                    //  We have received a change in Scanner status
                    String scannerStatus = extras.getString("STATUS");
                    if (scannerStatus.equals("WAITING") || scannerStatus.equals("SCANNING"))
                            okToSuspend = true;
                        else
                            okToSuspend = false;
                }
            }
        }
    }
};

Hi @Rkhan, we may have a workaround for this.

We can create a state variable "scannerDisabled" with a default value of false, then assign its value to the "Disabled" property of the "Scanner" component:

Add an event handler to the component to set the variable to true, when the scanner opens or captures:


And finally, add "Success" event handler to the query that runs when we scan an item. Here, set the "Disabled" property of the component back to false again so it's ready to be used again (we may need a "Failure" one too).

Hi @Paulo
Just to confirm, this for the the Zebra hardware barcode scanner and not for the Retool Camera barcode scanner? If yes, I can test it.

The "Zebra DataWedge Reader" component also has a "Capture" event handler we can use to achieve this functionality:



It should work as expected. :slightly_smiling_face:

Please let us know if it doesn't. We can help you debug the issue, or file a report internally if necessary.

@Paulo this does not work as intended. The goal is to disable/pause the hardware scanner so the scanner does not scan or light up. This would require the user to stop and look at the screen as to what is wrong.

Thank you for your feedback, @Rkhan!
We created the FR internally, we'll let you know when we get updates on it. :slightly_smiling_face: