public interface Connecter
| Modifier and Type | Field and Description |
|---|---|
static int |
FAIL
失败状态。用于表示发送、连接等状态码
|
static int |
NOT_PERMISSION
没有权限访问
|
static int |
NOT_SUPPORT
不支持
|
static int |
STATE_CONNECTED
已连接
|
static int |
STATE_CONNECTING
连接中
|
static int |
STATE_LISTEN
监听状态
|
static int |
STATE_NONE |
static int |
SUCCESS
成功状态。用于表示发送、连接等状态码
|
| Modifier and Type | Method and Description |
|---|---|
int |
close()
关闭连接
|
int |
connect()
打开连接
|
int |
connect(int pid,
int vid)
打开连接
|
void |
connect(Observer observer)
打开连接
|
boolean |
isConnected()
连接状态
|
int |
read(byte[] buffer,
int time)
读取数据
|
int |
read(byte[] buffer,
int offset,
int len,
int time)
读取数据
|
boolean |
write(byte[] bytes,
int timeout)
写数据
|
boolean |
write(byte[] bytes,
int offset,
int len,
int timeout)
写数据
|
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 - 连接异常STATE_NONE,
STATE_LISTEN,
STATE_CONNECTING,
STATE_CONNECTED,
NOT_PERMISSION,
NOT_SUPPORTvoid connect(Observer observer)
observer - 连接状况int connect(int pid,
int vid)
throws IOException
pid - usb product idvid - usb vendor idIOException - 连接异常int close()
int read(@Nullable
byte[] buffer,
int time)
throws IOException
buffer - 存放从打印机中读取数据的缓存区域time - 等待时间,单位:毫秒(ms)IOException - 读取数据异常int read(@Nullable
byte[] buffer,
int offset,
int len,
int time)
throws IOException
buffer - 存放从打印机中读取数据的缓存区域offset - 缓存数据偏移量(默认为0)time - 等待时间,单位:毫秒(ms)IOException - 读取数据异常boolean write(@Nullable
byte[] bytes,
int timeout)
throws IOException
bytes - 发送到打印机的数据timeout - 发送超时时间,单位:毫秒(ms)IOException - 发送数据异常boolean write(@Nullable
byte[] bytes,
int offset,
int len,
int timeout)
throws IOException
bytes - 发送到打印机的数据offset - 偏移量len - 发送的数据长度timeout - 发送超时时间,单位:毫秒(ms)IOException - 发送数据异常