当前位置: 首页>>代码示例>>Java>>正文


Java ZNetExplicitTxRequest类代码示例

本文整理汇总了Java中com.rapplogic.xbee.api.zigbee.ZNetExplicitTxRequest的典型用法代码示例。如果您正苦于以下问题:Java ZNetExplicitTxRequest类的具体用法?Java ZNetExplicitTxRequest怎么用?Java ZNetExplicitTxRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ZNetExplicitTxRequest类属于com.rapplogic.xbee.api.zigbee包,在下文中一共展示了ZNetExplicitTxRequest类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ZNetExplicitSenderExample

import com.rapplogic.xbee.api.zigbee.ZNetExplicitTxRequest; //导入依赖的package包/类
private ZNetExplicitSenderExample() throws XBeeException {
	
	XBee xbee = new XBee();
	
	try {
		// replace with your com port and baud rate. this is the com port of my coordinator
		//xbee.open("COM5", 9600);
		xbee.open("/dev/tty.usbserial-A6005v5M", 9600);
		
		// replace with end device's 64-bit address (SH + SL)
		XBeeAddress64 addr64 = new XBeeAddress64(0, 0x13, 0xa2, 0, 0x40, 0x0a, 0x3e, 0x02);
		
		// create an array of arbitrary data to send
		int[] payload = new int[] { 0, 0x66, 0xee };
		
		// loopback test
		int sourceEndpoint = 0;
		int destinationEndpoint = ZNetExplicitTxRequest.Endpoint.DATA.getValue();
		
		DoubleByte clusterId = new DoubleByte(0x0, ZNetExplicitTxRequest.ClusterId.SERIAL_LOOPBACK.getValue());
		//DoubleByte clusterId = new DoubleByte(0x0, ZNetExplicitTxRequest.ClusterId.TRANSPARENT_SERIAL.getValue());
		
		// first request we just send 64-bit address.  we get 16-bit network address with status response
		ZNetExplicitTxRequest request = new ZNetExplicitTxRequest(0xff, addr64, XBeeAddress16.ZNET_BROADCAST, 
					ZNetTxRequest.DEFAULT_BROADCAST_RADIUS, ZNetTxRequest.Option.UNICAST, payload, sourceEndpoint, destinationEndpoint, clusterId, ZNetExplicitTxRequest.znetProfileId);
		
		log.info("sending explicit " + request.toString());
		
		while (true) {
			xbee.sendAsynchronous(request);
			
			XBeeResponse response = xbee.getResponse();
			
			log.info("received response " + response.toString());
				
			try {
				// wait a bit then send another packet
				Thread.sleep(5000);
			} catch (InterruptedException e) {
			}
		}
	} finally {
		if (xbee != null && xbee.isConnected()) {
			xbee.close();		
		}
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:48,代码来源:ZNetExplicitSenderExample.java

示例2: ZNetExplicitSenderExample

import com.rapplogic.xbee.api.zigbee.ZNetExplicitTxRequest; //导入依赖的package包/类
private ZNetExplicitSenderExample() throws XBeeException {
	
	XBee xbee = new XBee();
	
	try {
		// replace with your com port and baud rate. this is the com port of my coordinator
		//xbee.open("COM5", 9600);
		xbee.open("/dev/tty.usbserial-A6005v5M", 9600);
		
		// replace with end device's 64-bit address (SH + SL)
		XBeeAddress64 addr64 = new XBeeAddress64(0, 0x13, 0xa2, 0, 0x40, 0x0a, 0x3e, 0x02);
		
		// create an array of arbitrary data to send
		int[] payload = new int[] { 0, 0x66, 0xee };
		
		// loopback test
		int sourceEndpoint = 0;
		int destinationEndpoint = ZNetExplicitTxRequest.Endpoint.DATA.getValue();
		
		DoubleByte clusterId = new DoubleByte(0x0, ZNetExplicitTxRequest.ClusterId.SERIAL_LOOPBACK.getValue());
		//DoubleByte clusterId = new DoubleByte(0x0, ZNetExplicitTxRequest.ClusterId.TRANSPARENT_SERIAL.getValue());
		
		// first request we just send 64-bit address.  we get 16-bit network address with status response
		ZNetExplicitTxRequest request = new ZNetExplicitTxRequest(0xff, addr64, XBeeAddress16.ZNET_BROADCAST, 
					ZNetTxRequest.DEFAULT_BROADCAST_RADIUS, ZNetTxRequest.Option.UNICAST, payload, sourceEndpoint, destinationEndpoint, clusterId, ZNetExplicitTxRequest.znetProfileId);
		
		log.info("sending explicit " + request.toString());
		
		while (true) {
			xbee.sendAsynchronous(request);
			
			XBeeResponse response = xbee.getResponse();
			
			log.info("received response " + response.toString());
				
			try {
				// wait a bit then send another packet
				Thread.sleep(5000);
			} catch (InterruptedException e) {
			}
		}
	} finally {
		xbee.close();
	}
}
 
开发者ID:allanlang,项目名称:xbee-api-jssc,代码行数:46,代码来源:ZNetExplicitSenderExample.java


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