gpt4 book ai didi

com.zsmartsystems.zigbee.ZigBeeEndpoint类的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 06:55:31 25 4
gpt4 key购买 nike

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

ZigBeeEndpoint介绍

[英]ZigBee endpoint. An endpoint is a virtual entity contained within a ZigBeeNode. The ZigBeeNode is the physical device and can contain up to 254 endpoints.
[中]ZigBee端点。端点是包含在节点中的虚拟实体。ZigBeeNode是物理设备,最多可包含254个端点。

代码示例

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

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out)
    throws IllegalArgumentException {
  if (args.length != 2) {
    throw new IllegalArgumentException("Invalid number of arguments");
  }
  final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
  ZigBeeProfileType profile = ZigBeeProfileType.getByValue(endpoint.getProfileId());
  ZigBeeDeviceType device = ZigBeeDeviceType.getByValue(endpoint.getDeviceId());
  out.println("IEEE Address     : " + endpoint.getIeeeAddress());
  out.println("Network Address  : " + endpoint.getParentNode().getNetworkAddress());
  out.println("Endpoint         : " + endpoint.getEndpointId());
  out.println("Device Profile   : " + String.format("0x%04X, ", endpoint.getProfileId())
      + (profile == null ? "Unknown" : profile.toString()));
  out.println("Device Type      : " + String.format("0x%04X, ", endpoint.getDeviceId())
      + (device == null ? "Unknown" : device.toString()));
  out.println("Device Version   : " + endpoint.getDeviceVersion());
  out.println("Input Clusters   : (Server)");
  printClusters(endpoint, true, out);
  out.println("Output Clusters  : (Client)");
  printClusters(endpoint, false, out);
}

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

public List<ZclClusterConfigHandler> getConfigHandlers(ZigBeeEndpoint endpoint) {
  List<ZclClusterConfigHandler> handlers = new ArrayList<>();
  for (int clusterId : endpoint.getInputClusterIds()) {
    try {
      ZclClusterConfigHandler handler = getClusterConfigHandler(endpoint.getInputCluster(clusterId));
      if (handler != null) {
        handlers.add(handler);
      }
    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
        | InvocationTargetException | NoSuchMethodException | SecurityException e) {
      logger.debug("{}: Exception while getting config for input cluster {}: ", endpoint.getIeeeAddress(),
          clusterId, e);
    }
  }
  for (int clusterId : endpoint.getOutputClusterIds()) {
    try {
      ZclClusterConfigHandler handler = getClusterConfigHandler(endpoint.getOutputCluster(clusterId));
      if (handler != null) {
        handlers.add(handler);
      }
    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
        | InvocationTargetException | NoSuchMethodException | SecurityException e) {
      logger.debug("{}: Exception while getting config for output cluster {}: ", endpoint.getIeeeAddress(),
          clusterId, e);
    }
  }
  return handlers;
}

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

@Override
  public String toString() {
    return "ZigBeeEndpoint [networkAddress=" + getEndpointAddress().toString() + ", profileId="
        + String.format("%04X", profileId) + ", deviceId=" + deviceId + ", deviceVersion=" + deviceVersion
        + ", inputClusterIds=" + getInputClusterIds().toString() + ", outputClusterIds="
        + getOutputClusterIds().toString() + "]";
  }
}

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

protected boolean hasIasZoneInputCluster(ZigBeeEndpoint endpoint) {
  if (endpoint.getInputCluster(ZclIasZoneCluster.CLUSTER_ID) == null) {
    logger.trace("{}: IAS zone cluster not found", endpoint.getIeeeAddress());
    return false;
  }
  return true;
}

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

/**
 * Gets a cluster from the input or output cluster list depending on the command {@link ZclCommandDirection} for a
 * received command.
 * <p>
 * If commandDirection is {@link ZclCommandDirection#CLIENT_TO_SERVER} then the cluster comes from the output
 * cluster list.
 * If commandDirection is {@link ZclCommandDirection#SERVER_TO_CLIENT} then the cluster comes from the input
 * cluster list.
 *
 * @param clusterId the cluster ID to get
 * @param direction the {@link ZclCommandDirection}
 * @return the {@link ZclCluster} or null if the cluster is not known
 */
private ZclCluster getReceiveCluster(int clusterId, ZclCommandDirection direction) {
  if (direction == ZclCommandDirection.CLIENT_TO_SERVER) {
    return getOutputCluster(clusterId);
  } else {
    return getInputCluster(clusterId);
  }
}

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

