gpt4 book ai didi

com.zsmartsystems.zigbee.ZigBeeNetworkManager.sendTransaction()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 08:51:31 31 4
gpt4 key购买 nike

本文整理了Java中com.zsmartsystems.zigbee.ZigBeeNetworkManager.sendTransaction()方法的一些代码示例,展示了ZigBeeNetworkManager.sendTransaction()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZigBeeNetworkManager.sendTransaction()方法的具体详情如下:
包路径:com.zsmartsystems.zigbee.ZigBeeNetworkManager
类名称:ZigBeeNetworkManager
方法名:sendTransaction

ZigBeeNetworkManager.sendTransaction介绍

暂无

代码示例

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
  public void run() {
    try {
      CommandResult response = sendTransaction(command, command).get();
      if (response.getStatusCode() == 0) {
        ZigBeeNode node = getNode(leaveAddress);
        if (node != null) {
          removeNode(node);
        } else {
          logger.debug("{}: No node found after successful leave command", leaveAddress);
        }
      } else {
        logger.debug("{}: No successful response received to leave command (status code {})",
            leaveAddress, response.getStatusCode());
      }
    } catch (InterruptedException | ExecutionException e) {
      logger.debug("Error sending leave command.", e);
    }
  }
}.start();

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Gets group memberships from device.
 *
 * @param device the device
 * @return the command result future
 */
