Scanner Module

RhoElements 2.x API

Overview

The Scanner Module controls the functionality of the device scanner.

Syntax

scanner (Module) <META> Syntax

<META HTTP-Equiv="Scanner" content="[parameter / method]">

<META HTTP-Equiv="Scanner" content="DecodeEvent:url('[jsFunction | url]')">

Scanner JavaScript Object Syntax:
By default the JavaScript Object 'scanner' will exist on the current page and can be used to interact directly with the scanner.
To Invoke scanner methods via JavaScript use the following syntax: scanner.method();

e.g. scanner.enumerate();

To Set scanner parameters via JavaScript use the following syntax: scanner.parameter = 'value'; remembering to enclose your value in quotes where appropriate.

e.g. scanner.enabled = 'value';

To Set scanner return events via JavaScript use the following syntax: scanner.event = Javascript Function;

e.g. scanner.decodeEvent = 'doFunction(%json)';

To set multiple EMML parameters / events on a single line use the following syntax: scanner.setEMML("[Your EMML Tags]");

e.g. scanner.setEMML("enabled:value;decodeEvent:url('JavaScript:doFunction(%json)');enumerate");

Methods

Items listed in this section indicate methods, or in some cases parameters that will be retrieved.

NameDescriptionDefault Value
enumerateReturn a list of scanners present on the device via EnumScannerEvent. This tag will be actioned immediately and should be called via JavaScript. N/A
enableEnables the default scanner if no scanner is currently enabled. Note: Enabling a scanner without setting decoders will result in some default decoders enabled. If decoders have been set and then disabled has been called, the required decoder settings should be reapplied.Device specific
disableDisables the currently enabled scanner. This reverts the scanner to its default state and flushes any current decoder settings.Device specific
startPerforms a soft trigger start. If the scan does not result in a decode it is necessary to perform a soft stop before another soft start. N/A
stopPerforms a soft trigger stop N/A

Parameters

Items listed in this section indicate parameters, or attributes which can be set.

NameDescription
enabled:[Value] Enables the specified scanner. The non-default scanner should only be used on licensed devices.

Possible Values:ID of Scanner, obtained via EnumScanner

Default: SCN1
[Decoder Name]:[Value] Sets each Decoders' parameters. Refer to the "Decoders" Section of this help file to know available decoders and Their Parameters.

Possible Values:Decoder Property

Default: Refer to the "Decoders" Section
autoEnter:[Value] If "enabled" then automatically append an Enter to the end of any barcodes scanned. This feature is only available when a decodeEvent is not specified and is useful for submitting forms. See Remarks.

Possible Values:'enabled' / 'disabled'

Default: 'Disabled'
autoTab:[Value] If "enabled" then automatically appends a Tab to the end of any barcodes scanned. This feature is only available when a decodeEvent is not specified and is useful for advancing to the next input field. See Remarks.

Possible Values:'enabled' / 'disabled'

Default: Disabled
linearSecurityLevel:[Value] Describes the linear security level used during decoding.
Possible values:
redundancyAndLength: Two times redundancy based on redundancy flags and code length.
shortOrCodabar: Two times redundancy if short barcode or Codabar.
longAndShort: Two times redundancy for long barcodes, three times for short barcodes.
allTwice: Two times redundancy for all barcodes.
allThrice: Three times redundancy for all barcodes.
Applicable scanner types: Laser and Imager / Camera
Default: Device specific
scanTimeout:[Value] Maximum time in milliseconds that laser scanners will emit a beam or imager scanners will enable the imager. A value of 0 indicates an infinite timeout. This parameter is compatibile with aimType:trigger, aimType:timedHold, aimType:timedRelease and aimType:pressAndRelease. Note that for regulatory reasons scanTimeout is not configurable on all laser/imager scanners.

Possible Values:milliseconds
Applicable scanner types: Laser and Imager / Camera
Default: 5000 (Laser), 15000 (Imager)
rasterMode:[Value] Describes the type of vertical rastering to use. This is not supported on Android.
Possible values:
none: No vertical rastering.
openAlways: Vertical rastering is always full open. To adjust the rastering height use the rasterHeight property.
smart: Vertical rastering mode is 'Smart'.
cyclone: Vertical rastering mode is 'Cyclone'.
Applicable scanner types: Laser Only
Default: Device specific
rasterHeight:[Value] Vertical rastering height to use, as a percentage, when rasterMode:openAlways is applied.

