Select your printer model

Parameters are refined by the selected printer.

connect


Starts communication with the printer.

Syntax

 
Public void connect(String target, int timeout) throws Epos2Exception

Parameter

target

Specifies the method of connecting to the printer by a character string.

The connection method varies according to the system configuration.

  • TM Printer Models
  • <connection type>:<identifier>

    I/F

    Connection type

    Identifier

    Example

    Wi-Fi/Ethernet

    "TCP"

    • IP address in IPv4 format
    • MAC address
    • Host name
     
    "TCP:192.168.192.168"
    

    Bluetooth

    "BT"

    BD address

     
    "BT:00:22:15:7D:70:9C"
    

    USB

    "USB"

    • Device node
    • USB Serial number
    • Omitted
     
    "USB:/dev/udev/*"
    "USB:000000000000000000"
    "USB:"
    

  • Customer Display Models
  • <connection type>:<identifier>

    I/F

    Connection type

    Identifier

    Example

    Wi-Fi/Ethernet

    "TCP"

    • IP address in IPv4 format
    • MAC address
    • Host name
     
    "TCP:192.168.192.168"
    

    Bluetooth

    "BT"

    BD address

     
    "BT:00:22:15:7D:70:9C"
    

    USB

    "USB"

    • Device node
    • USB Serial number
    • Omitted
     
    "USB:/dev/udev/*"
    "USB:000000000000000000"
    "USB:"
    

    To connect to the printer via SSL/TLS communication, specify using the following syntax.

    <connection type>:<identifier>[<device ID>]

    I/F

    Connection type

    Identifier

    Example

    Wi-Fi/Ethernet

    "TCPS"

    • IP address in IPv4 format
    • MAC address
    • Host name
     
    "TCPS:192.168.192.168[local_printer]"
    
  • TM Printer + DM-D + barcode scanner model/
    TM Printer + barcode scanner model
  • To connect via Wi-Fi/Ethernet network communication, specify using the following syntax.

    <connection type>:<identifier>[<device ID>]

    I/F

    Connection type

    Identifier

    Example

    Wi-Fi/Ethernet

    "TCP"

    • IP address in IPv4 format
    • MAC address
    • Host name
     
    "TCP:192.168.192.168[local_printer]"
    

    The device ID is fixed as [local_printer].

    To connect via Bluetooth or USB, specify using the following syntax.

    <connection type>:<identifier>

    I/F

    Connection type

    Identifier

    Example

    Bluetooth

    "BT"

    BD address

     
    "BT:00:22:15:7D:70:9C"
    

    USB

    "USB"

    • Device node
    • USB Serial number
    • Omitted
     
    "USB:/dev/udev/*"
    "USB:000000000000000000"
    "USB:"
    

  • POS Terminal Model
  • <connection type>:<identifier>[<device ID>]

    I/F

    Connection type

    Identifier

    Example

    Wi-Fi/Ethernet

    • "TCP"
    • "TCPS"
    • IP address in IPv4 format
    • MAC address
    • Host name
     
    "TCP:192.168.192.168[local_printer]"
    

    To connect to the printer via SSL/TLS communication, specify TCPS in the connection type.

timeout

Specifies the maximum time (in milliseconds) to wait for communication with the printer to be established.

Value

Description

Integer from 1000 to 300000

Maximum wait time before an error is returned (in milliseconds).

Print.PARAM_DEFAULT

Specifies the default value (15000).

Exception

When the process fails, Epos2Exception with one of the following error value occurs.

Error status

Description

ERR_PARAM

An invalid parameter was passed.

ERR_CONNECT

Failed to open the device.

ERR_TIMEOUT

Failed to communicate with the devices within the specified time.

ERR_ILLEGAL

Tried to start communication with a printer with which communication had been already established.

Tried to start communication with a printer during reconnection process.

ERR_MEMORY

Necessary memory could not be allocated.

ERR_FAILURE

An unknown error occurred.

ERR_PROCESSING

Could not run the process.

ERR_NOT_FOUND

The device could not be found.

ERR_IN_USE

The device was in use.

ERR_TYPE_INVALID

The device type is different.

ERR_RECOVERY_FAILURE

Failed to recover the printer.

Supplementary explanation

  • This API is not executed on the main thread. Execute it on the sub-thread.
  • When communication with the printer is no longer necessary, be sure to call disconnect to terminate it.
  • When using multi-threading to connect to multiple printers or peripheral devices, this API and disconnect cannot be started for other printers or peripheral devices until this API finishes processing. Start the next process after this API finishes processing.
  • The printer status is returned to the event registered with the Printer class.
    For details, refer to Epson ePOS SDK for Android User's Manual"
  • The device ID is an arbitrary character string that is set when the peripheral device is registered to the TM printer (master).
    For details, refer to the Technical Reference Guide of each printer.
  • If you are using DHCP to assign the IP address of the printer, specify the MAC address or host name of the printer as the identifier.
  • If you specify the host name of the printer as the identifier, use in the environment where it can be found by the DNS server.
  • When connecting through the USB, the identifiers that can be specified differ depending on the shape of the USB connector.
    When the identifier is omitted, Android OS connects with the USB device found first.
    When the Android terminal is set to the developer mode, you may not be able to connect through USB-A - Device Charging.
  • Identifier

    Shape of the USB connector

    USB-B

    USB-A - Device Charging

    Device node

    -

    USB Serial number

    -

    Omitted

  • This API will succeed regardless of the connection status of the TM printer (master) and peripheral devices.
  • Devices other than printers are exclusively locked.
  • If Epos2Exception including ERR_RECOVERY_FAILURE occurs, restart the printer.
 

Quick Access

  • [Name]
  • [Format]
  • [Range]
  • [Description]
  • [Notes]

Epson ePOS SDK includes patented or patent pending functions. The contents must not be disclosed to third parties.


Epson ePOS SDK for Android

Jump to the top