public interface Connecter
Modifier and Type | Field and Description |
---|---|
static int |
FAIL
Failure status.
|
static int |
NOT_PERMISSION
No access
|
static int |
NOT_SUPPORT
Not support
|
static int |
STATE_CONNECTED
Connected state
|
static int |
STATE_CONNECTING
Connecting state
|
static int |
STATE_LISTEN
Listening state
|
static int |
STATE_NONE |
static int |
SUCCESS
Success status.
|
Modifier and Type | Method and Description |
---|---|
int |
close()
Disconnect
|
int |
connect()
Open a connection
|
int |
connect(int pid,
int vid)
Open a connection
|
void |
connect(Observer observer)
Open a connection
|
boolean |
isConnected()
Connection state
|
int |
read(byte[] buffer,
int time)
Receive data
|
int |
read(byte[] buffer,
int offset,
int len,
int time)
Receive data
|
boolean |
write(byte[] bytes,
int timeout)
Writing data
|
boolean |
write(byte[] bytes,
int offset,
int len,
int timeout)
Writing data
|
static final int STATE_NONE
static final int STATE_LISTEN
static final int STATE_CONNECTING
static final int STATE_CONNECTED
static final int NOT_SUPPORT
static final int NOT_PERMISSION
static final int SUCCESS
static final int FAIL
boolean isConnected()
int connect() throws IOException
IOException
- Connecting exception.STATE_NONE
,
STATE_LISTEN
,
STATE_CONNECTING
,
STATE_CONNECTED
,
NOT_PERMISSION
,
NOT_SUPPORT
void connect(Observer observer)
observer
- Connect state block.int connect(int pid, int vid) throws IOException
pid
- Usb product id.vid
- Usb vendor id.IOException
- Connecting exception.STATE_NONE
,
STATE_CONNECTED
int close()
int read(@Nullable byte[] buffer, int time) throws IOException
buffer
- Cache area for reading data from the printer.time
- Waiting time in milliseconds (MS).IOException
- Receive data exception.int read(@Nullable byte[] buffer, int offset, int len, int time) throws IOException
buffer
- Cache area for reading data from the printer.offset
- Cache data offset.time
- Waiting time in milliseconds (MS).IOException
- Receive data exception.boolean write(@Nullable byte[] bytes, int timeout) throws IOException
bytes
- Data sent to printer.timeout
- Send timeout in milliseconds (MS).IOException
- Sending data exception.boolean write(@Nullable byte[] bytes, int offset, int len, int timeout) throws IOException
bytes
- Data sent to printer.offset
- The start offset in the data.len
- The number of bytes to write.timeout
- Send timeout in milliseconds (MS).IOException
- Sending data exception.