Cognex Browser

Configuring the Cognex Browser

Cognex Browser has a variety of settings allowing you to configure it to perform the best for your website.

General Settings

  • Scanner - Cognex Browser support reading with your phone's built-in camera and with Cognex readers that have Bluetooth Direct Connect feature.
    • Built-in camera: You need to get a feature key by creating an LPR on this page.
    • Bluetooth: You need to have a Bluetooth Direct Connect featured Cognex reader (e.g. DM8700 series)
  • Home URL - The URL address that opens when the browser launches or when Home button is pressed.
  • Restrict navigation to bookmarks - User cannot navigate away from the bookmarked URLs, sub-pages can still be accessed. Make sure to use this feature with mobile device management tool (e.g. SOTI).

Configuration Settings

You can define several different Configurations in Cognex Browser and assign these configurations when you bookmark a webpage. This way Cognex Browser works differently depending on which site you are. Of course it is possible to keep only one Configuration (Default one) and assign this to all bookmarked sites.

Browser Settings

  • Enable navigation buttons - Controls the access of back and forward buttons.
  • Enable address bar - Controls the access of address bar.
  • Hide toolbar when scrolling down a page - Hides the toolbar to use the screen more efficiently.
  • Soft scan button - User can have a button on the screen that can trigger the Cognex reader.
  • Show keyboard for input - Show the default soft-keyboard when tapping on an input field within a web page.
  • Fixed zoom - Zoom settings (manual, range and default zoom level) that applies of the page when it is opened. The first focused field on your page is considered when zooming. If this settings is changed Cognex Browser requests a reload on actual page to apply its effect (this operation may result loss of data on the current page).

Navigation

Settings within this group are disabled if "Keyboard wedge mode" is turned on.

  • Define input types - Select which input types will be focused on the web page for inserting a read result.
  • Initially focused input field - Configure which input field will be initially focused when web page is loaded.
    • first input field on the website
    • last input field on the website
    • or custom 
      • either to select the field from a list about available field on the defined web page
      • or configure the focus by name or DOM attribute
  • Move focus after read - Configure how the focus changes after reading a bar code successfully.
    • move to the next input field
    • move to the previous input field
    • or don't change the focus
  • Allow focus on touch or from JS - Allows to move the focus when an input field is tapped by the user (users can select different field to focus than it is), move the cursor via JavaScript or pressing TAB on a keyboard. If the selected input field's type is selected in "Define input types", then the read result will be inserted there.
  • Automatically submit forms - It is possible to submit a form when all the users are ready with a form. There are two possible ways to achieve this:
    • Last scan was performed on the last input field and "Move focus after read" is set to "Next input field"
    • Last scan was performed on the first input field and "Move focus after read" is set to "Previous input field"
  • Confirm auto-submit forms - If this setting is enabled, a dialog is shown to the user to get a confirmation before submitting the form.

Advanced

  • Keyboard wedge mode - Cognex Browser emulates keyboard when a barcode is entered into an input field. If it is tuned on, all other navigation settings are ignored and also disabled.
  • HTML inserts - Definition of HTML code that will be added to HEAD or BODY section of the page. If this settings is changed Cognex Browser requests a reload on actual page to apply its effect (this operation may result loss of data on the current page).
  • Send event on read result received - After scanning with a Cognex device, the browser will send an event to the web page instead of filling the configured input field. The event can be handled on the website with having an event-listener that will listen to the "readResultReceived" event.
    • Fill out focused input field with read result - Read result is also inserted into input field after the "readResultReceived" event is triggered. It means that the web page may implement additional logic with the read result additionally to input it into the field.
  • Send event if connection status changed - The browser sends an event to the web page when a Cognex device is connected or disconnected. The event can be handled on the website with having an event-listener that will listen to the "connectionStateChanged" event.

 

Input fields navigation

Cognex Browser allows you to configure how you want to navigate through the input fields of your web sites. If you enable keyboard wedge mode these settings are ignored.

Defining input types

You can define which type of input fields may be focused on when the browser is processing successful read result. This configuration can be done in "Define input types" from the "Navigation" group. Supported types are(bold ones are set by default): hidden, emailnumberpasswordsearchteltexttextareaurl.

Scanner focus

There are many settings for fine-tuning how focus changes after a successful read. When you first open the web page  the scanner focus is on the first input field that is enabled in the "Define input types" setting by default. That means this input field will be the first to receive a scan result when scanning a bar code with a Cognex reader. If there are no such input fields on the page or all input types are disabled, the scanned bar code will be copied on your devices clipboard.

It is always possible to read a code into address bar of Cognex Browser.

The initially focused field can be changed by going in the Cognex Browser settings and selecting "Initially focused input field": 

  1. First input field - The first input field on the web page that's type is enabled in the "Define input types" setting will be the first to focus initially.
  2. Last input field - The last input field on the web page that's type is enabled in the "Define input types" setting will be the first to focus initially.
  3. Custom input field - Provide additional ways for configuring the initially focused input field.
  • Web page URL - You will be given a choice to pick an input field from any web page (only the types enabled in "Define input types" will be shown), and that is the first to focus initially.
  • Define focused input field - You can configure which input field will be the first to focus initially by configuring the input name or defining a DOM attribute name and value for that input.

It is also possible to define where the focus should move after a successful read was performed in "Move focus after read" settings:

  1. Next input field - The scanner will focus on the next available input field after a successful read.
  2. Previous input field - The scanner will focus on the previous input field after a successful read.
  3. Do not move focus - The focus will not change, which means that the scanner will extend the text in the same input field, unless the focus change happens manually (with "Allow focus on touch or from JS" enabled and tapping on another input field or if another input field is focused using JavaScript).

