Package com.rapplogic.xbee.api

Examples of com.rapplogic.xbee.api.AtCommandResponse


      final int timeout) {
    if (!isConnected()) {
      return false;
    }
    try {
      AtCommandResponse response;
      int[] responseValue;
      final XBeeAddress16 remoteAddress = getXbeeAddress(remoteNode
          .getAddress());
      if (remoteAddress != null) {
        final RemoteAtRequest request = new RemoteAtRequest(
            remoteAddress, "MY");
        final RemoteAtResponse remoteResponse = (RemoteAtResponse) xbee
            .sendSynchronous(request,
                timeout <= 0 ? DEFAULT_WAIT_MILISECONDS
                    : timeout);
        response = remoteResponse;
      } else {
        response = (AtCommandResponse) xbee
            .sendSynchronous(new AtCommand("MY"));
      }
      if (response.isOk()) {
        responseValue = response.getValue();
        final String address = ByteUtils.toBase16(responseValue);
        log.info(String.format("Successfully got %1$s address %2$s",
            (remoteAddress != null ? "remote" : "local"), address));
        if (address != null && !address.isEmpty()) {
          return true;
        }
      } else {
        throw new XBeeException(
            "Failed to get remote address response. Status is "
                + response.getStatus());
      }
    } catch (final XBeeTimeoutException e) {
      log.warn("Timed out getting remote XBee address", e);
    } catch (final XBeeException e) {
      log.warn("Error getting remote XBee address", e);
View Full Code Here

TOP

Related Classes of com.rapplogic.xbee.api.AtCommandResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.