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

Java AtCommandResponse类代码示例

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

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



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

示例1: ZNetApiAtExample

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public ZNetApiAtExample() throws XBeeException {
		try {
			
			// replace with port and baud rate of your XBee
			xbee.open("COM6", 9600);	
			
			// get the 8 byte SH/SL address
			log.debug("SH is " + ByteUtils.toBase16(((AtCommandResponse)xbee.sendAtCommand(new AtCommand("SH"))).getValue()));
			log.debug("SL is " + ByteUtils.toBase16(((AtCommandResponse)xbee.sendAtCommand(new AtCommand("SL"))).getValue()));
			
			// uncomment to run
//			this.configureIOSamples(xbee);
//			this.associationStatus(xbee);
//			this.nodeDiscover(xbee);
//			this.configureCoordinator(xbee);
//			this.configureEndDevice(xbee);
		} finally {
			if (xbee != null && xbee.isConnected()) {
				xbee.close();		
			}
		}
	}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:23,代码来源:ZNetApiAtExample.java


示例2: ZNetApiAtExample

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public ZNetApiAtExample() throws XBeeException {
		try {
			
			// replace with port and baud rate of your XBee
			xbee.open("COM6", 9600);	
			
			// get the 8 byte SH/SL address
			log.debug("SH is " + ByteUtils.toBase16(((AtCommandResponse)xbee.sendAtCommand(new AtCommand("SH"))).getValue()));
			log.debug("SL is " + ByteUtils.toBase16(((AtCommandResponse)xbee.sendAtCommand(new AtCommand("SL"))).getValue()));
			
			// uncomment to run
//			this.configureIOSamples(xbee);
//			this.associationStatus(xbee);
//			this.nodeDiscover(xbee);
//			this.configureCoordinator(xbee);
//			this.configureEndDevice(xbee);
		} finally {
			xbee.close();
		}
	}
 
开发者ID:allanlang,项目名称:xbee-api-jssc,代码行数:21,代码来源:ZNetApiAtExample.java