Possible Values:0 - 100
Applicable scanner types: Laser Only
Default: Device specific
aimType:[Value] Describes the type of aiming to use. This is not supported on Android.
Possible values:
trigger: Standard trigger mode. Holding the trigger will start a decoding session. The decoding session ends when a barcode is decoded, scanTimeout occurs or the trigger is released.
timedHold: Aiming lasts for the time specified by 'timedAimDuration' before decoding. The decode will last until the barcode is decoded or scanTimeout occurs.
timedRelease: Aiming lasts until trigger is released. If the timedAimDuration has expired when the trigger is released then a decode session is started until a barcode is decoded or for the remaining time equal to the scanTimeout value.
presentation: Provided to support Kiosk devices. The scanner illuminates when movement is detected in the range of the scanner window. In order to use this mode the scanner must be initiated with a softscan using the scanner.start() method and again after each decode. The device must be equipped with a sensor to detect movement to use presentation mode. See examples below.
pressAndRelease: Scan will continue after the trigger is released until scanTimeout occurs.
continuousRead: Once the trigger is pulled barcodes will continue to be scanned whilst the trigger is held, enabling rapid scanning, to be used in conjunction with sameSymbolTimeout and differentSymbolTimeout. This value is ignored if viewfinderMode is set to 'dynamicReticle'
Applicable scanner types: Laser and Imager / Camera
Default: Device specific
timedAimDuration:[Value] Duration in milliseconds for aimType:timedHold and aimType:timedRelease

Possible Values:milliseconds
Applicable scanner types: Laser and Imager / Camera
Default: Device specific
sameSymbolTimeout:[Value] When the aimType:continuousRead property is applied this value defines the interval between which the same barcode can be decoded twice. The value is specified in milliseconds, use 0 to indicate no interval between successive reads. Use this value to prevent accidental duplicate scans.

Possible Values:milliseconds
Applicable scanner types: Laser and Imager / Camera
Default: 2500
differentSymbolTimeout:[Value] When the aimType:continuousRead property is applied this value defines the interval between which different barcodes can be scanned. The value is specified in milliseconds, use 0 to indicate no interval between successive reads. Use this setting to allow time for the operator to reaim the device between successive scans.

Possible Values:milliseconds
Applicable scanner types: Laser and Imager / Camera
Default: 500
aimMode:[Value] Describes the aiming mode to used.
Possible values:
none: No Aiming (Can be overridden by picklistMode).
dot: Laser barcode readers will show a dot for aiming.
slab: Laser barcode readers will show a slab for aiming.
reticle: Imager barcode readers will show a reticle for aiming
Applicable scanner types: Laser and Imager / Camera
Default: Device specific
picklistMode:[Value] Allows the imager to decode only the barcode that is directly under the cross-hair on Android and center of the reticle on WM/CE. This feature is most useful in applications where multiple barcodes may appear in the field of view during a decode session and only one of them is targeted for decode. When enabled picklistMode will override aimMode if no aiming is chosen and use aimMode:reticle. This mode will also interact with viewfinderMode, see the EMDK for C help file for more information. Enabling picklist mode may adversely affect overall decoding performance.
Possible values:
disabled: Disables picklist mode so any barcode within the field of view can be decoded.
hardwareReticle: (not available on Enterprise Tablet) Enables picklist mode so that only the barcode under the projected reticle can be decoded. If the imager does not support a projected reticle then the behaviour is the same as softwareReticle.
softwareReticle: Enables picklist mode so that only the barcode in the center of the image is decoded on WM/CE and under the cross-hair on Android. This is most useful when used in conjunction with static and dynamic reticle viewfinder modes.
Applicable scanner types: Imager / Camera Only
Default: Device specific
viewfinderMode:[Value] Configures the mode of the scanner viewfinder window. This attribute is not supported on all Scanners and will interact with the picklistMode parameter, see the EMDK for C help file for more information.
Possible values:
enabled: Only the viewfinder is enabled (not the reticle). Displays a viewfinder on the screen showing the image being captured by the camera.
disabled: (not available on Enterprise Tablet) The viewfinder will not be displayed during aiming or scanning.
staticReticle: Displays the viewfinder as well as draws a red reticle in the center of the image which helps with tracking the barcode.
dynamicReticle: (not available on Enterprise Tablet) Displays the viewfinder as well as draws a red reticle in the center of the image. If the barcode in the image is 'decodable' the reticle turns green to indicate this. This mode requires a second trigger press to decode the barcode after the reticle turns green.
Applicable scanner types: Camera Only
Default: Device specific
viewfinderX:[Value] When scanning a barcode using an imager scanner the viewfinder preview window will appear this number of pixels from the left hand side of the screen. The images displayed in the viewfinder will be scaled as appropriate.

Possible Values:pixels
Applicable scanner types: Camera Only
Default: Device specific
viewfinderY:[Value] When scanning a barcode using an imager scanner the viewfinder preview window will appear this number of pixels from the top of the screen. The images displayed in the viewfinder will be scaled as appropriate.

Possible Values:pixels
Applicable scanner types: Camera Only
Default: Device specific
viewfinderWidth:[Value] When scanning a barcode using an imager scanner the viewfinder preview window will be this number of pixels wide. The images displayed in the viewfinder will be scaled as appropriate.

Possible Values:pixels
Applicable scanner types: Camera Only
Default: Device specific
viewfinderHeight:[Value] When scanning a barcode using an imager scanner the viewfinder preview window will be this number of pixels high. The images displayed in the viewfinder will be scaled as appropriate.

Possible Values:pixels
Applicable scanner types: Camera Only
Default: Device specific
viewfinderFeedback:[Value] Configures the feedback given after a successful scan in milliseconds. This value is ignored if aimType is set to continuousRead and no feedback will be given.
Possible values:
disabled: No feedback is given after a successful decode.
enabled: The last image that was successfully decoded is displayed. The time for which the image is displayed can be configured by the viewfinderFeedbackTime parameter.
reticle: The last image that was successfully decoded is displayed along with a red reticle in the center of the image. The time for which the image is displayed can be configured by the viewfinderFeedbackTime parameter.
Applicable scanner types: Camera Only
Default: Device specific
viewfinderFeedbackTime:[Value] If the viewfinderFeedback:enabled or viewfinderFeedback:reticle are applied then the decoded barcode will remain on the screen for this duration.

Possible Values:milliseconds
Applicable scanner types: Camera Only
Default: Device specific
focusMode:[Value] Sets the focus mode in use.
Possible values:
fixed: Use fixed focus.
auto: Use auto focus.
Applicable scanner types: Imager / Camera Only
Default: Device specific
illuminationMode:[Value] Selects the illumination mode to use.
Possible values:
auto:(not available on Android) Auto-exposure algorithms will decide whether illumination is required or not.
alwaysOn: External illumination is always on.
alwaysOff: External illumination is always off. With illumination off, barcodes will be decoded only under bright light.
Note: On Android devices for Camera scanners this setting has to be enabled/disabled before starting the scanner.
Applicable scanner types: Imager / Camera Only
Default: Device specific
dpmMode:[Value] Allows Direct Part Marking (DPM) barcodes to be read when true but may adversely affect overall decoding performance. DPM is a way of stamping barcodes directly on physical objects and is only available on DPM terminals.

Possible Values:true / false
Applicable scanner types: Imager / Camera Only
Default: Device specific
inverse1dMode:[Value] Allows the user to select inverse 1D barcodes for decoding.
Possible values:
enabled: Inverse 1D symbology decoding is enabled.
disabled: Inverse 1D symbology decoding is disabled.
auto: Allows decoding of both positive and inverse 1D symbologies
Applicable scanner types: Imager / Camera Only and a scanning engine which supports Inverse barcodes.
Default: Device specific
poorQuality1dMode:[Value] Allows poor quality 1D barcodes to be read when true but this will adversely affect the overall decoding performance.

