Application Level

The Application Level regroups the features that are required for the application to operate in an optimum way.

One piece of information that is useful, especially in case of an anomaly, is to retrieve the version of Capture and the version of the Scanner connected to the host.

In the event multiple scanners are used on a single device, there is then a way to identify them by assigning a friendly name.

Also in the case of contactless reader/writer, that uses Bluetooth Low Energy (BLE) to connect to the host and in the event the deployment has multiple contactless reader/writer, it is possible to discover them and let the user picking the appropriate one.

Another useful feature is the scenario where the host computer is out of range from where the scan happens, and to confirm the barcode was actually received by the application.

Display the Capture Version

This feature is useful when an issue arises in a deployment in order to help identify the version of Capture SDK actually in use.

Here is a sample of code for retrieving the Capture Version:

const property = new SocketMobile.CaptureProperty(
  SocketMobile.CapturePropertyIds.Version,
  SocketMobile.CapturePropertyTypes.None,
  {}
);
capture.getProperty(property)
  .then(result => {
    const version = result.value;
    console.log(`version: ${version}`);
    displayVersion(`Capture version: ${version.major}.${version.middle}.${version.minor}.${version.build} ${version.month}/${version.day}/${version.year} `)
  })
  .catch(err => {
    console.log('error while getting device version: ', err);
  });

Here is an example for getting the device version:

const property = new SocketMobile.CaptureProperty(
  SocketMobile.CapturePropertyIds.VersionDevice,
  SocketMobile.CapturePropertyTypes.None,
  {}
);
captureDevice.getProperty(property)
.then(result => {
  const version = result.value;
  console.log(`version: `, version);
  displayVersion(`device version: ${version.major}.${version.middle}.${version.minor}.${version.build} ${version.month}/${version.day}/${version.year} `)
})
.catch(err => {
  console.log('error while getting device version: ', err);
});

Give a Friendly Name to a Scanner

In a deployment where multiple scanners are present, it is helpful to identify them with a friendly name that makes sense (e.g. ‘’Register1Scanner’’).

Here is a sample code to change the friendly name:

function onSetFriendlyName() {
  const input = document.getElementById('friendlyName');
  const property = new SocketMobile.CaptureProperty(
    SocketMobile.CapturePropertyIds.FriendlyNameDevice,
    SocketMobile.CapturePropertyTypes.String,
    input.value
  );
  captureDevice.setProperty(property)
  .catch(err => {
    console.log('error while setting friendly name: ', err);
  });
}

This code assumes the device that is opened is referenced by the captureDevice variable.

Contactless Reader/Writer Discovery And Selection

Please refer to Contactless Reader/Writer discovery.

Data Confirmation from the Application

For some deployments where the user might be unable to see the screen of the host when scanning a barcode, there is a way to have the application confirm the barcode received is correct.

In this case the trigger button will be disabled until the application confirms the decoded data or until the trigger lock out timer elapses.

First, Capture needs to be configured with Data Confirmation Mode set to ‘’App’’.

This mode is persistent in Capture. If a scanner is connected then it will be configured to App mode as well at this time, otherwise, when a scanner connects it will be automatically configured to App mode during the connection process.

The following example shows how to set the confirmation to the application:

function onSetConfirmationMode(){
  const select = document.getElementById('dataConfirmationMode');
  console.log('select: ', select.value);
  let mode = SocketMobile.DataConfirmationMode.ModeOff;
  if(select.value === 'app') {
    mode = SocketMobile.DataConfirmationMode.ModeApp;
  }
  else if(select.value === 'capture') {
    mode = SocketMobile.DataConfirmationMode.ModeCapture;
  }
  else if(select.value === 'device') {
    mode = SocketMobile.DataConfirmationMode.ModeDevice;
  }
  const property = new SocketMobile.CaptureProperty(
    SocketMobile.CapturePropertyIds.DataConfirmationMode,
    SocketMobile.CapturePropertyTypes.Byte,
    mode
  );
  capture.setProperty(property)
  .catch(err => {
    console.log(`set data confirmation mode fails with error: `, err);
  });
}

If the Data Confirmation Mode is configured to ‘’App’’, then the application is responsible for acknowledging the decoded data to the scanner.

Here is example code showing how an application can acknowledge the decoded data:

function confirmData() {
  const action = (SocketMobile.DataConfirmationRumble.Good<<4) +
      (SocketMobile.DataConfirmationBeep.Good<<2) +
      SocketMobile.DataConfirmationLed.Green;
  const property = new SocketMobile.CaptureProperty(
    SocketMobile.CapturePropertyIds.DataConfirmationDevice,
    SocketMobile.CapturePropertyTypes.Ulong,
    action
  );
  captureDevice.setProperty(property)
  .catch(err => {
      console.log('error while confirming the decoded data: ', err);
    });
}

Note

The Data Confirmation Mode set to ‘’App’’ is the slowest way of scanning barcodes. Another way to handle cases where the barcode might be incorrect, is to have the application sending a Bad Beep, Bad Rumble and Red LED to the scanner and disabling the trigger button until the user acknowledges a message on the host screen explaining the issue. Please refer to Wrong Barcode Indication and Disabling the Scanner Trigger Button