gpt4 book ai didi

com.zsmartsystems.zigbee.app.discovery.ZigBeeNodeServiceDiscoverer类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 06:47:31 26 4
gpt4 key购买 nike

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

ZigBeeNodeServiceDiscoverer介绍

[英]This class contains methods for discovering the services and features of a ZigBeeNode. All discovery methods are private and the class is utilised by calling #startDiscovery(Set) with a set of #NodeDiscoveryState for the stages wishing to be discovered or updated.

A single worker thread is ensured - if the thread is already active when #startDiscovery(Set) is called, the new tasks will be added to the existing task queue if they are not already in the queue. If the worker thread is not running, it will be started.

This class provides a centralised helper, used for discovering and updating information about the ZigBeeNode

A random exponential backoff is used for retries to reduce congestion. If the device replies that a command is not supported, then this will not be issued again on subsequent requests.

Once the discovery update is complete the ZigBeeNetworkManager#updateNode(ZigBeeNode) is called to alert users.
[中]此类包含用于发现ZigBeeNode的服务和功能的方法。所有发现方法都是私有的,该类通过调用#startDiscovery(Set)和一组#NodeDiscoveryState来使用,用于希望被发现或更新的阶段。
确保一个工作线程——如果在调用#startDiscovery(Set)时线程已经处于活动状态,则新任务将被添加到现有任务队列中(如果它们尚未在队列中)。如果工作线程没有运行,它将被启动。
这个类提供了一个集中的助手,用于发现和更新关于ZigBeeNode的信息
随机指数退避用于重试以减少拥塞。如果设备回复不支持命令,则不会在后续请求中再次发出该命令。
一旦发现更新完成,就会调用ZigBeeNetworkManager#updateNode(ZigBeeNode)来提醒用户。

代码示例

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

private void outputDiscoveryTasks(ZigBeeDiscoveryExtension extension, PrintStream out) {
  out.println("Mesh update period : " + extension.getUpdatePeriod() + " seconds");
  out.println();
  out.println("Address           Nwk    Last Start            Last Complete         Current Tasks");
  for (ZigBeeNodeServiceDiscoverer discoverer : extension.getNodeDiscoverers()) {
    ZigBeeNode node = discoverer.getNode();
    out.println(String.format("%s  %-5d  %-20s  %-20s  %s", node.getIeeeAddress(), node.getNetworkAddress(),
        discoverer.getLastDiscoveryStarted() == null ? NEVER
            : dfIso8601.format(discoverer.getLastDiscoveryStarted().getTime()),
        discoverer.getLastDiscoveryCompleted() == null ? NEVER
            : dfIso8601.format(discoverer.getLastDiscoveryCompleted().getTime()),
        tasksToString(discoverer.getTasks())));
  }
}

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

protected void startDiscovery(ZigBeeNode node) {
  ZigBeeNodeServiceDiscoverer nodeDiscoverer = new ZigBeeNodeServiceDiscoverer(networkManager, node);
  nodeDiscovery.put(node.getIeeeAddress(), nodeDiscoverer);
  nodeDiscoverer.startDiscovery();
}

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

@Override
  public void run() {
    logger.debug("DISCOVERY Extension: Starting mesh update");
    for (ZigBeeNodeServiceDiscoverer node : nodeDiscovery.values()) {
      logger.debug("DISCOVERY Extension: Starting mesh update for {}", node.getNode().getIeeeAddress());
      node.updateMesh();
    }
  }
};

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

private void displayNodeMesh(ZigBeeNode node, ZigBeeNodeServiceDiscoverer discoverer, PrintStream out) {
  out.println("IEEE Address             : " + node.getIeeeAddress().toString());
  out.println("NWK Address              : " + node.getNetworkAddress().toString());
  out.println("Last discovery started : " + discoverer.getLastDiscoveryStarted() == null ? NEVER
      : dfIso8601.format(discoverer.getLastDiscoveryStarted().getTime()));
  out.println("Last discovery completed : " + discoverer.getLastDiscoveryCompleted() == null ? NEVER
      : dfIso8601.format(discoverer.getLastDiscoveryStarted().getTime()));
  out.println("Current tasks            : " + tasksToString(discoverer.getTasks()));
}

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

