Scan and Pair using the EMDK

Version 2

    The Solution Center was recently asked to help a partner develop a scan and pair utility application.  The specific use case was for a retail establishment with a mix of Zebra Bluetooth enabled printers and Symbol mobile computers running either Windows CE or Windows Mobile.  The idea was to allow sales associates to print to any printer from any mobile computer, and to be able to do so without going through a time consuming pairing process.  The EMDK team was thoughtful enough to supply a C# API that makes the development of such a utility trivial.  Documentation for the API can be found in the help file included with the .NET EMDK, please see the Programmer's Guide->PowerTools->ScanAndPair section for details.  The source code solution for the utility developed is attached to this article.

     

    The utility had two basic design goals, make it simple to use, and make it configurable.  The approach to making to simple was achieved by limiting the number of actions required to pair, and limiting the number of possible outcomes.  The steps required to pair a printer are launch the utility and then scan a barcode.  If pairing succeeds, the utility exits, if pairing fails a dialog is presented informing the user that pairing failed, when the dialog is closed the utility also exits.  The main window of the application is designed to be full screen and has one button to cancel the operation, exiting the utility.  The barcodes that are scanned contain either a Bluetooth friendly name or a hexadecimal address of the target printer.  It is recommended that a hexadecimal address is used, the pairing process is quite fast as discovery is not required.  Configuration is achieved using the registry to obtain the values that can be set when using the API, setting values in the registry is optional, if no registry settings exist the default values in the API are used.  the values in the registry correspond directly to the fields in the ScanAndPairTool class that can be changed, and additionally a PIN can be stored if required.  The layout of the registry is given below with a brief explanation of each item.

     

     

    [HKEY_LOCAL_MACHINE\SOFTWARE\Zebra\ScanAndPair]

    "UnpairNotifyType"=dword:00000001

    "NotifyType"=dword:00000001

    "ScanTimeout"=dword:00000000

    "LocalComPort"=dword:0000005

    "ScannerType"=dword:00000000

    "TriggerType"=dword:00000000

    "ScannedDataType"=dword:00000000

    "Pin"=""

     

     

    Valid values are given below, invalid values result in default values being used, with the exception of "LocalComPort" the values provided above are the defaults.

     

    UnpairNotifyType 0 = no beeps, 1 = beeps

    NotifyType 0 = no beeps, 1 = beeps

    ScanTimeout , 0-5000.

    LocalComPort, 0-9   If no value is speciifed, the default behavior is to use the first available com port.

    ScannerType  0 = first available, 1 = laser, 2 = imager, 3 = camera

    TriggerType 0 = manual, 1 = auto

    ScanneDataType, 0 = unspecified, 1 = BTaddress, 2 = BTname

    Pin, string 0-15 characters in length , 0 length implies no pin.

     

    Please note that when the Stone Street Bluetooth stack is being used on the mobile device, the latest available version of the Stone Street files must be installed.  Installation packages of the latest Stone Street software can be obtained from the Zebra support web site.