Bluetooth LE Devices

Bluetooth LE devices use Bluetooth Low Energy (Bluetooth LE) to communicate with the host device. Here are some BLE devices, D600, S550 and S370.

Discovering Bluetooth LE Devices

The Device Manager drives the Bluetooth LE experience and communication with the Socket Mobile Bluetooth LE based devices. To interact with the Device Manager register a handler to the Capture Helper event: DeviceManagerArrival.

Here is an example on how you can register this handle:

public MainPage()
{
    InitializeComponent();

    // initialize CaptureHelper
    capture = new CaptureHelper();

    // register for the Capture Helper events
    capture.DeviceManagerArrival += Capture_DeviceManagerArrival;

}

The Device Manager has a property called “favorite” to configure and identify the Bluetooth LE devices that needs to be discovered. Favorite can be a single value or a semi-colon separated list. It can be a combination of any of the following values:

Favorites

Value

Description

*

Discover and connect to the first available Bluetooth LE devices

Unique Device Identifier

Identifier for a specific Bluetooth LE devices

“”

Empty for when the app is not interested in Bluetooth LE devices

The “favorite” property can be set as follow:

private void Capture_DeviceManagerArrival(object sender, CaptureHelper.DeviceArgs e)
{
    e.CaptureDevice.SetFavoritesAsync("*");
}

Each value in the favorite list represents a Bluetooth LE device. To start the auto discovery for Bluetooth LE devices devices set favorite to a valid value. Auto discovery will stop if the number of devices represented in the favorite are connected.

If favorite is set to empty, auto discovery will not be triggered. Please note that setting favorite to empty, will not disconnect a already connected device. However if the device gets disconnected, then auto discovery will not start until favorite is set to a valid value.

Once a Bluetooth LE device is discovered, a connection is established. After this it can be used to read NFC cards or barcodes. To interact with the device, register a handlher to the Capture Helper event: DeviceArrival.:

public MainPage()
{
    InitializeComponent();

    // initialize CaptureHelper
    capture = new CaptureHelper();

    // register for the Capture Helper events
    capture.DeviceArrival += Capture_DeviceArrival;

}

Manual Discovery

This feature lists all the Bluetooth LE devices available in the vicinity by running the discovery process for a specified time. To trigger a manual discovery, use the StartDeviceDiscoveryAsync(duration) along with the duration in milliseconds. Manual discovery runs for the specified duration and sends a DeviceDiscoveryEvent each time a Socket Mobile Bluetooth LE device is discovered. Discovery stops automatically once the duration in milliseconds has been reached.:

private void Capture_DeviceArrival(object sender, CaptureHelper.DeviceArgs e)
{
    e.CaptureDevice.StartDeviceDiscoveryAsync(1000);
}

To receive the list of the discovered devices, register a handler to the Capture Helper event: DeviceDiscovered.:

public MainPage()
{
    InitializeComponent();

    // initialize CaptureHelper
    capture = new CaptureHelper();

    // register for the Capture Helper events
    capture.DeviceDiscovered += Capture_DeviceDiscovered;

}

Reading Data

Once the connection is established successfully, data read from the device (NFC card. Smartphone wallet card, or Barcode) can be received by registering a handler to the Capture Helper event: DecodedData.:

public MainPage()
{
    InitializeComponent();

    // initialize CaptureHelper
    capture = new CaptureHelper();

    // register for the Capture Helper events
    capture.DecodedData += Capture_DecodedData;

}