Porting Guide
For users who have an existing Zebra Enterprise Browser web app, many of the functions from Zebra's Barcode Module can be adjusted for use with the Datalogic Enterprise Browser JavaScript SDK.
Many of the Zebra scanner properties of EB.Barcode
have equivalent Datalogic scanner properties found in the BcdPropIds
object. Note that while the Zebra scanner properties can be accessed as either data members of EB.Barcode
or through member functions, the Datalogic Properties can only be accessed through member functions using the constant values from BcdPropIds
.
The following table summarizes which Zebra functions are supported by the Datalogic JavaScript SDK.
Zebra Function | Datalogic Support |
---|---|
addConnectionListener | ❌ |
barcode_recognize | ❌ |
commandRemoteScanner | ❌ |
disable | ✔ |
enable | ✔ |
enumerate | ❌ |
getAllProperties | ✔ |
getautoCharacterSetPreference | ❌ |
getDefault | ❌ |
getProperties | ✔ |
getProperty | ✔ |
getSupportedProperties | ✔ |
isParamSupported | ✔ |
registerBluetoothStatus | ❌ |
removeConnectionListener | ❌ |
resetToDefault | ✔ |
setautoCharacterSetPreference | ❌ |
setDefault | ❌ |
setProperties | ✔ |
setProperty | ✔ |
start | ✔ |
stop | ✔ |
take | ✔ |
Functions
The following entries provide details on various Zebra functions and the equivalent code using the Datalogic SDK.
disable
Zebra:
Disable the scanner and place it in its default state.
EB.Barcode.disable();
Datalogic:
To reset scanner properties and disable physical triggers, use the following code:
DLBarcodeMgr.setDefaults();
DLKeyboardMgr.enableTriggers(false);
// Optionally, to also clear the callback listeners for scan and/or timeout.
DLBarcodeMgr.ignoreScan();
DLBarcodeMgr.ignoreTimeout();
enable
Zebra:
Enable the scanner, optionally configure its settings, and place it in a state where it will respond to hardware (or soft) triggers.
EB.Barcode.enable({}, scanReceived);
function scanReceived(params) {
if (params['data']== "" || params['time']=="") {
document.getElementById('display').innerHTML = "Scan timeout";
return;
}
var resultStr = "Barcode Data: " + params['data'] + "<br>Time: " + params['time'];
document.getElementById("display").innerHTML = resultStr;
}
Datalogic:
The scanner is always enabled. To enable physical triggers and start listening for scan results, use the following code:
DLKeyboardMgr.enableTriggers(true);
DLBarcodeMgr.onScan(scanReceived);
DLBarcodeMgr.onTimeout(scanTimeout);
function scanReceived(scan) {
var idStr = "Barcode ID: " + Object.keys(SymIds)[scan.id];
var dataStr = "<br>Data: " + scan.text;
document.getElementById("display").innerHTML = idStr + dataStr;
}
function scanTimeout() {
document.getElementById("display").innerHTML = "Scan timeout";
}
getAllProperties
Zebra:
Return all the scanner properties as object/value pairs.
let scanProps = EB.Barcode.getAllProperties();
Datalogic:
To get all of the scanner property values, use the following code:
let scanProps = {}; // This will contain all the scanner properties.
for (const key in BcdPropIds) {
scanProps[key] = DLBarcodeMgr.getProperty(BcdPropIds[key]);
}
getProperties
Zebra:
Return a set of requested scanner properties as object/value pairs.
let scanProps = EB.Barcode.getProperties(["code39", "code128"]);
Datalogic:
To read multiple scanner property values, use the following code:
let scanProps = {CODE39_ENABLE, CODE128_ENABLE};
for (const key in Object.keys(scanProps)) {
scanProps[key] = DLBarcodeMgr.getProperty(BcdPropIds[key]);
}
getProperty
Zebra:
Return the value of a scanner property.
let code39Enable = EB.Barcode.getProperty("code39");
Datalogic:
To read the value of a scanner property, use the following code:
let code39Enable = DLBarcodeMgr.getProperty(BcdPropIds.CODE39_ENABLE);
getSupportedProperties
Zebra:
Return an array with the scanner properties supported on the device.
let supportedProps = EB.Barcode.getSuportedProperties();
Datalogic:
To get the supported scanner properties, use the following code:
let supportedProps = {};
for (const key in Object.keys(BcdPropIds)) {
if (DLBarcodeMgr.isAvailable(BcdPropIds[key])) {
supportedProps[key] = DLBarcodeMgr.getProperty(BcdPropIds[key]);
}
}
isParamSupported
Zebra:
Returns true if the specified scanner property is supported on the device.
if (EB.Barcode.isParamSupported("code128")) {
alert("Code-128 enable property is supported");
}
Datalogic:
To determine if a scanner property is supported, use the following code:
if (DLBarcodeMgr.isAvailable(BcdPropIds.CODE128_ENABLE)) {
alert("Code-128 enable property is supported");
}
resetToDefault
Zebra:
Resets the scanner properties to default values.
EB.Barcode.resetToDefault();
Datalogic:
To reset scanner properties to defaults, use the following code:
DLBarcodeMgr.setDefaults();
setProperties
Zebra:
Set the values of scanner properties specified by property:value pairs.
EB.Barcode.setProperties(
{code39:"true", // ID/value for Code 39
code128minLength:"8"}); // ID/value for Code 128 min
Datalogic:
To set multiple scanner property values, use the following code:
DLBarcodeMgr.setProperties(
[BcdPropIds.CODE39_ENABLE, BcdPropIds.CODE128_LENGTH1], // IDs
[true, 8]); // Values (Note: values are not strings)
setProperty
Zebra:
Set the value of a scanner property.
EB.Barcode.setProperty("code39", "true");
Datalogic:
To set the value of a scanner property, use the following code:
DLBarcodeMgr.setProperty(BcdPropIds.CODE39_ENABLE, true);
start
Zebra:
Initiate a scan without pressing the hardware trigger.
EB.Barcode.start();
// Note: If the scan result is a timeout you need to make this call:
// EB.Barcode.stop();
Datalogic:
To start a scan (without a hardware trigger), use the following code:
DLBarcodeMgr.startDecode();
// Note: A call to stopDecode() is not required on a scan timeout.
stop
Zebra:
Stop a scan initiated with start().
EB.Barcode.stop();
Datalogic:
To stop a scan started by startDecode(), use the following code:
DLBarcodeMgr.stopDecode();
take
Zebra:
Enable the scanner, optionally configure its settings, and place it in a state where it will respond to hardware (or soft) triggers.
EB.Barcode.take({}, scanReceived);
function scanReceived(params) {
if (params['status']== "cancel") {
document.getElementById('display').innerHTML = "Scan cancelled";
return;
}
document.getElementById("display").innerHTML = "Barcode Data: " + params['barcode'];
}
Datalogic:
The scanner is always enabled. To start a scan listen for results, use the following code:
DLBarcodeMgr.onScan(scanReceived);
DLBarcodeMgr.onTimeout(scanTimeout);
DLBarcodeMgr.startDecode();
function scanReceived(scan) {
var idStr = "Barcode ID: " + Object.keys(SymIds)[scan.id];
var dataStr = "Data: " + scan.text;
document.getElementById("display").innerHTML = idStr + "<br>" + dataStr;
}
function scanTimeout() {
document.getElementById("display").innerHTML = "Scan timeout";
}