Download Print this page

Advertisement

Quick Links

ScanAPI Reference
Date
Description
4/29/2011
First release supporting Windows (big and WinMo), Android and
BlackBerry
6/16/2011
Added iOS details
9/16/2011
ScanApiHelper support for iOS, new Error code
ESKT_OUTDATEDVERSION
10/19/2011 Added more information about xCode integration
11/04/2011 Added Recommendations chapter
12/02/2011 Adding more information regarding Android permissions in
Recommendations for Android.
01/06/2012 Re-ordered the paragraph, reworded the Concept paragraph, and
modified the IDE integration for Xcode.
06/19/2012 Adding the properties, and the description of the SoftScan feature.
09/19/2012 Adding the missing symbology ids (USPS Intel. and DPM).
12/06/2012 Adding the Android permission
android.permission.BLUETOOTH_ADMIN that is required.
01/15/2013 Added new statistical counter names
01/18/2013 Added 2 new error codes for determining why a COM port can't be
opened
02/25/2013 Minor editorial updates based on feedback
05/29/2013 Update kSktScanPropIdTimersDevice
History

Advertisement

loading
Need help?

Need help?

Do you have a question about the ScanAPI and is the answer not in the manual?

Questions and answers

Summary of Contents for Socket ScanAPI

  • Page 1 ScanAPI Reference History Date Description 4/29/2011 First release supporting Windows (big and WinMo), Android and BlackBerry 6/16/2011 Added iOS details 9/16/2011 ScanApiHelper support for iOS, new Error code ESKT_OUTDATEDVERSION 10/19/2011 Added more information about xCode integration 11/04/2011 Added Recommendations chapter 12/02/2011 Adding more information regarding Android permissions in Recommendations for Android.
  • Page 2 Socket ScanAPI Reference 06/03/2013 Update the framework requirements for iOS ScanAPI RedLaser 06/3/2013 Correct all endian references to ‘big-endian’ © 2013 Socket Mobile, Inc. 2/152...
  • Page 3: Copyright Notice

    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.
  • Page 4: Table Of Contents

    Example of sending a command ..............16 Handling asynchronous events or completion events ........25 Termination ...................... 25 ScanAPI Helper (available for Java, C# and Objective C) ........26 Handling the ScanAPI Helper notifications ............ 26 Set ScanAPI Helper notification ............... 32 Open ScanAPI Helper ..................
  • Page 5 Socket ScanAPI Reference Roaming ......................40 Socket EZ Pair feature ..................40 API Functions ......................41 Open Function ....................41 Close Function ....................46 Set Function....................... 48 Get Function ...................... 53 Wait Function ....................57 Release Function ....................60 ScanObject ......................62 Asynchronous messages and events ..............
  • Page 6 ScanAPI Error handling and definitions ............124 15.1 Error codes ....................127 Symbologies Enumeration ................. 129 Data confirmation feature ................. 130 Sample handling asynchronous events of ScanAPI ......... 131 SktScanAPIOwnership (available for Java platforms) ........138 19.1 Constructor ....................139 19.2 register ......................
  • Page 7: Scanner Connection Overview

    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:...
  • Page 8 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.
  • Page 9 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.
  • Page 10: Scanapi Introduction

    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.
  • Page 11: Softscan Feature

    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...
  • Page 12: Android Requirements

    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.
  • Page 13: Device Object

    Socket ScanAPI Reference 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.
  • Page 14: Using Scanapi

    Socket ScanAPI Reference 4.4 Using ScanAPI 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.
  • Page 15: Get Or Set A Property

    Socket ScanAPI Reference 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.
  • Page 16: 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.
  • Page 17 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...
  • Page 18 TraceInfo(_T("unknown Message ID \ received:0x%x"), pSktObject->Msg.MsgID); break; // release the ScanObj we received in the wait SktScanRelease(hScanAPI,pSktObject); return Result; // called from the ScanAPI consumer logic // that is using SktScanWait API void CMyAppDlg::HandleGetOrSetComplete( IN TSktScanObject* pScanObj switch(pScanObj->Property.ID) case kSktScanPropIdTrigger: // ungray out the trigger btn m_TriggerBtn.Enable(TRUE);...
  • Page 19 = _device.SetProperty(scanObj); (SktScanErrors.SKTSUCCESS(result)) buttonTrigger.Enabled = false; else // display an error message DisplayError("Unable to trigger: " + result); // timer to checking and consuming ScanObject from ScanAPI private void timerScanAPIConsumer_Tick(object sender, EventArgs ISktScanObject scanObj=null; // wait for ScanAPI ScanObject...
  • Page 20 + result); break; return result; Java source code: // handler for the Trigger button class TriggerButtonHandler implements Runnable { private ISktScanDevice _device=null; private ButtonField _button; // constructor public TriggerButtonHandler( ISktScanDevice device, ButtonField button) _device=device; _button=button; © 2013 Socket Mobile, Inc. 20/152...
  • Page 21 DisplayError("Unable to trigger: "+result); class ScanAPIConsumer extends TimerTask { private ISktScanApi _scanApi; private AppRef _appRef; public ScanAPIConsumer(ISktScanApi scanApi,AppRef appRef) _scanApi=scanApi; _appRef=appRef; public void run() { ISktScanObject[]scanObj=new ISktScanObject[1]; // wait for scanAPI ScanObject long result=_scanApi.WaitForScanObject(scanObj,10); if(SktScanErrors.SKTSUCCESS(result)) if(result!=SktScanErrors.ESKT_WAITTIMEOUT) © 2013 Socket Mobile, Inc. 21/152...
  • Page 22 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 MsgID result= HandleTerminate(scanObj[0]); break; case ISktScanMsg.kSktScanMsgSetComplete: case ISktScanMsg.kSktScanMsgGetComplete: result= HandleGetOrSetComplete(scanObj[0]); break; case ISktScanMsg.kSktScanMsgEvent: break;...
  • Page 23 [[scanObj Property] setID:kSktScanPropIdTriggerDevice]; [[scanObj Property]setType:kSktScanPropTypeByte]; [[scanObj Property]setByte:kSktScanTriggerStart]; [_rootViewController AddPropertyToSet:scanObj]; [_rootViewController SendFirstPropertyToSet]; // timer handler for consuming ScanObject from ScanAPI // if ScanAPI is not initialized this handler does nothing -(void)onTimer{ if(_scanApiInitialized==true){ SKTRESULT result=[_scanapi WaitForScanObject:_scanObjectReceived TimeOut:0]; (SKTSUCCESS(result)) { (result!=ESKT_WAITTIMEOUT) { [self HandleScanObject:_scanObjectReceived];...
  • Page 24 -(void) DoSetComplete:(id<ISktScanObject>)scanObject{ SKTRESULT result=ESKT_NOERROR; (scanObject!=nil) { result=[[scanObject Msg]Result]; // send a notification to update the progress bar [[NSNotificationCenter defaultCenter] postNotificationName:@"msg_name" object:nil userInfo:nil]; _propertySetPending=NO; // and send the next property if there is one [self SendFirstPropertyToSet]; © 2013 Socket Mobile, Inc. 24/152...
  • Page 25: Handling Asynchronous Events Or Completion Events

    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.
  • Page 26: Scanapi Helper (Available For Java, C# And Objective C)

    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.
  • Page 27 _consumerTerminatedEvent.set(); if(_forceCloseUI){ Intent intent=new Intent(NOTIFY_CLOSE_ACTIVITY); sendBroadcast(intent); * ScanAPI is now initialized, if there is an error * then ask the activity to display it public void onScanApiInitializeComplete(long result) { // if ScanAPI couldn't be initialized // then display an error if(!SktScanErrors.SKTSUCCESS(result)){...
  • Page 28 Socket ScanAPI Reference intent.putExtra(EXTRA_SYMBOLOGY_NAME,decodedData.getSymbologyName()); intent.putExtra(EXTRA_DECODEDDATA,decodedData.getData()); sendBroadcast(intent); * an error occurs during the retrieval of ScanObject * from ScanAPI, this is critical error and only a restart * can fix this. public void onErrorRetrievingScanObject(long result) { Intent intent=new Intent(NOTIFY_ERROR_MESSAGE); String text="Error unable to retrieve ScanAPI message: ";...
  • Page 29 _deviceconnected=false; public void onDeviceArrival(long result, DeviceInfo newDevice) { synchronized(UiApplication.getEventLock()){ size=_scanApiHelper.getDevicesList().size(); _displayDeviceslist.setSize(size); _deviceconnected=true; public void onDecodedData(DeviceInfo deviceInfo, ISktScanDecodedData decodedData) { if(_scanwindow!=null) _scanwindow.DoScannedData(decodedData.getData(),decodedData.getSymbologyName()); Same notification handler but this time from Objective C version of Scanner Settings: © 2013 Socket Mobile, Inc. 29/152...
  • Page 30 Socket ScanAPI Reference © 2013 Socket Mobile, Inc. 30/152...
  • Page 31 Socket ScanAPI Reference © 2013 Socket Mobile, Inc. 31/152...
  • Page 32: Set Scanapi Helper Notification

    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.
  • Page 33: Decoded Data Notification

    5.6 Decoded data notification 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.
  • Page 34: Is There A Connected Scanner

    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”...
  • Page 35 Socket ScanAPI Reference 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.
  • Page 36: C# Version

    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. © 2013 Socket Mobile, Inc.
  • Page 37: Recommendations

    Socket ScanAPI Reference 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”...
  • Page 38: Ios

    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,...
  • Page 39: Subsequent Connection

    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.
  • Page 40: Roaming

    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.
  • Page 41: Api Functions

    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.
  • Page 42 Socket ScanAPI Reference 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.
  • Page 43 Socket ScanAPI Reference 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.
  • Page 44 // do whatever needs to be done Objective C: SKTRESULT Result=ESKT_NOERROR; id<ISktScanApi> scanApi=nil; scanApi=[SktClassFactory createScanApiInstance]; Result=[scanApi open:nil]; if(SKTSUCCESS(Result)){ // do whatever needs to be done See also: Sample handling asynchronous events of ScanAPI © 2013 Socket Mobile, Inc. 44/152...
  • Page 45: Function Information

    Windows XP, Windows Mobile 5.0 Java Import com.SocketMobile.ScanAPI.ISktScanApi com.SocketMobile.ScanAPI.SktClassFactory Jar File ScanAPIFactory.jar ScanAPI.jar Minimum operating system RIM 5.0.0, Android 2.1 Objective C Import SktScanApi.h ScanApi.h Framework libScanAPI.a ExternalAccessory.framework Minimum operating system iOS 4.1 9.1.6 See Also Close Function © 2013 Socket Mobile, Inc. 45/152...
  • Page 46: Close Function

    Socket ScanAPI Reference 9.2 Close Function This function closes ether a ScanAPI object or a Device object. 9.2.1 Syntax C/C++: SKTRESULT SktScanClose( SKTHANDLE hDevice hDevice [in] Handle to the scanner device or ScanAPI to close. Java or C#: long ISktScanDevice.Close(); or long ISktScanApi.Close();...
  • Page 47 Minimum operating systems Windows XP, Windows Mobile 5.0 Java Import com.SocketMobile.ScanAPI.ISktScanApi com.SocketMobile.ScanAPI.SktClassFactory Jar File ScanAPIFactory.jar ScanAPI.jar Minimum operating system RIM 5.0.0, Android 2.1 Objective C Import SktScanApi.h ScanApi.h Framework libScanAPI.a ExternalAccessory.framework Minimum operating system iOS 4.1 © 2013 Socket Mobile, Inc. 47/152...
  • Page 48: Set Function

    [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, [SktClassFactory releaseScanObject:scanObject]; © 2013 Socket Mobile, Inc. 48/152...
  • Page 49 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.
  • Page 50 ISktScanProperty.types. kSktScanPropTypeByte); property.setByte( ISktScanProperty.values.trigger. kSktScanTriggerStart); // set the property with the device // reference long result=_device.SetProperty(scanObj); // check the set result if(SktScanErrors.SKTSUCCESS(result)){ _button.setVisualState(VISUAL_STATE_DISABLED); else // display an error message DisplayError("Unable to trigger: "+result); © 2013 Socket Mobile, Inc. 50/152...
  • Page 51 // device [[scanObj Property]setID:kSktScanPropIdTriggerDevice]; [[scanObj Property]setType:kSktScanPropTypeByte]; [[scanObj Property]setByte:kSktScanTriggerStart]; // send the Set property message Result=[_scanapi setProperty:scanObj]; // release the scanObj as it is not needed anymore [SktClassFactory releaseScanObject:scanObj]; if(!SKTSUCCESS(Result)){ [self DisplayErrorMessage:@"Unable to trigger the device"]; © 2013 Socket Mobile, Inc. 51/152...
  • Page 52 Import com.SocketMobile.ScanAPI.ISktScanApi com.SocketMobile.ScanAPI.SktClassFactory Jar File ScanAPIFactory.jar ScanAPI.jar Minimum operating system RIM 5.0.0, Android 2.1 Objective C Import SktScanApi.h ScanApi.h Framework libScanAPI.a ExternalAccessory.framework Minimum operating system iOS 4.1 9.3.6 See Also Get Function, Wait Function © 2013 Socket Mobile, Inc. 52/152...
  • Page 53: Get Function

    Socket ScanAPI Reference 9.4 Get Function 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...
  • Page 54 // the final result should be fetched // in the Get Complete handler Result=SktScanGet(hDevice,&ScanObj); return Result; Java or C#: // get device friendly name long GetFriendlyName(ISktScanDevice device) long result=SktScanErrors.ESKT_NOERROR; ISktScanObject scanObj; scanObj=SktClassFactory.createScanObject(); ISktScanProperty property; property=scanObj.getProperty(); property.setID(ISktScanProperty.propId. © 2013 Socket Mobile, Inc. 54/152...
  • Page 55 SktScanAPI.h, include SktScanErrors.h, SktScanTypes.h Import library ScanAPI.lib Minimum operating systems Windows XP, Windows Mobile 5.0 Reference ScanAPIManaged.dll for Windows or ScanAPIManagedWM.dll for Windows Mobile Minimum operating systems Windows XP, Windows Mobile 5.0 Java Import com.SocketMobile.ScanAPI.ISktScanApi com.SocketMobile.ScanAPI.SktClassFactory © 2013 Socket Mobile, Inc. 55/152...
  • Page 56 Socket ScanAPI Reference Jar File ScanAPIFactory.jar ScanAPI.jar Minimum operating system RIM 5.0.0, Android 2.1 Objective C Import SktScanApi.h ScanApi.h Framework libScanAPI.a ExternalAccessory.framework Minimum operating system iOS 4.1 9.4.6 See Also Set Function, Wait Function © 2013 Socket Mobile, Inc. 56/152...
  • Page 57: Wait Function

    Socket ScanAPI Reference 9.5 Wait Function 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.
  • Page 58 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.
  • Page 59 Socket ScanAPI Reference If the object reference specified is not a ScanAPI object, the function returns ESKT_INVALIDHANDLE. If the timeout value is bigger than 10000 the function returns ESKT_INVALIDTIMEOUT. If the timeout occurs, the function returns ESKT_WAITTIMEOUT. 9.5.3 Remarks The ScanObject retrieved using this API should be released by using the Release API.
  • Page 60: Release Function

    9.6 Release Function 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.
  • Page 61 Socket ScanAPI Reference 9.6.2 Return Value If the function succeeds it returns ESKT_NOERROR. If the object reference specified is not to a ScanAPI object, the function returns ESKT_INVALIDHANDLE. 9.6.3 Remarks 9.6.4 Example See the Sample handling asynchronous events of ScanAPI.
  • Page 62: Scanobject

    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.
  • Page 63: Asynchronous Messages And Events

    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.
  • Page 64: Get Complete

    -reserved- -reserved- State A helper macro can be used for retrieving the value. Macro name Description SKTPOWER_GETSTATE(powerStatus) Returns the least significant byte Byte 0 of the double word powerStatus which represents the power state. © 2013 Socket Mobile, Inc. 64/152...
  • Page 65 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. The helper macro can be found in ScanAPI.SktScan.helper. Objective C: The helper macro can be found in the SktScanPropIds.h file.
  • Page 66 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 © 2013 Socket Mobile, Inc. 66/152...
  • Page 67 Socket ScanAPI Reference Java: The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper. 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...
  • Page 68 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.
  • Page 69: Introduction To Properties

    © 2013 Socket Mobile, Inc. 69/152...
  • Page 70: Scanapi Object Properties

    The current property holds a reference to an object. The object definition depends on the Property. 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.
  • Page 71: Property Ksktscanpropidversion

    Socket ScanAPI Reference 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 Get Complete...
  • Page 72 Integer.toHexString(scanObject.getProperty(). getVersion().getMonth())+"/"+ Integer.toHexString(scanObject.getProperty(). getVersion().getDay())+" "+ Integer.toHexString(scanObject.getProperty(). getVersion().getHour())+":"+ Integer.toHexString(scanObject.getProperty(). getVersion().getMinute())); switch(scanObject.Property.Type) case ISktScanProperty.types.kSktScanPropTypeNone: break; /………………/ case ISktScanProperty.types.kSktScanPropTypeVersion: OutputString("version: "+ Convert.ToString(data._scanObject.Property.Version.wMajor,16)+"."+ Convert.ToString(data._scanObject.Property.Version.wMiddle,16)+"."+ Convert.ToString(data._scanObject.Property.Version.wMinor,16)+ " "+ data._scanObject.Property.Version.dwBuild+CARRIAGE_RETURN+ "Date: "+ Convert.ToString(data._scanObject.Property.Version.wYear,16)+"/"+ Convert.ToString(data._scanObject.Property.Version.wMonth,16)+"/"+ Convert.ToString(data._scanObject.Property.Version.wDay,16)+" "+ Convert.ToString(data._scanObject.Property.Version.wHour,16)+":"+ Convert.ToString(data._scanObject.Property.Version.wMinute,16)); break; © 2013 Socket Mobile, Inc. 72/152...
  • Page 73: Property Ksktscanpropidinterfaceversion

    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.
  • Page 74: Property Ksktscanpropidconfiguration

    Not applicable Not applicable Version ScanAPI Interface Version 1.0.0 or higher 13.4 Property kSktScanPropIdConfiguration This property is used to set or get a ScanAPI property. The following property values can be used: Name Description Values kSktScanConfigSerialComPort Contains the list of COM3:;COM4:…...
  • Page 75 Example TSktScanObject ScanObj; memset(&ScanObj,0,sizeof(ScanObj); // allocate memory to receive the new config string ScanObj.Property.String.pValue=new char[64]; if(ScanObj.Property.String.pValue) ScanObj.Property.ID=kSktScanPropIdConfiguration; ScanObj.Property.Type=kSktScanPropTypeString; printf(ScanObj.Property.String.pValue,"%s=%s", kSktScanConfigSerialComPort,"COM3:;COM4:"); ScanObj.Property.String.nLength= strlen(ScanObj.Property.String.pValue); // set the configuration here Result=SktScanSet(hScanAPI,&ScanObj); // done with this buffer © 2013 Socket Mobile, Inc. 75/152...
  • Page 76: Property Ksktscanpropiddataconfirmationmode

    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.
  • Page 77 This property value is a type of byte and its value is summarized in the following table: Name Description kSktScanDataConfirmationModeOff ScanAPI layer doesn’t try to alter 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.
  • Page 78: Property Ksktscanpropiddataconfirmationaction

    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;...
  • Page 79: Property Ksktscanpropidmonitormode

    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.
  • Page 80 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 © 2013 Socket Mobile, Inc. 80/152...
  • Page 81: Property Ksktscanpropidsoftscanstatus

    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:...
  • Page 82: Device Object Properties

    The first is the interface type that can be one of the following values: Value Description kSktScanDeviceTypeInterfaceNone Unspecified interface type for this device kSktScanDeviceTypeInterfaceSD Secure Digital IO interface kSktScanDeviceTypeInterfaceCF Compact Flash interface kSktScanDeviceTypeInterfaceBluetooth Bluetooth interface kSktScanDeviceTypeInterfaceSerial Serial cable interface © 2013 Socket Mobile, Inc. 82/152...
  • Page 83 For the device camera used as barcode scanner. NOTE: The CRS family is supported by ScanAPI since version 10.0.4. The SoftScan feature is supported by ScanAPI since version 10.0.9. A set of predefined macros can be used in order to retrieve one of the two information types contained in the device type.
  • Page 84: 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.
  • Page 85: Property Ksktscanpropidsymbologydevice

    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.
  • Page 86 Planet US Post kSktScanSymbologyPlessey PLESSEY kSktScanSymbologyPostnet POSTNET US Post kSktScanSymbologyQRCode QR Code kSktScanSymbologyStandard2of5 Standard 2 of 5 kSktScanSymbologyTelepen Telepen kSktScanSymbologyTlc39 TLC 39 kSktScanSymbologyUpcA UPC A kSktScanSymbologyUpcE0 UPC E0 kSktScanSymbologyUpcE1 UPC E1 kSktScanSymbologyUspsIntelligentMail USPS Intelligent Mail © 2013 Socket Mobile, Inc. 86/152...
  • Page 87: Property Ksktscanpropidtriggerdevice

    Set operation. Its Byte value can have one of the following values: Name Description kSktScanTriggerStart Start a scan kSktScanTriggerStop Stop a scan kSktScanTriggerEnable Enable the trigger button kSktScanTriggerDisable Disable the trigger button © 2013 Socket Mobile, Inc. 87/152...
  • Page 88: Property Ksktscanpropidapplyconfigdevice

    The Trigger defines can be found in SktScanPropIds.h file. Java: The Trigger defines can be found in com.SocketMobile.ScanAPI.ISktScanProperty.values.trigger 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...
  • Page 89: Property Ksktscanpropidpreambledevice

    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.
  • Page 90: Property Ksktscanpropidcapabilitiesdevice

    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.
  • Page 91 ISktScanProperty.propId.kSktScanPropIdCapabilitiesDevice: (SktScanErrors.SKTSUCCESS(result)) selectedScanner.OriginalProperties.Configuration.DoesRumble = ((scanObj.Property.Ulong& ISktScanProperty.values.capabilityLocalFunctions.kSktScanCapabilityLocalFunctionRumble)== ISktScanProperty.values.capabilityLocalFunctions.kSktScanCapabilityLocalFunctionRumble); else // unable to get the capabilities even after multiple // retries by ScanAPI Helper StopRetrievingPropertiesAndDisplayError("Failed to retrieve the Capabilities: " result); break; case ISktScanProperty.propId.kSktScanPropIdPostambleDevice: /………………/ break; C/C++: The constants definitions for the capabilities can be found in SktScanPropIds.h file.
  • Page 92: 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.
  • Page 93: Property Ksktscanpropidfriendlynamedevice

    ScanObj.Property.Type=kSktScanPropTypeString; ScanObj.Property.String.pValue=pszNewFriendlyName; ScanObj.Property.String.nLength= strlen(pszNewFriendlyName); // set the friendly name here // the final result should be fetched // in the Set Complete handler Result=SktScanSet(hDevice,&ScanObj); return Result; Java: public long SetNewFriendlyName(ISktScanDevice device,String newFriendlyName){ long result=SktScanErrors.ESKT_NOERROR; © 2013 Socket Mobile, Inc. 93/152...
  • Page 94 SKTRESULT Result=ESKT_NOERROR; id<ISktScanObject>scanObj=nil; scanObj=[SktClassFactory createScanObject]; [[scanObj Property]setID:kSktScanPropIdFriendlyNameDevice]; [[scanObj Property]setType:kSktScanPropTypeString]; [[scanObj Property]setString:friendlyName]; // set the friendly name here // the final result should be fetched // in the set Complete handler Result=[device setProperty:scanObj]; return Result; © 2013 Socket Mobile, Inc. 94/152...
  • Page 95: Property Ksktscanpropidsecuritymodedevice

    Socket ScanAPI Reference 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.
  • Page 96: Property Ksktscanpropidpincodedevice

    The new PIN code will be required by the host when the device connects the next time. Parameter type Get Complete Set Complete Not applicable Not applicable String None Version ScanAPI Interface Version 1.0.0 or higher © 2013 Socket Mobile, Inc. 96/152...
  • Page 97: Property Ksktscanpropiddeletepairingbondingdevice

    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. Parameter type Get Complete Set Complete Not applicable Not applicable Byte None Version ScanAPI Interface Version 1.0.0 or higher © 2013 Socket Mobile, Inc. 97/152...
  • Page 98: Property Ksktscanpropidrestorefactorydefaultsdevice

    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. © 2013 Socket Mobile, Inc. 98/152...
  • Page 99: Property Ksktscanpropidsoundconfigdevice

    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. The helper macro can be found in ScanAPI.SktScan.helper. Objective C: The helper macro can be found in the SktScanPropIds.h file.
  • Page 100 The Get request property uses only a byte value to request the configuration of a particular sound action. The following is an example of an array that can be used for the Set request: Word Values Description kSktScanSoundActionTypeGoodScanLocal Configuration for the Good Scan Local © 2013 Socket Mobile, Inc. 100/152...
  • Page 101 Tone 1 Pause … … Repeat the last 6 bytes for the next tone C/C++: The constant definition can be found in the SktScanPropIds.h file. Java: The constant definition can be found in com.SocketMobile.ScanAPI.ISktScanProperty.values.soundConfig © 2013 Socket Mobile, Inc. 101/152...
  • Page 102: Property Ksktscanpropidtimersdevice

    Trigger Lock out 2 bytes Time in 1/4 second increments for the timer trigger to be locked out. Disconnected auto 2 bytes Time in minutes to leave power on © 2013 Socket Mobile, Inc. 102/152...
  • Page 103 The constant definition can be found in ScanAPI.ISktScanProperty.values.timers. Objective C: The constant definition can be found in the SktScanPropIds.h file. Parameter type Get Complete Set Complete None Array Array None Version ScanAPI Interface Version 1.0.0 or higher © 2013 Socket Mobile, Inc. 103/152...
  • Page 104: Property Ksktscanpropidlocalacknowledgmentdevice

    The host can acknowledge the decoded data by using the kSktScanPropIdDataConfirmationDevice property. Depending on how the ScanAPI kSktScanPropIdDataConfirmationMode is set, ScanAPI can confirm the decoded data automatically. Please refer to paragraph 17 Data confirmation feature.
  • Page 105: Property Ksktscanpropiddataconfirmationdevice

    14.21 Property kSktScanPropIdDataConfirmationDevice This property acknowledges positively or negatively on decoded data. This property is mostly used by the application when the ScanAPI Data Confirmation Mode has been set to kSktScanDataConfirmationModeApp. This property can be sent at any time by the application to make the device beep, flash or rumble.
  • Page 106: Property Ksktscanpropidbatteryleveldevice

    C/C++: The helper macro and the constant definitions can be found in the SktScanPropIds.h file. Java: The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper. The constant definition can be found in Com.SocketMobile.ScanAPI.ISktScanProperty.values.dataConfirmation The helper macro can be found in ScanAPI.SktScan.helper.
  • Page 107: Property Ksktscanpropidlocaldecodeactiondevice

    Objective C: The constant definitions can be found in the SktScanPropIds.h file. Property type Get Complete Set Complete None Byte Byte None Version ScanAPI Interface Version 1.0.0 or higher See also 17 Data confirmation feature © 2013 Socket Mobile, Inc. 107/152...
  • Page 108: Property Ksktscanpropidbluetoothaddress

    ESKT_NOTSUPPORTED error will be returned in the Get Complete event for these devices. In Java only, ScanAPI provides a static function to convert this Bluetooth address array of 6 bytes into a string. It can be found in SktJava.helper. This function is formatBluetoothAddress.
  • Page 109 UART sends a packet. kSktScanCounterUartReceive Counter represents the number of times the UART receives a packet. kSktScanCounterButtonLeftPress Counter represents the number of times the left button has been pressed on the Cordless Ring © 2013 Socket Mobile, Inc. 109/152...
  • Page 110 The constant definition can be found in Com.SocketMobile.ScanAPI.ISktScanProperty.values.counters. The constant definition can be found in ScanAPI.ISktScanProperty.values.counters. Objective C: The constant definitions can be found in the SktScanPropIds.h file. Parameter type Get Complete Set Complete None Array Not applicable Not applicable © 2013 Socket Mobile, Inc. 110/152...
  • Page 111: Property Ksktscanpropidrumbleconfigdevice

    The maximum number of rumbles is 5. On duration 2 bytes Get Complete, Set Define the duration when the rumble is active. The On duration range is 50 (0x32) to 32767 (0x7FFF) © 2013 Socket Mobile, Inc. 111/152...
  • Page 112 These constant definitions can be found in Com.SocketMobile.ScanAPI.ISktScanProperty.values.rumbleActionType. These constant definitions can be found in ScanAPI.ISktScanProperty.values.rumbleActionType. Objective C: These constant definitions can be found in the SktScanPropIds.h file. Parameter type Get Complete Set Complete Byte Array Array None © 2013 Socket Mobile, Inc. 112/152...
  • Page 113: Property Ksktscanpropidprofileconfigdevice

    Com.SocketMobile.ScanAPI.ISktScanProperty.values.profile and Com.SocketMobile.ScanAPI.ISktScanProperty.values.profileConfig. The constant definition can be found in ScanAPI.ISktScanProperty.values.profile and ScanAPI.ISktScanProperty.values.profileConfig Objective C: The constant definitions can be found in the SktScanPropIds.h file. Parameter type Get Complete Set Complete None Array Array None © 2013 Socket Mobile, Inc. 113/152...
  • Page 114: Property Ksktscanpropiddisconnectdevice

    The constant definition can be found in ScanAPI.ISktScanProperty.values.disconnect Objective C: The constant definitions can be found in the SktScanPropIds.h file. Parameter type Get Complete Set Complete Not applicable Not applicable Byte None Version ScanAPI Interface Version 1.0.0 or higher © 2013 Socket Mobile, Inc. 114/152...
  • Page 115: Property Ksktscanpropiddatastoredevice

    You can check the firmware of the scanner to verify scanner model support using the kSktScanPropIdVersionDevice command or checking the result on the default init result on the OnScannerFirmware:scanObject Parameter type Get Complete Set Complete Array Array Array None © 2013 Socket Mobile, Inc. 115/152...
  • Page 116: Property Ksktscanpropidnotificationsdevice

    The constant definitions can be found in the SktScanPropIds.h file. Java: The constant definitions can be found in com.SocketMobile.ScanAPI.ISktScanProperty.values.notifications The constant definitions can be found in ScanAPI.ISktScanProperty.values.notifications Objective C: The constant definitions can be found in the SktScanPropIds.h file. © 2013 Socket Mobile, Inc. 116/152...
  • Page 117: Property Ksktscanpropidconnectreasondevice

    Objective C: The helper macro and the constant definition can be found in the SktScanPropIds.h file. NOTE: This feature is only available in the 7x series, an ESKT_NOTSUPPORTED error is returned for the other series. © 2013 Socket Mobile, Inc. 117/152...
  • Page 118: Property Ksktscanpropidpowerstatedevice

    The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper and the constant definition can be found in com.SocketMobile.ScanAPI.ISktScanProperty.values.powerStates. The helper macro can be found in ScanAPI.SktScan.helper and the constant definition can be found in ScanAPI.ISktScanProperty.values.powerStates. Objective C: The helper macro and the constant definition can be found in the SktScanPropIds.h file.
  • Page 119: Property Ksktscanpropidstartuprolesppdevice

    The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper and the constant definition can be found in Com.SocketMobile.ScanAPI.ISktScanProperty.values.startUpRoleSpp. The helper macro can be found in ScanAPI.SktScan.helper and the constant definition can be found in ScanAPI.ISktScanProperty.values.startUpRoleSpp. Objective C: © 2013 Socket Mobile, Inc.
  • Page 120: Property Ksktscanpropidconnectionbeepconfigdevice

    ScanAPI will send a data confirmation to the scanner to make it beep. If the scanner is used without ScanAPI in SPP mode, the connection beep can be configured using this property so the scanner beeps each time it connects.
  • Page 121: Property Ksktscanpropidflashdevice

    The helper macro can be found in com.SocketMobile.ScanAPI.SktScan.helper and the constant definition can be found in Com.SocketMobile.ScanAPI.ISktScanProperty.values.connectBeepConfig. The helper macro can be found in ScanAPI.SktScan.helper and the constant definition can be found in ScanAPI.ISktScanProperty.values.connectBeepConfig. Objective C: The helper macro and the constant definition can be found in the SktScanPropIds.h file.
  • Page 122: Property Ksktscanpropidoverlayviewdevice

    UI object used to display the view taken by the camera during the scanning operation. The Get parameter returns the reference of the same UI object used to display the view taken by the camera. © 2013 Socket Mobile, Inc. 122/152...
  • Page 123 // callback that should have the Bluetooth address of the scanner [_scanApiHelper postGetBtAddress:_lastConnected Target:self Response:@selector(onBtAddressForRegistration:)]; #endif else { UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Error" message:@"Unable to open the scanner" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; Java example (Android only): scanButton.setOnClickListener( © 2013 Socket Mobile, Inc. 123/152...
  • Page 124: Scanapi Error Handling And Definitions

    1.0.1 or higher 15 ScanAPI Error handling and definitions The result of the ScanAPI functions can be negative which means the API failed, or it can be 0 which means the API succeeded or it can be a positive value indicating the API succeeds but is returning information about its operation.
  • Page 125 The ScanAPI error is defined by the type SKTRESULT. All the ScanAPI APIs returns a SKTRESULT result. Java and C#: The ScanAPI error is defined as a long. All the ScanAPI APIs return a long result. The SKTSUCCESS function is defined in the SktScanErrors class as well as the error codes.
  • Page 126 // receive events from this device or we can set or get its // properties id<ISktScanDevice> iDevice=[SktClassFactory createDeviceInstance:_scanapi]; SKTRESULT result=[iDevice open:deviceGuid]; // create a device info object to display the device main // information in the table view © 2013 Socket Mobile, Inc. 126/152...
  • Page 127: Error Codes

    [alert release]; 15.1 Error codes The list of error codes is as follows: Name Value ESKT_WAITTIMEOUT ESKT_ALREADYDONE ESKT_PENDING ESKT_STILLPENDING ESKT_CREATED ESKT_NOERROR ESKT_TESTFAILED ESKT_NOTENOUGHMEMORY ESKT_UNABLECREATELOCK ESKT_UNABLELOCK ESKT_UNABLEUNLOCK ESKT_LISTEMPTY ESKT_UNABLECREATEEVENT ESKT_UNABLESETEVENT ESKT_UNABLERESETEVENT ESKT_EVENTNOTCREATED -10L ESKT_INVALIDHANDLE -11L © 2013 Socket Mobile, Inc. 127/152...
  • Page 128 ESKT_COMMUNICATIONERROR -38L ESKT_RECEIVEUNEXPECTEDCOMMAND -39L ESKT_UNABLECREATEGUID -40L ESKT_INVALIDVALUE -41L ESKT_REQUESTTIMEDOUT -42L ESKT_INVALIDOPERATION -43L ESKT_WRONGPROTOCOL -44L ESKT_QUEUERESETED -45L ESKT_EXCEEDINGMTUSIZE -46L ESKT_NOTHINGTOLISTEN -47L ESKT_OUTDATEDVERSION -48L ESKT_UNABLEREGISTERFORHIDCHANGES -50L ESKT_UNABLERETRIEVEMESSAGE -51L ESKT_SYNTAXERROR -52L ESKT_UNABLEOPENFILE -53L ESKT_UNABLERETRIEVEPATH -54L ESKT_UNABLECREATEDIRECTORY -55L © 2013 Socket Mobile, Inc. 128/152...
  • Page 129: Symbologies Enumeration

    The symbology is identified in ScanAPI by a Symbology ID. The kSktScanSymbologyLastSymbologyID is actually not a symbology but instead indicates the number total of symbologies supported in ScanAPI (this value could change with different versions). A symbology status is retrieved by using the Get API with a kSktScanPropIdSymbologyDevice property as described in this document.
  • Page 130: Data Confirmation Feature

    In order to indicate to ScanAPI at which level the data confirmation should be done, the kSktScanPropIdDataConfirmationMode should be set with its byte value set to the appropriate value. If the choice is to have either ScanAPI or the device to confirm the decoded data, there is another property that needs to be used in order to specify what action should be made when ScanAPI or the device confirms the data.
  • Page 131: Sample Handling Asynchronous Events Of Scanapi

    The default setting is data confirmation has done locally in the device. 18 Sample handling asynchronous events of ScanAPI In most cases, the application using ScanAPI has some sort of UI. Since ScanAPI is based on asynchronous API, it fits very well in an architecture that has some UI involved.
  • Page 132 Msg ID of the ScanObject can be used to dispatch to an appropriate sub handler. 5) If the Terminate event is received, it means the timer can be safely terminated, and the ScanAPI object can be closed. Here is what the C/C++ code might look like: ©...
  • Page 133 The main windproc message handler can have these 2 entries: // on create of the window case WM_CREATE: Socket ScanAPI Reference Global.hWnd=hWnd; SKTRESULT Result=SktScanOpen(NULL,&Global.hScanAPI); if(!SKTSUCCESS(Result)) DisplayError("Unable to Open ScanAPI:%d",Result); else // start the timer to consume ScanAPI ScanObject SetTimer(hWnd,TIMER_ID,200,NULL); break; case WM_TIMER: TimerHandler(); break; void TimerHandler() TSktScanObject* pScanObj=NULL; bool bTerminate=false;...
  • Page 134 // then remove its info from the // application scanner list if(SKTSUCCESS(Result)) Result=RemoveScanner(hDevice); return Result; SKTRESULT HandleSetComplete( IN TSktScanObject* pScanObj SKTRESULT Result=ESKT_NOERROR; Result=pScanObj->Msg.Result; if(SKTSUCCESS(Result)) UpdateUI(); return Result; SKTRESULT HandleGetComplete( IN TSktScanObject* pScanObj SKTRESULT Result=ESKT_NOERROR; SKTHANDLE hDevice=NULL; © 2013 Socket Mobile, Inc. 134/152...
  • Page 135 DisplayMessage(_T("Low Battery")); case kSktScanEventButtons: break; default: DisplayError(_T("Receive unexpected Event!!!")); return Result; Here is a sample in Java for the BlackBerry platform. import com.SocketMobile.ScanAPI.ISktScanApi; import com.SocketMobile.ScanAPI.ISktScanDecodedData; import com.SocketMobile.ScanAPI.ISktScanDevice; import com.SocketMobile.ScanAPI.ISktScanEvent; import com.SocketMobile.ScanAPI.ISktScanMsg; import com.SocketMobile.ScanAPI.ISktScanObject; © 2013 Socket Mobile, Inc. 135/152...
  • Page 136 _scanApiConsumer.schedule(_ScanAPIConsumerTimer, 1, 200); * _ScanAPIConsumerTimer * This is a timer task that checks every once a while * if there is a ScanObject to retrieve from ScanAPI * and it checks if there is a command to send private TimerTask...
  • Page 137 // if there is a command to send // now might be a good time sendNextCommand(); * HandleScanObject * This method is called each time this application receives a * ScanObject from ScanAPI. protected boolean HandleScanObject(ISktScanObject scanObject) { boolean closeScanApi=false;...
  • Page 138: Sktscanapiownership (Available For Java Platforms)

    Why it is important to use this SktScanApiOwnership API? If your application works with other Socket applications such as SocketScan 10 Keyboard wedge, Scanner Settings or Socket EZ Pair, then this API will prevent any conflict using ScanAPI as they all use the same SktScanApiOwnership API.
  • Page 139: Constructor

    Socket ScanAPI Reference 7) When the application is shutting down, it closes ScanAPI and it releases ScanAPI ownership, unregisters from ScanAPI ownership. 19.1 Constructor The ScanAPIOwnership object constructor requires the name of the application and the notification interface implementation to receive the notification from ScanAPI ownership change.
  • Page 140: Register

    Not available Framework Not available Minimum operating system Not available 19.2 register The register method of SktScanApiOwnership class allows the application to register for receiving notification about a change in ScanAPI ownership. 19.2.1 Syntax C/C++: Not available Java: For BlackBerry platform: ©...
  • Page 141 19.2.3 Remarks This method installs the notification handler, and makes the application aware of any change in ScanAPI ownership. The unregister method must be called when the application is done with ScanAPI otherwise a memory leak might occur. 19.2.4 Example...
  • Page 142: Unregister

    Once this method is called the application won’t receive any notification about change in ScanAPI ownership. If the application registers for notification, the unregister method must be called when the application is done using ScanAPI in order to avoid a memory leak. © 2013 Socket Mobile, Inc. 142/152...
  • Page 143: Askforownership

    ScanAPI and it doesn’t have already its ownership. When the request is honored the ScanApiOwnership callback is called with released flag set to false. At this point the application can safely claim the ScanAPI ownership by using the claimOwnership API.
  • Page 144: Claimownership

    Not available 19.5 claimOwnership This method claims the ScanAPI ownership. This method is usually called just before opening ScanAPI. The recommended way of calling this method is directly in the ScanApiOwnership notification, when the released flag is set to false.
  • Page 145 SktScanApiOwnership.Error.kNoError in case of success. 19.5.3 Remarks When an application receives a ScanAPI ownership notification indicating it can now take the ownership of ScanAPI, it must call this method in order to claim the ScanAPI ownership prior opening ScanAPI. 19.5.4 Example...
  • Page 146: Releaseownership

    ScanAPI application the ownership can be taken and ScanAPI can be used. When the application receives a ScanAPI ownership notification asking the application to close ScanAPI, it must call this function in order to really release the ownership correctly. © 2013 Socket Mobile, Inc.
  • Page 147: Notification Onscanapiownershipchange

    A Boolean called release indicates what to do with the current ScanAPI ownership. If the Boolean release is set to true, then the application has to release the ScanAPI ownership and close ScanAPI. If this Boolean is false then the application can take the ScanAPI ownership by calling the claimOwnership method and then can open ScanAPI.
  • Page 148 [in] If this Boolean is true then the ownership has to be released and ScanAPI has to be closed. If it is false, then the ScanAPI ownership can be claimed and ScanAPI can be opened. Not available.
  • Page 149 Socket ScanAPI Reference * Only one application at a time can have access to ScanAPI. * When another application is claiming ScanAPI ownership, this * callback is called with release set to true asking this application * to release scanAPI. When the other application is done with ScanAPI * it calls releaseOwnership, causing this callback to be called again * but this time with release set to false.
  • Page 150: Softscan Feature

    20.1 Usage ScanAPI provides a property to enable or disable this feature. If the SoftScan feature is enabled, a device arrival event is fired assuming the host device has the necessary hardware to support this feature.
  • Page 151: Ios Integration

    SoftScan feature with the help of the RedLaser SDK. ScanAPI provides a camera overlay view to help the aiming of the camero onto the barcode. This overlay is active as soon as the trigger starts.
  • Page 152: Android Integration

    Socket ScanAPI Reference 20.3 Android integration © 2013 Socket Mobile, Inc. 152/152...