Possible Values:true / false
Applicable scanner types: Imager / Camera Only
Default: Device specific
beamWidth:[Value] Specifies the width of the laser beam.

Possible Values:normal / narrow / wide
Applicable scanner types: Laser Only
Default: Device specific
dbpMode:[Value] Describes the type of Digital Bar Pulse (DBP) being produced by the scan engine.
Possible values:
normal: Tells the engine to produce normal DBP.
composite: Tells the engine to produce composite DBP, which is 2 different sets of DBP data multiplexed together for better decode performance. In order to enable this mode it must be supported by the scanner.
Applicable scanner types: Laser Only
Default: Device specific
klasseEins:[Value] Enables or disables the Klasse Eins laser on time function.

Possible Values:true / false
Applicable scanner types: Laser Only
Default: Device specific
adaptiveScanning:[Value] Enables or disables adaptive scanning. When set to true, the scan engine will automatically toggle between 2 scan angles, wide and narrow, allowing the scan engine to decode barcodes both in close proximity and far away (~100 inches). Adaptive scanning is only supported in high performance, long working range scan engines such as SE960.

Possible Values:true / false
Applicable scanner types: Laser Only
Default: Device specific
bidirectionalRedundancy:[Value] Enables or disables bidirectional redundancy.

Possible Values:true / false
Applicable scanner types: Laser Only
Default: Device specific
barcodeDataFormat:[Value] Specifies the format in which the barcode data is returned, binary data is returned in Data URI format with the appropriate mime type. This parameter is designed to be used primarily with image based symbologies (eg. Signature). Binary data will not be output as keystrokes, you must set a decodeEvent in order to receive scanned data.

Possible Values:text / binary
Applicable scanner types: Imager Only
Default: Text
dataBufferSize:[Value] Specifies the number of bytes allocated to receive the scanned barcode. This parameter is designed to be used primarily with image based symbologies and should not be modified unless absolutely necessary (eg. Signature).

Possible Values:Number
Applicable scanner types: All
Default: 2500 bytes
connectionIdleTimeout:[Value] Specifies the time, in seconds, that an external scanner will be allowed to remain idle before the connection is terminated to conserve power.

Possible Values:seconds
Applicable scanner types: Bluetooth Only
Default: Device specific
disconnectBtOnDisable:[Value] Forces the scanner to disconnect from the terminal when it is 'disabled'. Since the scanner is disabled when you navigate to a new page, set this value to false if you want to maintain the bluetooth connection to your remote scanner.

Possible Values:true / false
Applicable scanner types: Bluetooth Only
Default: Device specific
displayBtAddressBarcodeOnEnable:[Value] If set to true the bluetooth address will be displayed as a barcode on the screen during the pairing process, initiated by calling 'enable' on a bluetooth scanner. Not all devices support this functionality. Note you must specify this parameter before calling 'enable'.

Possible Values:true / false
Applicable scanner types: Bluetooth Only
Default: Device specific
enableTimeout:[Value] Configures the time (in seconds) allowed to pair with the external bluetooth scanner after calling the 'enable()' method. You must specify this parameter before calling 'enable'.

Possible Values:seconds
Applicable scanner types: Bluetooth Only
Default: Device specific

Events

Values are returned to the caller in RhoElements via Events. Most modules contain events and those returned from this module are given below along with the event parameters. Events can cause a navigation to a new URL or a Javascript function on the page to be invoked. Each event will in most cases have a number of parameters associated with it which will either be strings or javascript arrays. Event parameters can be accessed either directly or via JSON objects.


decodeEvent

A decode event is sent by the Scanner whenever a barcode is decoded.

IDNameDescription
1dataThe data decoded by the scanner or imaging device
2sourceThe source device and human readable decoder type of the decoded barcode or symbol
3typeHex value representing the decoder type
4timeThe time at which the decode occurred (hh:mm:ss)
5lengthThe length of the decoded barcode or symbol
6eventThe type of event which has occurred at the scanner. This field will be either 'Decode' for barcode scanning or a message from a Bluetooth scanner. See Remarks


