@Test public void updateEndpoint() { ZigBeeEndpoint endpoint1 = getEndpoint(); ZigBeeEndpoint endpoint2 = new ZigBeeEndpoint(node, 5); assertFalse(endpoint1.updateEndpoint(endpoint2)); List<Integer> clusterIds = new ArrayList<>(); clusterIds.add(1); clusterIds.add(2); endpoint2.setInputClusterIds(clusterIds); assertTrue(endpoint1.updateEndpoint(endpoint2)); assertEquals(endpoint1.getInputClusterIds().size(), 2); assertTrue(endpoint1.getInputClusterIds().contains(1)); assertTrue(endpoint1.getInputClusterIds().contains(2)); endpoint2.setOutputClusterIds(clusterIds); assertTrue(endpoint1.updateEndpoint(endpoint2)); assertEquals(endpoint1.getOutputClusterIds().size(), 2); assertTrue(endpoint1.getOutputClusterIds().contains(1)); assertTrue(endpoint1.getOutputClusterIds().contains(2)); }
public boolean updateEndpoint(ZigBeeEndpoint endpoint) { if (!(endpoint.getIeeeAddress().equals(getIeeeAddress()) && endpoint.getEndpointId() == getEndpointId())) { logger.debug("{}: Endpoint {}. Updating from {} not allowed", getIeeeAddress(), getEndpointId(), endpoint.getIeeeAddress()); return false; } boolean updated = false; logger.debug("{}: Endpoint {} updating", getIeeeAddress(), getEndpointId()); if (!endpoint.getInputClusterIds().equals(getInputClusterIds())) { for (Integer clusterId : endpoint.getInputClusterIds()) { if (!inputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding input cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); inputClusters.put(clusterId, endpoint.getInputCluster(clusterId)); updated = true; } } } if (!endpoint.getOutputClusterIds().equals(getOutputClusterIds())) { for (Integer clusterId : endpoint.getOutputClusterIds()) { if (!outputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding output cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); outputClusters.put(clusterId, endpoint.getOutputCluster(clusterId)); updated = true; } } } return updated; }
ZigBeeEndpoint { public boolean updateEndpoint(ZigBeeEndpoint endpoint) { if (!(endpoint.getIeeeAddress().equals(getIeeeAddress()) && endpoint.getEndpointId() == getEndpointId())) { logger.debug("{}: Endpoint {}. Updating from {} not allowed", getIeeeAddress(), getEndpointId(), endpoint.getIeeeAddress()); return false; } boolean updated = false; logger.debug("{}: Endpoint {} updating", getIeeeAddress(), getEndpointId()); if (!endpoint.getInputClusterIds().equals(getInputClusterIds())) { for (Integer clusterId : endpoint.getInputClusterIds()) { if (!inputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding input cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); inputClusters.put(clusterId, endpoint.getInputCluster(clusterId)); updated = true; } } } if (!endpoint.getOutputClusterIds().equals(getOutputClusterIds())) { for (Integer clusterId : endpoint.getOutputClusterIds()) { if (!outputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding output cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); outputClusters.put(clusterId, endpoint.getOutputCluster(clusterId)); updated = true; } } } return updated; } }
ZigBeeEndpoint { public boolean updateEndpoint(ZigBeeEndpoint endpoint) { if (!(endpoint.getIeeeAddress().equals(getIeeeAddress()) && endpoint.getEndpointId() == getEndpointId())) { logger.debug("{}: Endpoint {}. Updating from {} not allowed", getIeeeAddress(), getEndpointId(), endpoint.getIeeeAddress()); return false; } boolean updated = false; logger.debug("{}: Endpoint {} updating", getIeeeAddress(), getEndpointId()); if (!endpoint.getInputClusterIds().equals(getInputClusterIds())) { for (Integer clusterId : endpoint.getInputClusterIds()) { if (!inputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding input cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); inputClusters.put(clusterId, endpoint.getInputCluster(clusterId)); updated = true; } } } if (!endpoint.getOutputClusterIds().equals(getOutputClusterIds())) { for (Integer clusterId : endpoint.getOutputClusterIds()) { if (!outputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding output cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); outputClusters.put(clusterId, endpoint.getOutputCluster(clusterId)); updated = true; } } } return updated; } ZigBeeEndpoint(ZigBeeNode node, int endpoint); }
ZigBeeEndpoint { public boolean updateEndpoint(ZigBeeEndpoint endpoint) { if (!(endpoint.getIeeeAddress().equals(getIeeeAddress()) && endpoint.getEndpointId() == getEndpointId())) { logger.debug("{}: Endpoint {}. Updating from {} not allowed", getIeeeAddress(), getEndpointId(), endpoint.getIeeeAddress()); return false; } boolean updated = false; logger.debug("{}: Endpoint {} updating", getIeeeAddress(), getEndpointId()); if (!endpoint.getInputClusterIds().equals(getInputClusterIds())) { for (Integer clusterId : endpoint.getInputClusterIds()) { if (!inputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding input cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); inputClusters.put(clusterId, endpoint.getInputCluster(clusterId)); updated = true; } } } if (!endpoint.getOutputClusterIds().equals(getOutputClusterIds())) { for (Integer clusterId : endpoint.getOutputClusterIds()) { if (!outputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding output cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); outputClusters.put(clusterId, endpoint.getOutputCluster(clusterId)); updated = true; } } } return updated; } ZigBeeEndpoint(ZigBeeNode node, int endpoint); int getDeviceId(); void setDeviceId(int deviceId); int getDeviceVersion(); void setDeviceVersion(int deviceVersion); int getEndpointId(); Collection<Integer> getInputClusterIds(); boolean addInputCluster(ZclCluster cluster); ZclCluster getInputCluster(int clusterId); ZclCluster getOutputCluster(int clusterId); void setInputClusterIds(List<Integer> inputClusterIds); IeeeAddress getIeeeAddress(); ZigBeeEndpointAddress getEndpointAddress(); Collection<Integer> getOutputClusterIds(); void setOutputClusterIds(Collection<Integer> outputClusterIds); boolean addOutputCluster(ZclCluster cluster); int getProfileId(); void setProfileId(int profileId); ZigBeeNode getParentNode(); ZigBeeStatus addApplication(ZigBeeApplication application); ZigBeeApplication getApplication(int clusterId); void commandReceived(ZclCommand command); boolean updateEndpoint(ZigBeeEndpoint endpoint); ZigBeeEndpointDao getDao(); void setDao(ZigBeeEndpointDao dao); void sendTransaction(ZigBeeCommand command); Future<CommandResult> sendTransaction(ZigBeeCommand command, ZigBeeTransactionMatcher responseMatcher); NotificationService getNotificationService(); @Override String toString(); }
ZigBeeEndpoint { public boolean updateEndpoint(ZigBeeEndpoint endpoint) { if (!(endpoint.getIeeeAddress().equals(getIeeeAddress()) && endpoint.getEndpointId() == getEndpointId())) { logger.debug("{}: Endpoint {}. Updating from {} not allowed", getIeeeAddress(), getEndpointId(), endpoint.getIeeeAddress()); return false; } boolean updated = false; logger.debug("{}: Endpoint {} updating", getIeeeAddress(), getEndpointId()); if (!endpoint.getInputClusterIds().equals(getInputClusterIds())) { for (Integer clusterId : endpoint.getInputClusterIds()) { if (!inputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding input cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); inputClusters.put(clusterId, endpoint.getInputCluster(clusterId)); updated = true; } } } if (!endpoint.getOutputClusterIds().equals(getOutputClusterIds())) { for (Integer clusterId : endpoint.getOutputClusterIds()) { if (!outputClusters.containsKey(clusterId)) { logger.debug("{}: Endpoint {}. Adding output cluster {}", getEndpointAddress(), getEndpointId(), String.format("%04X", clusterId)); outputClusters.put(clusterId, endpoint.getOutputCluster(clusterId)); updated = true; } } } return updated; } ZigBeeEndpoint(ZigBeeNode node, int endpoint); int getDeviceId(); void setDeviceId(int deviceId); int getDeviceVersion(); void setDeviceVersion(int deviceVersion); int getEndpointId(); Collection<Integer> getInputClusterIds(); boolean addInputCluster(ZclCluster cluster); ZclCluster getInputCluster(int clusterId); ZclCluster getOutputCluster(int clusterId); void setInputClusterIds(List<Integer> inputClusterIds); IeeeAddress getIeeeAddress(); ZigBeeEndpointAddress getEndpointAddress(); Collection<Integer> getOutputClusterIds(); void setOutputClusterIds(Collection<Integer> outputClusterIds); boolean addOutputCluster(ZclCluster cluster); int getProfileId(); void setProfileId(int profileId); ZigBeeNode getParentNode(); ZigBeeStatus addApplication(ZigBeeApplication application); ZigBeeApplication getApplication(int clusterId); void commandReceived(ZclCommand command); boolean updateEndpoint(ZigBeeEndpoint endpoint); ZigBeeEndpointDao getDao(); void setDao(ZigBeeEndpointDao dao); void sendTransaction(ZigBeeCommand command); Future<CommandResult> sendTransaction(ZigBeeCommand command, ZigBeeTransactionMatcher responseMatcher); NotificationService getNotificationService(); @Override String toString();  }