/**
 * Sets input cluster IDs. This will add any new clusters in the list, and remove any that are no longer in the
 * list.
 *
 * @param inputClusterIds the input cluster IDs
 */
public void setInputClusterIds(List<Integer> inputClusterIds) {
  inputClusters.clear();
  logger.debug("{}: Setting input clusters {}", getEndpointAddress(), inputClusterIds);
  updateClusters(inputClusters, inputClusterIds, true);
}

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

logger.debug("{}: Checking endpoint {} channels", nodeIeeeAddress, endpoint.getEndpointId());
  nodeChannels.addAll(channelFactory.getChannels(getThing().getUID(), endpoint));
  endpoint = new ZigBeeEndpoint(node, endpointId);
  endpoint.setProfileId(profileId);
  node.addEndpoint(endpoint);
staticClusters = processClusterList(endpoint.getInputClusterIds(),
    properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_INPUTCLUSTERS));
if (!staticClusters.isEmpty()) {
  logger.debug("{}: Forcing endpoint {} input clusters {}", nodeIeeeAddress, endpointId, staticClusters);
  endpoint.setInputClusterIds(staticClusters);
  modified = true;
staticClusters = processClusterList(endpoint.getOutputClusterIds(),
    properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_OUTPUTCLUSTERS));
if (!staticClusters.isEmpty()) {
  logger.debug("{}: Forcing endpoint {} output clusters {}", nodeIeeeAddress, endpointId, staticClusters);
  endpoint.setOutputClusterIds(staticClusters);
  modified = true;

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

@Override
public boolean initializeConverter() {
  clusterOnOffClient = (ZclOnOffCluster) endpoint.getOutputCluster(ZclOnOffCluster.CLUSTER_ID);
  clusterOnOffServer = (ZclOnOffCluster) endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID);
  if (clusterOnOffClient == null && clusterOnOffServer == null) {
    logger.error("{}: Error opening device on/off controls", endpoint.getIeeeAddress());
    return false;
  }
  if (clusterOnOffServer != null) {
    // Add the listener
    clusterOnOffServer.addAttributeListener(this);
  }
  if (clusterOnOffClient != null) {
    // Add the command listener
    clusterOnOffClient.addCommandListener(this);
  }
  return true;
}

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

/**
 * Adds a binding from the cluster to the destination {@link ZigBeeEndpoint}.
 *
 * @param address the destination {@link IeeeAddress}
 * @param endpointId the destination endpoint ID
 * @return Command future
 */
public Future<CommandResult> bind(IeeeAddress address, int endpointId) {
  final BindRequest command = new BindRequest();
  command.setDestinationAddress(new ZigBeeEndpointAddress(zigbeeEndpoint.getEndpointAddress().getAddress()));
  command.setSrcAddress(zigbeeEndpoint.getIeeeAddress());
  command.setSrcEndpoint(zigbeeEndpoint.getEndpointId());
  command.setBindCluster(clusterId);
  command.setDstAddrMode(3); // 64 bit addressing
  command.setDstAddress(address);
  command.setDstEndpoint(endpointId);
  return zigbeeEndpoint.sendTransaction(command, new BindRequest());
}

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

@Test
public void testInputClusterIds() {
  ZigBeeEndpoint endpoint = getEndpoint();
  List<Integer> clusterIdList = new ArrayList<Integer>();
  clusterIdList.add(ZclAlarmsCluster.CLUSTER_ID);
  clusterIdList.add(ZclBasicCluster.CLUSTER_ID);
  clusterIdList.add(ZclColorControlCluster.CLUSTER_ID);
  clusterIdList.add(ZclDoorLockCluster.CLUSTER_ID);
  clusterIdList.add(ZclLevelControlCluster.CLUSTER_ID);
  endpoint.setInputClusterIds(clusterIdList);
  assertEquals(5, endpoint.getInputClusterIds().size());
  assertNotNull(endpoint.getInputCluster(ZclAlarmsCluster.CLUSTER_ID));
  assertFalse(endpoint.getInputCluster(ZclAlarmsCluster.CLUSTER_ID).isClient());
  assertTrue(endpoint.getInputCluster(ZclAlarmsCluster.CLUSTER_ID).isServer());
  assertNotNull(endpoint.getInputCluster(ZclLevelControlCluster.CLUSTER_ID));
  assertFalse(endpoint.getInputCluster(ZclLevelControlCluster.CLUSTER_ID).isClient());
  assertTrue(endpoint.getInputCluster(ZclLevelControlCluster.CLUSTER_ID).isServer());
  assertTrue(endpoint.addInputCluster(new ZclScenesCluster(endpoint)));
  assertFalse(endpoint.addInputCluster(new ZclScenesCluster(endpoint)));
  assertTrue(endpoint.getInputClusterIds().contains(ZclScenesCluster.CLUSTER_ID));
  assertTrue(endpoint.getOutputClusterIds().isEmpty());
}

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

