Scanner Meta Tag

PocketBrowser 3.x API

The Scanner Meta Tag is an action tag that controls the functionality of the device scanner.

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


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

Name Description
Default Value
Enumerate Return a list of scanners present on the device via EnumScannerEvent. This tag will be actioned immediately and should be called via JavaScript. N/A
Enabled Enables the default scanner Device specific
Disabled Disables the scanner. This reverts the scanner to its default state and flushes any current decoder settings. Device specific
Start Performs a soft trigger start N/A
Stop Performs a soft trigger stop N/A
Copy methods template to clipboard: Copy META Tag template to clipboard META Tags Copy Javascript template to clipboard Javascript

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

Name Possible Values Description
Default Value
Enabled:[Value] ID of Scanner, obtained via EnumScanner Enables the specified scanner. SCN1 (or SCN2 if SCN1 not found on device)
[Decoder Name]:[Value] Refer "Decoders and Parameters Tag" Section to know available decoders and Their Parameters Sets each Decoder's parameters Refer "Decoders and Parameters Tag" Section
AutoEnter:[Value] Enabled / Disabled If "Enabled" then automatically append an Enter to the end of any barcodes scanned. This feature is only available when decodeevent is not specified and is useful for submitting forms. See Remarks. Disabled
AutoTab:[Value] Enabled / Disabled If "Enabled" then automatically appends a Bab to the end of any barcodes scanned. This feature is only available when decodeevent is not specified and is useful for advancing to the next input field. See Remarks. Disabled
RasterMode:[Value] None / Open_Always / Smart / Cyclone None: No vertical rastering. Open_Always: Vertical rastering is always full open. Smart: Vertical rastering mode is 'Smart'. Cyclone: Vertical rastering mode is 'Cyclone'. Device specific
AimType:[Value] Trigger / Timed_Hold / Timed_Release / Presentation Trigger: Standard trigger mode. Timed_Hold: Aiming lasts for a specified time before decoding. Timed_Release: Aiming lasts until trigger is released. Presentation: Only applicable to Kiosk devices, the scanner illuminates when movement is detected in the range of the scanner window. The scanner must be initiated with a softscan using the start method. Please see the example for usage Device specific
Copy parameters template to clipboard: Copy META Tag template to clipboard META Tags Copy Javascript template to clipboard Javascript

Modules return information back to their web pages via retrieval tags, for example the scanner has a retrieval tag called 'DecodeEvent' which is called whenever it decodes a barcode. To register to receive a retrieval tag call the module as follows:

<META HTTP-Equiv="[Module]" content="[RetrievalTag]:url('[URI]')">
So to register to retrieve the Scanner's DecodeEvent the following syntax would be used:
<META HTTP-Equiv="Scanner" content="DecodeEvent:url('Javascript:doScan('%6', '%s', %3, '%2');')">

Retrieval tags return information by replacing the text in place holders, defined as '%s' or '%<number>'. Each place holder represents 1 return value with '%s' being populated sequentially or '%<number>' providing direct acces to the desired value.

If the content for the Scanner's DecodeEvent is:

"url('Javascript:doScan('%6', '%s', %3, '%2');')"

The function would be called as follows:
"Javascript:doScan('Decode', '5449000053879', 0x35, 'SCN:EAN13');"


DecodeEvent
A decode event is sent by the Scanner whenever a barcode is decoded or a Bluetooth connection / disconnection event occurs.

ID Name Description
1 Data The data decoded by the scanner or imaging device
2 Source The source device and human readable decoder type of the decoded barcode or symbol
3 Type Hex value representing the decoder type
4 Time The time at which the decode occured (hh:mm:ss)
5 Length The length of the decoded barcode or symbol
6 Event The type of event which has occured at the scanner. This field will be either 'Decode' for barcode scanning or a message from a Bluetooth scanner. See Remarks
Copy this return value template to clipboard: Copy META Tag template to clipboard META Tags Copy Javascript template to clipboard Javascript


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

