Socket, the Socket logo, Battery Friendly, Socket Bluetooth Cordless Hand Scanner, and SocketScan are trademarks or
registered trademarks of Socket Mobile, Inc. Bluetooth and the Bluetooth logos are registered trademarks owned by Bluetooth
SIG, Inc., U.S.A. and licensed to Socket Mobile, Inc. All other brand and product names are trademarks of their respective
holders.
The Socket Bluetooth Cordless Hand Scanner includes technology licensed under United States Patent Numbers 5,902,991,
7,429,000 B1 and D526,320 S.
Reproduction of the contents of this manual without the permission of Socket Mobile is expressly prohibited. Please be aware
that the products described in this manual may change without notice. Feel free to contact Socket Mobile at:
Other than the above, Socket Mobile can assume no responsibility for anything resulting from the application of information
contained in this manual.
Please refrain from any applications of the Socket Bluetooth Cordless Hand Scanner that are not described in this manual.
Please refrain from disassembling the Bluetooth Cordless Hand Scanner. Disassembly of this device will void the product
warranty.
You can track new product releases, software updates and technical bulletins by visiting the Socket Mobile website at:
http://www.socketmobile.com.
Socket Mobile, Inc.
39700 Eureka Drive, Newark, CA 94560-4808, USA
+1-510-933-3000
USA/Canada Toll-free: 1-800-552-3300
This SDK is designed for use with the Socket CHS 7 series scanners on several
OS platforms including Apple iOS, Android, RIM, Windows Desktop and
Windows Mobile 6.x. The intended usage is to develop a native application that
includes built in support for the Socket 7 series scanners. This SDK gives the full
programmatic access to a connected 7 series scanner to customize the scanner
Symbology and data support, manages scanner feedback messages and
functions or modifies default scanner behavior.
Before beginning the process of implementing the ScanAPI into an application it
is first recommended reading through this intro regarding the connection process
of the scanner as this might answer many questions in regards to how an
application communicates with the scanner.
1.1 Scanner connection information
The connection information below applies mainly to the Android, RIM and
Windows operating systems.
For the iOS platform the connection is simplified based on the host iOS handling
the connection. It is recommended to refer to the readme.rtf file from the ScanAPI
SDK DMG install that is part of the ScanAPI iOS SDK..
1.1.1 Scanner HID mode
The CHS 7 series scanners are shipped by default in HID profile mode and will
display the following friendly name:
For the 7Xi series:
Socket 7Xi [xxxxxx] (where x’s are the last 6 digits of the BD address of the
scanner)
Or for the 7Ci/M/P series:
Socket CHS [xxxxxx]
In this mode the scanner functions as a standard HID keyboard device and can
be tested in this mode as if it is a keyboard.
It will NOT work with an application using ScanAPI.
NOTE: if the scanner in HID mode is discovered and tested it may cause conflicts
with discovering and using the scanner in SPP mode due to the fact that some
devices will cache the name and service information of the device.
Socket recommends that the pairing information is removed by deleting or
unpairing the device using the host device Bluetooth manager before connecting
the scanner in a different mode.
1.1.2 SPP Mode for the SDK
The SPP Mode is the required mode for the Scanner to be able to communicate
with an application using ScanAPI.
The SPP Mode has 2 configurations. One configuration called Acceptor, and
another called Initiator.
In Acceptor configuration, the scanner is discoverable and connectable and
basically waits for a host to connect. The scanner indicates that it is in this mode
by a slow blue LED flashing.
In Initiator configuration, the scanner knows the Bluetooth address of the host to
connect to.
Each time the scanner is powered on in this configuration, it will try to connect to
the host corresponding to the Bluetooth address it has in memory.
The scanner indicates that it is in this mode by a fast blue LED flashing. The
scanner stays in this mode until it successfully connects to the host or after a
2minutes timeout occurs, which it will signal by doing a long beep.
At this point the scanner can be powered off and on to retry to connect to the
host.
1.1.3 Initial connection to iOS host or to any host for a 7Ci,M and P
series
The process of connecting a scanner to an iOS host device or a 7Ci, M and P
scanner to any host device is the same and can be summarized to these simple
steps.
Step 1: The scanner must be in Acceptor mode.
For an iOS device, the scanner can be in configured in Acceptor mode by
scanning a barcode that has the value of “#FNC IOS ACCEPTOR
000000000000#” for a 7Xi or “#FNB00F40002#” for a 7Ci.
For any other host Device (not iOS) the scanner can be configured in Acceptor
mode by scanning a barcode that has the value of “#FNB00F40000#” for a 7 P,M or Ci series, or “#FNC SPP ACCEPTOR 0000000000#” for a 7Xi series scanner.
The barcode can be a 2D barcode for a 7Xi scanner only.
Step 2: Discover and pair the scanner from the host.
By using the Bluetooth settings of your host device, discover and pair the
scanner. If a PIN code is request use “0000” (4 zeros) and the pairing should
complete.
For iOS host device this is the final step. The scanner can now be used by the
application using ScanAPI.
Step 3: (For all hosts but iOS devices) Instruct the scanner to connect back to the
host by using Socket EZ Pair application.
Once the scanner is configured correctly, it will always try to reconnect back to
the host each time it is powered on or back in range.
1.1.4 Simplified connection process to any host but iOS devices
There is a simplified process that can be used when the host Bluetooth device
address is known either by printing out barcode or by using 7xi with Socket
EzPair.
This process isn’t possible for iOS device as there is no API to retrieve the iOS
Bluetooth address and the iOS devices won’t authorize a scanner to connect
and pair unless the Bluetooth Settings page is displayed on the screen.
The following steps for 7Xi series is as simple as scanning a 2D barcode that has
the value: “#FNC SPP INITIATOR xxxxxxxxxxxx#” with xxxxxxxxxxxx replaced by
the host Bluetooth address, or by scanning out of the Socket EZ Pair screen the
2D barcode.
The same principle for 7 P, M and Ci series scanner, by scanning a Code 128
barcode that has the value: “#FNIxxxxxxxxxxxx#” with xxxxxxxxxxxx replaced by
the host Bluetooth address. NOTE the 7 P, M and Ci series scanner shoud be
first and only once set to SPP mode by scanning the “#FNB00F40000#” Code
128 barcode.
1.1.5 Connection Process integration
For the 7P, M and Ci series scanners there are two methods that canbe used to
configure the scanner to be an initiator to the host device:
Implement the 1D EZ Pair process in your app to select a pre discovered scanner
and configure it to be an initiator to the host device. This process is explained in
paragraph 8.6 Socket EZ Pair feature.
Method 2:
-Manually create an EZ Pair barcode with each host system Bluetooth address
so that the 1D scanner simply needs to scan the barcode to configure it as an
initiator to the host device
For the 7Xi series scanners you can just present the EZ pair barcode as part of
your application setup process.
Either way once that part is done your app just needs to have ScanAPI initialized
and waiting to receive the incoming connection of the scanner.
2 ScanAPI Introduction
ScanAPI delivers an application programming interface (API) to control and
configure Socket Bluetooth Cordless Handled Scanners (CHS) connected to a host
computer.
A ScanApi Helper component is provided for Objective C, C# and Java platforms to
integrate more easily ScanAPI into an application. ScanAPI Helper handles the
asynchronous events through callbacks, and gives an easy way to manipulate the
asynchronous commands an application can send to a CHS by providing a callback
mechanism that is invoked when the command response is received.
A CHS has severall properties that can be retrieved, modified or actioned.
CHS properties can be by example a symbology state, its friendly name, or triggering
a scan.
This API is asynchronous. The property operation is therefore a 2-step process. The
application sends a property get or set command and if this is successful, a property
get or set complete event is received with the CHS result of that property command.
At any time a CHS can send events to the host that are retrieved using the same
mechanism as the completion of the property operation.
ScanAPI has only one entry point to receive these asynchronous events making it
very easy to manage.
The other benefit of this asynchronous API is to be able to drive a scanner from a
graphical user interface (GUI) application without danger of blocking the user
interface while waiting for a lengthy operation to complete.
The SoftScan is a feature that makes the host device built-in camera acting as a
barcode scanner. This feature is implemented using third-party technology and
therefore the developer should comply to the third-party license agreement.
Currently the SoftScan feature is available on for iOS and Android based devices.
This feature is not activated by default. In order to activate it, the application should
set the ScanAPI kSktScanPropIdSoftScanStatus to kSktScanEnableSoftScan. As soon
as ScanAPI is initialized and SoftScan is enabled, a SoftScanner device arrival event
is generated.
A device removal event is generated when the SoftScan feature is disabled by using
the same ScanAPI property with its value sets to kSktScanDisableSoftScan.
The SoftScanner doesn’t support all the properties described in this document and
returns a ESKT_NOTSUPPORTED error for them.
3.1 Licensing requirements
The third-party used for implementing the SoftScan feature is RedLaser from eBay
corporation. The RedLaser requires a license to be purchased in order to offer
unlimited scan. Without the license the SoftScanner is limited to 25 scans on a
particular host.
The License should be purchase on RedLaser portal, and the license file should be
part of the application package.
3.2 iOS requirements
The ScanAPI library for iOS is split in to 2 versions; one that supports the SoftScan
feature and one that doesn’t.
In the version that doesn’t support the SoftScan feature the required frameworks
are:
- externalAccessory.framework
- audioToolbox.framework
In the version that does support the SoftScan feature the extra frameworks required
are:
- libstdc++.dylib or libstd++6.0.9.dylib if you’re using OS6.x SDK.
3.3 Android requirements
The overlay view is a requirement for the SoftScanner in order to display the video
output in the application. This is implemented through an Activity that must be
added to the application manifest. This activity is defined as
com.SocketMobile.ScanAPI.SoftScanActivity.
The manifest should also have the following permissions:
- android.permission.CAMERA,
- android.permission.ACCESS_NETWORK_STATE
- android.permission.INTERNET
A specific layout should be created that will be displayed as the overlay view of the
SoftScan. This layout can have a white rectangle that is called a “View Finder” that is
used as a scanning guide but also is use by the softscan scanner to improve the
barcode recognition in this region. The “View Finder” ID can be passed in the hash
table of the kSktScanPropIdOverlayViewDevice property. A flash button can be
added as well and its ID should be also specified in the same hash table of the same
property. If the flash feature is not available the SoftScan scanner will disable it
automatically.
The RedLaser libraries must be added to the Android application. The simplest way
for doing this is to copy the redlasersdk.jar and the armeabi/libredlaser.so in the
“libs” directory of the Android application. That “libs” subdirectory is automatically
taking in consideration by Android Development tools (ADT 18 or higher).
4 Concept
This API defines 3 main objects: ScanAPI object, Device object and ScanObject.
4.1 ScanAPI object
This object controls the API.
In order to use ScanAPI, this object must be opened first and this first open
initializes ScanAPI. The handle returned from this open must be used for any
subsequent ScanAPI operations.
All asynchronous events are received through this ScanAPI object.
The ScanAPI object has few properties that can be retrieved or modified.
When an application is ready to use ScanAPI, it can open it by using the ScanAPI
Open API with no device name in the parameter.
4.2 Device object
The Device object represents a CHS. In order to use and receive events from a CHS,
its corresponding Device object must be opened.
The handle returned from opening a Device object is used by the application to
retrieve or modify a particular property of the CHS.
ScanAPI notifies the application each time a Device Object is available by sending a
Device Arrival event with a UUID identifying the Device Object. The application can
open this particular Device Object by specifying this UUID in the ScanAPI open API.
If a CHS disconnects from the host, a Device Removal is sent by ScanAPI to the
application to indicate that the matching Device Object is no longer valid and the
application should close it if it has it opened.
4.3 ScanObject
The ScanObject is a data placeholder used for exchanging information between the
application and the CHS or ScanAPI object.
A ScanObject holds 2 kinds of information: a property and a message.
When a ScanObject is sent from the application to ScanAPI, only the property
information in ScanObject is relevant.
When a ScanObject is received from ScanAPI by the application, the message
information is always relevant and depending on the message received the property
information might be relevant.
ScanAPI creates a ScanObject each time it receives an asynchronous event, and in
this case the application must release this ScanObject by calling a ScanAPI release
API.
The application can create a ScanObject to send specific information to either a
Device or ScanAPI. In this case the application is responsible for releasing the
ScanObject correctly.
An application has two things to do in order to setup ScanAPI correctly. It needs first
to open ScanAPI by specifying no name in the open parameter API, and then starts
either a timer or a thread to consume the asynchronous events coming from
ScanAPI.
When a CHS connects to the host, ScanAPI sends a Device Arrival event to the
application through the application ScanAPI consumer logic.
The Device Arrival event contains an UUID identifying a Device Object that
represents a CHS. The application can open the Device Object by specifying this
UUID in the ScanAPI open function.
Once the Device Object is opened, the application can retrieve or modify the CHS
properties by using the get property or set property API.
The get property and set property APIs are asynchronous. These APIs return
success if the property has been sent correctly to the CHS. The property completion
event is received in the application consumer.
If the CHS doesn't respond to a get or set property within the timeout period (about
5 seconds), for whatever reason, a matching property get or set complete event is
generated with a timeout error.
Only one property can be sent at the time to the CHS. An error occurs if a property is
sent prior the completion of the previous property operation.
ScanAPI sends a Device Removal event when a CHS disconnects from the host. The
application should close the matching Device Object if it has it opened.
4.5 ScanAPI configuration
ScanAPI has one thread listening on a serial communication port. This configuration
can be retrieved or modified by creating a ScanObject and setting its property to
ScanAPI configuration property. The ScanObject can be sent to ScanAPI using the get
property or set property API to respectively retrieve or modify this property.
Modifying the ScanAPI configuration will prompt the listener thread to restart. An
error event is generated if the configuration is incorrect.
Each time the listener starts, a Listener Start event is generated.
ScanAPI drops the connection to a CHS if it was connected during the process of
changing the ScanAPI configuration.
Please refer to the ScanAPI object properties paragraph for more information.
4.6 Get or Set a property
The ScanAPI object and the Device object have both properties that can be retrieved
or altered by using the get property or set property API.
The process of getting or setting a property is simple. A ScanObject holds a Property
field. The application must create a ScanObject instance and fill its Property member
according to the property of the object it would like to modify.
A property has an ID, a data type,data value and a context. They must be specified
accordingly to the characteristics of the property that needs to be retrieved or
modified.
The context is a field an application can use for maintaining a context. This context is
returned when a property set or get operation completes.
Once the property member of the ScanObject has been filled correctly, the
application can call the get or set API with the reference of the object to which it
wishes to retrieve or modify the property.
If the API returns success, the application can wait for the completion to be received
through the wait API.
An application cannot send multiple properties to the same object before the
previous set or get property operation has been fully completed. An error is
generated during the Set or Get API call if the previous property of the same object
hasn’t been completed yet.
The application receives the complete event through its ScanAPI consumer logic that
uses the wait API with the ScanAPI object reference.
A ScanObject that is received from ScanAPI has always its message field filled out.
The property complete event is received in a ScanObject with a Message ID set to a
Get Complete ID or Set Complete ID.
The Message has a result field that indicates if the completion of the get or set
property has been successful or not. The Property member of the ScanObject
contains the Property ID matching to the one that has been set, and in case of
success, the data type and value are filled as expected.
An important point is the fact that a property set or get can fail for many reasons,
and some of them will require the application to retry the operation and some
should just be taken into consideration. For example, if a property returns a
REQUEST TIMEOUT error because the scanner is out of the range for a brief instant
or busy receiving decoded data, having retry logic can fix this issue.
4.7 Example of sending a command
This section describes the steps for sending a command to a device.
Let’s imagine an application using ScanAPI has a button on its UI to trigger a scan.
For clarity purposes we assume the application correctly handles the connection of
the scanner and has kept a handle to ScanAPI and to this scanner accessible.
The application has ScanAPI consumer logic that will receive the messages from
ScanAPI.
This consumer logic uses the wait API with the ScanAPI object reference that has
been previously opened with the open API with NULL as device name.
The button handler creates a ScanObject, and fills the Property part with a property
ID set to kSktScanPropIdTriggerDevice, a property type set to byte, and the property
byte value set to kSktScanTriggerStart as explained in the paragraph 14.5 Property kSktScanPropIdTriggerDevice.
This button handler uses the set API to send this property to the device identified by
its reference. If the return code of this API is successful, the button handler can then
disable the trigger button indicating the trigger is in progress.
The application’s ScanAPI consumer logic that was waiting for ScanAPI messages by
using the wait API should receive the Set Complete message with the property ID set
to kSktScanPropIdTriggerDevice.
The result indicates if the trigger worked. At that point the device should have the
aim light turned on and should be ready to scan and decode data. The application
trigger button can then be enabled.
// initialize a ScanObject to // trigger the device ScanObj.Property.ID=kSktScanPropIdTriggerDevice;
ScanObj.Property.Type=kSktScanPropTypeByte;
ScanObj.Property.Byte=kSktScanTriggerStart;
// set the property with the // device handle Result=SktScanSet(m_hDevice,&ScanObj);
// check the Set result if(SKTSUCCESS(Result))
m_TriggerBtn.Enable(FALSE);
else {
// display an error message DisplayError(_T("Unable to trigger: %d"),Result);
}
}
SKTRESULT CMyAppDlg::Consume(
IN SKTHANDLE hScanAPI,
IN unsignedlong ulTimeoutInMilliseconds,
OUT BOOL* pbContinue)
{
SKTRESULT Result;
TSktScanObject* pSktObject=NULL;
Result=SktScanWait(hScanAPI,&pSktObject,ulTimeoutInMilliseconds);
if(SKTSUCCESS(Result))
{
if(Result!=ESKT_WAITTIMEOUT)
{
if(pSktObject)
{
switch(pSktObject->Msg.MsgID)
{
case kSktScanMsgIdDeviceArrival:
Result=HandleDeviceArrival(pSktObject);
break;
case kSktScanMsgIdDeviceRemoval:
Result=HandleDeviceRemoval(pSktObject);
break;
case kSktScanMsgIdTerminate:
// we are done with ScanAPI, somebody // called SktSet with Abort MsgId if(pbContinue)
*pbContinue=FALSE;// quit the for TraceInfo(_T("Receive a Terminate Msg, \
then shutdown the App receiving \ thread"));
break;
case kSktScanMsgSetComplete:
case kSktScanMsgGetComplete: Result=
// set the property with the device // reference long result = _device.SetProperty(scanObj);
if (SktScanErrors.SKTSUCCESS(result))
{
buttonTrigger.Enabled = false;
}
else
{
// display an error message
DisplayError("Unable to trigger: " + result);
}
}
// timer to checking and consuming ScanObject from ScanAPI privatevoid timerScanAPIConsumer_Tick(object sender,
{
ISktScanObject scanObj=null;
// wait for ScanAPI ScanObject long result = _scanApi.WaitForScanObject(out scanObj, 10);
if (SktScanErrors.SKTSUCCESS(result))
{
if (result != SktScanErrors.ESKT_WAITTIMEOUT)
{
int propId = scanObj.Msg.ID;
switch (propId)
{
caseISktScanMsg.kSktScanMsgIdDeviceArrival:
result = HandleDeviceArrival(scanObj);
break;
caseISktScanMsg.kSktScanMsgIdDeviceRemoval:
result = HandleDeviceRemoval(scanObj);
break;
caseISktScanMsg.kSktScanMsgIdTerminate:
// we are done with ScanAPI, somebody
result = HandleTerminate(scanObj);
break;
caseISktScanMsg.kSktScanMsgGetComplete:
caseISktScanMsg.kSktScanMsgSetComplete:
result = HandleGetOrSetComplete(scanObj);
break;
caseISktScanMsg.kSktScanMsgEvent:
result = HandleEvent(scanObj);
break;
}
// release the ScanObject we received in the wait
_scanApi.ReleaseScanObject(scanObj);
}
}
}
privatelong HandleGetOrSetComplete(ISktScanObject scanObj)
{
long result = SktScanErrors.ESKT_NOERROR;
ISktScanProperty property = scanObj.Property;
switch (property.ID)
{
// set the property with the device// referencelong result=_device.SetProperty(scanObj);
// check the set resultif(SktScanErrors.SKTSUCCESS(result)){
_button.setVisualState(VISUAL_STATE_DISABLED);
}
else{
// display an error messageDisplayError("Unable to trigger: "+result);
}
}
switch(propId){
case ISktScanMsg.kSktScanMsgIdDeviceArrival:
result=
HandleDeviceArrival(scanObj[0]);
break;
case ISktScanMsg.kSktScanMsgIdDeviceRemoval:
result=
HandleDeviceRemoval(scanObj[0]);
break;
case ISktScanMsg.kSktScanMsgIdTerminate:
// we are done with ScanAPI, somebody// called Set with Abort as MsgIDresult=
HandleTerminate(scanObj[0]);
break;
case ISktScanMsg.kSktScanMsgSetComplete:
case ISktScanMsg.kSktScanMsgGetComplete:
result=
HandleGetOrSetComplete(scanObj[0]);
break;
case ISktScanMsg.kSktScanMsgEvent:
break;
}
// release the ScanObj we received in the wait_scanApi.ReleaseScanObject(scanObj[0]);
}
}
}
// called from the ScanAPI consumer logic// that is using the wait APIprivatelong HandleGetOrSetComplete(ISktScanObject scanObj) {
long result=SktScanErrors.ESKT_NOERROR;
ISktScanProperty property=scanObj.getProperty();
switch(property.getID()){
case ISktScanProperty.propId.
kSktScanPropIdTriggerDevice:
// ungray out the trigger btn_appRef.getTriggerBtn().
setVisualState(VISUAL_STATE_NORMAL);
4.8 Handling asynchronous events or completion events
The ScanAPI object maintains a queue to receive asynchronous events and property
operation complete events waitting for the application to consume them.
An application can retrieve these events by using the wait API.
This API returns a ScanObject that will need to get released once the application is
done with it by calling the release API.
The wait API returns immediately if there is an event in the queue, or it will wait the
specified input parameter time if the queue is empty.
Completion events or asynchronous events can arrive at any time and in any order.
The recommended way for handling these events is to create a switch statement on
the message ID received in the ScanObject.
There are only 6 possible message types: kSktScanMsgIdDeviceArrival,
kSktScanMsgIdDeviceRemoval, kSktScanMsgIdTerminate,
kSktScanMsgSetComplete, kSktScanMsgGetComplete and kSktScanMsgEvent.
For each of these message types a handler function can be called. Inside the handler
function, the Result member of the Message received should be checked to be sure
the process can continue.
The handler functions for the Set Property Complete or Get Property Complete
event can also have a switch statement on the property ID. If the application used
the context member of a property, the same context is then returned in the complete
property.
The decoded data or the CHS button’s press status is received in the handler
functions for the messages that have kSktScanMsgEvent as message ID.
4.9 Termination
When ScanAPI is no longer needed it can be terminated by setting an Abort property
to the ScanAPI object.
At that point, if there are any devices open, ScanAPI sends a Removal event for each
of the Device objects open, upon which the Device object should be closed by the
application using the close API.
Once all the Device objects have been closed, ScanAPI sends a Terminate event and
at that point it is safe to close ScanAPI.
5 ScanAPI Helper (available for Java, C# and Objective C)
ScanAPI Helper has been created to facilitate the integration of ScanAPI into an
application.
It is released as source code and therefore can be highly customizable for the need
of your application. Some basic and common features are provided as sample on
how to use ScanAPI.
NOTE: ScanAPI Helper is available for Java, C# and Objective C base code.
ScanAPI Helper maintains a list of commands to send to ScanAPI. Since properties
cannot be sent before the completion of the previous one, it offers an easy way to
queue the commands and provides a callback for each command completion.
A command in this context is either a “Set Property” or a “Get Property”.
By example, if an application wants to retrieve the friendly name and the version of
the connected device, it uses ScanAPIHelper to do a “PostGetFriendlyName” and a
“PostGetDeviceVersion” in a row, and for each of these functions, a callback is
passed, so when the Get Friendly Name completes, the callback is called and the
application can refresh the UI with the new friendly name, and it follows the same
logic when Get Device Version completes.
It retries sending the command up to 3 times if the command completion failed in
time out error.
The Java version of ScanAPI Helper creates a timer task to consume asynchronous
ScanObject coming from ScanAPI.
The C# and Objective C version of ScanAPI Helper does not create a timer, but
instead provides a method, DoScanAPIReceive, that has to be called from a timer
function or a thread.
The following paragraph describes the steps required for using ScanAPI Helper.
5.1 Handling the ScanAPI Helper notifications
Since most of the ScanAPI operations are asynchronous, it is very important to setup
a way for handling notifications. ScanAPI Helper provides a
ScanAPIHelperNotification interface or a ScanApiHelperDelegate protocol for
Objective C environment that must be implemented in order to handle the various
notifications correctly.
Here is how Scanner Settings for Android is using this interface:
ScanAPI Helper must be instructed to use your notification handler object and this
can be accomplished by calling the setNotification method (or setDelegate in
Objective C) with the reference to the notification interface implementation.
This is important to use this function prior calling the open function to be sure to
trap all the notifications.
5.3 Open ScanAPI Helper
Once the ScanAPI Helper object has been instantiate by using the new function, it
can then be open using the open() method. The open() method doesn’t return
anything but instead the onScanApiInitializeComplete notification will be called
once the ScanAPI initialization process has been completed. A result code indicates
how successful the initialization was.
Example:
_scanApiHelper.open();
5.4 Close ScanAPI Helper
Once the application is done with ScanAPI, it can close it by calling the close method
of the ScanAPIHelper object as shown below:
_scanApiHelper.close();
The close method doesn’t return any value, but the notification
onScanApiTerminated will be called when ScanAPI has effectively shutdown.
5.5 Scanner arrival
When a scanner connects to the host, ScanAPI Helper notifies the application using
the onDeviceArrival notification and specifies a result code, and in case of success it
also specifies the device information (friendly name, device type). ScanAPI Helper
keeps the device information object into its devices list. The application can retrieve
this list at any time. In our Scanner Settings SDK sample application for Android
platform, this notification asks the activity to refresh with the new scanner
information or in case of an error, it displays an error message as described below:
/**
* a device is connecting, update the UI accordingly */
Each time a scanner decodes correctly a barcode, ScanAPI Helper calls the
onDecodedData notification with the device information object and the decoded
data. In the Scanner Settings for Android case the activity that has registered for the
NOTIFY_DATA_ARRIVAL intent will receive and display the decoded data. This
activity is the ScanWindowActivity.
Here is the code extract from Android Scanner Settings for this notification:
/**
* ScanAPI is delivering some decoded data * as the activity to display them */
When a scanner disconnects from the host, the ScanAPI Helper notifies the
application by calling the notification onDeviceRemoval. Usually the application
updates its UI to reflect that change. The Scanner Settings for Android sends an
Intent to the Activity that has registered for it, as shown in the following lines:
/**
* a device has disconnected. Update the UI accordingly */
At any point of time, the application can interrogate ScanApi Helper to know if there
is at least one device connected by using the following method:
_scanApiHelper.isDeviceConnected();
This might be useful to know what application menu should be displayed by
example, which could change in function of the connection status.
5.9 Get the list of scanners
The list of connected scanner reference can be retrieved by using the getDevicesList
method.
5.10 No Device Connected item
In some occasion the application might want to display a specific text when no
device is connected. The ScanAPI Helper method setNoDeviceText() allows the
application to specify a text that will be used to display the only item of the devices
list when no scanner is connected.
6 IDE Integration
6.1 C/C++ Version
ScanAPI has been compiled with Microsoft Visual Studio 2008. The inclusion of
ScanAPI in this environment in your C/C++ project can be done in 2 ways; by adding
the following lines in your source file directly:
#include “<SDK Install Path>\include\ScanAPI.h”
#pragma comment(“lib”,”<SDK Install Path>\\lib\ScanAPI.lib”
Or by adding only the include line in your source file and by adding the lib file in
your Project Link input settings.
6.2 Java Version
ScanAPI has been compiled using Eclipse Galileo (version 3.5).
ScanAPI is composed of two JAR files located under the lib directory of the SDK Java
portion.
Following are the steps required in order to include ScanAPI into your project and
workspace.
6.2.1 Setting up the Eclipse workspace
From Eclipse select the menu Window / Preferences.
For a BlackBerry target, select from the left tree control the path Java\Build
Path\User Libraries
Choose the “Import…” button and browse to where ScanAPI_SDK is installed to
select the ScanAPI_SDK.user libraries file. Check the ScanAPIBlackBerry option and
click OK.
For an Android target, select on the left tree control the path Java\Build
Path\Classpath Variables. Click on the “New…” button and type in the Name field:”
ScanAPI_Libs” and click the Folder… button to browse to where your ScanAPI_SDK
is installed to select the Lib folder underneath it. Click OK to validate your choice,
and Click OK again to add the New Variable Entry in your workspace.
6.2.2 Setting up the application project for using ScanAPI
For a BlackBerry target, go to your Java application project properties; select Java
Build Path in the tree on the left panel of your application properties dialog. On the
right panel, select the Libraries tab and click on the “Add Library…” button. In the
Add Library dialog window select “User Library” and click next. In the next screen
select the ScanAPI library corresponding to your targeted device platform and click
the Finish button.
For an Android target, go to your Java application project properties; select Java
Build Path in the tree on the left panel of your application properties dialog. Click on
the “Add Variable…” button, select the ScanAPI_Libs variables and click on Extend.
Select ScanAPIAndroid.jar and click OK. Repeat this operation but this time select
the ScanAPIFactoryAndroid.jar file. Both jar files are required in order to use
ScanAPI in your application.
At this point your Java application is ready to use ScanAPI.
6.2.3 Tools provided with ScanAPI SDK
There are 2 tools provides in the SDK and that are launched automatically during
the installation of ScanAPI SDK but they will not be launched if you have installed
ScanAPI SDK using the compressed SDK file.
UpdateWorkspace.jar tool creates a series of Path Variables that are used mostly for
compiling the SDK Sample application. The sample application is sharing source files
across BlackBerry and Android by using the Path Variable mechanism available in
Eclipse. Since the Path Variable contains a complete path, and not a relative path,
this tool updates these variables with the path of where the ScanAPI SDK installed
on the host machine. The Path Variables are stored in the Eclispe workspace. The
tool asks the user for the path of the workspace to update with these new Path
Variables.
SetupScanAPI_SDK.jar. tool modifies the project settings of the sample application
for Android platform and setup the ScanAPI SDK path in the user library file that is
used for the BlackBerry platform.
If only one platform is targeted, it is entirely safe to run both of these tools.
6.3 C# Version
ScanAPI has been compiled with Visual Studio 2008 and using the Compact
Framework 2.0 and the .NET framework 3.5.
The C# version uses a wrapper. ScanAPI has been compiled as a native (unmanaged)
DLL. This DLL is ScanAPIDLL.dll for Windows platforms and ScanAPIDLLWM.dll for
Windows Mobile platform. The managed API is assembled in ScanAPIManaged.dll
for Windows platforms and in ScanAPIManagedWM.dll for the Windows Mobile
platforms.
Both sets of DLLs are therefore required on the host device and should be located at
the same place. So for a Windows host, the application using ScanAPI should have in
its directory ScanAPIDLL.dll and ScanAPIManaged.dll. Same for a Windows Mobile
host, the application using ScanAPI should have in its directory ScanAPIDLLWM.dll
and ScanAPIManagedWM.dll.
In order to build your ScanAPI application, add the ScanAPI Managed reference in
the References folder of your application by browsing to where ScanAPI SDK is
installed on your developer machine, and pointing to the right dll. Depending on
where the ScanAPI SDK has been installed, the path may look like this:
C:\Program Files\Socket Mobile\SocketScan 10\ScanAPI_SDK\Windows\lib.
6.4 Objective C Xcode integration
ScanAPI is released in a static library form, a serie of header files and the source files
for ScanApiHelper, DeviceInfo and Debug.
The recommended way to integrate ScanAPI in your Xcode project is to drag and
drop the ScanAPI folder located at the root of the ScanAPI SDK into your Xcode
project.
The application must add the External accessory framework, and in the info plist the
“Supported External Accessory Protocol” should contains the string
“com.socketmobile.chs”.
Most of the time, ScanApiHelper should be integrated into one of the controller of
the iOS application. The header of this controller should contains the following line:
#import “ScanApiHelper.h”
The controller must derive from ScanApiHelperDelegate protocol.
7 Recommendations
7.1 General
The recommended approach of managing a scanner connection to the host is to
detect if a scanner is connected when needed in the application. It is not
recommended to control the connection and disconnection of the scanner as the
scanner can be disconnected or connected independently of the application state.
If an application has multiple views, but only one view requires a scanner to be
connected, the best approach for this view is to check if a scanner is connected. If a
scanner is not connected, then the application should direct the user on how to
connect the scanner to the host. This can be done by scanning a barcode, or simply
by turning on a scanner that is already paired to the host. The scanner can be left
connected through the life cycle of the application knowing that the power
consumption for both, the host and the scanner, is minimal in that operational
mode.
If the scanner doesn’t have any activity, it will shut itself down after a 2 hours
timeout. If for some reason, the host and the scanner are out of range, the scanner
will automatically try to reconnect to the host during a period of 45 seconds for a
CHS 7x series or up to 30 connection attempts for a CHS 7(E,M,P) series.
At any time the user can turn off or on the scanner. Upon turning the scanner back
one, it will reconnect automatically to the last paired host device.
7.2 Android
It is not recommended to attach ScanAPI or ScanApiHelper to the Activity class, as
this object will get destroy and re-created upon screen rotation causing a connection
drop of the eventual connected scanner. The scanner will automatically reconnect to
the host in this case, but the user experience won’t be ideal.
We recommend attaching ScanAPI or ScanApiHelper to the application class as
shown in our sample application ScannerSettings for the optimal user experience.
It is important to note that your application must request the permission to use
Bluetooth and to write in the external storage. This last permission is required
because the ScanAPI settings are stored into a file on the external storage.
These permissions are identified respectively as follow:
android.permission.BLUETOOTH,
android.permission.BLUETOOTH_ADMIN and
android.permission.WRITE_EXTERNAL_STORAGE.
If these permissions aren’t requested, the external storage will make ScanAPI
returning error ESKT_TESTFAILED (-1), and the Bluetooth one will make ScanAPI
returning error ESKT_UNABLEOPENDEVICE (-27) and then
ESKT_NOTHINGTOLISTEN (-47).
7.3 iOS
On an iOS device, the scanner will always stay connected to the host. If the
application goes to the background, the application is paused. The External
Accessory framework will then simulate a device disconnection to the application,
but the Bluetooth link remains active. When the application is brought back to the
foreground, the External Accessory framework simulates a device connection. Only
certain application types are authorized to run while in background. For these types
of applications, the connection to the scanner will stay alive and running. The
application types are multi-media (music applications playing music while moved to
the background), VOIP applications and location based applications. This restriction
is dictated by iOS and is out of the control of ScanAPI.
8 Device Connection and Disconnection process
With this Version 3 of CHS, in order to have the best user experience possible, the
CHS is always the initiator of the connection process. That is, the CHS will always be
the device to start the connection process, after an initial setup connection has been
made.
8.1 Initial Connection
The process of the initial connection starts by having the CHS scan a connect
barcode. Once the Bluetooth pairing process is completed, the ScanAPI object
generates a Device Arrival notification that contains the device information.
If the scanner is a 2D Imager scanner, 7X series, the connect barcode can be scanned
directly from the device screen. This can be accomplished through the use of Socket
EZ Pair which is a separate application released with the SDK.
If the scanner is a 1D Laser scanner, 7 series, the connect barcode must be printed
out on paper. Socket EZ Pair can configure the scanner to have it connect back to the
host without the need to scan a connect barcode. In this case, the 1D scanner must
be paired with the host first using the Bluetooth functionality present on the host.
The connect barcode contains the Bluetooth Device Address of the host. It could be a
Data Matrix 2D barcode for the 2D Imager scanner 7x series, or it could be a Code
128 1D barcode for the 1D Laser scanner 7 series. The 1D connect barcode can also
be used by the 2D Imager scanner 7x series. Refer to the scanner documentation for
more information about the connect barcode.
Some hosts require having their Bluetooth mode set to discoverable in order to
accept the first initial connection.
If the host is an iOS device, the connect barcode doesn’t contain the host Bluetooth
address, as iOS does not provide an API to retrieve the Bluetooth address, but
instead contains a command to switch the CHS into ‘iOS mode’. The initial
connection can be then started from the iOS Bluetooth manager by tapping on the
desired CHS listed in the Bluetooth discovered devices list. This will initiate the
pairing process and the CHS will connect back to the iOS device as soon as it is
powered on and do this until its connection information is cleared.
8.2 Subsequent Connection
Once the initial connection is made between the scanner and the host, the scanner
will automatically reconnect to the host each time it powers on. If the host doesn’t
have a ScanAPI application running at the time the scanner connects, the scanner
will try a certain number of times before aborting the connection process.
ScanAPI sends a device arrival notification to the application each time a scanner
connects to the host.
8.3 Reconnection
If the connection between the scanner and host is lost for any reason, such as the
scanner moving out of range of the host, the host suspending or going to sleep, the
scanner will try to reconnect to the host for a period of time (45 seconds for a 7X
CHS) or a fixed number of times (30 times for a 7(E,M,P)CHS) before going to idle
mode.
8.4 Disconnection
The disconnection process usually only happens when the scanner powers off. This
occurs when the user presses the scanner power button to shut it down, or if the
scanner is connected for a long period of time without activity and automatically
powers itself off.
There is also a property (kSktScanPropIdDisconnectDevice) that can be set to the
scanner to make it disconnect.
Each time a scanner disconnects, a device removal notification from ScanAPI is sent
to the application containing the scanner information.
8.5 Roaming
The scanner can connect from one host to another by simply scanning the connect
barcode of another host if available. Note this effectively pairs it to the new host.
8.6 Socket EZ Pair feature
This feature is not available for iOS devices. The Scanner reconnects automatically
as soon as the iOS device has successfully paired with the Scanner from its General
Bluetooth settings.
The Socket EZ Pair application configures a scanner to connect back to the host
either by scanning a barcode displayed on the screen or by using a set of properties
sent to the scanner. The latter case is described here.
In order to have ScanAPI connecting to a particular scanner, the ScanAPI
communication port configuration must be changed.
Usually, when a host discovers a scanner, it either assigns a communication port to
this particular scanner (Windows based platforms), or its friendly name is used to
initiate a Bluetooth connection (BlackBerry and Android platforms). If the ScanAPI
serial port configuration is modified to use an outbound port, ScanAPI will then
connect to the remote device that is assigned to this outbound port.
For the scanner to connect back to the host, ScanAPI needs to be re-configured to
use a generic inbound communications port that the scanner will connect back on.
Once ScanAPI has connected to the scanner using either its assigned communication
port or friendly name, the device arrival notification is received by the application.
At that time the application should send the following properties to configure the
scanner to reconnect back to the host:
- Property kSktScanPropIdProfileConfigDevice : to transmit the host Bluetooth
address to the scanner and to specify that the scanner should initiate the
connection in Serial Port Profile (SPP) mode.
- Property kSktScanPropIdDisconnectDevice: to disconnect the scanner and
make the new configuration active. At that point the scanner will try to
reconnect back to the host.
Once the last property has been set, the configuration of ScanAPI must be reverted
back to its original configuration so that it is waiting for an incoming connection.
The ScanAPI property kSktScanPropIdConfiguration “SerialPorts” is used in order to
read and modify the ScanAPI communication port.
NOTE: It is not recommended to use ScanAPI as the initiator of the connection. It
doesn’t have reconnection logic, and it will need to get restarted each time a
connection has to be made.
9 API Functions
The ScanAPI has 6 entry points: Open, Close, Get, Set, Wait and Release.
They all use a reference to either a ScanAPI object or a Device object. These
references are represented differently depending on the programming language
used.
For C/C++ language this reference is represented as SKTHANDLE. This handle is
initialized during the open function and invalidated after calling the close function.
For Java and C#, this reference is an interface. There are 2 interfaces, one for each
object it represents; ISktScanApi for representing a ScanAPI object and
ISktScanDevice for representing a Device object. The ISktScanApi interface is a
superset of the ISktScanDevice.
Objective C uses the same concept and same name except it is called protocol
instead of interface.
A request to get these interfaces instantiated can be made by using the
SktClassFactory, ie: ISktScanApi scanApi=SktClassFactory.createScanApiInstance();
Or in Objective C:
Id<ISktScanApi> scanApi=[SktClassFactory createScanApiInstance];
Having an interface or protocol instance is not enough to use the object it
represents. The open must be invoked to initialize the object, and the close will
invalidate the object.
9.1 Open Function
The Open function opens either ScanAPI object or a Device object.
In order to open a ScanAPI object, the device name should be set to NULL.
The first open of a ScanAPI object initializes the ScanAPI layer and starts the process
of listening for device connections.
Once this open is successful the application can use this ScanAPI object reference to
call the wait API in its consumer logic.
If, for some reason, ScanAPI layer cannot open the Bluetooth serial ports indicated
in its configuration, an error will be sent to the application through a ScanObject
with the Message ID set to Event Message ID.
Device object
In order to open a device object, the device GUID should be specified as the device
name parameter of the open API. The device GUID is retrieved from the device
arrival notification event.
The application will start to receive device asynchronous events as soon as it opens
the device object.
9.1.1 Syntax
C/C++ :
SKTRESULT SktScanOpen(
const char* pszDeviceName,
SKTHANDLE* phDevice
);
pszDeviceName
[in] the scanner device GUID in a string format to open a device or NULL to
open ScanAPI object. If the GUID “{11D47F36-BE62-4D28-9177-
89F1BF3DDD4B}” is specified, this API will return a handle to a ScanAPI
object that won’t have a listener thread and that can be used for editing the
ScanAPI configuration.
phDevice
[out] pointer to receive the reference of the Device object or ScanAPI object.
deviceName:
[in] usually set to NULL in order to open ScanAPI object or it could be set to
“{11D47F36-BE62-4D28-9177-89F1BF3DDD4B}” to open ScanAPI object without a
listener thread. This last case is mostly used to edit a ScanAPI configuration without
conflicting with another application using ScanAPI.
long ISktScanDevice.Open(
String deviceName
);
deviceName
[in] the scanner device GUID in a string to open a device.
Java:
long ISktScanApi.Open(
String deviceName
);
deviceName:
[in] usually set to NULL in order to open ScanAPI object or it could be set to
“{11D47F36-BE62-4D28-9177-89F1BF3DDD4B}” to open ScanAPI object without a
listener thread. This last case is mostly used to edit a ScanAPI configuration without
conflicting with another application using ScanAPI.
long ISktScanDevice.Open(
String deviceName
);
deviceName
[in] the scanner device GUID as a string to open a particular device. This
device GUID can be retrieved from the Device Arrival message event.
Objective C:
-(SKTRESULT) open: (NSString*)deviceName;
of the protocol ISktScanApi.
deviceName:
[in] usually set to NULL in order to open ScanAPI object or it could be set to
“{11D47f36-BE62-4D28-9177-89F1BF3DDD4B}” to open ScanAPI object without a
listener thread. This latter case is used to edit a ScanAPI configuration without
conflicting with another application using ScanAPI.
Same message prototype for a device but this time from the protocol
ISktScanDevice.
[in] the scanner device GUID as a string to open a particular device. This
device GUID can be retrieved from the Device Arrival message event.
9.1.2 Return value
If the function succeeds the return value is ESKT_NOERROR.
9.1.3 Remarks
A close call should be done for each object that has been previously opened
If the open function is called more than once, it increases the reference count of the
object it opens. The same number of closes should be made in order to completely
close the object.
9.1.4 Example
C/C++:
SKTHANDLE hScanAPI=NULL;
SKTRESULT result=SktScanOpen(NULL,&hScanAPI);
if(SKTSUCCESS(result))
{
// do whatever needs to be done ...
}
Java or C#:
ISktScanApi _ScanApi=null;
_ScanApi=SktClassFactory.createScanApiInstance();
long result=_scanApi.Open(null);
if(SktScanErrors.SKTSUCCESS(result))
{
// do whatever needs to be done}
The Set function sets a property of an object identified by its reference. This function
returns immediately before the property set is actually done. The final status should
be checked using the Wait function.
9.3.1 Syntax
C/C++:
SKTRESULT SktScanSet(
SKTHANDLE hDevice,
TSktScanObject * pSktObj
);
hDevice
[in] handle of the device.
pSktObj
[in] pointer to an allocated TSktScanObject that contains the property and its
value to set.
Java or C#:
long ISktScanDevice.SetProperty(
ISktScanObject scanObj
);
Or
Long ISktScanApi.SetProperty(
ISktScanObject scanObj
);
scanObj
[in] reference to a ScanObject that contains the property and its value to set.
The ScanObject should be created using the
SktClassFactory.createScanObject().
Objective C:
-(SKTRESULT) setProperty: (id<ISktScanObject>) scanObj;
From the ISktScanApi or ISktScanDevice protocol.
scanObj
[in] reference to a ScanObject that contains the property and its value to set.
The ScanObject should be created using the [SktClassFactory
createScanObject] message. Once this object is no longer useful it should be
freed by using the message releaseScanObject of the same class,
The return value is ESKT_INVALIDHANDLE if the object reference is invalid.
If the function is called before the completion of an outstanding set or get operation,
it returns ESKT_PENDINGOPERATIONNOTCOMPLETED.
9.3.3 Remarks
The Set function allows an application to set a property of a scanner or ScanAPI, or
to send a command such as triggering a scan.
The ScanObject contains a property structure that defines the property to set. This
structure has a property ID field, a property type field and a value field. These fields
must be set accordingly to the property otherwise an error code will be returned.
In the success case, it will always return the completion code in the ScanObject that
must be retrieved with Wait function.
The Set function will fail if it is called before the completion of a previous Set
function or Get function.
9.3.4 Example
C/C++:
void CMyAppDlg:OnTriggerButton()
{
SKTRESULT Result=ESKT_NOERROR;
TSktScanObject ScanObj;
memset(&ScanObj,0,sizeof(ScanObj));
// initialize a ScanObject to // trigger the device ScanObj.Property.ID=kSktScanPropIdTriggerDevice;
ScanObj.Property.Type=kSktScanPropTypeByte;
ScanObj.Property.Byte=kSktScanTriggerStart;
// set the property with the // device handle Result=SktScanSet(m_hDevice,&ScanObj);
// check the Set result if(SKTSUCCESS(Result))
m_TriggerBtn.Enable(FALSE);
else {
// display an error message DisplayError(_T("Unable to trigger: %d"),Result);
}
}
// set the property with the device// referencelong result=_device.SetProperty(scanObj);
// check the set resultif(SktScanErrors.SKTSUCCESS(result)){
_button.setVisualState(VISUAL_STATE_DISABLED);
}
else{
// display an error messageDisplayError("Unable to trigger: "+result);
}
}
// set the property with the device // reference long result = _device.SetProperty(scanObj);
if (SktScanErrors.SKTSUCCESS(result))
{
buttonTrigger.Enabled = false;
}
else
{
// display an error message
DisplayError("Unable to trigger: " + result);
}
}
// fill out the Scan Object property to trigger the // device
[[scanObj Property]setID:kSktScanPropIdTriggerDevice];
[[scanObj Property]setType:kSktScanPropTypeByte];
[[scanObj Property]setByte:kSktScanTriggerStart];
// send the Set property message
Result=[_scanapisetProperty:scanObj];
// release the scanObj as it is not needed anymore
[SktClassFactoryreleaseScanObject:scanObj];
if(!SKTSUCCESS(Result)){
[selfDisplayErrorMessage:@"Unable to trigger the device"];
}
The Get function retrieves a property from ScanAPI object or from a device object
identified by its reference. This function returns immediately, and its final result
should be checked by using Wait function.
9.4.1 Syntax
C/C++:
SKTRESULT SktScanGet(
SKTHANDLE hDevice,
TSktScanObject* pSktObj
);
hDevice
[in] Handle to the device the property must be retrieved from.
pSktObj
[in] Pointer to a TSktScanObject that contains the property ID that needs to
be retrieved.
Java or C#:
long ISktScanDevice.GetProperty(
ISktScanObject scanObj
);
scanObj
[in] reference to a ScanObject that contains the property ID that needs to be
retrieved. The ScanObject should be created using the
SktClassFactory.createScanObject().
Objective C:
-(SKTRESULT) getProperty: (id<ISktScanObject>) scanObj;
From the ISktScanApi or ISktScanDevice protocol.
scanObj
[in] reference to a ScanObject that contains the property to get. The
ScanObject should be created using the [SktClassFactory createScanObject]
message. Once this object is no longer useful it should be freed using the
message releaseScanObject of the same class, [SktClassFactory
The return value is ESKT_INVALIDHANDLE if the object reference is invalid.
If the function is called before the completion of an outstanding set or get operation,
it returns ESKT_PENDINGOPERATIONNOTCOMPLETED.
9.4.3 Remarks
This function returns immediately. In the success case, it will always return the
completion code in the ScanObject that must be retrieved with Wait function. The
Wait function returns the ScanObject structure with the Property field filled with the
result of the operation if it has been successful. The success code can be retrieve
from that same structure in the Result field.
9.4.4 Example
C/C++:
// Get device friendly name
SKTRESULT GetFriendlyName(
IN SKTHANDLE hDevice,
)
{
SKTRESULT Result=ESKT_NOERROR;
// create a Scan Object
scanObj=[SktClassFactorycreateScanObject];
// fill out the Scan Object property to query the // device friendly name
[[scanObj Property]setID:kSktScanPropIdFriendlyNameDevice];
[[scanObj Property]setType:kSktScanPropTypeNone];
// send the Get property message
Result=[_scanapigetProperty:scanObj];
// release the scanObj as it is not needed anymore
[SktClassFactoryreleaseScanObject:scanObj];
The Wait function waits for any asynchronous events. Only a ScanAPI object can be
used as reference for the wait function.
Most of the time, applications using ScanAPI, use a timer to consume the ScanAPI
asynchronous events. In this case, the wait function can be called with 0 as timeout
so that it returns immediately with timeout result if there is no ScanObject or with
no error result if it has retrieved a ScanObject.
9.5.1 Syntax
C/C++:
SKTRESULT SktScanWait(
SKTHANDLE hScanAPI,
TSktScanObject** ppSktObj,
DWORD dwTimeout
);
hScanAPI
[in] handle to ScanAPI object. This handle cannot be a handle of a scanner
device. If this handle is not a ScanAPI object, this function will return an
invalid handle error.
ppSktObj
[out] pointer to a TSktScanObject pointer. TSktScanObject is allocated by
ScanAPI. This object must be released when it is no longer needed.
dwTimeout
[in] a timeout value expressed in milliseconds. The timeout cannot be bigger
than 10000ms otherwise an error will be returned.
Java:
long ISktScanApi.WaitForScanObject(
ISktScanObject[] scanObj,
long ulTimeout
);
scanObj
[out] reference to a ScanObject that is allocated by ScanAPI. This object must
[in] a timeout value expressed in milliseconds. The timeout cannot be bigger
than 10000ms otherwise an error will be returned.
C#:
long ISktScanApi.WaitForScanObject(
ISktScanObject out scanObj,
long ulTimeout
);
scanObj
[out] reference to a ScanObject that is allocated by ScanAPI. This object must
be released when it is no longer needed.
ulTimeout
[in] a timeout value expressed in milliseconds. The timeout cannot be bigger
than 10000ms otherwise an error will be returned.
Objective C:
-(SKTRESULT) waitForScanObject: (id<ISktScanObject>) scanObj TimeOut:
(unsigned long) ulTimeout;
Only from the ISktScanApi protocol.
scanObj
[in] reference to a ScanObject that will contain the asynchronous message
coming from ScanAPI. The ScanObject should be created using the
[SktClassFactory createScanObject] message. Once this object is no longer
useful it should first be released from ScanAPI using the ReleaseScanObject
API and then it should be freed by using the message releaseScanObject of
the same class, [SktClassFactory releaseScanObject:scanObject];
To avoid unnecessary calls to SktClassFactory, a good approach is at startup
of the application to create one ScanObject instance dedicated to be used for
any subsequent calls to this WaitForScanObject. Once the application is done
using ScanAPI, it can release this dedicated ScanObject.
ulTimeout
[in] timeout to wait for a ScanObject expresses in milliseconds. The timeout
cannot be bigger than 10000ms otherwise an error will be returned.
The Release function releases the ScanObject the Wait function has allocated. This
function must be called each time the Wait function returns success. Only a ScanAPI
object can be used as referenced when calling this Release function.
9.6.1 Syntax
C/C++:
SKTRESULT SktScanRelease(
SKTHANDLE hScanAPI,
TSktScanObject* pSktObj
);
hScanAPI
[in] handle to ScanAPI object. This handle cannot be a handle of a scanner
device. If this handle is not a ScanAPI object, this function will return an
invalid handle error.
pSktObj
[in] pointer to a TSktScanObject to release when it is no longer needed.
Java or C#:
long ISktScanApi.ReleaseScanObject(
ISktScanObject scanObj
);
scanObj
[in] reference to a ScanObject to release when it is no longer needed.
Objective C:
-(SKTRESULT) releaseScanObject: (id<ISktScanObject>) scanObj;
Only from the ISktScanApi protocol.
scanObj
[in] reference to a ScanObject that was received in WaitForScanObject API.
Indicates a new device has arrived and is ready to
be used. The Device field contains the
information about that device.
kSktScanMsgIdDeviceRemoval
Indicates a device is no longer available through
ScanAPI. The only possible operation is the Close
API with the device reference. The Device field
contains the information about that device
including the GUID and the device reference if the
device is still open by the application.
kSktScanMsgIdTerminate
Indicates ScanAPI is ready for shutdown. All the
devices have been removed and closed by the
application. It is safe for the application to close
ScanAPI object after releasing the last ScanObject.
kSktScanMsgSetComplete
Indicates when a Set API operation is completed.
The result of this operation can be retrieved in
the Result field of the Message. The ScanObject
property field contains the property information.
kSktScanMsgGetComplete
Indicates when a Get API operation is completed.
The result of this operation can be retrieved in
the Result field of the message. The ScanObject
property field contains the property information.
kSktScanMsgEvent
An asynchronous event has been received.
10 ScanObject
The ScanObject is the main object that is exchanged between the application and
ScanAPI.
This object has two main members: Message and Property.
Only the Property is relevant when the application is sending a property to a
ScanAPI object or a Device object.
The Message member is relevant only when the application is receiving a ScanObject
from ScanAPI. The Property member is only relevant if the Message ID received is a
Get Complete or a Set Complete.
A Message has a message identifier field, a result field, a device field, and an event
field.
The identifier field indicates the type of message received. It can be one of the
following:
The Wait API returns a ScanObject with its MsgID field set to
kSktScanMsgDeviceArrival and the Device structure field set to the device friendly
name, the device GUID that can be used in the Open API and the device type.
The device arrival can be received as soon as a scanner connects to the host
computer or if a scanner is connected before ScanAPI is initialized.
The device GUID is generated each time a scanner connects to the host. If the same
scanner connects and disconnects several times, its GUID will be different each time.
11.2 Device Removal
The device removal is received by the Wait API as soon as a scanner disconnects
from the host computer or during the termination process of ScanAPI.
The Wait API returns a ScanObject with its MsgID field set to
kSktScanMsgDeviceRemoval and the Device structure field set to the device friendly
name, the device GUID and the device object reference if this device was successfully
opened.
This device object reference can be directly used to close the device by using the
Close API.
If the device wasn’t opened, this reference is set to NULL and the GUID is an empty
string.
11.3 Terminate
The terminate message is received once a Set API has been invoked with the Abort
property, and once every device removal has been responded to by a close device.
When this message is received it is safe to stop the consumer logic that was waiting
on the asynchronous events, to release this last ScanObject and the ScanAPI object
reference can be safely close using the Close API.
11.4 Set Complete
When a Set API operation is completed, the Wait API returns with a ScanObject that
has its MsgID field set to kSktScanSetComplete. The Result field contains the result
of the Set operation, and the Property of the ScanObject contains the property ID for
which the operation has been completed. There is usually no property value on a Set
Complete event. As an example, if an application is changing a device friendly name
Returns the least significant byte
Byte 0 of the double word
powerStatus which represents the
power state.
using the Set API, the Set Complete will return the property ID of the friendly name,
but it won’t return the new friendly name.
11.5 Get Complete
When a Get API operation is completed, the Wait API returns with a ScanObject that
has its MsgID field set to kSktScanGetComplete. The Result field contains the result
of the Get operation. If the result is successful the data can be retrieved according to
the data type that is set in the Type field of the ScanObject Property member.
11.6 Events
Asynchronous events such as decoded data or low battery can be received in the
Wait API. The Msg field of the ScanObject has an event member that is defined by
ScanEvent.
The ScanEvent contains the event identifier and the event data. The event data
defines data that is associated to the event received. Event Data has a type
descriptor and a value that depends on the type descriptor, which could be None,
Byte, Ulong, Array, String or Decoded Data.
11.6.1 Power Event
The Power Event is received when the device has a change regarding its power. This
allows the application UI to display clearly the power state of the device by example
when the device is charging.
The Power Event is not activated by default. The device notification must be
modified in order to turn on this notification. This is accomplished by using the
property kSktScanPropIdNotificationDevice.
The power information is coded in a double word that can be decomposed in 4 fields
from the most significant byte to the least significant:
A helper macro can be used for retrieving the value.
The helper macro can be found in the SktScanPropIds.h file.
Java:
The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper.
C#:
The helper macro can be found in ScanAPI.SktScan.helper.
Objective C:
The helper macro can be found in the SktScanPropIds.h file.
Event Data Type: kSktScanEventDataTypeUlong.
See also:
Property kSktScanPropIdBatteryLevelDevice
11.6.2 Decoded Data Event
The decoded data event occurs each time successful data has been decoded by the
scanner.
The event data contains a decoded data structure that has 3 fields; a string field to
hold the decoded data as received from the scanner, a string field to hold the
symbology name and a SymbologyID field that indicates the symbology ID the
decoded data has been extracted from.
The decoded data arrives in the application only if the application has previously
opened the device.
The decoded data is usually in 7-bit ASCII, however, if the scanner is a 2D Imager
scanner, the data may be in a binary format, such as UNICODE, Shift_JIS or raw
binary data, depending on the barcode scanned. The decoded data will always be
NULL terminated with a byte, and the null byte does not count in the length.
Event Data Type: kSktScanEventDataTypeDecodedData.
11.6.3 Buttons Event
The buttons event occurs each time a user presses a button on the device.
The event will be received only if the device has been previously opened and the
device has been configured to send those events.
Returns true if the left button is
pressed, false otherwise.
SKTBUTTON_ISRIGHTPRESSED(buttons)
Returns true if the right button is
pressed, false otherwise.
SKTBUTTON_ISMIDDLEPRESSED(buttons)
Returns true if the middle button is
pressed, false otherwise.
SKTBUTTON_ISPOWERPRESSED(buttons)
Returns true if the power button is
pressed, false otherwise.
SKTBUTTON_ISRINGDETACHED(buttons)
Returns true if the Ring unit is
detached from the wrist unit, false
otherwise.
The Buttons Event is not activated by default. The device notification must be
modified in order to turn on this notification. This is accomplished by using the
property kSktScanPropIdNotificationDevice.
The same property can be used to configure which button event the device will
send. See the Property kSktScanPropIdNotificationsDevice for more information.
The buttons code is a byte value with a bit field value and is defined as follows:
If the bit is set it means the button has been pressed.
A set of macros are defined to retrieve the status.
Several buttons can be pressed at the same time and the button code will reflect that
condition with multiple bits set to 1.
The button status can also be retrieved at any time by doing a get operation with the
Property kSktScanPropIdButtonStatusDevice.
NOTE:
On a scanner that has only one trigger button such as 7 series scanners, the Middle
button is the trigger button.
The power button will generate one event when it is pressed and another event
when it is released whereas the left and right buttons generate an event only when
they are pressed.
C/C++:
The helper macro can be found in the SktScanPropIds.h file
The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper.
C#:
The helper macro can be found in ScanAPI.SktScan.helper.
Objective C:
The helper macro can be found in the SktScanPropIds.h file.
Event Data Type: kSktScanEventDataTypeByte.
See also:
Property kSktScanPropIdButtonStatusDevice
11.6.4 Error Event
This event occurs each time there is an error, usually during communication with
the device. The error code can be retrieve in the Result field of the message
structure.
Event Data Type: kSktScanEventDataTypeNone or kSktScanEventDataTypeString.
In the case of a String data type, the Event String data contains more information
about the error. For example, it might contain the communication port name that is
reporting an error.
11.6.5 Battery Level Event
The Battery Level Event is received when the device has a change regarding its
battery level. This allows the application UI to display an alert if the battery level
gets low.
The Battery Level Event is not activated by default. The device notification must be
modified in order to turn on this notification. This is accomplished by using the
property kSktScanPropIdNotificationDevice.
The device must be opened in order to receive this event.
The power information is coded in a Ulong that can be decomposed into three fields
from the most significant byte to the less significant:
A set of macros is defined in order to retrieve these values.
Returns the Byte 1 of the double
word batteryLevel that contains
the current battery level within the
Min Level and the Max Level
values.
SKTBATTERY_GETMINLEVEL(batteryLevel)
Returns the Byte 2 of the double
word batteryLevel that contains
the level minimum.
SKTBATTERY_GETMAXLEVEL(batteryLevel)
Returns the Byte 3 of the double
word batteryLevel that contains
the level maximum.
C/C++:
The helper macro can be found in the SktScanPropIds.h file
Java:
The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper.
C#:
The helper macro can be found in ScanAPI.SktScan.helper.
Objective C:
The helper macro can be found in the SktScanPropIds.h file.
Event Data Type: kSktScanEventDataTypeUlong.
See also:
Property kSktScanPropIdBatteryLevelDevice
11.6.6 Listener Started Event
When ScanAPI starts and is initialized, a listener started event is sent indicating the
listener is running and listening on the communication ports.
If the ScanAPI communication port configuration is modified, the listener will
restart in order to retrieve and apply the new configuration. During this process, the
listener sends a Listener Started event.
If for some reason the configuration is incorrect, or none of the communication
ports can be used, the listener will then wait for a new configuration after reporting
this error condition.
The application UI can then report a configuration issue that needs to be addressed.
As soon as a new configuration is applied, the application can refresh its UI status
when it receives the Listener Started event.
<data type>:
defines the
expected type for a
get operation.
<data type>:
defines the type
received in the get
complete
operation.
<data type>:
defines the
expected type for a
set operation
<data type>:
defines the type
received in the set
complete
operation.
Event Data Type: kSktScanEventDataTypeNone.
12 Introduction to Properties
The Property is a member of a ScanObject. There are used by an application to
retrieve or modify a scanner property by using the Get or Set API respectively.
Each of these operations is completed only upon reception of the Get Complete or
Set Complete events, which also contains the resulting property.
Properties are defined with a property identifier, a value type and a value.
A property contains a Context that is a user parameter field that can be associated to
the property. If an application is using this Context field during a Get or a Set
property operation, the matching Get Complete or Set Complete property received
will return the same Context value.
Once a Set or Get operation is successful the result will always be delivered in the
corresponding Set Complete or Get Complete event. The Msg structure of the
ScanObject received by the application contains the identifier for a Set Complete
message or a Get Complete message and the Result field indicates the success of the
Set or Get operation.
If for some reason the device cannot respond to a Set or Get property operation, that
operation will eventually time out (about 5s), and a Set or a Get complete with a
timeout error in the Msg Result field will be received by the application.
Each property defined in the next chapter accepts different data type for a Get
Operation or a Set Operation.
The data type has to be set accordingly prior performing the operation.
Here is the how this table is defined for each property:
The current property does not support this operation.
None
The current property does not have any data attached for this
operation.
Byte
The current property has a byte as data. A byte is an 8-bit
value.
Ulong
The current property has an unsigned long as data. An
unsigned long is a 32 bit value.
Array
The current property has an array of bytes as data. The array
has a size field denoting the number of bytes in the array.
String
The current property has a UTF8 character string as data. The
string has a length field and is terminated with a NULL
character. The length does not include the NULL character.
Version
The current property has a Version structure as data.
Symbology
The current property has a Symbology structure as data.
Object
The current property holds a reference to an object. The
object definition depends on the Property.
The following table summarizes what the data type could be and what its definition
is.
There are two sets of properties; the first set applies to a ScanAPI object and the
second set applies to a Device object.
An error (ESKT_INVALIDHANDLE) is returned if a property is applied to a wrong
object. A wrong object would be a ScanAPI object when the property works only for
a Device object or vice versa.
An error (ESKT_INVALIDOPERATION) is returned if a property operation is not
applicable.
An error (ESKT_INVALIDPARAMETER) is returned if a property operation is used
with an incorrect property data type.
13 ScanAPI object properties
13.1 Property kSktScanPropIdAbort
This property is used to start the shutdown process of ScanAPI. This property must
be used in order to proceed to a clean shutdown. Once this property is set, a set
complete message should be received followed by a series of Device Removals if
there are any devices connected to the host. If their matching Device objects have
been opened by the application, they should be closed using the Close API. Once all
the Device objects have been close or if no device handle has been previously
opened, a Terminate message is received. Upon reception of this last message, it is
safe to stop the ScanAPI consumer logic that uses the Wait API, release this last
message by using Release API and close ScanAPI by using the Close API with the
ScanAPI object reference.
This property can only be set. A get operation on this property will return an error.
Parameter type
Version
13.2 Property kSktScanPropIdVersion
This property is used to retrieve the version of ScanAPI. This property can only be
used with the Get function.
The value returned in a Get Complete Response is a Version structure. The
ScanObject Property has its type set to kSktScanPropTypeVersion indicating that its
SktScanVersion structure is valid and contains the retrieved information. If the
result code is successful, the version can be read from that structure.
The Version structure has 9 fields; Major, Middle, Minor, Build, Month, Day, Year,
Hour and Minute.
Each field of the Version structure is a 2-byte quantity. The Build is a 4-byte
quantity.
All the fields are normally displayed in Hexadecimal format; however the Build
number is usually displayed in a decimal format.
default:
OutputString("Value: Type unknown or not implemented:" +
data._scanObject.Property.Type + CARRIAGE_RETURN);
break;
}
Objective C:
switch([[scanObj Property]getType]){
case kSktScanPropTypeNone:
break;
case kSktScanPropTypeVersion:
OutputString("version: %x.%x.%x %d\nDate: %x/%02x/%02x %02x:%02x\n",
[[[scanObj Property] Version ]getMajor],
[[[scanObj Property] Version ]getMiddle],
[[[scanObj Property] Version ]getMinor],
[[[scanObj Property] Version ]getBuild],
[[[scanObj Property] Version ]getYear],
[[[scanObj Property] Version ]getMonth],
[[[scanObj Property] Version ]getDay],
[[[scanObj Property] Version ]getHour],
[[[scanObj Property] Version ]getMinute]);
break;
/.../
default:
OutputString("Value: Type unknown or not implemented:%d\n",[[scanObj
Property]getType]);
break;
Version
13.3 Property kSktScanPropIdInterfaceVersion
This property is used to retrieve the ScanAPI interface version. If the interface
contract has been modified, this version will be changed to reflect that modification.
This is important for an application that uses ScanAPI as a separate component such
as a DLL, where ScanAPI can be updated without the need of the application code to
be recompiled. Therefore the ScanAPI DLL installed on the host might be different
from the ScanAPI used during the development of an application. An application can
check if the ScanAPI installed on the system has the expected interface.
ScanAPI will always try to provide a backward compatible interface. Therefore if the
interface version is higher than what the application expected, the application
should not have any problem using this version of ScanAPI. However, if the interface
version returned is lower, the application may not be able to run correctly if it uses
some property not available in the current version of the installed ScanAPI.
This property can only be used with the SktScanGet API. Using it with the SktScanSet
API will fail.
Contains the list of
Serial Ports separated
by semi colon ScanAPI
will listen on.
COM3:;COM4:…
kSktScanConfigPath
Allows to retrieve the
configuration path
where ScanAPI save its
configuration on the
host.
This value can
only be read.
The Get
complete
returns the
path.
kSktScanConfigMonitorDbgLevel
Contains the actual
Debug Level for the
traces. This settings
works only if the
ScanAPI is compiled
with the Traces
capability turned on.
(Java platforms can use
this option).
This value is
expressed in
hexadecimal. A
value of 0x04
will trace only
the error. A
value of
0xfffff9f7 will
turn on all the
traces. The
ScanAPI will
need to be
closed and
restarted in
order for the
changes to take
Return Value
The value is returned in the Version structure of the Property. The Property type is
set to kSktScanPropTypeVersion. The version structure has 9 fields; Major, Middle,
Minor, Build, Month, Day, Year, Hour and Minute.
Parameter type
Version
13.4 Property kSktScanPropIdConfiguration
This property is used to set or get a ScanAPI property.
The following property values can be used:
Add or remove the file
and line information in
the traces. This feature
works only on
Windows Platforms.
This value is
expressed in
hexadecimal.
kSktScanConfigMonitorDbgChannel
Modify the channel to
where the debug traces
are directed.
This value is
expressed in
hexadecimal.
0x01 for the
normal debug
window.
0x08 for using
the application
output if
correctly setup.
A value of 0x09
will display
traces on both,
debug window
and application
output.
The value of the serial port configuration contains a list of COM port names where
each item of the list is separated by semi colon: “COM3:;COM4:”
In order to set the property, the configuration name should be specified in the
property string field with an equal sign and the new value for this configuration.
Changing the COM port ScanAPI is listening will cause ScanAPI to shutdown any
active connections and restart its listener thread on the newly specified COM port. If
the COM port doesn’t exist or cannot be opened an error
(ESKT_UNABLEOPENDEVICE) is generated and sent to the application as an
asynchronous message. ScanAPI generates an error (ESKT_NOTHINGTOLISTEN) if
no COM port can be successfully open.
C/C++:
The configuration define can be found in the SktScanPropIds.h file.
Java:
The configuration define can be found in
com.SocketMobile.ScanAPI.ISktScanProperty.values.configuration.
C#:
The configuration define can be found in
ScanAPI.ISktScanProperty.values.configuration
Objective C:
The configuration define can be found in the SktScanPropIds.h file.
Parameter type
Version
13.5 Property kSktScanPropIdDataConfirmationMode
This property is used to read or modify the Data Confirmation feature.
The Data Confirmation feature controls how decoded data should be acknowledged.
Decoded data can be acknowledged at three different locations; locally on the
scanner device, remotely on the host at the ScanAPI level or at the application level.
The advantage of acknowledging the data locally on the device is speed, but the
operator doesn’t know for sure the data has arrived at the application level. The
actual device configuration. It will be
whatever the device has its local
acknowledgment set.
kSktScanDataConfirmationModeDevice
The decoded data is confirmed locally on
the device.
kSktScanDataConfirmationModeScanAPI
The decoded data is confirmed at
ScanAPI level if an application has
previously opened the device handle.
kSktScanDataConfirmationModeApp
The decoded data is confirmed at the
application level. The application should
send a Set property with the identifier
set to
kSktScanPropIdDataConfirmationDevice.
Get
Get Complete
Set
Set Complete
None
Byte
Byte
None
advantage for the application acknowledging the decoded data is to confirm that it
corresponds to something expected by the application and if not then the
application can acknowledge negatively the decoded data letting the operator know
the barcode he or she just scanned is incorrect. The problem with this mode of
acknowledgment is the small time lag that it introduces between each scan
operation.
This property value is a type of byte and its value is summarized in the following
table:
C/C++:
The data confirmation defines can be found in the SktScanPropIds.h file.
Java:
The configuration define can be found in
com.SocketMobile.ScanAPI.ISktScanProperty.values.confirmationMode.
C#:
The configuration define can be found in
ScanAPI.ISktScanProperty.values.confirmationMode.
Objective C:
The data confirmation defines can be found in the SktScanPropIds.h file.
This property reads or sets the ScanAPI Data Confirmation Action.
The Data Confirmation Action is used by ScanAPI only if the Data Confirmation
Mode is set to kSktScanDataConfirmationModeScanAPI.
In that mode, when ScanAPI receives decoded data, it will respond with the Action
defined by this property.
The Action is defined by a set of bits. There are 3 actions that can be configured;
Rumble, Beep and LED. The Rumble can be set on device that doesn’t have a Rumble
motor, but will have no effect.
Some helper macros have been defined to help to configure this setting.
The following table summarizes the possible values that can be used with the macro
SKTDATACONFIRMATION.
This monitor mode changes the debug
level. The Debug level is described
below.
kSktScanMonitorDbgChannel
This monitor mode changes the channel
where the traces can be outputted.
kSktScanMonitorDbgFileLineLevel
This monitor mode changes the level
from which the traces will have the line
number and the file name in the traces.
The helper macro and the defines can be found in the SktScanPropIds.h file.
Java:
The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper and the
values are defined in
com.SocketMobile.ScanAPI.ISktScanProperty.values.dataConfirmation
C#:
The helper macro can be found in ScanAPI.SktScan.helper and the values are defined
in ScanAPI.ISktScanProperty.values.dataConfirmation.
Objective C:
The helper macro and the defines can be found in the SktScanPropIds.h file.
Parameter type
Version
See also:
Data confirmation feature
13.7 Property kSktScanPropIdMonitorMode
This property is used to configure the debug option of ScanAPI.
NOTE:
C/C++ and C#:
This property works only if ScanAPI has been compiled in Debug mode. It will
have no effect on a release build. Only release builds are included with the SDK.
The monitor mode output traces in a remote debugger.
There are three monitor modes that can be changed and they are described in the
following table:
The default only outputs the line number
and the file name if a trace is at the
specified error level.
Name
Value
Description
DBGSKT_CORET
0x00000011
Traces from the Core
DBGSKT_COREW
0x00000012
Warning from the Core
DBGSKT_COREE
0x00000014
Errors from the Core
DBGSKT_LISTENERT
0x00000021
Traces from the listener
DBGSKT_LISTENERW
0x00000022
Warnings from the
listener
DBGSKT_LISTENERE
0x00000024
Errors from the listener
DBGSKT_PROTOCOLT
0x00000041
Traces from the protocol
DBGSKT_PROTOCOLW
0x00000042
Warnings from the
protocol
DGBSKT_PROTOCOLE
0x00000044
Errors from the protocol
DBGSKT_SERIALT
0x00000081
Traces from the serial
interface
DBGSKT_SERIALW
0x00000082
Warnings from the serial
interface
DBGSKT_SERIALE
0x00000084
Errors from the serial
interface
DBGSKT_DEVICEINTT
0x00000101
Traces from the device
interface
DGBSKT_DEVICEINTW
0x00000102
Warnings from the device
interface
DGBSKT_DEVICEINTE
0x00000104
Errors from the device
interface
DBGSKT_RXT
0x00000201
Traces from the receive
path
DBGSKT_RXW
0x00000202
Warning from the receive
path
DBGSKT_RXE
0x00000204
Errors from the receive
path
DBGSKT_TXT
0x00000401
Traces from the transmit
Debug Level Definition
The Debug Level is defined in a 32 bit variable and is defined as follows:
Bit 0: Level Trace
Bit 1: Level Warning
Bit 2: Level Error
Bit 3: Level Always.
Bit 4 to Bit 31: Modules.
Enables the SoftScan feature when used
in the Set operation, or the SoftScan
feature is enabled when retrieved in the
Get Complete response.
kSktScanDisableSoftScan
Disables the SoftScan feature when used
in the Set operation or the SoftScan
feature is disabled when retrieved in the
Get Complete response.
The Get property can be used to retrieve a particular monitor mode. The property
must have its byte value set to one of the monitor modes. The Get complete contains
the actual level in its Ulong value.
The Set property can be used to change the monitor mode level. An array of 5 bytes
should be initialized with the first byte set to the particular monitor mode, and the 4
remaining bytes should contain the new 32 bit value in big-endian format.
Parameter type
Version
13.8 Property kSktScanPropIdSoftScanStatus
This property enables or disables the SoftScan feature. The SoftScan feature uses the
device camera to scan a barcode. Some devices might not meet all of the
requirements for such an operation. When the SoftScan is enabled and the
requirements are all met for scanning a barcode using the camera, then a new
device arrival will be generated with the necessary information for opening a
SoftScan scanner.
ScanAPI generates a device removal when the SoftScan scanner is disabled by using
this same property to turn this feature off.
The possible values for the byte data field are described in the following table:
This property retrieves the version information of a connected device. The version
of the device can be read upon reception of the Get Complete event. The property
has its type set to kSktScanPropTypeVersion, and the version field of the property
contains the version information of the device identified by its handle. The version is
described by 9 fields: wMajor, wMiddle, wMinor, dwBuild, wYear, wMonth, wDay,
wHour and wMinute.
These fields are all expressed in hexadecimal except for the dwBuild field that is
expressed in decimal.
Parameter type
Version
14.2 Property kSktScanPropIdDeviceType
This property is used to retrieve the Device Type of a connected device.
A device type is defined in a 32-bit value composed of 2 types of information.
The first is the interface type that can be one of the following values:
The helper macro can be found in the SktScanPropIds.h file.
This property cannot be used with the SktScanSet API.
Property Type
Version
14.3 Property kSktScanPropIdDeviceSpecific
This property can send a device specific command. The command depends on the
device type connected to the host. ScanAPI acts just as a pass-through without
interpreting any data in the command that is sent to the device using this property.
The command should be set in the Array member of the property, and the response
command is returned in the Array member of the property.
The command format depends on the device used. The command format for the 7x
series is different from the command format used in the 7 series.
The command format for the 7x series is decomposed as described in the following
table.
The command format for the 7 series is decomposed as described in the following
table.
Contains the Symbology ID (e.g.
kSktScanSymbologyCode39)
Flags
Indicates if the Param field is used or
not.
Status
Indicates the status of the symbology,
This status can be one of the following:
kSktScanSymbologyStatusDisable,
kSktScanSymbologyStatusEnable,
kSktScanSymbologyStatusNotSupported
Param
Contains extra parameters about the
symbology. Not used in this version.
Name
Contains the symbology name. The name
field is ignored when the application is
doing a get or set operation. Only a get
complete returns the name of the
symbology.
Name
Definition
kSktScanSymbologyStatusEnable
The symbology is present and activated.
kSktScanSymbologyStatusDisable
The symbology is present but
deactivated.
kSktScanSymbologyStatusNotSupported
The symbology is not supported by the
device.
Name
Definition
kSktScanSymbologyNotSpecified
The symbology ID is unknown or not
specified.
kSktScanSymbologyAustraliaPost
Austrial Post
Version
14.4 Property kSktScanPropIdSymbologyDevice
This property is used to retrieve or set the status of a particular symbology. A
symbology is identified by a unique ID. A ScanAPI symbology structure is used in
order to manipulate the setting of a symbology.
This structure is TSktScanSymbology. It has the following fields:
A symbology that has a kSktScanSymbologyStatusNotSupported status means the
device doesn’t support this symbology.
The following table gives the possible Symbology Status.
The following table gives the list of Symbology ID.
Last symbology ID, this is not an actual
symbology.
Get
Get Complete
Set
Set Complete
Symbology
Symbology
Symbology
None
ScanAPI Interface Version
1.0.0 or higher
Name
Description
kSktScanTriggerStart
Start a scan
kSktScanTriggerStop
Stop a scan
kSktScanTriggerEnable
Enable the trigger button
kSktScanTriggerDisable
Disable the trigger button
The enumeration of the available symbologiwa of a device can be done by doing get
operations with the symbology ID incremented one by one from
kSktScanSymbologyNotSpecified+1 to kSktScanSymbologyLastSymbolID-1. For
more information please see section 16.
C/C++:
The Symbology ID and Symbology status defines can be found in SktScanTypes.h
file.
Java:
The Symbology ID and Symbology status defines can be found in:
com.SocketMobile.ScanAPI.ISktScanSymbology.id and
com.SocketMobile.ScanAPI.ISktScanSymbology.status
C#:
The Symbology ID and Symbology status defines can be found in:
ScanAPI.ISktScanSymbology.id and ScanAPI.ISktScanSymbology.status.
Objective C:
The Symbology ID and Symbology status defines can be found in SktScanTypes.h
file.
Property type
Version
See also:
11.6.2 Decoded Data Event
14.5 Property kSktScanPropIdTriggerDevice
This property allows the application to start or stop a trigger operation of a device
remotely or to activate/deactivate the device trigger button. This property can only
be used in a Set operation. Its Byte value can have one of the following values:
NOTE: Enabling or Disabling the trigger will be not effective on CHS 7C
version:3.4.0.1869. It will return an error (ESKT_RECEIVEUNEXPECTEDCOMMAND)
for both of these commands. This version of the CHS 7C is a limited release and this
issue has been fixed in the next revision of the scanner.
C/C++:
The Trigger defines can be found in SktScanPropIds.h file.
Java:
The Trigger defines can be found in
com.SocketMobile.ScanAPI.ISktScanProperty.values.trigger
C#:
The Trigger defines can be found in ScanAPI.ISktScanProperty.values.trigger.
Objective C:
The helper macro can be found in the SktScanPropIds.h file.
Property type
Version
See also:
4.7 Example of sending a command
14.6 Property kSktScanPropIdApplyConfigDevice
This property applies the device configuration stored on the host to the device.
This property can only be set and doesn’t have any parameters.
This property can be used to set or get the device preamble. When a preamble is set,
it will be added in front of the decoded data. The preamble is defined as a string with
a length that can contain any value for each character from 0 (0x00) to 255 (0xff).
NOTE: The 7 series 3.1 scanners don’t support a true preamble. The preamble
is actually stored on the device as part as the friendly name and postamble.
The total amount of characters for the friendly name, preamble and postamble
cannot be bigger than 28 characters. If a preamble is too long, an error
ESKT_INVALIDPARAMETER would be generated in the return of the
SktScanSet API. If the device is used without ScanAPI, the preamble won’t
appear in front of the decoded data.
The 7 series 3.2 or higher scanners support a limited preamble. The preamble
can only be one character long. It can be used without ScanAPI once it is setup.
The 7 series version can be determined by the Version property Major and
Middle values.
These remarks do not apply for the 7x series.
Property type
Version
14.8 Property kSktScanPropIdPostambleDevice
This property can be used to set or get the device postamble. When a postamble is
set, it will be added at the tail of the decoded data. The postamble is defined as a
string with a length that can contains any value for each character from 0 (0x00) to
255 (0xff).
NOTE: The 7 series v3.1 don’t support a true postamble. The postamble is
actually stored on the device as part as the friendly name and preamble. The
total amount of characters for the friendly name, preamble and postamble
cannot be bigger than 28 characters. If a postamble is too long, an error
ESKT_INVALIDPARAMETER would be generated in the return of the
SktScanSet API. If the device is used without ScanAPI, the postamble won’t
appear at the tail of the decoded data.
The 7 series v3.2 or higher support a limited postamble. The postamble can
only be 2 characters long. It can be used without ScanAPI once it is setup.
This property can be used to get the device capabilities.
The capabilities of a device have been divided in 2 groups: General and Local
Functions.
The General group contains the information about the device to determine if it has a
Local Function Group capability.
The Local Function Group regroups the features that are implemented locally on the
device, such as Friendly Name, Sound, Led flash, Rumble, etc.
The features that belong to the General Group are features implemented in any type
of device, such as Device Type, Symbology settings, Trigger etc… Most of the time,
these features are implemented in the scanner engine.
The Get Request has a one-byte parameter to interrogate the one of the capabilities
group.
The following table describes the capabilities of each group.
If the Get Property byte value is set to kSktScanCapabilityGeneral, the return value
of the Get Complete Property is a Ulong describing the general capability. In the
current version of ScanAPI only Bit 0 is set to 1 if the device supports Local
Functions.
The X is set to 1 when the device supports Local Functions.
If the Get Property byte value is set to kSktScanCapabilityLocalFunctions, the return
value of the Get Complete Property is an unsigned long (Ulong) describing the Local
Functions capability.
In the current version of ScanAPI, the Bit 0 is set to 1 if the device supports Rumble
mode and the Bit 1 is set to 1 if the Change ID feature is present.
Bit 0 is set to 1 when the device supports Rumble Mode.
Bit 1 is set to 1 when the device supports the Change ID feature.
These are the constants used for capability definition:
kSktScanCapabilityLocalFunctionRumble and
kSktScanCapabilityLocalFunctionChangeID.
Example:
switch (scanObj.Property.ID)
{
caseISktScanProperty.propId.kSktScanPropIdFriendlyNameDevice: /………………/break;
caseISktScanProperty.propId.kSktScanPropIdCapabilitiesDevice: if (SktScanErrors.SKTSUCCESS(result))
The constants definitions for the capabilities can be found in SktScanPropIds.h file.
Java:
The constants definition for the capabilities can be found in
com.SocketMobile.ScanAPI.ISktScanProperty.values.capabilityGroup
com.SocketMobile.ScanAPI.ISktScanProperty.values.capabilityGeneral
com.SocketMobile.ScanAPI.ISktScanProperty.values.capabilityLocalFunctions
C#:
The constants definition for the capabilities can be found in
ScanAPI.ISktScanProperty.values.capabilityGroup
ScanAPI.ISktScanProperty.values.capabilityGeneral
ScanAPI.ISktScanProperty.values.capabilityLocalFunctions
The constants definitions for the capabilities can be found in SktScanPropIds.h file.
Property type
Version
14.10 Property kSktScanPropIdChangeIdDevice
This property returns a Change ID of the device symbology configuration and the
device preamble and postamble. This Change ID will reflect any configuration
change in the scanner engine that could have been made outside ScanAPI by
scanning a scanner engine configuration barcode.
This feature is useful to figure out if the device has a different symbology
configuration or preamble/postamble than the host has stored for this device.
The enumeration of all the supported symbologies can be a lengthy operation that
can be greatly improved by implementing a symbology cache mechanism.
The first time a device is connected to the host, its symbology status gets
enumerated and stored into a cache. The change ID is also requested.
If the device disconnects and then reconnects at a later time to this host, the change
ID is requested and compared with the ChangeID stored in the host cache.
If the change ID is the same then the symbology can be displayed out of the cache
without requesting it from the device.
If the ChangeID is different, this means the symbology on the device has been
altered, and it will require a new enumeration of the symbology from the device.
The change ID is a Ulong value that is a checksum of all the scanner engine settings
(including symbology activation and preamble/postamble).
Other scanner properties aren’t cover by this Change ID such as beeps/LED/Rumble
configuration, friendly name, data store, and confirmation settings.
This property is used to read or modify the friendly name of a device. The friendly
name is carried as a string in the property.
The friendly name of a device is what appears during a Bluetooth device discovery
process. The main purpose of changing the friendly name of a device is to have an
easy way to identify a particular device.
The changes are active immediately upon success of the Set Complete operation.
The friendly name size can be as long as 32 UTF8 characters including the null
terminator.
Example:
C/C++:
// Set a new friendly name
SKTRESULT SetNewFriendlyName(
IN SKTHANDLE hDevice,
IN constchar* pszNewFriendlyName
)
{
SKTRESULT Result=ESKT_NOERROR;
Same as above
but the device
only keeps the
security
NOTE: For the 7 series v3.1, ScanAPI uses the friendly name memory to store
the preamble and the postamble. The total amount of characters for the
friendly name, preamble and postamble cannot be bigger than 28 characters.
If a friendly name is too long to be stored along with the preamble and
postamble, an error ESKT_INVALIDPARAMETER would be generated in the
return of the SktScanSet API.
This remark doesn’t apply for the 7 series v3.2 or 7x series.
Property type
Version
14.12 Property kSktScanPropIdSecurityModeDevice
This property gets or set the security mode of a device.
The security mode can be one of the following values:
information for
one host.
Connecting to
another host
cause the
security
process to start
all over again.
Get
Get Complete
Set
Set Complete
None
Byte
Byte
None
ScanAPI Interface Version
1.0.0 or higher
Get
Get Complete
Set
Set Complete
Not applicable
Not applicable
String
None
ScanAPI Interface Version
1.0.0 or higher
C/C++:
These security constants are defined in SktScanPropIds.h file.
Java:
These security constants are defined in
com.SocketMobile.ScanAPI.ISktScanProperty.values.securityMode
C#:
These security constants are defined in
ScanAPI.ISktScanProperty.values.securityMode
Objective C:
These security constants are defined in SktScanPropIds.h file.
Parameter type
Version
14.13 Property kSktScanPropIdPinCodeDevice
This property sets a new pin code for a connected device. The new PIN code should
be a string and cannot be longer than 16 characters. The new PIN code will have
effect at the next connection of the device. Changing the PIN code of the connected
device won’t disconnect device. The new PIN code will be required by the host when
the device connects the next time.
This property deletes the Bluetooth pairing and bonding information from the
device identified by its reference. Once the pairing and bonding information have
been deleted from the device, the device stays connected. The new pairing and
bonding information will be created at the next connection of the device to the host.
This property can only be used in a Set operation and has one parameter indicating
if the pairing and bonding information should be deleted for all the hosts the
scanner might know or only for the current host.
A constant has been defined for each of these modes:
C/C++:
The delete and pairing constants are defined in SktScanPropIds.h file.
Java:
The delete and pairing constants are defined in
com.SocketMobile.ScanAPI.ISktScanProperty.values.deletePairing
C#:
The delete and pairing constants are defined in
ScanAPI.ISktScanProperty.values.deletePairing
Objective C:
The delete and pairing constants are defined in SktScanPropIds.h file.
This property sets the connected device to its factory defaults. The device will
power down once the factory defaults have been applied and the Set Complete has
been sent.
Parameter type
Version
14.16 Property kSktScanPropIdSetPowerOffDevice
This property turns the power off from the device causing it to disconnect.
This property can only be used in a Set operation and doesn’t have any parameters.
This is one of the rare cases where a Set Complete might not be received before the
device drops the connection. From the application point of view, the device removal
might come before the Set Complete timeout error. If the application closes right
away the device upon reception of the device removal event, the Set Complete
timeout error will never be received by the application.
Parameter type
Version
14.17 Property kSktScanPropIdButtonStatusDevice
This property gets the button status of the connected device.
The button status is coded in one byte as a bit field indicating the status of each
button on the device.
A set of macros can be used in order to retrieve the status of a particular button. The
macro returns a Boolean to indicate if the button is pressed (true) or released (false)
or, in the case of the Series 9 Ring Scanner, it is detached (true) or attached (false).
The macro definitions can be found in paragraph 11.6.3 Buttons Event.
Sound played when a good scan
occurs when the host is sending a
positive data confirmation
kSktScanSoundActionTypeGoodScanLocal
Sound played when the device
locally acknowledges a good scan.
kSktScanSoundActionTypeBadScan
Sound played when a bad scan
occurs when the host is sending a
negative data confirmation
kSktScanSoundActionTypeBadScanLocal
Sound played when the device
locally acknowledges a bad scan.
Name
Description
kSktScanSoundFrequencyNone
No sound
C/C++:
The helper macro can be found in the SktScanPropIds.h file.
Java:
The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper.
C#:
The helper macro can be found in ScanAPI.SktScan.helper.
Objective C:
The helper macro can be found in the SktScanPropIds.h file.
Parameter type
Version
14.18 Property kSktScanPropIdSoundConfigDevice
This property gets or sets the sound configuration of the connected device.
Each action can have its own sound definition.
Here is the list of possible actions:
A sound configuration is composed of two parameters; the number of tones and the
tones. A tone is defined by its frequency, its duration and the pause before the next
tone.
These parameters are expressed as 16 bit words in big-endian format.
The frequency can be set to one of the following values: