SocketMobile.Capture
1.0.475.552
See the version list below for details.
dotnet add package SocketMobile.Capture --version 1.0.475.552
NuGet\Install-Package SocketMobile.Capture -Version 1.0.475.552
<PackageReference Include="SocketMobile.Capture" Version="1.0.475.552" />
paket add SocketMobile.Capture --version 1.0.475.552
#r "nuget: SocketMobile.Capture, 1.0.475.552"
// Install SocketMobile.Capture as a Cake Addin #addin nuget:?package=SocketMobile.Capture&version=1.0.475.552 // Install SocketMobile.Capture as a Cake Tool #tool nuget:?package=SocketMobile.Capture&version=1.0.475.552
Capture SDK Version 1.0.475.552
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:
Add
SocketMobile.Capture
NuGet into the application solution by selecting Package Manager for solution in the Tools menu NuGet Package Manager.Add
using SocketMobile.Capture;
in your application in the source where CaptureHelper should be instantiated.Subscribe for the Capture events the application is interested in.
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:
- Make sure the Socket Mobile Companion is running by checking the present of the scanner icon in the tray bar.
- Setup the Socket Mobile device in Application mode
- Discover and pair the Socket Mobile device from the Bluetooth settings
- Verify Bluetooth connected state between Windows and the device by checking if the Socket Mobile Companion icon light up.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
MonoAndroid | monoandroid10 is compatible. |
-
.NETFramework 4.5
- Newtonsoft.Json (>= 9.0.1)
-
MonoAndroid 1.0
- Newtonsoft.Json (>= 9.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.7.34.67 | 154 | 11/20/2024 |
1.5.139.360 | 136 | 10/4/2024 |
1.5.125.744 | 158 | 8/26/2024 |
1.5.40.754 | 176 | 5/21/2024 |
1.5.16.891 | 751 | 3/25/2024 |
1.5.7.434 | 704 | 2/26/2024 |
1.5.2.256 | 1,602 | 2/14/2024 |
1.5.0.248 | 152 | 2/14/2024 |
1.4.17.146 | 1,602 | 11/29/2023 |
1.4.8.28 | 674 | 11/11/2023 |
1.3.77.946 | 5,609 | 11/14/2022 |
1.3.10.386 | 2,850 | 10/4/2022 |
1.0.513.13 | 16,850 | 5/16/2019 |
1.0.475.552 | 4,008 | 1/4/2019 |
1.0.438.512 | 1,050 | 10/17/2018 |
1.0.396.477 | 883 | 10/4/2018 |
1.0.272.337 | 4,648 | 1/29/2018 |
First version of Capture SDK as NuGet