ID Name Description
1 ScannerArray 2 dimensional array of scanners present on the device.
Copy this return value template to clipboard: Copy META Tag template to clipboard META Tags Copy Javascript template to clipboard Javascript



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

<META HTTP-Equiv="scanner" Content="Enabled">
<META HTTP-Equiv="scanner" Content="AutoEnter:Enabled">
<META HTTP-Equiv="scanner" Content="Start">
Copy example to clipboard Copy example to clipboard

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')">
Copy example to clipboard Copy example to clipboard

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

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

<script>
function doScan(data, source, type, time, length)
{
if(type == 0x35) //ean 13
{
alert('Please scan a non EAN 13 code!');
}
else
{
var amount = prompt('Enter an amount for code: ' + data', '');
}
}
</script>
Copy example to clipboard Copy example to clipboard

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="enabled">
</HEAD>
<BODY onLoad="doSoftScan();">
<SCRIPT LANGAUGE="JavaScript">
var Generic = new ActiveXObject("PocketBrowser.Generic");

function doSoftScan()
{
Generic.InvokeMetaFunction('scanner', 'start');
}

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

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

<HTML>
<HEAD>
<!-- Status Updates are received via Scanner-Navigate along with Barcode Data -->
<META HTTP-Equiv="Scanner" Content="DecodeEvent:url('Javascript:ScanFunc('%s', '%s', '%s', '%s', '%s', '%s');')">
<!-- 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>
<SCRIPT LANGUAGE="JavaScript">
//  Keep track of whether we have minimised PB for the user to scan the association barcode
var scanningAssociationBarcode = false;
//  Whether or not the next barcode data we receive will be the unpairing barcode
var expectingUnpairingBarcode = false;
function ScanFunc(data, source, type, time, length, theEvent)
{
var Generic = new ActiveXObject("PocketBrowser.Generic");
if (expectingUnpairingBarcode)
{
//  After we scan the Unpairing barcode ScanFunc will be called, 
//  restart the scanner component so it is ready
//  to accept a different Bluetooth Scanner
expectingUnpairingBarcode = false;
Generic.InvokeMETAFunction('Scanner', 'Disabled');
Generic.InvokeMETAFunction('Scanner', 'Enabled:SCN2');
return;
}
if (theEvent == 'BTScanAssociationBarcode')
{
scanningAssociationBarcode = true;
//  Minimise PocketBrowser and Show the Association barcode for the user to scan
Generic.InvokeMETAFunction('Application', 'minimize');
Generic.LaunchProcessNonBlocking('\\application\\BT_Information.exe', 'ShowBarcodeOnly');
}
else if(theEvent == 'BluetoothConnected')
{
//  Check to see if we are scanning the association barcode, if we are then return user control to PocketBrowser
if (scanningAssociationBarcode)
{
//  The Association barcode is currently shown
scanningAssociationBarcode = false;
Generic.InvokeMETAFunction('Application', 'restore');
}
message.innerHTML = "Bluetooth Scanner Connected";
}
else if(theEvent == 'BluetoothDisconnected')
{
message.innerHTML = "Bluetooth Disconnected, Please Reconnect";
}
else if(theEvent == 'Decode')
{
//  Consider a normal Barcode Scan (to test the BT connection)
bcode.innerHTML = data;
}
}
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>
Copy example to clipboard Copy example to clipboard

The following example displays the available scanners on screen and enables the Bluetooth Scanner (if available)

<HTML>
<HEAD>
<META HTTP-Equiv="Scanner" Content="DecodeEvent:url('Javascript:ScanFunc('%s', '%s', '%s', '%s', '%s', '%s');')">
<META HTTP-Equiv="Scanner" Content="EnumScannerEvent:url('Javascript:EnumScanners(%s);')">
</HEAD>
<BODY BGCOLOR="#FFFFEA" TEXT="#0000A0" LINK="#FF0000" VLINK="#808080" ALINK="#008040" onLoad="setEnumScannerTimer();">
<DIV ID="message"></DIV>
</BODY>
</HTML>
<SCRIPT LANGUAGE="JavaScript">
function ScanFunc(data, source, type, time, length, theEvent)
{
message.innerHTML = data + ' (' + theEvent + ')';
}
function EnumScanners(scannerArray)
{
var scannerInfo = "Scanners On Device: " + scannerArray.length + "<BR>ID  --  Name<BR>" 
for (i=0; i < scannerArray.length; i++)
{
scannerInfo = scannerInfo + scannerArray[i][0] + ' -- ' + scannerArray[i][1] + '<BR>';
//  See if this is the Bluetooth Scanner
if (scannerArray[i][1].indexOf("Bluetooth") >= 0)
{
//  This is the Bluetooth Scanner, Enable it
var Generic = new ActiveXObject("PocketBrowser.Generic");
Generic.InvokeMETAFunction('Scanner', 'Enabled:' + scannerArray[i][0]);
}
}
message.innerHTML = scannerInfo;
}
//  We can not call Scanner:Enumerate during page load on WM so give the page 3 seconds to finish loading
function setEnumScannerTimer()
{
setTimeout("onScannerEnable()", 3000);
}
function onScannerEnable()
{
var Generic = new ActiveXObject("PocketBrowser.Generic");
Generic.InvokeMETAFunction('Scanner', 'Enumerate');
}
</SCRIPT>
Copy example to clipboard Copy example to clipboard
General
If the Scanner Meta Tag is used without DecodeEvent, the data will be output as keystrokes. Presentation trigger causes the scanner to illuminate when movement is detected in the range of the scanner window. The scanner must be initiated with a softscan using the scanner start parameter. Please see the example for usage. Note: Not all devices support presentation mode. 0 On unlicensed devices it is not recommended to enable the Scanner on the application's startup page, this can interfere with the license screen. The device's camera based scanner can not be used at the same time as the Imager. Once the Imager is 'Enabled' the camera based scanner will be unavailable until the Imager is 'Disabled'.

Enabling/Disabling Scanner
The properties which was set before enabling the scanner will be lost if the scanner is disabled and re-enabled. For Example: If all decoder is disabled before enabling the scanner then after enabling the scanner if we disable and re-enable the scanner, the previous set property will be lost.

Enabling/Disabling Decoders
Before enabling/disabling decoders, it is recommended to first disable the scanner and then enable/disable the decoders and then enable the scanner. Note: If the decoder is disabled after enabling the scanner, it will not reflect the respective change at the first time during scanning. This is because of the enabled scanner which is actually waiting for the scan event to fire for scanning the barcode.

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. Also note that the default value for AccelerateKey is 'Norm', meaning by default the Enter key is disabled; for more information on AccelerateKey see the Key Capture Overview and Key Capture help file entry.

AutoEnter and AccelerateKey
The AccelerateKey Meta tag controls the behaviour of Accelerate keys on Windows CE, if the Enter key is configured to be non functional then AutoEnter will also appear to not function either

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.
The following messages will be received from the Bluetooth Scanner:
* 'BTScanAssociationBarcode' 
Means the device is ready to be associated with a BT scanner.  You must scan the 
association barcode within a specified timeout (configured via the registry, see the EMDK help file).  
Either run 'Display_BD_Address.exe' to present the user with the barcode to scan or prompt them to scan 
a barcode physically stuck somewhere on the device.  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.(NOTE: Donot specify link to new page in decodeevent before connecting to BT
Scanner, Since BTScanAssocistionBarcode is passed in decodeevent url.)

* 'BluetoothConnected'
The remote scanner has successfully connected to the device.  If you have launched 'Display_BD_Address.exe' 
then return control to full user control to PocketBrowser at this stage.

* '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.
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"
Use with Imager
Scanner Tag can not be used along with Image Capture Tags in the same page due to Hardware Limitations


Supported Platforms Windows CE, Windows Mobile, Windows Mobile SE
Persistence This tag is page specific, though once you enable a scanner you must disable it before enabling another scanner on the same device.
Min. Requirements Scanner module.