connectionListenerEvent

Supported on Android Lollipop only. If using an RS507/RS6000/RS4000 scanner, it is possible to register for connectionListenerEvent to receive the status of the connected or disconnected state of a particular scanner through this event.

IDNameDescription
1connectionStateThe message describing the connection state of particular scanner when connected or disconnected. Possible values are true or false.
2connectionTypeThe message describing the connection type of particular scanner when connected or disconnected.
3decoderTypeThe message describing the decoder type of particular scanner when connected or disconnected.
4deviceTypeThe message describing the device type of particular scanner when connected or disconnected.
5friendlyNameThe message describing the friendly name of particular scanner when connected or disconnected.
6isDefaultScannerThe message describing whether the particular scanner when connected or disconnected is a default scanner or not. Possible values are true or false.


bluetoothStatusEvent

A bluetoothStatusEvent is sent whenever a bluetooth connection / disconnection event occurs. If you are connected to a bluetooth scanner and have not registered to receive this event the status message will be sent as the sixth return value of the decodeEvent.

IDNameDescription
1statusThe message describing the bluetooth connection, see remarks.


enumScannerEvent

The Enum Scanner Event is used to ascertain the scanners present on the device.

IDNameDescription
1scannerArray (deviceName, friendlyName)2 dimensional array of scanners present on the device. See remarks.

Multi Instance

When multiple RhoElememts applications are running the following considerations should be made: Only the foreground RhoElements application is given access to the device scanner, when an application is sent to the background its state will be saved and it will automatically relinquish control of the Scanner. When brought back to the foreground, an application previously using the scanner will have its previous configuration (eg. selected decoders) reapplied to the scanner automatically.

Remarks

General

If the Scanner Meta Tag is used without DecodeEvent, the data will be output as keystrokes. On unlicensed devices it is not recommended to enable the Scanner on the application's startup page, this can interfere with the license screen.

Omnii XT15

On the Zebra Omnii XT15 device running Windows Mobile/CE, the decode success and failure sounds are not audible unless the decode sound is configured manually in the Config.xml file. To configure this setting, see the <ScanDecodeWav> parameter in the Config.xml Reference Guide.

Limitation of Scanner and Barcode APIs

The RE 2.x Scanner API and the EB 1.x Barcode API should not be used simultaneously in any Enterprise Browser application; only one or the other should be used.

Use Meta Tags Instead of Scanner Object

Prefer Meta Tags instead of Scanner Object, if an application is designed to perform continuos scanning on reload of the page with certain properties(exposed by scanner object).

Scanning and Image Capture Interaction

In some device configurations the scanner and imager share the same hardware, e.g. the blockbuster scanner and top mounted imager on the MC75a. Where two modules share the same physical hardware they cannot be enabled simultaneously, once the scanner is enabled it must be disabled before the imager can be used, and vice versa.

AutoEnter and AutoTab

AutoEnter and AutoTab are mutually exclusive, only one can be enabled at any one time. If both are enabled then AutoEnter will take priority.

Bluetooth Scanner Overview

Once associated with the Device a Bluetooth Scanner will remain associated even after losing the BT connection. In order to associate a different Bluetooth scanner with the device it is necessary to scan the 'unpairing' barcode and then invoke the 'disabled' meta tag followed by the 'enabled' meta tag, this will allow you to scan the BT association barcode with a different scanner. You can override this default behaviour using the disconnectBtOnDisable parameter.


The following messages will be received from the Bluetooth Scanner in the bluetoothStatus event:

* 'BTScanAssociationBarcode' 
   Means the device is ready to be associated with a BT scanner.  You must scan the 
   association barcode.  It is only necessary to scan the association 
   barcode when you first associate a scanner with the device, this pairing will be remembered until
   you scan the unpairing barcode.

* 'BluetoothConnected'
   The remote scanner has successfully connected to the device.

* 'BluetoothDisconnected'
   The remote scanner has become disconnected from the device, this may be due to loss of battery, being out
   of range or scanning the 'unpairing' barcode.  The scanner will attempt to reconnect automatically for
   a period of time once it regains power or goes out of range, if it fails to reconnect after the specified
   timeout the reconnect button on the device should be pushed.  Once the unpairing barcode is scanned
   it is necessary to disable the scanner and then re-enable it before another scanner can be associated.

