SocketMobile.Capture 1.0.513.13

Capture SDK for Windows C# to integrate Socket Mobile Bluetooth Scanners in your app using Socket Mobile Companion Service. The Socket Mobile Companion service is required to be installed on the host.

Install-Package SocketMobile.Capture -Version 1.0.513.13
dotnet add package SocketMobile.Capture --version 1.0.513.13
<PackageReference Include="SocketMobile.Capture" Version="1.0.513.13" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SocketMobile.Capture --version 1.0.513.13
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Capture SDK Version 1.0.513

Socket Mobile is a leading innovator of data capture and delivery solutions for enhanced productivity.

Capture SDK is the easiest solution for adding barcode scanning capability to a Windows application.

The Socket Mobile barcode scanner is an ergonomic, fast and accurate solution to a variety of data entry scenarios.

This SDK is very easy to integrate to an application without any requirement to follow a specific design architecture.

Integration into an application can be done in as little as 10 minutes!

More documentation can be found here.

Table of Contents

  • Quick install notes
  • Capture usage
  • Sample code
  • Configure and connect a Socket Mobile device

Quick install notes

The Capture SDK is available as NuGet package.

To install the SDK in an application, open the Manage NuGet Packages for Solution accessible through the Visual Studio Tools menu by selecting NuGet Package Manager.

A dialog displays a list of various NuGet sources. Make sure the Package source is set to either All or nuget.org. In the search box type SocketMobile.Capture to list the Socket Mobile Capture NuGet. Make sure to select SocketMobile.Capture.

An AppKey is required in order to use Capture SDK and can be generated by registering your application on Socket Mobile developer portal.

Our sample applications do not require any registration, they include a default AppKey.

IMPORTANT: Capture relies on the Socket Mobile Companion which is a service running in background. The Socket Mobile Companion can be downloaded here.

The Socket Mobile Companion requires at least ONE BLUETOOTH INBOUND port that is prompted during its installation.

Capture usage

The Capture API is described in detail in the documentation.

The recommended way of using Capture is to use CaptureHelper.cs.

1 getting a CaptureHelper instance

CaptureHelper can be instantiated by doing a simple new allocation and the reference can be kept in a field of an object where Capture is needed.

2 CaptureHelper events subscription

An application can subscribe for various events but at minimum it should subcribe to the decoded data event in order to receive the decoded data read by the Socket Mobile device.

Other events such as the device arrival and device removal can be used to track the presence of a Socket Mobile device.

The terminate event can be used in order to track when Capture has been completely shutdown or when the Socket Mobile Companion service has been terminated.

3 Opening CaptureHelper

The API for starting Capture is the OpenAsync method that needs to be invoked with the application information retrieved from the Socket Mobile developer portal, after registering the application.

Once Capture is open, then the device arrival notification can occurs as soon as a scanner is connected to the Windows host.

Summary for integrating Capture in a Windows project is a simple 4 step process:

  1. Add SocketMobile.Capture NuGet into the application solution by selecting Package Manager for solution in the Tools menu NuGet Package Manager.

  2. Add using SocketMobile.Capture; in your application in the source where CaptureHelper should be instantiated.

  3. Subscribe for the Capture events the application is interested in.

  4. Initialize CaptureHelper by calling CaptureHelper OpenAsync method with the application information to start using Capture.

//1- add the SocketMobile Capture namespace
using SocketMobile.Capture;

public partial class Form1 : Form
{
    //2- Create a CaptureHelper member
    CaptureHelper mCapture;
    public Form1()
    {
        InitializeComponent();
        // 3- instantiate and configure CaptureHelper
        mCapture = new CaptureHelper();
        mCapture.ContextForEvents = WindowsFormsSynchronizationContext.Current;
        mCapture.DeviceArrival += mCapture_DeviceArrival;
        mCapture.DeviceRemoval += mCapture_DeviceRemoval;
        mCapture.DecodedData += mCapture_DecodedData;

        // this is to handle the case of the Socket Mobile Companion
        // being stopped for some reason
        mCapture.Terminate+= mCapture_Terminate;

        // 4- Start opening the connection to Socket Mobile Companion
        // which must be running, here it is done with a timer
        // because we restart this timer in case the Socket Mobile Companion
        // has been stopped
        timerOpenCapture.Tick += timerOpenCapture_Tick;
        timerOpenCapture.Start();
    }

