gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-15 21:29:31 27 4
gpt4 key购买 nike

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

ZigBeeNode.setNetworkAddress介绍

[英]Sets the 16 bit network address of the node.
[中]设置节点的16位网络地址。

代码示例

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

/**
   * Updates {@link ZigBeeNode} and adds it to the {@link ZigBeeNetworkManager}
   *
   * @param ieeeAddress the {@link IeeeAddress} of the newly announced node
   * @param networkAddress the network address of the newly announced node
   */
  private void addNode(final IeeeAddress ieeeAddress, int networkAddress) {
    logger.debug("{}: NWK Discovery add node {}", ieeeAddress, networkAddress);
    ZigBeeNode node = networkManager.getNode(ieeeAddress);
    if (node != null) {
      if (node.getNetworkAddress() != networkAddress) {
        logger.debug("{}: NWK Discovery updated network address to {}", ieeeAddress, networkAddress);
      }
      node.setNodeState(ZigBeeNodeState.ONLINE);
      node.setNetworkAddress(networkAddress);
      networkManager.updateNode(node);
      return;
    }

    node = new ZigBeeNode(networkManager, ieeeAddress);
    node.setNetworkAddress(networkAddress);

    // Add the node to the network...
    networkManager.addNode(node);
  }
}

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

private void addLocalNode() {
  Integer nwkAddress = transport.getNwkAddress();
  IeeeAddress ieeeAddress = transport.getIeeeAddress();
  if (nwkAddress != null && ieeeAddress != null) {
    ZigBeeNode node = getNode(ieeeAddress);
    if (node == null) {
      logger.debug("{}: Adding local node to network, NWK={}", ieeeAddress, nwkAddress);
      node = new ZigBeeNode(this, ieeeAddress);
      node.setNetworkAddress(nwkAddress);
      addNode(node);
    }
  }
}

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

private ZigBeeEndpoint getEndpoint() {
    ZigBeeTransportTransmit mockedTransport = Mockito.mock(ZigBeeTransportTransmit.class);
    ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(mockedTransport);
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    return new ZigBeeEndpoint(node, 5);
  }
}

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

@Test
public void commandReceived() {
  ZigBeeNode node = new ZigBeeNode(Mockito.mock(ZigBeeNetworkManager.class), new IeeeAddress("1234567890"));
  node.setNetworkAddress(12345);

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

@Test
public void testNodeNetworkAddressUpdate() {
  mockedTransport = Mockito.mock(ZigBeeTransportTransmit.class);
  mockedApsFrameListener = ArgumentCaptor.forClass(ZigBeeApsFrame.class);
  ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(mockedTransport);
  ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress("12345678990ABCDEF"));
  node.setNetworkAddress(12345);
  ZigBeeEndpoint endpoint = new ZigBeeEndpoint(node, 1);
  ZclOnOffCluster cluster = new ZclOnOffCluster(endpoint);
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  Mockito.doNothing().when(mockedTransport).sendCommand(mockedApsFrameListener.capture());
  cluster.onCommand();
  assertEquals(12345, mockedApsFrameListener.getValue().getDestinationAddress());
  node.setNetworkAddress(54321);
  cluster.offCommand();
  assertEquals(54321, mockedApsFrameListener.getValue().getDestinationAddress());
}

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

@Test
  public void testNodeAddressUpdate() {
    IeeeAddress ieeeAddress = new IeeeAddress("123456890ABCDEF");

    ZigBeeNode node = Mockito.mock(ZigBeeNode.class);// new ZigBeeNode(networkManager, ieeeAddress);
    Mockito.doReturn(node).when(networkManager).getNode(ArgumentMatchers.any(IeeeAddress.class));

    DeviceAnnounce announce = new DeviceAnnounce();
    announce.setIeeeAddr(ieeeAddress);
    announce.setNwkAddrOfInterest(12345);

    ZigBeeNetworkDiscoverer discoverer = new ZigBeeNetworkDiscoverer(networkManager);
    discoverer.setRetryPeriod(0);
    discoverer.setRequeryPeriod(0);
    discoverer.setRetryCount(0);

    discoverer.commandReceived(announce);
    Mockito.verify(node, Mockito.times(1)).setNetworkAddress(ArgumentMatchers.anyInt());

    ZigBeeEndpointAddress address = Mockito.mock(ZigBeeEndpointAddress.class);
    Mockito.when(address.getAddress()).thenReturn(12345);
    ZclCommand zclCommand = Mockito.mock(ZclCommand.class);
    Mockito.when(zclCommand.getSourceAddress()).thenReturn(address);
    discoverer.commandReceived(zclCommand);
  }
}

