Motorola Cordova Plugin

platforms: android
$ cordova plugin add com.bluefletch.motorola

Cordova Motorola DataWedge Plugin

This is a Cordova/Phonegap plugin to interact with Motorola ruggedized devices' Barcode Scanners and Magnetic Stripe Readers (eg, ET1, MC40, TC55). The plugin works by interacting with the "DataWedge" application configured to output scan and magstripe events.

This plugin is compatible with plugman. To install, run the following from your project command line: $ cordova plugin add

Configure DataWedge:

You have two options to interact with the current version of the DataWedge:

  1. Broadcast an intent from the Default (0) profile. This can be a custom action of your choosing. NOTE: Category must be empty.
  2. Create a custom profile associated to your app, and send a "startActivity" intent. This must use the default plugin action: "com.bluefletch.motorola.datawedge.ACTION" and EMPTY category.

The DataWedge User Guide is located here:

Intent configuration:

Special configuration for option 2:

  1. You'll need to first create a Profile in your DataWedge Application to run startActivity for an intent on scan/magstripe events as applicable. NOTE: you MUST set the action to: "com.bluefletch.motorola.datawedge.ACTION" and category to EMPTY/BLANK
  2. Associate your app to the DataWedge profile so it loads with your app. Configure this under (Your profile) > Associated apps > New app/activity (menu button) > (Select your app)
  3. Lastly, you need to set your application to be "singleTop" in Cordova. This will make sure each scan doesn't launch a new instance of your app. Add the following to your config.xml: <preference name="AndroidLaunchMode" value="singleTop" />

To Use:

1) First, you need to "activate" the plugin and OPTIONALLY tell it what intent to listen for. Default is "com.bluefletch.motorola.datawedge.ACTION"

   document.addEventListener("deviceready", function(){ 
      if (window.datawedge) {
         datawedge.start(); //uses default

2) Register for callbacks for barcode scanning and/or magnetic stripe reads:

   document.addEventListener("deviceready", function(){ 
           var labelType = data.type,
               barcode   = data.barcode;

           console.log("Barcode scanned.  Label type is: " + labelType + ", " + barcode);

           //TODO: handle barcode/label type
       //This function will be passed an array with the read values for each track.  
       //NOTE: If a track could not be read, it will contain null
           var track1, track2;
           console.log("read magstripe value : " + JSON.stringify(tracks));

           //read track 1
           if (tracks[0]) {
              //track 1 uses carets as dividers
              track1 = tracks[0].split('^');

              var cc = {
                 number : track1[0].substr(2), //strip leading %B
                 name : track1[1].trim(),
                 expr : '20' + track1[2].substr(0,2) + '-' + track1[2].substr(2,2)

              //TODO: handle track 1
           else if (tracks[1]) {
              track2 = tracks[1];

              //TODO: handle track 2
           else {
              //ERROR: track 3 almost never has anything in it


More API options:

Data Wedge
  • Switch Profile: if you need to change DataWedge Profiles (ie, to disable the scanner buttons or to apply rules to data, etc), call datawedge.switchProfile('DisabledScannerButton')
  • You can wire a soft button to the barcode scanner by calling datawedge.startScanner()
  • Turn off the scanner manually using: datawedge.stopScanner()
  • Unregister for barcode scans by calling: datawedge.unregisterBarcode()
  • Unregister for barcode scans by calling: datawedge.unregisterMagstripe()

Copyright 2014 BlueFletch Mobile

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.