@Test
public void testOutputClusterIds() {
  ZigBeeEndpoint endpoint = getEndpoint();
  List<Integer> clusterIdList = new ArrayList<Integer>();
  clusterIdList.add(ZclAlarmsCluster.CLUSTER_ID);
  clusterIdList.add(ZclBasicCluster.CLUSTER_ID);
  clusterIdList.add(ZclColorControlCluster.CLUSTER_ID);
  clusterIdList.add(ZclDoorLockCluster.CLUSTER_ID);
  clusterIdList.add(ZclLevelControlCluster.CLUSTER_ID);
  endpoint.setOutputClusterIds(clusterIdList);
  assertEquals(5, endpoint.getOutputClusterIds().size());
  assertNotNull(endpoint.getOutputCluster(ZclAlarmsCluster.CLUSTER_ID));
  assertTrue(endpoint.getOutputCluster(ZclAlarmsCluster.CLUSTER_ID).isClient());
  assertFalse(endpoint.getOutputCluster(ZclAlarmsCluster.CLUSTER_ID).isServer());
  assertNotNull(endpoint.getOutputCluster(ZclLevelControlCluster.CLUSTER_ID));
  assertTrue(endpoint.getOutputCluster(ZclLevelControlCluster.CLUSTER_ID).isClient());
  assertFalse(endpoint.getOutputCluster(ZclLevelControlCluster.CLUSTER_ID).isServer());
  clusterIdList = new ArrayList<Integer>();
  clusterIdList.add(ZclAlarmsCluster.CLUSTER_ID);
  clusterIdList.add(ZclBasicCluster.CLUSTER_ID);
  assertTrue(endpoint.getOutputCluster(ZclAlarmsCluster.CLUSTER_ID).isClient());
  assertFalse(endpoint.getOutputCluster(ZclLevelControlCluster.CLUSTER_ID).isServer());
  assertTrue(endpoint.addOutputCluster(new ZclScenesCluster(endpoint)));
  assertFalse(endpoint.addOutputCluster(new ZclScenesCluster(endpoint)));
  assertTrue(endpoint.getOutputClusterIds().contains(ZclScenesCluster.CLUSTER_ID));
  assertTrue(endpoint.getInputClusterIds().isEmpty());
  System.out.println(endpoint.toString());
}

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

@Override
public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) {
  ZclPowerConfigurationCluster powerConfigurationCluster = (ZclPowerConfigurationCluster) endpoint
      .getInputCluster(ZclPowerConfigurationCluster.CLUSTER_ID);
  if (powerConfigurationCluster == null) {
    logger.trace("{}: Power configuration cluster not found on endpoint {}", endpoint.getIeeeAddress(),
        endpoint.getEndpointId());
    return null;
  }
  try {
    if (!powerConfigurationCluster.discoverAttributes(false).get() && !powerConfigurationCluster
        .isAttributeSupported(ZclPowerConfigurationCluster.ATTR_BATTERYALARMSTATE)) {
      logger.trace("{}: Power configuration cluster battery alarm state not supported",
          endpoint.getIeeeAddress());
      return null;
    }
  } catch (InterruptedException | ExecutionException e) {
    logger.warn("{}: Exception discovering attributes in power configuration cluster",
        endpoint.getIeeeAddress(), e);
    return null;
  }
  return ChannelBuilder
      .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_POWER_BATTERYALARM),
          ZigBeeBindingConstants.ITEM_TYPE_STRING)
      .withType(ZigBeeBindingConstants.CHANNEL_POWER_BATTERYALARM)
      .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_POWER_BATTERYALARM)
      .withProperties(createProperties(endpoint)).build();
}

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

ZigBeeEndpoint endpoint = new ZigBeeEndpoint(node, endpointId);
SimpleDescriptor simpleDescriptor = simpleDescriptorResponse.getSimpleDescriptor();
endpoint.setProfileId(simpleDescriptor.getProfileId());
endpoint.setDeviceId(simpleDescriptor.getDeviceId());
endpoint.setDeviceVersion(simpleDescriptor.getDeviceVersion());
endpoint.setInputClusterIds(simpleDescriptor.getInputClusterList());
endpoint.setOutputClusterIds(simpleDescriptor.getOutputClusterList());

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

