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


Java AtCommandResponse.getValue方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。