    private async void timerOpenCapture_Tick(object sender, EventArgs e)
    {
        timerOpenCapture.Stop();

        long Result = await mCapture.OpenAsync("windows:com.socketmobile.singleentry",
            "BB57D8E1-F911-47BA-B510-693BE162686A",
            "MCwCFAJIzwgOK1fYEE5KdmPOe+Lm+5x6AhR6kYJKPLvEsh8TO7jaivECRe5C9A==");
        if (!SktErrors.SKTSUCCESS(Result))
        {
            labelVersion.Text = "Unable to connect to Socket Mobile Companion";
            DialogResult dialogResult = MessageBox.Show(
                "Unable to open Capture, is Socket Mobile Companion Service running?",
                "Error",
                MessageBoxButtons.RetryCancel,
                MessageBoxIcon.Warning);
            if (dialogResult == DialogResult.Retry)
            {
                timerOpenCapture.Start();
            }
            else
            {
                Close();
            }
        }
    }
}

CaptureHelper makes the application aware of a new device connection by invoking the device arrival event handler and, in the same way when a device disconnects, the device removal event handler is invoked.

A CaptureHelperDevice instance representing the device that is connected can be used to retrieve or set a device property.

If the scanner triggers a scan, the decoded data can be retrieved in the decoded data event handler.

Sample code

Sample code can be found in GitHub / SocketMobile

Configure and connect a Socket Mobile device

The Socket Mobile devices are shipped by default in Basic mode which is NOT compatible with the Capture SDK.

The device can be configured into the Application mode by using the "Help to connect" popup menu item from the Socket Mobile Companion.

You can also refer to the documentation for instructions without using Companion.

SUMMARY

For ALL user scenarios with the Socket Mobile device and any sample app or developed application with Capture support these steps MUST occur in order to be able to connect and communicate with the device:

  1. Make sure the Socket Mobile Companion is running by checking the present of the scanner icon in the tray bar.
  2. Setup the Socket Mobile device in Application mode
  3. Discover and pair the Socket Mobile device from the Bluetooth settings
  4. Verify Bluetooth connected state between Windows and the device by checking if the Socket Mobile Companion icon light up.

Capture SDK Version 1.0.513

Socket Mobile is a leading innovator of data capture and delivery solutions for enhanced productivity.

Capture SDK is the easiest solution for adding barcode scanning capability to a Windows application.

The Socket Mobile barcode scanner is an ergonomic, fast and accurate solution to a variety of data entry scenarios.

This SDK is very easy to integrate to an application without any requirement to follow a specific design architecture.

Integration into an application can be done in as little as 10 minutes!

More documentation can be found here.

Table of Contents

  • Quick install notes
  • Capture usage
  • Sample code
  • Configure and connect a Socket Mobile device

Quick install notes

The Capture SDK is available as NuGet package.

To install the SDK in an application, open the Manage NuGet Packages for Solution accessible through the Visual Studio Tools menu by selecting NuGet Package Manager.

A dialog displays a list of various NuGet sources. Make sure the Package source is set to either All or nuget.org. In the search box type SocketMobile.Capture to list the Socket Mobile Capture NuGet. Make sure to select SocketMobile.Capture.

An AppKey is required in order to use Capture SDK and can be generated by registering your application on Socket Mobile developer portal.

Our sample applications do not require any registration, they include a default AppKey.

IMPORTANT: Capture relies on the Socket Mobile Companion which is a service running in background. The Socket Mobile Companion can be downloaded here.

The Socket Mobile Companion requires at least ONE BLUETOOTH INBOUND port that is prompted during its installation.

Capture usage

The Capture API is described in detail in the documentation.

The recommended way of using Capture is to use CaptureHelper.cs.

1 getting a CaptureHelper instance

CaptureHelper can be instantiated by doing a simple new allocation and the reference can be kept in a field of an object where Capture is needed.

2 CaptureHelper events subscription

An application can subscribe for various events but at minimum it should subcribe to the decoded data event in order to receive the decoded data read by the Socket Mobile device.

Other events such as the device arrival and device removal can be used to track the presence of a Socket Mobile device.

The terminate event can be used in order to track when Capture has been completely shutdown or when the Socket Mobile Companion service has been terminated.