result = endpoint.getInputCluster(clusterId);
} else if (isOutput) {
  result = endpoint.getOutputCluster(clusterId);
} else {
  ZclCluster cluster = endpoint.getInputCluster(clusterId);
  result = (cluster != null) ? cluster : endpoint.getOutputCluster(clusterId);
} else {
  throw new IllegalArgumentException("A cluster specified by " + clusterSpecifier
      + " is not found for endpoint " + endpoint.getEndpointId());

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

/**
 * Creates a standard channel UID given the {@link ZigBeeEndpoint}
 *
 * @param thingUID the {@link ThingUID}
 * @param endpoint the {@link ZigBeeEndpoint}
 * @param channelName the name of the channel
 * @return
 */
protected ChannelUID createChannelUID(ThingUID thingUID, ZigBeeEndpoint endpoint, String channelName) {
  return new ChannelUID(thingUID, endpoint.getIeeeAddress() + "_" + endpoint.getEndpointId() + "_" + channelName);
}

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

private void outputEndpoint(PrintStream out, ZigBeeEndpoint endpoint) {
    out.println("Profile     " + String.format("%04X ", endpoint.getProfileId())
        + ZigBeeProfileType.getByValue(endpoint.getProfileId()));
    out.println("                 : Device Type " + String.format("%04X ", endpoint.getDeviceId())
        + com.zsmartsystems.zigbee.ZigBeeDeviceType.getByValue(endpoint.getDeviceId()).toString());
    for (Integer clusterId : endpoint.getInputClusterIds()) {
      out.println("                   -> " + ZclClusterType.getValueById(clusterId));
    }
    for (Integer clusterId : endpoint.getOutputClusterIds()) {
      out.println("                   <- " + ZclClusterType.getValueById(clusterId));
    }
  }
}

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

/**
 * Returns the ZigBee address of this cluster
 *
 * @return the {@link ZigBeeEndpointAddress} of the cluster
 */
public ZigBeeEndpointAddress getZigBeeAddress() {
  return zigbeeEndpoint.getEndpointAddress();
}

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

endpoint.getIeeeAddress(), channel.getUID());
return false;
ZclCluster clientCluster = endpoint.getOutputCluster(clusterId);
if (clientCluster == null) {
  logger.error("{}: Error opening client cluster {} on endpoint {}", endpoint.getIeeeAddress(), clusterId,
      endpoint.getEndpointId());
  return false;
  CommandResult bindResponse = bind(clientCluster).get();
  if (!bindResponse.isSuccess()) {
    logger.error("{}: Error 0x{} setting client binding for cluster {}", endpoint.getIeeeAddress(),
        toHexString(bindResponse.getStatusCode()), clusterId);
  logger.error(endpoint.getIeeeAddress() + ": Exception setting binding to cluster " + clusterId, e);

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

private void cmdDisplayAllNodes(ZigBeeNetworkManager networkManager, PrintStream out) {
  Map<Integer, ZigBeeEndpoint> applications = getApplications(networkManager, ZclOtaUpgradeCluster.CLUSTER_ID);
  if (applications.isEmpty()) {
    out.println("No OTA upgrade servers found.");
    return;
  }
  out.println("Address    Ieee Address      State     ");
  for (ZigBeeEndpoint endpoint : applications.values()) {
    ZclOtaUpgradeServer otaServer = (ZclOtaUpgradeServer) endpoint
        .getApplication(ZclOtaUpgradeCluster.CLUSTER_ID);
    out.println(String.format("%-9s  %s  %-8s", endpoint.getEndpointAddress(), endpoint.getIeeeAddress(),
        otaServer.getServerStatus()));
  }
}

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

private void createEndpoint() {
  endpoint = Mockito.mock(ZigBeeEndpoint.class);
  Mockito.when(endpoint.getEndpointId()).thenReturn(5);
  Mockito.when(endpoint.getEndpointAddress()).thenReturn(new ZigBeeEndpointAddress(1234, 5));
  commandCapture = ArgumentCaptor.forClass(ZigBeeCommand.class);
  matcherCapture = ArgumentCaptor.forClass(ZigBeeTransactionMatcher.class);
  Mockito.when(endpoint.sendTransaction(commandCapture.capture(), matcherCapture.capture())).thenReturn(null);
}

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