gpt4 book ai didi

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

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

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

ZigBeeNetworkManager.addAnnounceListener介绍

[英]Add a ZigBeeAnnounceListener that will be notified whenever a new device is detected on the network.
[中]添加一个监听器,当网络上检测到新设备时,该监听器将收到通知。

代码示例

代码示例来源:origin: openhab/org.openhab.binding.zigbee

/**
 * Adds a {@link ZigBeeAnnounceListener} to receive node announce messages
 *
 * @param listener the {@link ZigBeeAnnounceListener} to add
 */
public void addAnnounceListener(ZigBeeAnnounceListener listener) {
  // Save the listeners until the network is initialised
  synchronized (announceListeners) {
    announceListeners.add(listener);
  }
  if (networkManager == null) {
    return;
  }
  networkManager.addAnnounceListener(listener);
}

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

/**
 * Starts up ZigBee network discoverer. This adds a listener to wait for the network to go online.
 */
protected void startup() {
  logger.debug("Network discovery task: starting");
  initialized = true;
  networkManager.addCommandListener(this);
  networkManager.addAnnounceListener(this);
  // Start discovery from root node.
  startNodeDiscovery(0);
}

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

@Test
public void nodeStatusUpdate() {
  ZigBeeTransportTransmit transport = Mockito.mock(ZigBeeTransportTransmit.class);
  ZigBeeNetworkManager manager = new ZigBeeNetworkManager(transport);
  ZigBeeNode node = Mockito.mock(ZigBeeNode.class);
  Mockito.when(node.getIeeeAddress()).thenReturn(new IeeeAddress("1234567890ABCDEF"));
  manager.addNode(node);
  ZigBeeAnnounceListener announceListener = Mockito.mock(ZigBeeAnnounceListener.class);
  manager.addAnnounceListener(announceListener);
  manager.nodeStatusUpdate(ZigBeeNodeStatus.DEVICE_LEFT, 1234, new IeeeAddress("123456789ABCDEF0"));
  Mockito.verify(node, Mockito.times(0)).setNodeState(ArgumentMatchers.any(ZigBeeNodeState.class));
  Mockito.verify(announceListener, Mockito.timeout(TIMEOUT).times(1)).deviceStatusUpdate(
      ArgumentMatchers.any(ZigBeeNodeStatus.class), ArgumentMatchers.any(Integer.class),
      ArgumentMatchers.any(IeeeAddress.class));
  manager.nodeStatusUpdate(ZigBeeNodeStatus.DEVICE_LEFT, 1234, new IeeeAddress("1234567890ABCDEF"));
  Mockito.verify(node, Mockito.times(1)).setNodeState(ZigBeeNodeState.OFFLINE);
  Mockito.verify(announceListener, Mockito.timeout(TIMEOUT).times(2)).deviceStatusUpdate(
      ArgumentMatchers.any(ZigBeeNodeStatus.class), ArgumentMatchers.any(Integer.class),
      ArgumentMatchers.any(IeeeAddress.class));
  manager.removeAnnounceListener(announceListener);
}

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

@Test
public void testNormal() {
  // Add all the required responses to a list
  IeeeAddressResponse ieeeResponse = new IeeeAddressResponse();
  ieeeResponse.setStatus(ZdoStatus.SUCCESS);
  ieeeResponse.setSourceAddress(new ZigBeeEndpointAddress(0));
  ieeeResponse.setDestinationAddress(new ZigBeeEndpointAddress(0));
  ieeeResponse.setIeeeAddrRemoteDev(new IeeeAddress("1234567890ABCDEF"));
  responses.put(ZdoCommandType.IEEE_ADDRESS_REQUEST.getClusterId(), ieeeResponse);
  ZigBeeNetworkDiscoverer discoverer = new ZigBeeNetworkDiscoverer(networkManager);
  discoverer.setRetryPeriod(1);
  discoverer.startup();
  // Check it registers listeners
  Mockito.verify(networkManager).addCommandListener(discoverer);
  Mockito.verify(networkManager).addAnnounceListener(discoverer);
  // Then wait for the node to be added
  Mockito.verify(networkManager, Mockito.timeout(TIMEOUT).times(1)).addNode(nodeCapture.capture());
  ZigBeeNode node = nodeCapture.getValue();
  assertNotNull(node);
  assertEquals(Integer.valueOf(0), node.getNetworkAddress());
  assertEquals(new IeeeAddress("1234567890ABCDEF"), node.getIeeeAddress());
  assertEquals(0, node.getEndpoints().size());
}

代码示例来源:origin: openhab/org.openhab.binding.zigbee

networkManager.addAnnounceListener(listener);

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