Bluetooth Scanner Support On Android Devices

Enterprise Browser does not support Bluetooth scanners on the Zebra TC70 GA1 device.

Enterprise Browser supports Bluetooth scanners on devices running Android KitKat and higher.

ScannerArray attribute

The ScannerArray attribute returned from Scanner tag with parameter "EnumScannerEvent" will enumerate each scanner present on the device in a 2D array, associating each scanner's device name with a user friendly name. The device ID can be passed as a parameter to "Scanner" "Enabled:<deviceID>", the friendly name is a user readable description of the scanner, e.g:


"SCN1", "1D Scanner Driver"
"SCN2", "Camera"
"SCN3", "Bluetooth SSI Scanner Driver"

Viewfinder Position Parameters

The scanner viewfinder window is not infinitely resizable, when setting ViewFinderX, ViewFinderY, ViewFinderWidth and ViewFinderHeight ensure you do not exceed the size of the screen and it is recommended to use the same aspect ratio as your device. For applications designed to handle screen rotation it is recommended to use a scan window whose longest side will fit within both the screen width and screen height. If your viewfinder position fails to be applied it is recommended you query your log file to see which parameter is causing trouble, or reposition the window away from the edges of the screen.

DataWedge Interaction With Native Apps

In order to use the scanner with RhoElements Native Apps you will need to either disable DataWedge or create a DataWedge profile for your app.

DISABLING DATAWEDGE
1.  Start the DataWedge app
2.  Click the menu button > "Settings" and untick "DataWedge enabled". 
RHOELEMENTS DATAWEDGE PROFILE
1.  Install your RhoElements native app,
2.  Start the DataWedge app
3.  Click the menu button > "New Profile" and enter a name,
4.  Click on the link to the new profile in the profile list,
5.  Click on "Associated apps" in the "Applications" section,
6.  Click the menu button > "New app/activity",
7.  Select the package name for your app,
8.  Select "*",
9.  Click the "Back" capacitive button,
10. Make sure the "Profile enabled" checkbox is ticked.
11. Uncheck all three "Enabled" checkboxes under the sections of:
  "Barcode input", "Keystroke output" and "Intent output".

Devices lacking support

Due to platform limitations this API is not available on the following Zebra Technologies devices on specific platform. Note: However one can enable legacy scanner service and can scan the respective barcode.

  • VH10 CE 6.0

Requirements

RhoElements Version1.0.0 or above
Supported DevicesAll supported devices that have a scanner component. Android only supports the following parameters: enabled, [Decoder Name], autoEnter, autoTab, illuminationMode, linearSecurityLevel, picklistMode, scanTimeout, viewfinderMode, inverse1d. Note that not all parameters will be supported by all scanner engines, e.g. Inverse1D barcodes are not supported on the MK4000.
Minimum RequirementsNone.
PersistenceTransient - The scanner is disabled when navigating to a new page or refreshing the current page. Disabling and Re-enabling the scanner may reset some parameters back to their device default. The Zebra utility CtlPanel, available as a separate download, can be used to configure the default state of the scanner. For Scanner to work with VC70, it should be connected as SSI mode.

HTML/JavaScript Examples

The following example enables the scanner, turns on autoenter and performs a soft trigger start:


<META HTTP-Equiv="scanner" Content="Enable">
<META HTTP-Equiv="scanner" Content="AutoEnter:Enabled">
<META HTTP-Equiv="scanner" Content="Start">

The following example sets up the scanner on a page to submit the scanned data to an asp page upon successful decoding:


<META HTTP-Equiv="scanner" Content="enabled">
<META HTTP-Equiv="scanner" Content="DecodeEvent:url('mypage.asp?Data=%s&Source=%s&Type=%s&Time=%s&Length=%s')">

