Microvision SDK for Windows Mobile®
Developer Articles
The SDK for Windows Mobile allows developers to quickly and easily integrate bar code scanning into a Windows Mobile application. The SDK package includes the C Application Programming Interface (API), documentation, and sample projects that demonstrate how to create a scanner interface. All sample applications were developed and built using Visual Studio 2005. The SDK files include:
BcsSdkWM |
|
ReadMeFirst.pdf |
This document |
\BcsSdk |
|
Bcs.h |
The header file to include when creating an SDK interface |
BcsMsgs.h |
The header file that contains the messages used in the SDK |
\WM5\ Bcs.dll / .lib \WM6\ Bcs.dll / .lib \PPC2003\ Bcs.dll / .lib |
The DLL and library files for the SDK API for Windows Mobile 5, Windows Mobile 6 (WM6) and Pocket PC 2003. The .lib files are used to statically link the API functions into your application. |
\Docs |
Documentation directory |
DC0121181 EULA.txt |
SDK End User License Agreement |
DA0120591 Microvision Scanner Programming Guide.pdf |
Detailed Scanner Programming and Interface Guide that includes scanner commands, communications protocols, and interface best practices |
\Samples |
|
\BcsBarCode.CS-NET.CF-2.0 |
Demo project that shows how to create a C#.NET scanner interface |
*.* |
The actual SDK demo project files |
\BcsBarCode.VB-NET.CF-2.0 |
Demo project that shows how to create a VB.NET scanner interface |
*.* |
The actual SDK demo project files |
\Wtf\BcsBarCode.Cpp |
Demo project that shows how to create a C++ scanner interface |
*.* |
The actual SDK demo project files |
The Microvision SDK for Windows Mobile includes a C API that provides a very fine level of scanner control. The SDK package includes demo projects in C++, C#.NET Compact, and VB.NET Compact. Each project includes fully documented source code with Intellisense comments. Review the interface guidelines in this document and then proceed to examine one of the demo projects.
The C API gives you the option of using a DLL or statically linking the API library into your application. For the .NET languages (C#, VB.NET) the SDK provides a .NET component which allows your .NET application to access the C functions in the API.
The Scanner Interface
The Microvision SDK for Windows Mobile allows you to easily create an interface between your host computer and the ROV Scanner. This section explains the integration process. The scanner interface requires each of these steps described below. Please refer to the appropriate demo project for more details.
Enumerating Scanners
The first step in the communication process is creating a connection by discovering and/or enumerating the scanners. The SDK can enumerate new scanners and show details about scanners that are already paired. Normally you use “0000” as the PIN when pairing Bluetooth scanners.
Call BcsEnumConnections to discover and enumerate scanners. Press and release the scan button to put the scanner into Discoverable mode (the LED should double-blink repeatedly). BcsEnumConnections takes a callback function as an argument. This callback is invoked with each connection. Typical applications use the callback function to create a list of scanners and the user selects the specific scanner to connect to.
Connecting to the Scanner
After enumerating the scanners you must connect to a specific scanner. Normally, you display a list of scanners from the previous step and select the scanner from this list.
Call BcsOpenConnection to open a connection to a specific scanner. BcsOpenConnection takes an Event Handler callback function as an argument. This Event Handler Callback handles the scanner-related system events (continue reading for details on events).
Events and Event Handling
As part of the communication, the SDK generates a number of events in response to scanner data that was sent or received. These events allow the application to monitor, and act upon, the behavior of the connected scanner. The SDK can generate these events:
eEventFlicBanner |
Banner received from the scanner |
|
eEventDataReceived |
Data received from the scanner |
|
eEventBarCodeDataReceived |
Bar code data received from scanner |
|
eEventCommandPacket |
Packet that will be sent to the scanner |
|
eEventResponsePacket |
Packet received from scanner |
|
eEventBluetoothAttemptingToConnect |
Trying to connect to a Bluetooth device |
|
eEventBluetoothConnectionLost |
Connection with Bluetooth device lost |
|
eEventBluetoothDeviceConnected |
Bluetooth connection established |
With these event notifications your application can display scanned data, display a live status showing that your Bluetooth scanner is in or out of range, and so on. You can also ignore the events that do not concern your application. For example, if your application does not need to know if a Bluetooth scanner is connected or out of range then simply ignore the Bluetooth connection events.
The Event Handler Callback function passed in the BcsOpenConnection call can respond to the desired events. The actions taken by the Event Handler Callback will vary depending on your requirements and your scanner configuration. The SDK samples demonstrate how to use the Event Handler Callback.
Reading Bar Codes
When the API detects scanner data it generates an eEventDataReceived event. Your application should then post a system notification to alert the application to process the bar codes. We normally create a custom notification called SW_GETBARCODES that is typically defined as WM_APP + 0x100. Your application event loop then calls a bar code reading function after it detects the SW_GETBARCODES notification. This function calls BcsGetBarCodes to send a download request to the scanner. One of the parameters to BcsGetBarCodes is a callback function that is called for each bar code downloaded. If the host receives a batch of bar codes then the callback function is called for each bar code. Your application handles the bar codes one at a time through the callback function.
Scanner Configuration
The Microvision Scanner Programming Guide contains the complete list of scanner properties and their descriptions. It also contains a list of commands to get and set the scanner properties. The developer can get and/or set properties of a connected scanner in two ways:
- The BcsCommand SDK function sends a command to the scanner. Use BcsCommand to get and set scanner properties, send a download request, clear scanner data, etc.
- The BcsGetProp /BcsSetProp SDK functions get and set a specific scanner property. These require the property name to set or get. The Set functions also require the value of the property to set (see the Programming Guide for details).
Disconnect Scanner
Calls BcsCloseConnection to terminate the scanner connection.
The bcsBarCode Demo Projects
The SDK includes projects that demonstrate how to create a scanner interface application. These projects include full source code and are provided for C++ , Visual Basic.NET Compact (VB.NET Compact), and C#.NET Compact.
You may use any of these demo projects as an example or you may cut and paste source code directly into your project.
Additional Resources
Microvision SDK for Windows Mobile product page |
||
DC0119391 |
XSP – eXtensible Scanner Protocol Specification |
