Getnet DocsGetnet Docs

Connecting via USB (CreateUsb)

This guide explains how to establish a connection with an Integrated POS using the USB (serial) transport.

What is the USB connection

The USB connection model establishes a direct physical link between the automation system and the POS terminal using a serial interface. You call CreateUsb with the required parameters for your platform; the function returns a Connector instance that exposes the same device operation functions as HTTP connectors.

When to use the USB connection

Use a USB connection when:

  • The POS terminal is physically close to the automation system
  • Network connectivity is unavailable or restricted
  • A direct, point-to-point connection is required

USB provides a simple and deterministic channel but is sensitive to physical disconnection—if the cable is unplugged, the channel is lost and must be re-established.

If you use setupParams (Kotlin) or the Setup command (.NET) with the terminal, check the reconnection behavior sections in this documentation.

Before you begin

Before connecting via USB, ensure that:

  • The POS terminal is powered on and configured for Integrated POS Mode
  • The USB cable is properly connected between the POS and the automation system
  • The Integrated POS library is available in your application
  • The operating system recognizes the POS as a serial device (e.g. COM port on Windows, /dev/ttyACM0 on Linux)

Step 1: Create the USB Connector

Create a Connector using CreateUsb with the required parameter for your platform.

Parameters:

ParameterTypeRequiredDescriptionAvailability
addressstringYesThe local serial port address (e.g. Windows: COM1, COM3; Linux: /dev/ttyACM0)..NET
usbDeviceUsbDeviceYesAndroid device object for the USB connection.Kotlin
setupParamsHashMap<String, String>NoTerminal configuration (e.g. friendly name). See the reconnection flow section for details.Kotlin

Example — C#:

Connector connector = Connector.CreateUsb("COM3");

Example — Kotlin:

fun setupConnectorInstance(context: Context): POSIntegrado? {
    val usbManager = context.getSystemService(Context.USB_SERVICE) as UsbManager
    
    // Retrieve available device for USB connection
    val deviceList: List<UsbDevice> = usbManager.deviceList.map { it.value }
    
    // Select a available device
    val selectedDevice = deviceList.firstOrNull()
    
    val connectorInstance = if (selectedDevice != null) {
        POSIntegrado.createUsb(
            context = context,
            usbDevice = selectedDevice,
            setupParams = hashMapOf(
                SetupParameters.SELLER_FRIENDLY_NAME to "My Store"
            )
        )
    } else {
        null
    }
    
    return connectorInstance
}

When the call succeeds, a Connector instance is returned. The connection is initialized but the terminal has not yet been validated.

Step 2: Validate the terminal

Before executing any device operation, validate the terminal using Polling:

var pollingResult = connector.PollingAsync();

Proceed only if the Polling response indicates that the terminal is ready.

Step 3: Execute operations

Once validated, use the Connector to run device operations such as Sale, Refund, or GetReports. Only one operation can be processed at a time per Connector.

Step 4: Close the connection

After completing all operations, release the connection:

connector.Close();

The Connector instance becomes invalid after closure and cannot be reused.

Next steps