@Test
public void test() throws Exception {
  ZigBeeNode node = Mockito.mock(ZigBeeNode.class);
  ZigBeeNodeServiceDiscoverer discoverer = new ZigBeeNodeServiceDiscoverer(networkManager, node);
  discoverer.setMaxBackoff(10);
  assertEquals(10, discoverer.getMaxBackoff());
  assertTrue(discoverer.getTasks().isEmpty());
  assertEquals(node, discoverer.getNode());
  responses.put(ZdoCommandType.MANAGEMENT_ROUTING_REQUEST.getClusterId(), routingResponse);
  discoverer.startDiscovery();
  assertTrue(discoverer.getTasks().contains(NodeDiscoveryTask.ACTIVE_ENDPOINTS));

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

@Test
  public void testLocal() throws Exception {
    ZigBeeNode node = Mockito.mock(ZigBeeNode.class);
    ZigBeeNodeServiceDiscoverer discoverer = new ZigBeeNodeServiceDiscoverer(networkManager, node);

    TestUtilities.setField(ZigBeeNodeServiceDiscoverer.class, discoverer, "retryPeriod", 1);

    NodeDescriptor initialNodeDescriptor = Mockito.mock(NodeDescriptor.class);
    Mockito.when(initialNodeDescriptor.getLogicalType()).thenReturn(LogicalType.UNKNOWN);
    Mockito.when(node.getNodeDescriptor()).thenReturn(initialNodeDescriptor);

    PowerDescriptor initialPowerDescriptor = Mockito.mock(PowerDescriptor.class);
    Mockito.when(initialPowerDescriptor.getCurrentPowerMode()).thenReturn(CurrentPowerModeType.UNKNOWN);
    Mockito.when(node.getPowerDescriptor()).thenReturn(initialPowerDescriptor);

    // Use node 0 and we should not try and get the local endpoints
    Mockito.when(node.getNetworkAddress()).thenReturn(0);

    ScheduledFuture<?> futureTask = Mockito.mock(ScheduledFuture.class);
    TestUtilities.setField(ZigBeeNodeServiceDiscoverer.class, discoverer, "futureTask", futureTask);

    discoverer.startDiscovery();

    Mockito.verify(futureTask, Mockito.times(1)).cancel(true);

    assertFalse(discoverer.getTasks().contains(NodeDiscoveryTask.ACTIVE_ENDPOINTS));
  }
}

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

break;
case "start":
  discoverer.startDiscovery();
  out.println("Discovery for " + node.getIeeeAddress().toString() + " has been started.");
  return;
case "update":
  discoverer.updateMesh();
  out.println("Network mesh update for " + node.getIeeeAddress().toString() + " has been started.");
  return;

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

/**
 * Starts service discovery for the node in order to update the mesh. This adds the
 * {@link NodeDiscoveryTask#NEIGHBORS} and {@link NodeDiscoveryTask#ROUTES} tasks to the task list.
 * <p>
 * Note that {@link NodeDiscoveryTask#ROUTES} is not added for end devices.
 */
public void updateMesh() {
  logger.debug("{}: Node SVC Discovery: Update mesh", node.getIeeeAddress());
  Set<NodeDiscoveryTask> tasks = new HashSet<NodeDiscoveryTask>();
  tasks.add(NodeDiscoveryTask.NEIGHBORS);
  if (node.getNodeDescriptor().getLogicalType() != LogicalType.END_DEVICE) {
    tasks.add(NodeDiscoveryTask.ROUTES);
  }
  startDiscovery(tasks);
}

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

private ZigBeeNodeServiceDiscoverer getNodeDiscoverer(ZigBeeDiscoveryExtension extension, IeeeAddress ieeeAddress) {
  for (ZigBeeNodeServiceDiscoverer discoverer : extension.getNodeDiscoverers()) {
    if (discoverer.getNode().getIeeeAddress().equals(ieeeAddress)) {
      return discoverer;
    }
  }
  return null;
}

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

ZigBeeEndpoint endpoint = getSimpleDescriptor(endpointId);
if (endpoint == null) {
  return false;

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

/**
 * Starts service discovery for the node.
 */
public void startDiscovery() {
  logger.debug("{}: Node SVC Discovery: start discovery", node.getIeeeAddress());
  Set<NodeDiscoveryTask> tasks = new HashSet<NodeDiscoveryTask>();
  // Always request the network address - in case it's changed
  tasks.add(NodeDiscoveryTask.NWK_ADDRESS);
  if (node.getNodeDescriptor().getLogicalType() == LogicalType.UNKNOWN) {
    tasks.add(NodeDiscoveryTask.NODE_DESCRIPTOR);
  }
  if (node.getPowerDescriptor().getCurrentPowerMode() == CurrentPowerModeType.UNKNOWN) {
    tasks.add(NodeDiscoveryTask.POWER_DESCRIPTOR);
  }
  if (node.getEndpoints().size() == 0 && node.getNetworkAddress() != networkManager.getLocalNwkAddress()) {
    tasks.add(NodeDiscoveryTask.ACTIVE_ENDPOINTS);
  }
  tasks.add(NodeDiscoveryTask.NEIGHBORS);
  startDiscovery(tasks);
}

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