代码示例来源: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

@Test
public void testAddExistingNode() {
  String address = "123456789ABCDEF0";
  ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
  ZigBeeNode node1 = new ZigBeeNode(Mockito.mock(ZigBeeNetworkManager.class), new IeeeAddress(address));
  node1.setNetworkAddress(1234);
  ZigBeeNode node2 = new ZigBeeNode(Mockito.mock(ZigBeeNetworkManager.class), new IeeeAddress(address));
  node2.setNetworkAddress(5678);
  networkManager.addNode(node1);
  assertEquals(1, networkManager.getNodes().size());
  ZigBeeNode nodeWeGot = networkManager.getNode(new IeeeAddress(address));
  assertEquals(Integer.valueOf(1234), nodeWeGot.getNetworkAddress());
  networkManager.addNode(node2);
  assertEquals(1, networkManager.getNodes().size());
  assertEquals(Integer.valueOf(5678), nodeWeGot.getNetworkAddress());
}

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

ZigBeeNode invalidNode = new ZigBeeNode(Mockito.mock(ZigBeeNetworkManager.class),
    new IeeeAddress("ABCDEF1234567890"));
node.setNetworkAddress(1234);
newNode.setNetworkAddress(1234);
newNode.setNetworkAddress(5678);
assertTrue(node.updateNode(newNode));

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

ZigBeeNetworkManager mockedNetworkManager = Mockito.mock(ZigBeeNetworkManager.class);
ZigBeeNode node = new ZigBeeNode(mockedNetworkManager, ieeeAddress);
node.setNetworkAddress(networkAddress.getAddress());
node.setNodeDescriptor(nodeDescriptor);
ZigBeeEndpoint endpoint = new ZigBeeEndpoint(node, networkAddress.getEndpoint());

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

node1.setNetworkAddress(1234);
ZigBeeNode node2 = new ZigBeeNode(Mockito.mock(ZigBeeNetworkManager.class),
    new IeeeAddress("123456789ABCDEF0"));
node2.setNetworkAddress(5678);

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

@Test
  public void testSerialize() {
    ZigBeeTransportTransmit mockedTransport = Mockito.mock(ZigBeeTransportTransmit.class);
    ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(mockedTransport);
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress("1234567890ABCDEF"));
    node.setNetworkAddress(12345);

    ZigBeeEndpoint endpoint;
    endpoint = new ZigBeeEndpoint(node, 1);
    endpoint.setProfileId(123);
    node.addEndpoint(endpoint);
    endpoint = new ZigBeeEndpoint(node, 2);
    endpoint.setProfileId(321);
    node.addEndpoint(endpoint);
    /*
     * ZigBeeNodeDao nodeDao = ZigBeeNodeDao.createFromZigBeeNode(node);
     * assertEquals(new IeeeAddress("1234567890ABCDEF").toString(), nodeDao.getIeeeAddress());
     * assertEquals(Integer.valueOf(12345), nodeDao.getNetworkAddress());
     *
     * node = ZigBeeNodeDao.createFromZigBeeDao(networkManager, nodeDao);
     * assertEquals(new IeeeAddress("1234567890ABCDEF"), node.getIeeeAddress());
     * assertEquals(Integer.valueOf(12345), node.getNetworkAddress());
     * assertEquals(2, node.getEndpoints().size());
     *
     * endpoint = node.getEndpoint(1);
     * assertEquals(123, endpoint.getProfileId());
     */
  }
}

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