The following example demonstrates to how to set the connectionListenerEvent from an HTML page (Supported on Android Lollipop only):

 
  <html>
  <head>
  <script type="text/javascript" src="../elements.js"></script> 
  <script>
    function doConnectionListener(object)
    {
      //connectionState, connectionType, decoderType, deviceType, friendlyName, isDefaultScanner
      document.getElementById('myJsID').innerHTML = '<B><BR>1.Scanner-isScannerConnected:' + object.connectionState + '<BR>' +
                              '2.Scanner-ConnectionType:' + object.connectionType + '<BR>' +
                              '3.Scanner-DecoderType:' + object.decoderType + '<BR>' +
                              '4.Scanner-DeviceType:' + object.deviceType + '<BR>' +
                              '5.Scanner-FriendlyName:' + object.friendlyName + '<BR>' +
                              '6.Scanner-isDefaultScanner:' + object.isDefaultScanner + '</B>';
    }
    function addConnectionListenerEvent()
    {
      scanner.connectionListenerEvent = 'doConnectionListener(%json)';
    }
    function removeConnectionListenerEvent()
    {
      scanner.connectionListenerEvent = "";
    }
    function enumerateScanners()
    { 
      scanner.enumScannerEvent = "EnumScanners(%s);";
      scanner.enumerate();    
    }
    function EnumScanners(scannerArray)
    {
      var scannerInfo = "Scanners On Device: " + scannerArray.length + "<BR>ID  --  Name<BR>" 
      var scannerButtons = "";
      for (i=0; i < scannerArray.length; i++)
      {
        scannerInfo = scannerInfo + scannerArray[i][0] + ' -- ' + scannerArray[i][1] + '<BR>';
        scannerButtons += '<br><br> <input type="button" onclick="enableSpecifiedScanner(' + '\'' + scannerArray[i][0] + '\'' + ')" value="Enable' + scannerArray[i][0] + '" />';
      }
      availableScanners.innerHTML = scannerInfo;
      document.getElementById('setEnableButtons').innerHTML = scannerButtons;
    }
    function enableSpecifiedScanner(theScanner)
    {
      msg.innerHTML = "Enabling Specified Scanner: " + theScanner;
      scanner.enabled = theScanner;
    }  
    function disableScanner()
    {
      msg.innerHTML = "Disabling Scanner";
      scanner.disable();
    }
  </script>
  </head> 
  <body>
    <br><br> <div id="availableScanners">EnumScanners goes Here</div>
    <br><br> <div id=myJsID></div>
    <br><br> <div id="msg">Messages Go Here</div>
    <br><br> <input type='button' onClick="addConnectionListenerEvent()" value="Add Connection Listener Event"/>
    <br><br> <input type='button' onClick="removeConnectionListenerEvent()" value="Remove Connection Listener Event"/>
    <br><br> <input type="button" onclick="enumerateScanners()" value="Enumerate Scanners">
    <br><br> <div id="setEnableButtons"></div>
    <br><br> <input type="button" onclick="disableScanner()" value="Disable Scanner" />
  </body>
  </html> 

The following example sets up the scanner on a page to call a JavaScript function upon successful decoding:


<META HTTP-Equiv="scanner" Content="enable">
<META HTTP-Equiv="scanner" Content="DecodeEvent:url('javascript:doScan(%json);')">

<script>
   function doScan(jsonObject)
   {
      if(jsonObject.type == 0x35) //ean 13
      {
         alert('Please scan a non EAN 13 code!');
      }
      else
      {
         alert('You scanned: ' + jsonObject.data);
      }
   }
</script>

The following example demonstrates how to set a device into presentation mode.


<HTML>
<HEAD>
  <Meta http-equiv="scanner" content="aimType:presentation">
  <Meta http-equiv="scanner" content="DecodeEvent:url('Javascript:doScan('%s');')">
  <Meta http-equiv="scanner" content="enable">
</HEAD>
<BODY onLoad="doSoftScan();">
  <SCRIPT LANGUAGE="JavaScript">

    function doSoftScan()
    {
      scanner.start();
    }

    function doScan(jsonObject)
    {
      bcode.innerHTML = jsonObject.data;
      doSoftScan();
  }
  </SCRIPT>
  <div id="bcode"></div>
</BODY>
</HTML>

