本文整理汇总了Java中com.rapplogic.xbee.api.zigbee.ZNetRxResponse类的典型用法代码示例。如果您正苦于以下问题:Java ZNetRxResponse类的具体用法?Java ZNetRxResponse怎么用?Java ZNetRxResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZNetRxResponse类属于com.rapplogic.xbee.api.zigbee包,在下文中一共展示了ZNetRxResponse类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processResponse
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
public void processResponse(XBeeResponse response)
{
if (response.getApiId() == ApiId.ZNET_RX_RESPONSE)
{
ZNetRxResponse rx = (ZNetRxResponse) response;
XBeeAddress64 addr = rx.getRemoteAddress64();
int[] payload = rx.getData();
switch (payload[0]) {
case 2:
log.debug("Adding ID: " + payload[1] + " to address " + addr);
chessbots.add(addr, (Integer) payload[1]);
break;
}
chessbots.updateMessageReceived(addr, rx);
}
}
示例2: processResponse
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
public void processResponse(XBeeResponse response)
{
if (response.getApiId() == ApiId.ZNET_RX_RESPONSE)
{
ZNetRxResponse rx = (ZNetRxResponse) response;
XBeeAddress64 addr = rx.getRemoteAddress64();
int[] payload = rx.getData();
if(payload[0] == 2)
{
botAddresses.set(payload[1], addr);
log.debug(rx);
}
}
}
示例3: updateMessageReceived
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
public void updateMessageReceived(XBeeAddress64 addr, ZNetRxResponse msg) {
ChessbotInfo chessbotInfo = getChessbotInfoFromAddress(addr);
int chessbotInfoIndex = chessbotArr.indexOf(chessbotInfo);
chessbotInfo.setLastTimeCommunicated(new Date());
chessbotInfo.setLastMessageReceived(msg);
chessbotArr.set(chessbotInfoIndex, chessbotInfo);
updated = true;
}
示例4: processResponse
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
@Override
public void processResponse(XBeeResponse response) {
if (response.getApiId() == ApiId.ZNET_RX_RESPONSE) {
final ZNetRxResponse rxResponse = (ZNetRxResponse) response;
final String message = ByteUtils.toString(rxResponse.getData());
final String remoteAddress = FormatUtil.readableAddress(rxResponse.getRemoteAddress64().getAddress());
processResponse(message, remoteAddress);
}
}
示例5: ZNetReceiverExample
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
private ZNetReceiverExample() throws Exception {
XBee xbee = new XBee();
try {
// replace with the com port of your receiving XBee (typically your end device)
// router
xbee.open("/dev/tty.usbserial-A6005uPi", 9600);
while (true) {
try {
// we wait here until a packet is received.
XBeeResponse response = xbee.getResponse();
log.info("received response " + response.toString());
if (response.getApiId() == ApiId.ZNET_RX_RESPONSE) {
// we received a packet from ZNetSenderTest.java
ZNetRxResponse rx = (ZNetRxResponse) response;
log.info("Received RX packet, option is " + rx.getOption() + ", sender 64 address is " + ByteUtils.toBase16(rx.getRemoteAddress64().getAddress()) + ", remote 16-bit address is " + ByteUtils.toBase16(rx.getRemoteAddress16().getAddress()) + ", data is " + ByteUtils.toBase16(rx.getData()));
// optionally we may want to get the signal strength (RSSI) of the last hop.
// keep in mind if you have routers in your network, this will be the signal of the last hop.
AtCommand at = new AtCommand("DB");
xbee.sendAsynchronous(at);
XBeeResponse atResponse = xbee.getResponse();
if (atResponse.getApiId() == ApiId.AT_RESPONSE) {
// remember rssi is a negative db value
log.info("RSSI of last response is " + -((AtCommandResponse)atResponse).getValue()[0]);
} else {
// we didn't get an AT response
log.info("expected RSSI, but received " + atResponse.toString());
}
} else {
log.debug("received unexpected packet " + response.toString());
}
} catch (Exception e) {
log.error(e);
}
}
} finally {
if (xbee != null && xbee.isConnected()) {
xbee.close();
}
}
}
示例6: open
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
@Override
protected void open(final Map<String, Object> context) throws Exception {
if (context.get("connectionType") instanceof LocalConnection) {
LocalConnection localConnection = (LocalConnection) context.get("connectionType");
xbee.open((String) localConnection.getSerialPort(), localConnection.getBaudRate());
} else {
SerialServerConnection ser = (SerialServerConnection) context.get("connectionType");
xbee.initProviderConnection((XBeeConnection)new SocketXBeeConnection(ser.getHost(), ser.getPort()));
}
final boolean verbose = (Boolean) context.get("verbose");
xbee.addPacketListener(new PacketListener() {
@Override
public void processResponse(XBeeResponse response) {
if (response.getApiId() == ApiId.ZNET_RX_RESPONSE || response.getApiId() == ApiId.RX_64_RESPONSE) {
if (verbose) {
System.out.println("Received rx packet from arduino " + response);
}
if (response.getApiId() == ApiId.ZNET_RX_RESPONSE) {
ZNetRxResponse zb = (ZNetRxResponse) response;
if (zb.getData()[0] == MAGIC_BYTE1 && zb.getData()[1] == MAGIC_BYTE2) {
addReply(zb.getData());
} else {
System.out.println("Ignoring non-programming packet " + zb);
}
} else {
RxResponse rx64 = (RxResponse64) response;
if (rx64.getData()[0] == MAGIC_BYTE1 && rx64.getData()[1] == MAGIC_BYTE2) {
addReply(rx64.getData());
} else {
System.out.println("Ignoring non-programming packet " + rx64);
}
}
} else if (response.getApiId() == ApiId.ZNET_TX_STATUS_RESPONSE) {
ZNetTxStatusResponse zNetTxStatusResponse = (ZNetTxStatusResponse) response;
if (zNetTxStatusResponse.isSuccess()) {
// yay
} else {
// interrupt thread in case it's waiting for ack, which will never come
System.out.println("Failed to deliver packet. Interrupting main thread. Response: " + response);
interrupt();
}
} else if (response.getApiId() == ApiId.TX_STATUS_RESPONSE) {
TxStatusResponse txStatusResponse = (TxStatusResponse) response;
if (txStatusResponse.isSuccess()) {
// yay
} else {
// interrupt thread in case it's waiting for ack, which will never come
System.out.println("Failed to deliver packet. Interrupting main thread. Response: " + response);
interrupt();
}
}
}
});
}
示例7: ZNetReceiverExample
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
private ZNetReceiverExample() throws Exception {
XBee xbee = new XBee();
try {
// replace with the com port of your receiving XBee (typically your end device)
// router
xbee.open("/dev/tty.usbserial-A6005uPi", 9600);
while (true) {
try {
// we wait here until a packet is received.
XBeeResponse response = xbee.getResponse();
log.info("received response " + response.toString());
if (response.getApiId() == ApiId.ZNET_RX_RESPONSE) {
// we received a packet from ZNetSenderTest.java
ZNetRxResponse rx = (ZNetRxResponse) response;
log.info("Received RX packet, option is " + rx.getOption() + ", sender 64 address is " + ByteUtils.toBase16(rx.getRemoteAddress64().getAddress()) + ", remote 16-bit address is " + ByteUtils.toBase16(rx.getRemoteAddress16().getAddress()) + ", data is " + ByteUtils.toBase16(rx.getData()));
// optionally we may want to get the signal strength (RSSI) of the last hop.
// keep in mind if you have routers in your network, this will be the signal of the last hop.
AtCommand at = new AtCommand("DB");
xbee.sendAsynchronous(at);
XBeeResponse atResponse = xbee.getResponse();
if (atResponse.getApiId() == ApiId.AT_RESPONSE) {
// remember rssi is a negative db value
log.info("RSSI of last response is " + -((AtCommandResponse)atResponse).getValue()[0]);
} else {
// we didn't get an AT response
log.info("expected RSSI, but received " + atResponse.toString());
}
} else {
log.debug("received unexpected packet " + response.toString());
}
} catch (Exception e) {
log.error(e);
}
}
} finally {
if (xbee.isConnected()) {
xbee.close();
}
}
}
示例8: getLastMessageReceived
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
public ZNetRxResponse getLastMessageReceived() {
return lastMessageReceived;
}
示例9: setLastMessageReceived
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
public void setLastMessageReceived(ZNetRxResponse lastMessageReceived) {
this.lastMessageReceived = lastMessageReceived;
}