public Future<CommandResult> getGroupMemberships(final ZigBeeEndpoint device) {
  final GetGroupMembershipCommand command = new GetGroupMembershipCommand();
  command.setGroupCount(0);
  command.setGroupList(Collections.<Integer> emptyList());
  command.setDestinationAddress(device.getEndpointAddress());
  return networkManager.sendTransaction(command, new ZclTransactionMatcher());
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Sends {@link ZclCommand} command to {@link ZigBeeAddress}.
 *
 * @param destination the destination
 * @param command the {@link ZclCommand}
 * @return the command result future
 */
public Future<CommandResult> send(ZigBeeAddress destination, ZclCommand command) {
  command.setDestinationAddress(destination);
  if (destination.isGroup()) {
    return broadcast(command);
  } else {
    final ZigBeeTransactionMatcher responseMatcher = new ZclTransactionMatcher();
    return sendTransaction(command, responseMatcher);
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Before
public void setupTest() {
  networkManager = Mockito.mock(ZigBeeNetworkManager.class);
  nodeCapture = ArgumentCaptor.forClass(ZigBeeNode.class);
  Mockito.doAnswer(new Answer<Future<CommandResult>>() {
    @Override
    public Future<CommandResult> answer(InvocationOnMock invocation) {
      ZigBeeCommand command = (ZigBeeCommand) invocation.getArguments()[0];
      ZigBeeTransactionFuture commandFuture = new ZigBeeTransactionFuture();
      CommandResult result = new CommandResult(responses.get(command.getClusterId()));
      commandFuture.set(result);
      return commandFuture;
    }
  }).when(networkManager).sendTransaction(ArgumentMatchers.any(ZigBeeCommand.class),
      ArgumentMatchers.any(ZigBeeTransactionMatcher.class));
  Mockito.doAnswer(new Answer<Void>() {
    @Override
    public Void answer(InvocationOnMock invocation) {
      Runnable runnable = (Runnable) invocation.getArguments()[0];
      new Thread(runnable).start();
      return null;
    }
  }).when(networkManager).executeTask(ArgumentMatchers.any(Runnable.class));
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Views group membership from device.
 *
 * @param device the device
 * @param groupId the group ID
 * @return the command result future
 */
public Future<CommandResult> viewMembership(final ZigBeeEndpoint device, final int groupId) {
  final ViewGroupCommand command = new ViewGroupCommand();
  command.setGroupId(groupId);
  command.setDestinationAddress(device.getEndpointAddress());
  return networkManager.sendTransaction(command, new ZclTransactionMatcher());
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
   * Removes group membership from device.
   *
   * @param device the device
   * @param groupId the group ID
   * @return the command result future
   */
  public Future<CommandResult> removeMembership(final ZigBeeEndpoint device, final int groupId) {
    final RemoveGroupCommand command = new RemoveGroupCommand();
    command.setGroupId(groupId);

    command.setDestinationAddress(device.getEndpointAddress());

    return networkManager.sendTransaction(command, new ZclTransactionMatcher());
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

new ZigBeeEndpointAddress(ZigBeeBroadcastDestination.BROADCAST_RX_ON.getKey()));
CommandResult response;
response = networkManager.sendTransaction(request, request).get();

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

return commandFuture;
}).when(networkManager).sendTransaction(ArgumentMatchers.any(ZigBeeCommand.class),
    ArgumentMatchers.any(ZigBeeTransactionMatcher.class));

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

routeRequest.setStartIndex(startIndex);
CommandResult response = networkManager.sendTransaction(routeRequest, routeRequest).get();
final ManagementRoutingResponse routingResponse = response.getResponse();
logger.debug("{}: Node SVC Discovery: ManagementRoutingRequest returned {}", node.getIeeeAddress(),

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Adds group membership to device.
 *
 * @param device the device
 * @param groupId the group ID
 * @param groupName the group name
 * @return the command result future
 */
public Future<CommandResult> addMembership(final ZigBeeEndpoint device, final int groupId, final String groupName) {
  final AddGroupCommand command = new AddGroupCommand();
  command.setGroupId(groupId);
  command.setGroupName(groupName);
  command.setDestinationAddress(device.getEndpointAddress());
  return networkManager.sendTransaction(command, new ZclTransactionMatcher());
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

neighborRequest.setStartIndex(startIndex);
CommandResult response = networkManager.sendTransaction(neighborRequest, neighborRequest).get();
final ManagementLqiResponse neighborResponse = response.getResponse();
logger.debug("{}: Node SVC Discovery: ManagementLqiRequest response {}", node.getIeeeAddress(), response);

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

ieeeAddressRequest.setStartIndex(startIndex);
ieeeAddressRequest.setNwkAddrOfInterest(node.getNetworkAddress());
CommandResult response = networkManager.sendTransaction(ieeeAddressRequest, ieeeAddressRequest).get();

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

activeEndpointsRequest.setNwkAddrOfInterest(node.getNetworkAddress());
CommandResult response = networkManager.sendTransaction(activeEndpointsRequest, activeEndpointsRequest).get();
final ActiveEndpointsResponse activeEndpointsResponse = (ActiveEndpointsResponse) response.getResponse();
logger.debug("{}: Node SVC Discovery: ActiveEndpointsResponse returned {}", node.getIeeeAddress(), response);

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

ieeeAddressRequest.setStartIndex(startIndex);
ieeeAddressRequest.setNwkAddrOfInterest(networkAddress);
CommandResult response = networkManager.sendTransaction(ieeeAddressRequest, ieeeAddressRequest).get();
if (response.isError()) {
  return false;

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Get node descriptor
 *
 * @return true if the message was processed ok
 * @throws ExecutionException
 * @throws InterruptedException
 */
private boolean requestNodeDescriptor() throws InterruptedException, ExecutionException {
  final NodeDescriptorRequest nodeDescriptorRequest = new NodeDescriptorRequest();
  nodeDescriptorRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
  nodeDescriptorRequest.setNwkAddrOfInterest(node.getNetworkAddress());
  CommandResult response = networkManager.sendTransaction(nodeDescriptorRequest, nodeDescriptorRequest).get();
  final NodeDescriptorResponse nodeDescriptorResponse = (NodeDescriptorResponse) response.getResponse();
  logger.debug("{}: Node SVC Discovery: NodeDescriptorResponse returned {}", node.getIeeeAddress(),
      nodeDescriptorResponse);
  if (nodeDescriptorResponse == null) {
    return false;
  }
  if (nodeDescriptorResponse.getStatus() == ZdoStatus.SUCCESS) {
    node.setNodeDescriptor(nodeDescriptorResponse.getNodeDescriptor());
    return true;
  }
  return false;
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Get node power descriptor
 *
 * @return true if the message was processed ok, or if the end device does not support the power descriptor
 * @throws ExecutionException
 * @throws InterruptedException
 */
private boolean requestPowerDescriptor() throws InterruptedException, ExecutionException {
  final PowerDescriptorRequest powerDescriptorRequest = new PowerDescriptorRequest();
  powerDescriptorRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
  powerDescriptorRequest.setNwkAddrOfInterest(node.getNetworkAddress());
  CommandResult response = networkManager.sendTransaction(powerDescriptorRequest, powerDescriptorRequest).get();
  final PowerDescriptorResponse powerDescriptorResponse = (PowerDescriptorResponse) response.getResponse();
  logger.debug("{}: Node SVC Discovery: PowerDescriptorResponse returned {}", node.getIeeeAddress(),
      powerDescriptorResponse);
  if (powerDescriptorResponse == null) {
    return false;
  }
  if (powerDescriptorResponse.getStatus() == ZdoStatus.SUCCESS) {
    node.setPowerDescriptor(powerDescriptorResponse.getPowerDescriptor());
    return true;
  } else if (powerDescriptorResponse.getStatus() == ZdoStatus.NOT_SUPPORTED) {
    return true;
  }
  return false;
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Get node descriptor
 *
 * @return true if the message was processed ok
 * @throws ExecutionException
 * @throws InterruptedException
 */
private boolean requestNetworkAddress() throws InterruptedException, ExecutionException {
  NetworkAddressRequest networkAddressRequest = new NetworkAddressRequest();
  networkAddressRequest.setIeeeAddr(node.getIeeeAddress());
  networkAddressRequest.setRequestType(0);
  networkAddressRequest.setStartIndex(0);
  networkAddressRequest.setDestinationAddress(
      new ZigBeeEndpointAddress(ZigBeeBroadcastDestination.BROADCAST_ALL_DEVICES.getKey()));
  CommandResult response = networkManager.sendTransaction(networkAddressRequest, networkAddressRequest).get();
  final NetworkAddressResponse networkAddressResponse = (NetworkAddressResponse) response.getResponse();
  logger.debug("{}: Node SVC Discovery: NetworkAddressRequest returned {}", node.getNetworkAddress(),
      networkAddressResponse);
  if (networkAddressResponse == null) {
    return false;
  }
  if (networkAddressResponse.getStatus() == ZdoStatus.SUCCESS) {
    node.setNetworkAddress(networkAddressResponse.getNwkAddrRemoteDev());
    return true;
  }
  return false;
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

return null;
}).when(mockedNetworkManager).sendTransaction(mockedCommandCaptor.capture(),
    (ZigBeeTransactionMatcher) ArgumentMatchers.anyObject());

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

simpleDescriptorRequest.setEndpoint(endpointId);
CommandResult response = networkManager.sendTransaction(simpleDescriptorRequest, simpleDescriptorRequest).get();

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com