• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ZNetRxResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
    }
}
 
开发者ID:utdrobotchess,项目名称:chess-game,代码行数:20,代码来源:ChessbotCommunicator.java


示例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);
        }

    }
}
 
开发者ID:utdrobotchess,项目名称:chess-game,代码行数:18,代码来源:BotFinder.java


示例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;
}
 
开发者ID:utdrobotchess,项目名称:chess-game,代码行数:9,代码来源:ChessbotInfoArrayHandler.java


示例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);
	}
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:11,代码来源:DiyOnXBeeBinding.java


示例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();		
		}
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:49,代码来源:ZNetReceiverExample.java


示例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();
				}
			}
		}
	});
}
 
开发者ID:andrewrapp,项目名称:arduino-remote-uploader,代码行数:63,代码来源:XBeeSketchUploader.java


示例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();
		}
	}
}
 
开发者ID:allanlang,项目名称:xbee-api-jssc,代码行数:49,代码来源:ZNetReceiverExample.java


示例8: getLastMessageReceived

import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
public ZNetRxResponse getLastMessageReceived() {
    return lastMessageReceived;
}
 
开发者ID:utdrobotchess,项目名称:chess-game,代码行数:4,代码来源:ChessbotInfo.java


示例9: setLastMessageReceived

import com.rapplogic.xbee.api.zigbee.ZNetRxResponse; //导入依赖的package包/类
public void setLastMessageReceived(ZNetRxResponse lastMessageReceived) {
    this.lastMessageReceived = lastMessageReceived;
}
 
开发者ID:utdrobotchess,项目名称:chess-game,代码行数:4,代码来源:ChessbotInfo.java



注:本文中的com.rapplogic.xbee.api.zigbee.ZNetRxResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PropertyChange类代码示例发布时间:2022-05-22
下一篇:
Java EntityComplexPart类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap