public class UsbConnection extends ConnectionA implements com.zebra.sdk.comm.internal.ConnectionI
Constructor and Description |
---|
UsbConnection(android.hardware.usb.UsbManager manager,
android.hardware.usb.UsbDevice device)
Creates a new UsbConnection.
|
UsbConnection(android.hardware.usb.UsbManager manager,
android.hardware.usb.UsbDevice device,
int maxTimeoutForRead,
int timeToWaitForMoreData)
Creates a new UsbConnection.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<String,String> |
getConnectionAttributes()
For internal use of the Zebra Printer API only.
|
ConnectionReestablisher |
getConnectionReestablisher(long thresholdTime)
Returns a
ConnectionReestablisher which allows for easy recreation of a connection which may have
been closed. |
String |
getDeviceName()
Returns the USB device name.
|
android.hardware.usb.UsbManager |
getManager()
Returns the UsbManager object.
|
String |
getManufacturer()
Returns the printer's manufacturer.
|
UsbPermissionRequestor |
getRequestor()
Gets the @see com.zebra.sdk.comm.UsbPermissionRequestor instance.
|
String |
getSerialNumber()
Returns the serial number of the printer.
|
String |
getSimpleConnectionName()
Return the device name as the description.
|
byte[] |
read(int maxBytesToRead)
Reads
maxBytesToRead of the available data from the connection. |
void |
setRequestor(UsbPermissionRequestor requestor)
Sets the @see com.zebra.sdk.comm.UsbPermissionRequestor instance.
|
String |
toString()
Returns
USB :[Device path]The USB device name is obtained from the device when this connection is opened. |
void |
write(byte[] data,
int offset,
int length)
Writes
length bytes from data starting at offset . |
addWriteLogStream, bytesAvailable, close, getMaxDataToWrite, getMaxTimeoutForRead, getTimeToWaitForMoreData, isConnected, open, read, read, read, readChar, sendAndWaitForResponse, sendAndWaitForResponse, sendAndWaitForValidResponse, sendAndWaitForValidResponse, setMaxDataToWrite, setMaxTimeoutForRead, setReadTimeout, setTimeToWaitForMoreData, waitForData, write, write
getMaxDataToWrite, read, setMaxDataToWrite, setReadTimeout
bytesAvailable, close, getMaxTimeoutForRead, getTimeToWaitForMoreData, isConnected, open, read, read, readChar, sendAndWaitForResponse, sendAndWaitForResponse, sendAndWaitForValidResponse, sendAndWaitForValidResponse, setMaxTimeoutForRead, setTimeToWaitForMoreData, waitForData, write, write
public UsbConnection(android.hardware.usb.UsbManager manager, android.hardware.usb.UsbDevice device)
manager
- The UsbManager object used to create this UsbConnection.device
- The UsbDevice object.public UsbConnection(android.hardware.usb.UsbManager manager, android.hardware.usb.UsbDevice device, int maxTimeoutForRead, int timeToWaitForMoreData)
manager
- The UsbManager object used to create this UsbConnection.device
- The UsbDevice object.maxTimeoutForRead
- Maximum time to wait for read data.timeToWaitForMoreData
- Maximum time to wait for more data after initial data is sent from printer.public android.hardware.usb.UsbManager getManager()
public String getDeviceName()
public String toString()
USB
:[Device path]toString
in interface Connection
toString
in class Object
Connection.toString()
public String getSimpleConnectionName()
getSimpleConnectionName
in interface Connection
Connection.getSimpleConnectionName()
public ConnectionReestablisher getConnectionReestablisher(long thresholdTime) throws ConnectionException
Connection
ConnectionReestablisher
which allows for easy recreation of a connection which may have
been closed.
getConnectionReestablisher
in interface Connection
getConnectionReestablisher
in class ConnectionA
thresholdTime
- how long the Connection reestablisher will wait before attempting to reconnection to the
printerConnectionException
- if the ConnectionReestablisher could not be created.ConnectionA.getConnectionReestablisher(long thresholdTime)
public UsbPermissionRequestor getRequestor()
public void setRequestor(UsbPermissionRequestor requestor)
requestor
- The UsbPermissionRequestor object.public String getManufacturer()
ConnectionA
getManufacturer
in interface com.zebra.sdk.comm.internal.ConnectionI
getManufacturer
in class ConnectionA
ConnectionA.getManufacturer()
public String getSerialNumber()
public byte[] read(int maxBytesToRead) throws ConnectionException
ConnectionA
maxBytesToRead
of the available data from the connection. This call is non-blocking.read
in interface com.zebra.sdk.comm.internal.ConnectionI
read
in class ConnectionA
maxBytesToRead
- number of bytes to readConnectionException
- if an I/O error occurs.ConnectionA.read(int)
public void write(byte[] data, int offset, int length) throws ConnectionException
Connection
length
bytes from data
starting at offset
. The connection must be
open before this method is called. If write
is called when a connection is closed, a
ConnectionException
is thrown.write
in interface Connection
write
in class ConnectionA
data
- the data.offset
- the start offset in the data
.length
- number of bytes to write.ConnectionException
- if an I/O error occurs.ConnectionA.write(byte[], int, int)
public java.util.Map<String,String> getConnectionAttributes()
© 2017 ZIH Corp. All Rights Reserved.