When tapping on an input field on the web page, if that input fields type is enabled in the "Define input types" setting, by default the scanner focus will move to that input field. This can be changed in the Cognex Browser settings by changing the "Allow focus on touch or from JS" switch. When this setting is disabled, the scanner focus changes will happen only as it is defined by the "Initially focused input" and "Move focus after read" settings. Keep in mind, if this setting is enabled and you select an input field that's type is disabled in the "Define input types" setting, the scanner focus will not go into that input field even though a cursor will appear there. This allows you to type something into that input field, but you cannot scan a bar code, and have the result inserted since that type is disabled.

Automatically submit HTML forms

Cognex Browser can automatically submit an HTML form. To enable this feature you have to change the "Automatically submit forms" switch. When this setting is enabled, the form will be automatically submitted in two cases:

  1. After scanning a bar code in the last input field on the web page, with the "Move focus after read" setting set to "Next input field".
  2. After scanning a bar code in the first input field on the web page, with the "Move focus after read" setting set to "Previous input field".

To prevent accidental form submissions, right below the "Automatically submit forms" setting you will find the "Confirm auto-submit forms" setting. If this is enabled, then a confirmation is displayed every time before automatically submitting the form.

 

Integration with Cognex Hardware

It is possible to interact with a Cognex reader from Cognex Browser using JavaScript on you webpage. There are two events that caught from JavaScript code: "readResultReceived" and "connectionStateChanged".

readResultReceived

The "readResultReceived" event is triggered when the Cognex reader is triggered and "Send event on read result received" is enabled. The read result that is sent to that event has the following format:

{
    "readResults" :     [
                {
            "goodRead" : 1,
            "readString" : "2112345678900",
            "symbology" : 4,
            "symbologyString" : "UPC-EAN",
            "xml" : "...",
        }
    ],
    "subReadResults" :     [
    ],
    "xml" : "...",
}

The main readResult object contains three key-value pairs:

  1. readResults (Array): An array of read result objects that were scanned. If multicode is not enabled on the device, then only one result is in this array. If multicode is configured, then this array contains the main result and all the sub read results.
  2. subReadResults (Array): An array of read result objects excluding the main result. For single code scanning, this array will be empty.
  3. xml (String): The raw XML string received by the reader.

To listen for "readResultReceived" event on your website, add the JavaScript event listener like in the example below:

document.addEventListener('readResultReceived', function(barcode_result){
    alert(JSON.stringify(barcode_result.detail));
});

connectionStateChanged

The "connectionStateChanged" event is triggered when the Cognex device changes its connection state and "Send event if connection status changed" is enabled. The attached object has a number representing the new connection state:

0 - Disconnected, the readerDevice is not connected to any remote system.
1 - Connecting, the readerDevice is in the process of establishing a connection to a remote system.
2 - Connected, the readerDevice is connected to a remote system.
3 - Disconnecting, the readerDevice is in the process of disconnecting from a remote system.
4 - Unknown, the readerDevices connection state is unavailable.

To listen for "connectionStateChanged" event on your website, add the following JavaScript event listener:

document.addEventListener('connectionStateChanged', function(connection_state){
    alert(JSON.stringify(connection_state.detail));
});

Other possibilities to control MX mobile terminal

The Cognex Browser allows communication from the web site to the Cognex reader. An object named as "cmbSDK" is available from Javascript after the web page has been loaded. By using this object it is possible to:

  • start scanning without having to push trigger on Cognex reader
  • stop scanning
  • trigger userEvent1 and userEvent2 (configurable events on Cognex readers)

All you have to do is add the following functions to your web site and call them whenever you need (using timer, on button press, etc.).

function startScanning() {
   cmbSDK.triggerStartScan();
}
function stopScanning() {
   cmbSDK.triggerStopScan();
}
function triggerUserEvent1() {
  cmbSDK.triggerUserEvent1();
}     
function triggerUserEvent2() {
  cmbSDK.triggerUserEvent2();
}

 

Mass configuration - MDM

Cognex Browser provides possibility to push configuration via MDM and prevent that the end user may change settings.

  1. Create a configuration that serves your needs in the best way. We would suggest to involve end users in testing if it is really the best solution.
  2. If you are satisfied with the result, then create a configuration file with "Export settings and bookmarks" (available from action menu on the list of Settings screen) . Get the file from the device in your preferred way (e-mail, download...)
  3. Push this file from your EMM/MDM software to all device you want to configure and make sure that it is located in "Internal Storage/Android/data/com.cognex.browser/".
  4. It is done. All settings will be effective from the next start of Cognex Browser.

Important to know that in this case you are not able to modify any setting on the configured device (so does your end users).

  1. Create a configuration that serves your needs in the best way. We would suggest to involve end users in testing if it is really the best solution.
  2. If you are satisfied with the result, then create a configuration file with "Export settings and bookmarks" (available from action menu on the list of Settings screen) . Get the file from the device in your preferred way (e-mail, download...)
  3. Upload your file to a host that is accessible by your managed phones. 
  4. Set the App configuration for Cognex Browser to the following:
<dict>
  <key>configurationURL</key>
  <string>https://myserver.com/firmwares/firmware_file_name</string>
</dict>
  1. It is done. All settings will be effective from the next start of Cognex Browser.

Important to know that in this case you are not able to modify any setting on the configured device (so does your end users).