本文整理了Java中com.zsmartsystems.zigbee.transport.ZigBeePort
类的一些代码示例,展示了ZigBeePort
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZigBeePort
类的具体详情如下:
包路径:com.zsmartsystems.zigbee.transport.ZigBeePort
类名称:ZigBeePort
[英]Interface for a generic port used for the ZigBee API. The stack will call the interface to #open and #close the port, and to read and write data.
[中]用于ZigBee API的通用端口的接口。堆栈将调用接口#打开和#关闭端口,并读取和写入数据。
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Opens connection to ZigBee Network.
*
* @return true if connection startup was success.
*/
@Override
public boolean open() {
if (!port.open()) {
return false;
}
parser = new ZToolPacketParser(port, this);
return true;
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
int val = serialPort.read();
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Send raw bytes to output stream.
*
* @param packet the byte buffer
* @throws IOException if IO exception occurs when writing or flushing bytes.
*/
@Override
public void sendRaw(int[] packet) throws IOException {
synchronized (port) {
for (int i = 0; i < packet.length; i++) {
port.write(packet[i]);
}
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void shutdown() {
if (conbeeHandler == null) {
return;
}
conbeeHandler.setClosing();
zigbeeNetworkReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
serialPort.close();
conbeeHandler.close();
logger.debug("ConBee dongle shutdown.");
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Closes connection to ZigBee Network.
*/
@Override
public void close() {
synchronized (port) {
if (parser != null) {
parser.setClosing();
}
if (port != null) {
port.close();
}
if (parser != null) {
parser.close();
}
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
while (!close) {
try {
int val = port.read();
if (val == ZToolPacket.START_BYTE) {
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
if (!serialPort.open()) {
logger.error("Unable to open ConBee serial port");
return ZigBeeStatus.COMMUNICATION_ERROR;
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
serialPort.write(SLIP_END);
case SLIP_END:
serialPort.write(SLIP_ESC);
serialPort.write(SLIP_ESC_END);
break;
case SLIP_ESC:
serialPort.write(SLIP_ESC);
serialPort.write(SLIP_ESC_ESC);
break;
default:
serialPort.write(val);
break;
serialPort.write(SLIP_END);
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* TODO implement as class that extends inputstream?
* <p/>
* This method reads bytes from the underlying input stream and performs the following tasks: keeps track of how
* many bytes we've read, un-escapes bytes if necessary and verifies the checksum.
*/
@Override
public int read() throws IOException {
int b = port.read();
if (b == -1) {
throw new ZToolParseException("Read -1 from input stream while reading packet!");
}
bytesRead++;
// when verifying checksum you must add the checksum that we are verifying
// when computing checksum, do not include start byte; when verifying, include checksum
checksum.addByte(b);
// log.debug("Read byte " + ByteUtils.formatByte(b) + " at position " + bytesRead + ", data length is " +
// this.length.getLength() + ", #escapeBytes is " + escapeBytes + ", remaining bytes is " +
// this.getRemainingBytes());
if (this.getFrameDataBytesRead() >= (length + 1)) {
// this is checksum and final byte of packet
done = true;
// log.debug("Checksum byte is " + b);
/*
* if (!checksum.verify()) {/////////////Maybe expected in ZTool is 0x00, not FF//////////////////// throw
* new ZToolParseException("Checksum is incorrect. Expected 0xff, but got " + checksum.getChecksum()); }
*/
}
return b;
}
内容来源于网络,如有侵权,请联系作者删除!