com.unitech.lib.transport

## Class TransportBluetooth

- java.lang.Object
- - com.unitech.lib.transport.BaseTransport
  - - com.unitech.lib.transport.TransportBluetooth

-     public class TransportBluetooth
      extends BaseTransport

  The Transport class is a class for abstracting connections with Reader devices.

- - ### Field Summary

    - ### Fields inherited from class com.unitech.lib.transport.BaseTransport

      `_address, _byteQueue, _connState, _connType, _devName, _devType, _macAddress, DUMP, INFO, IO, TAG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TransportBluetooth()` Create an instance of the TransportBluetooth class
    `TransportBluetooth(DeviceType type, java.lang.String name, java.lang.String address)` Create an instance of the TransportBluetooth class

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()` Returns the length of data that can be read with the read method.
    `boolean` | `connect()` Attempts to connect to the appliance using an instance of the Transport class.
    `void` | `destroy()` Destroys the instance and returns the resource.
    `void` | `disconnect()` An instance of the Transport class closes the connection to the device to which the device is connected.
    `void` | `listen()` An instance of the BaseTransport class waits for the device to connect.
    `int` | `read(byte[] data, int offset, int length)` Read data received from the device.
    `int` | `read(byte[] data, int offset, int length, int timeout)` Read data received from the device.
    `int` | `write(byte[] data, int offset, int length)` Transfer data to the device.
    `int` | `write(byte[] data, int offset, int length, int timeout)` Transfer data to the device.

    - ### Methods inherited from class com.unitech.lib.transport.BaseTransport

      `checkBufferSize, getAddress, getConnectType, getDeviceName, getDeviceType, getMacAddress, getState, read, read, setAddress, setDeviceName, setDeviceType, setMacAddress, setState, setStateListener, toString, write, write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TransportBluetooth

          public TransportBluetooth()

      Create an instance of the TransportBluetooth class

    - #### TransportBluetooth

          public TransportBluetooth(DeviceType type,
                                    java.lang.String name,
                                    java.lang.String address)

      Create an instance of the TransportBluetooth class
      Parameters:
        `type` - A DeviceType enumeration that specifies the type of connected device using an instance of the TransportBluetooth class.
        `name` - A string that specifies the name of the connected device using an instance of the TransportBluetooth class.
        `address` - A string that specifies the address of the connected device by using an instance of the TransportBluetooth class.

  - ### Method Detail

    - #### destroy

          public void destroy()

      Description copied from class: `BaseTransport`
      Destroys the instance and returns the resource.
      Specified by:
        `destroy` in class `BaseTransport`

    - #### connect

          public boolean connect()

      Description copied from class: `BaseTransport`
      Attempts to connect to the appliance using an instance of the Transport class.
      Specified by:
        `connect` in class `BaseTransport`
      Returns:
        Returns true if the connection attempt with the device is successful, false if it fails.

    - #### listen

          public void listen()

      Description copied from class: `BaseTransport`
      An instance of the BaseTransport class waits for the device to connect.
      Specified by:
        `listen` in class `BaseTransport`

    - #### disconnect

          public void disconnect()

      Description copied from class: `BaseTransport`
      An instance of the Transport class closes the connection to the device to which the device is connected.
      Specified by:
        `disconnect` in class `BaseTransport`

    - #### write

          public int write(byte[] data,
                           int offset,
                           int length)

      Description copied from class: `BaseTransport`
      Transfer data to the device.
      Specified by:
        `write` in class `BaseTransport`
      Parameters:
        `data` - A byte array that specifies the data to transfer to the Device.
        `offset` - An integer indicating the start address of the data to be transferred to the Device.
        `length` - An integer indicating the length of the data to be transferred to the Device.
      Returns:
        Returns the length of the data transferred to the Device.

    - #### write

          public int write(byte[] data,
                           int offset,
                           int length,
                           int timeout)

      Description copied from class: `BaseTransport`
      Transfer data to the device.
      Specified by:
        `write` in class `BaseTransport`
      Parameters:
        `data` - A byte array that specifies the data to transfer to the Device.
        `offset` - An integer indicating the start address of the data to be transferred to the Device.
        `length` - An integer indicating the length of the data to be transferred to the Device.
        `timeout` - An integer specifying the timeout of data transmission to the device.
      Returns:
        Returns the length of the data transferred to the Device.

    - #### available

          public int available()

      Description copied from class: `BaseTransport`
      Returns the length of data that can be read with the read method.
      Specified by:
        `available` in class `BaseTransport`
      Returns:
        Returns the length of data received from the device.

    - #### read

          public int read(byte[] data,
                          int offset,
                          int length,
                          int timeout)

      Description copied from class: `BaseTransport`
      Read data received from the device.
      Specified by:
        `read` in class `BaseTransport`
      Parameters:
        `data` - A byte array to store the data received from the device.
        `offset` - Integer specifying the start address at which data received from device will begin to be stored in a byte array.
        `length` - An integer specifying the maximum length at which data received from the device can be stored in a byte array.
        `timeout` - An integer that specifies the timeout for reading data received from the device.
      Returns:
        Returns the length of data received from device and stored in a byte array.

    - #### read

          public int read(byte[] data,
                          int offset,
                          int length)

      Description copied from class: `BaseTransport`
      Read data received from the device.
      Specified by:
        `read` in class `BaseTransport`
      Parameters:
        `data` - A byte array to store the data received from the device.
        `offset` - Integer specifying the start address at which data received from device will begin to be stored in a byte array.
        `length` - An integer specifying the maximum length at which data received from the device can be stored in a byte array.
      Returns:
        Returns the length of data received from device and stored in a byte array.