Connecting a Socket Mobile Device

Socket Mobile Companion

The easiest way to connect a Socket Mobile Device to a host independently of a Capture enabled app is to use the Socket Mobile Companion app.

Socket Mobile Companion for iOS can be found on the App Store, and for Android on Play Store .

Connecting with a Socket Mobile barcode scanner

The Socket Mobile barcode scanners use Bluetooth for connecting to the host.

For an Android host, Socket Mobile Companion takes care of all the details to connect and pair to a Socket Mobile scanner.

For iOS host, the application needs to be configured with some specific settings that include an External Accessory Protocol String and some Privacy Bluetooth Description strings.

The application is aware when the scanner is connected and ready to be used when it receives the DeviceArrival notification.

Configuring Contactless NFC Reader/Writer D600 and S550

The Socket Mobile Contactless NFC Reader/Writer D600 <https://www.logiscenter.us/cx3384-1777-d600-contactless-reader-writer>, S550 <https://www.logiscenter.us/socket-tx3867-2902-scanner> and S370 are using Bluetooth Low Energy (Bluetooth LE) for connecting to the host.

The iOS platform fully supports both Socket Mobile NFC devices. Android currently supports the S550.

The BluetoothLE experience is handled by a Capture Device Manager. Following the same logic as for any other device, Capture will send a DeviceManagerArrival when BluetoothLE is supported.

The BluetoothLE connection process use a Capture Auto Discovery mechanism that is enabled as soon as the Capture BluetoothLE Device Manager Favorite contains either a “*” (star) character or a Unique Device UUID.

In the case of the favorite containing a “*”, the BluetoothLE Capture Device Manager will discover and connect to the first Socket Mobile it finds.

In the case of the favorite containing a Unique device UUID, the BluetoothLE Capture Device Manager will search and connect to the corresponding Socket Mobile Contactless NFC Reader/Writer.

Once a Socket Mobile Contactless NFC Reader/Writer is connected to the host, Capture sends a Device Arrival notification as for any other device.

BLE Device Manager onCaptureEvent Sample Code

You can check for the BLE Device Manager in the onCaptureEvent callback like you would any other capture event. See below. .. code-block::javascript

case CaptureEventIds.DeviceManagerArrival:

const newBleDeviceManager = new CaptureRn(); let {name, guid, type} = e.value; //where ‘e’ is the capture event that is registered in the onCaptureEvent function. dev.openDevice(guid, capture)

.then((result) => {

setStatus(result of opening ${name} : ${result}); setBleDeviceManagerCapture(dev); getFavorite(dev);

})

break;

case CaptureEventIds.DeviceManagerRemoval:

setBleDeviceManagerCapture(null); break;

As you can see, we use the same :code-block:`openDevice` method that we would use for a regular device arrival. Once we have opened the BLE Device Manager, we can now try to get any favorites using :code-block:`getFavorite`. See below. .. code-block::javascript

const getFavorite = async (dev) => {
var property = new CaptureProperty(

CapturePropertyIds.Favorite, CapturePropertyTypes.None, {},

); try {

let favorite = await dev.getProperty(property); setStatus(‘retrieving BLE Device Manager favorite… ‘); if (favorite.value.length === 0) {

setFavorite(dev);

} else {

setStatus(‘Favorite found! Try using an NFC reader!’);

}

} catch (err) {

setStatus(failed to get favorite: ${err.code} : ${err.message});

}

};

Here we are making sure we have a favorite and if we do we can then be ready to pair with the closest NFC device. If our favorite’s value is empty, then we will need to set a favorite to ensure we can connect with NFC devices. To do this, we will make use of :code-block:`setProperty` in our function called :code-block:`setFavorite`. See below.

Once we are able to set the favorite, our app should be ready to connect with NFC devices nearby.

Note

A Device Manager Arrival is required in order to open a Device Manager and to be able to set or get its favorite. Such notification is only sent on the host supporting BluetoothLE and with Capture supporting at least one of the Socket Mobile Contactless NFC Reader/Writers.