The following example shows how an application might handle a Bluetooth Scanner whose ID is SCN2:


<HTML>
<HEAD>
<!-- Status Updates are received via bluetoothStatusEvent -->
<META HTTP-Equiv="Scanner" Content="BluetoothStatusEvent:url('Javascript:BTStatusFunc(%json);')">
<META HTTP-Equiv="Scanner" Content="DecodeEvent:url('Javascript:ScanFunc(%json);')">
<!-- Enable the Bluetooth Scanner, this will commence the BT pairing -->
<META HTTP-Equiv="Scanner" Content="Enabled:SCN2">
</HEAD>

Barcode Data: <DIV ID="bcode"> </DIV>
User Message: <DIV ID="message"> </DIV>
<P><INPUT TYPE="button" VALUE="Change Associated Scanner" ONCLICK="onChangeScanner();"></P>
</BODY>
</HTML>


:::javascript
<SCRIPT LANGUAGE="JavaScript">

//  Whether or not the next barcode data we receive will be the unpairing barcode
var expectingUnpairingBarcode = false;

function ScanFunc(jsonObject)
{
  //  Output the scanned barcode
  bcode.innerHTML = data;
}

function BTStatusFunc(jsonObject)
{
  if (expectingUnpairingBarcode)
  {
    //  restart the scanner component so it is ready
    //  to accept a different Bluetooth Scanner
    expectingUnpairingBarcode = false;
    scanner.disable();
    scanner.enabled = 'SCN2';
    return;
  }

  if (jsonObject.status == 'BTScanAssociationBarcode')
  {
    //  Instruct the User to scan the association barcode
    alert('Scan Association Barcode');
  }
  else if(jsonObject.status == 'BluetoothConnected')
  {
    message.innerHTML = "Bluetooth Scanner Connected";
  }
  else if(jsonObject.status == 'BluetoothDisconnected')
  {
    message.innerHTML = "Bluetooth Disconnected, Please Reconnect";
  }
}

function onChangeScanner()
{
  //  Change the BT Scanner associated with the device, the logic to do this is handled
  //  once the 'unpairing' barcode is scanned.
  message.innerHTML = "Please Scan Unpairing Barcode";
  expectingUnpairingBarcode = true;
}
</SCRIPT>

The following example displays the available scanners on screen and enables a Bluetooth Scanner:


<HTML>
<HEAD>
<META HTTP-Equiv="Scanner" Content="DecodeEvent:url('Javascript:ScanFunc(%json);')">
<META HTTP-Equiv="Scanner" Content="BluetoothStatusEvent:url('Javascript:BTFunc(%json);')">
<META HTTP-Equiv="Scanner" Content="EnumScannerEvent:url('Javascript:EnumScanners(%json);')">
</HEAD>

<BODY onLoad="setEnumScannerTimer();">
<DIV ID="message"></DIV>
</BODY>
</HTML>

<SCRIPT LANGUAGE="JavaScript">
function ScanFunc(jsonObject) {message.innerHTML = jsonObject.data;}

function BTFunc(jsonObject) {message.innerHTML = jsonObject.status;}

function EnumScanners(jsonObject)
{
  var scannerInfo = "Scanners On Device: " + jsonObject.scannerArray.length + "<BR>ID  --  Name<BR>" 
  for (i=0; i < jsonObject.scannerArray.length; i++)
  {
    scannerInfo = scannerInfo + jsonObject.scannerArray[i].deviceName + ' -- '
    + jsonObject.scannerArray[i].friendlyName + '<BR>';
    //  See if this is the Bluetooth Scanner
    if (jsonObject.scannerArray[i].friendlyName.indexOf("Bluetooth") >= 0)
    {
      //  This is the Bluetooth Scanner, Enable it
      scanner.enabled = jsonObject.scannerArray[i].deviceName;
    }
  }
  message.innerHTML = scannerInfo;
}

//  Wait for the DOM to fully load before we enumerate the scanners
function setEnumScannerTimer()
{
    setTimeout("onScannerEnable()", 3000);
}
function onScannerEnable()
{
  scanner.enumerate();
}
</SCRIPT>