示例3: processResponse

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public void processResponse(XBeeResponse response)
{
    if (response.getApiId() == ApiId.AT_RESPONSE)
    {
        NodeDiscover nd = NodeDiscover.parse((AtCommandResponse)response);
        XBeeAddress64 addr = nd.getNodeAddress64();

        if(!nodeAddresses.contains(addr))
        {
            nodeAddresses.add(addr);
            log.debug(nd);
        }

        if(!currentNodeAddresses.contains(addr))
            currentNodeAddresses.add(addr);

        for(int i = 0; i < pruningIndex; i++)
        {
            if(unresponsiveNodes.get(i).contains(addr))
                unresponsiveNodes.get(i).remove(addr);
        }

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


示例4: ZBNodeDiscoverExample

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public ZBNodeDiscoverExample() throws XBeeException, InterruptedException {
	
	try {
		// replace with your serial port
		xbee.open("/dev/tty.usbserial-A6005v5M", 9600);
		
		
		// get the Node discovery timeout
		xbee.sendAsynchronous(new AtCommand("NT"));
		AtCommandResponse nodeTimeout = (AtCommandResponse) xbee.getResponse();
		
		// default is 6 seconds
		int nodeDiscoveryTimeout = ByteUtils.convertMultiByteToInt(nodeTimeout.getValue()) * 100;			
		log.info("Node discovery timeout is " + nodeDiscoveryTimeout + " milliseconds");
					
		log.info("Sending Node Discover command");
		xbee.sendAsynchronous(new AtCommand("ND"));

		// NOTE: increase NT if you are not seeing all your nodes reported
		
		List<? extends XBeeResponse> responses = xbee.collectResponses(nodeDiscoveryTimeout);
		
		log.info("Time is up!  You should have heard back from all nodes by now.  If not make sure all nodes are associated and/or try increasing the node timeout (NT)");
		
		for (XBeeResponse response : responses) {
			if (response instanceof AtCommandResponse) {
				AtCommandResponse atResponse = (AtCommandResponse) response;
				
				if (atResponse.getCommand().equals("ND") && atResponse.getValue() != null && atResponse.getValue().length > 0) {
					ZBNodeDiscover nd = ZBNodeDiscover.parse((AtCommandResponse)response);
					log.info("Node Discover is " + nd);							
				}
			}
		}
	} finally {
		if (xbee != null && xbee.isConnected()) {
			xbee.close();		
		}
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:41,代码来源:ZBNodeDiscoverExample.java


示例5: parseIsSample

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public static ZNetRxIoSampleResponse parseIsSample(AtCommandResponse response) throws IOException {
	
	if (!response.getCommand().equals("IS")) {
		throw new RuntimeException("This is only applicable to the \"IS\" AT command");
	}
	
	IntArrayInputStream in = new IntArrayInputStream(response.getValue());
	ZNetRxIoSampleResponse sample = new ZNetRxIoSampleResponse();
	sample.parseIoSample(in);
	
	return sample;
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:13,代码来源:ZNetRxIoSampleResponse.java


示例6: ZBNodeDiscoverExample

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public ZBNodeDiscoverExample() throws XBeeException, InterruptedException {
	
	try {
		// replace with your serial port
		xbee.open("/dev/tty.usbserial-A6005v5M", 9600);
		
		
		// get the Node discovery timeout
		xbee.sendAsynchronous(new AtCommand("NT"));
		AtCommandResponse nodeTimeout = (AtCommandResponse) xbee.getResponse();
		
		// default is 6 seconds
		int nodeDiscoveryTimeout = ByteUtils.convertMultiByteToInt(nodeTimeout.getValue()) * 100;			
		log.info("Node discovery timeout is " + nodeDiscoveryTimeout + " milliseconds");
					
		log.info("Sending Node Discover command");
		xbee.sendAsynchronous(new AtCommand("ND"));

		// NOTE: increase NT if you are not seeing all your nodes reported
		
		List<? extends XBeeResponse> responses = xbee.collectResponses(nodeDiscoveryTimeout);
		
		log.info("Time is up!  You should have heard back from all nodes by now.  If not make sure all nodes are associated and/or try increasing the node timeout (NT)");
		
		for (XBeeResponse response : responses) {
			if (response instanceof AtCommandResponse) {
				AtCommandResponse atResponse = (AtCommandResponse) response;
				
				if (atResponse.getCommand().equals("ND") && atResponse.getValue() != null && atResponse.getValue().length > 0) {
					ZBNodeDiscover nd = ZBNodeDiscover.parse((AtCommandResponse)response);
					log.info("Node Discover is " + nd);							
				}
			}
		}
	} finally {
		xbee.close();
	}
}
 
开发者ID:allanlang,项目名称:xbee-api-jssc,代码行数:39,代码来源:ZBNodeDiscoverExample.java


示例7: processResponse

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public void processResponse(XBeeResponse response)
{
    if (response.getApiId() == ApiId.AT_RESPONSE)
    {
        NodeDiscover nd = NodeDiscover.parse((AtCommandResponse)response);
        XBeeAddress64 addr = nd.getNodeAddress64();
        log.debug("Found Address: " + addr);
        chessbots.add(addr);
    }
}
 
开发者ID:utdrobotchess,项目名称:chess-game,代码行数:11,代码来源:ChessbotCommunicator.java


示例8: associationStatus

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
private void associationStatus(XBee xbee) throws XBeeException {
	// get association status - success indicates it is associated to another XBee
	AtCommandResponse response = (AtCommandResponse) xbee.sendAtCommand(new AtCommand("AI"));
	log.debug("Association Status is " + AssociationStatus.get(response));		
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:6,代码来源:ZNetApiAtExample.java


示例9: ZNetReceiverExample

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的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


示例10: ZNetReceiverExample

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的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


示例11: parse

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public static ZBNodeDiscover parse(AtCommandResponse response) {
	
	if (!response.getCommand().equals("ND")) {
		throw new RuntimeException("This method is only applicable for the ND command");
	}
	
	int[] data = response.getValue();
	
	IntArrayInputStream in = new IntArrayInputStream(data);
	
	ZBNodeDiscover nd = new ZBNodeDiscover();
	
	nd.setNodeAddress16(new XBeeAddress16(in.read(2)));
	
	nd.setNodeAddress64(new XBeeAddress64(in.read(8)));

	StringBuffer ni = new StringBuffer();
	
	int ch;
	
	// NI is terminated with 0
	while ((ch = in.read()) != 0) {
		if (ch < 32 || ch > 126) {
			throw new RuntimeException("Node Identifier " + ch + " is non-ascii");
		}
		
		ni.append((char)ch);	
	}
	
	nd.setNodeIdentifier(ni.toString());
			
	nd.setParent(new XBeeAddress16(in.read(2)));
	nd.setDeviceType(DeviceType.get(in.read()));
	// TODO this is being reported as 1 (router) for my end device
	nd.setStatus(in.read());
	nd.setProfileId(in.read(2));
	nd.setMfgId(in.read(2));
	
	return nd;
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:41,代码来源:ZBNodeDiscover.java


示例12: parse

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
public static WpanNodeDiscover parse(AtCommandResponse response) {
	
	if (!response.getCommand().equals("ND")) {
		throw new IllegalArgumentException("This method is only applicable for the ND command");
	}
	
	int[] data = response.getValue();
	
	if (data == null || data.length == 0) {
		throw new IllegalArgumentException("ND command has no value");
	}
	
	IntArrayInputStream in = new IntArrayInputStream(data);
	
	WpanNodeDiscover nd = new WpanNodeDiscover();
	
	nd.setNodeAddress16(new XBeeAddress16(in.read(2)));
	
	nd.setNodeAddress64(new XBeeAddress64(in.read(8)));
	
	nd.setRssi(-1*in.read());

	StringBuilder ni = new StringBuilder();
	
	int ch;
	
	// NI is terminated with 0
	while ((ch = in.read()) != 0) {
		if (ch < 32 || ch > 126) {
			throw new RuntimeException("Node Identifier " + ch + " is non-ascii");
		}
		
		ni.append((char)ch);	
	}
	
	nd.setNodeIdentifier(ni.toString());
	
	return nd;
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:40,代码来源:WpanNodeDiscover.java


示例13: setState

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
@Override
public void setState(boolean state) throws IOException {

    NDC.push("write(" + address + ")");
    Marker m = new Marker("write(" + address + ")");
    
    try {
        
        XBeeAddress64 xbeeAddress = Parser.parse(address.hardwareAddress);
        String channel = address.channel;
        
        int deviceState = state ? 5 : 4;
        RemoteAtRequest request = new RemoteAtRequest(xbeeAddress, channel, new int[] {deviceState});
        AtCommandResponse rsp = (AtCommandResponse) container.sendSynchronous(request, XBeeConstants.TIMEOUT_AT_MILLIS);

        logger.info(channel + " response: " + rsp);

        if (rsp.isError()) {
            
            throw new IOException(channel + " + query failed, status: " + rsp.getStatus());
        }

    } catch (Throwable t) {

        IOException secondary = new IOException("Unable to write " + address);

        secondary.initCause(t);

        throw secondary;

    } finally {

        m.close();
        NDC.pop();
    }
}
 
开发者ID:home-climate-control,项目名称:dz,代码行数:37,代码来源:XBeeSwitch.java


示例14: getSignal

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
@Override
public DataSample<Double> getSignal() {
    
    NDC.push("getSignal(" + address + ")");
    Marker m = new Marker("getSignal(" + address + ")");

    try {
        
        XBeeAddress64 xbeeAddress = Parser.parse(address.hardwareAddress);
        String channel = address.channel;
        
        RemoteAtRequest request = new RemoteAtRequest(xbeeAddress, "IS");
        AtCommandResponse rsp = (AtCommandResponse) container.sendSynchronous(request, XBeeConstants.TIMEOUT_IS_MILLIS);

        logger.debug(channel + " response: " + rsp);

        if (rsp.isError()) {
            
            throw new IOException(channel + " + query failed, status: " + rsp.getStatus());
        }
        
        IoSample sample = new IoSample(rsp.getValue(), xbeeAddress, logger);
        
        logger.debug("sample: " + sample);
        
        return new DataSample<Double>(System.currentTimeMillis(), sourceName, signature, sample.getChannel(channel), null);
        
    } catch (Throwable t) {

        IOException secondary = new IOException("Unable to read " + address);

        secondary.initCause(t);

        throw new IllegalStateException("Not Implemented", t);

    } finally {

        m.close();
        NDC.pop();
    }
}
 
开发者ID:home-climate-control,项目名称:dz,代码行数:42,代码来源:XBeeSensor.java


示例15: processResponse

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
@Override
public void processResponse(XBeeResponse packet) {
    
    NDC.push("processResponse");
    
    try {
        
        logger.debug("packet: " + packet);
        
        ApiId apiId = packet.getApiId();
        
        switch (apiId) {
        
        case AT_RESPONSE:
            
            AtCommandResponse atCommandResponse = (AtCommandResponse) packet;
            String command = atCommandResponse.getCommand();
            
            if ("ND".equals(command)) {
            
                createPrototype(ZBNodeDiscover.parse(atCommandResponse));
                
            } else if ("NT".equals(command)) {
                
                // No big deal, browse() initiated it and handled it
                
            } else {
                
                logger.warn("Unexpected response received (command: " + command + ")");
            }
            
            break;
            
        case ZNET_IO_SAMPLE_RESPONSE:
            
            broadcastIoSample((ZNetRxIoSampleResponse) packet);
            break;
        
        default:
            
            // Have no idea what this is, don't care
            break;
        }

    } catch (Throwable t) {
        
        logger.error("Oops", t);
    } finally {
        NDC.pop();
    }
    
}
 
开发者ID:home-climate-control,项目名称:dz,代码行数:53,代码来源:XBeeDeviceFactory.java


示例16: getState

import com.rapplogic.xbee.api.AtCommandResponse; //导入依赖的package包/类
@Override
public boolean getState() throws IOException {

    NDC.push("read(" + address + ")");
    Marker m = new Marker("read(" + address + ")");

    try {
        
        XBeeAddress64 xbeeAddress = Parser.parse(address.hardwareAddress);
        String channel = address.channel;
        
        RemoteAtRequest request = new RemoteAtRequest(xbeeAddress, channel);
        AtCommandResponse rsp = (AtCommandResponse) container.sendSynchronous(request, XBeeConstants.TIMEOUT_AT_MILLIS);

        logger.info(channel + " response: " + rsp);

        if (rsp.isError()) {
            
            throw new IOException(channel + " + query failed, status: " + rsp.getStatus());
        }
        
        int buffer[] = rsp.getValue();
        
        if (buffer.length != 1) {
            
            throw new IOException("Unexpected buffer size " + buffer.length);
        }
        
        switch (buffer[0]) {
        case 4:
            
            return false;
            
        case 5:
            
            return true;
            
        default:
            
            throw new IOException(channel + " is not configured as switch, state is " + buffer[0]);
        }

    } catch (Throwable t) {

        IOException secondary = new IOException("Unable to read " + address);

        secondary.initCause(t);

        throw secondary;

    } finally {

        m.close();
        NDC.pop();
    }
}
 
开发者ID:home-climate-control,项目名称:dz,代码行数:57,代码来源:XBeeSwitch.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Mutable类代码示例发布时间:2022-05-22
下一篇:
Java KeyLookup类代码示例发布时间: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