3 Opening CaptureHelper

The API for starting Capture is the OpenAsync method that needs to be invoked with the application information retrieved from the Socket Mobile developer portal, after registering the application.

Once Capture is open, then the device arrival notification can occurs as soon as a scanner is connected to the Windows host.

Summary for integrating Capture in a Windows project is a simple 4 step process:

  1. Add SocketMobile.Capture NuGet into the application solution by selecting Package Manager for solution in the Tools menu NuGet Package Manager.

  2. Add using SocketMobile.Capture; in your application in the source where CaptureHelper should be instantiated.

  3. Subscribe for the Capture events the application is interested in.

  4. Initialize CaptureHelper by calling CaptureHelper OpenAsync method with the application information to start using Capture.

//1- add the SocketMobile Capture namespace
using SocketMobile.Capture;

public partial class Form1 : Form
{
    //2- Create a CaptureHelper member
    CaptureHelper mCapture;
    public Form1()
    {
        InitializeComponent();
        // 3- instantiate and configure CaptureHelper
        mCapture = new CaptureHelper();
        mCapture.ContextForEvents = WindowsFormsSynchronizationContext.Current;
        mCapture.DeviceArrival += mCapture_DeviceArrival;
        mCapture.DeviceRemoval += mCapture_DeviceRemoval;
        mCapture.DecodedData += mCapture_DecodedData;

        // this is to handle the case of the Socket Mobile Companion
        // being stopped for some reason
        mCapture.Terminate+= mCapture_Terminate;

        // 4- Start opening the connection to Socket Mobile Companion
        // which must be running, here it is done with a timer
        // because we restart this timer in case the Socket Mobile Companion
        // has been stopped
        timerOpenCapture.Tick += timerOpenCapture_Tick;
        timerOpenCapture.Start();
    }

    private async void timerOpenCapture_Tick(object sender, EventArgs e)
    {
        timerOpenCapture.Stop();

        long Result = await mCapture.OpenAsync("windows:com.socketmobile.singleentry",
            "BB57D8E1-F911-47BA-B510-693BE162686A",
            "MCwCFAJIzwgOK1fYEE5KdmPOe+Lm+5x6AhR6kYJKPLvEsh8TO7jaivECRe5C9A==");
        if (!SktErrors.SKTSUCCESS(Result))
        {
            labelVersion.Text = "Unable to connect to Socket Mobile Companion";
            DialogResult dialogResult = MessageBox.Show(
                "Unable to open Capture, is Socket Mobile Companion Service running?",
                "Error",
                MessageBoxButtons.RetryCancel,
                MessageBoxIcon.Warning);
            if (dialogResult == DialogResult.Retry)
            {
                timerOpenCapture.Start();
            }
            else
            {
                Close();
            }
        }
    }
}

CaptureHelper makes the application aware of a new device connection by invoking the device arrival event handler and, in the same way when a device disconnects, the device removal event handler is invoked.

A CaptureHelperDevice instance representing the device that is connected can be used to retrieve or set a device property.

If the scanner triggers a scan, the decoded data can be retrieved in the decoded data event handler.

Sample code

Sample code can be found in GitHub / SocketMobile

Configure and connect a Socket Mobile device

The Socket Mobile devices are shipped by default in Basic mode which is NOT compatible with the Capture SDK.

The device can be configured into the Application mode by using the "Help to connect" popup menu item from the Socket Mobile Companion.

You can also refer to the documentation for instructions without using Companion.

SUMMARY

For ALL user scenarios with the Socket Mobile device and any sample app or developed application with Capture support these steps MUST occur in order to be able to connect and communicate with the device:

  1. Make sure the Socket Mobile Companion is running by checking the present of the scanner icon in the tray bar.
  2. Setup the Socket Mobile device in Application mode
  3. Discover and pair the Socket Mobile device from the Bluetooth settings
  4. Verify Bluetooth connected state between Windows and the device by checking if the Socket Mobile Companion icon light up.

Release Notes

First version of Capture SDK as NuGet

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.513.13 388 5/16/2019
1.0.475.552 1,504 1/4/2019
1.0.438.512 362 10/17/2018
1.0.396.477 241 10/4/2018
1.0.272.337 3,307 1/29/2018