@Test public void setDao() { createEndpoint(); ZclOnOffCluster cluster = new ZclOnOffCluster(endpoint); Set<Integer> onOffClusterAttributeIds = cluster.getAttributes().stream().map(ZclAttribute::getId) .collect(toSet()); ZclClusterDao clusterDao = cluster.getDao(); Map<Integer, ZclAttributeDao> attributeDaos = clusterDao.getAttributes(); ZclAttributeDao manufacturerSpecificAttributeDao = new ZclAttributeDao(); manufacturerSpecificAttributeDao.setId(0xF000); manufacturerSpecificAttributeDao.setManufacturerCode(0x1234); manufacturerSpecificAttributeDao.setDataType(ZclDataType.SIGNED_16_BIT_INTEGER); manufacturerSpecificAttributeDao.setLastValue(Double.valueOf(123)); attributeDaos.put(manufacturerSpecificAttributeDao.getId(), manufacturerSpecificAttributeDao); ZclAttributeDao onOffAttributeDao = attributeDaos.get(ATTR_ONOFF); onOffAttributeDao.setLastValue(TRUE); onOffAttributeDao.setImplemented(true); clusterDao.setAttributes(attributeDaos); cluster.setDao(clusterDao); assertEquals(onOffClusterAttributeIds.size() + 1, cluster.getAttributes().size()); for (Integer attributeId : onOffClusterAttributeIds) { ZclAttribute attribute = cluster.getAttribute(attributeId); assertNotNull(attribute); assertEquals(new ZclOnOffCluster(endpoint).getAttribute(attributeId).getDataType(), attribute.getDataType()); assertEquals(new ZclOnOffCluster(endpoint).getAttribute(attributeId).getMaximumReportingPeriod(), attribute.getMaximumReportingPeriod()); assertEquals(new ZclOnOffCluster(endpoint).getAttribute(attributeId).getName(), attribute.getName()); } ZclAttribute onOffAttribute = cluster.getAttribute(ATTR_ONOFF); assertEquals(TRUE, onOffAttribute.getLastValue()); assertTrue(onOffAttribute.isImplemented()); ZclAttribute manufacturerSpecificAttribute = cluster.getAttribute(0xF000); assertEquals(manufacturerSpecificAttribute.getManufacturerCode(), Integer.valueOf(0x1234)); assertEquals(manufacturerSpecificAttribute.getLastValue(), Integer.valueOf(123)); }
public void setDao(ZclClusterDao dao) { clusterId = dao.getClusterId(); isClient = dao.getClient(); supportedAttributesKnown = dao.getSupportedAttributes() != null; if (supportedAttributesKnown) { supportedAttributes.addAll(dao.getSupportedAttributes()); } supportedCommandsGenerated.addAll(dao.getSupportedCommandsGenerated()); supportedCommandsReceived.addAll(dao.getSupportedCommandsReceived()); Map<Integer, ZclAttribute> attributes = isClient ? clientAttributes : serverAttributes; for (ZclAttributeDao daoAttribute : dao.getAttributes().values()) { daoAttribute .setLastValue(normalizer.normalizeZclData(daoAttribute.getDataType(), daoAttribute.getLastValue())); ZclAttribute attribute = attributes.get(daoAttribute.getId()); if (attribute == null || daoAttribute.getManufacturerCode() != null) { attribute = new ZclAttribute(); attribute.setDao(this, daoAttribute); attributes.put(daoAttribute.getId(), attribute); } else { attribute.setDynamicStateFromDao(daoAttribute); } } }
ZclCluster { public void setDao(ZclClusterDao dao) { clusterId = dao.getClusterId(); isClient = dao.getClient(); supportedAttributesKnown = dao.getSupportedAttributes() != null; if (supportedAttributesKnown) { supportedAttributes.addAll(dao.getSupportedAttributes()); } supportedCommandsGenerated.addAll(dao.getSupportedCommandsGenerated()); supportedCommandsReceived.addAll(dao.getSupportedCommandsReceived()); Map<Integer, ZclAttribute> attributes = isClient ? clientAttributes : serverAttributes; for (ZclAttributeDao daoAttribute : dao.getAttributes().values()) { daoAttribute .setLastValue(normalizer.normalizeZclData(daoAttribute.getDataType(), daoAttribute.getLastValue())); ZclAttribute attribute = attributes.get(daoAttribute.getId()); if (attribute == null || daoAttribute.getManufacturerCode() != null) { attribute = new ZclAttribute(); attribute.setDao(this, daoAttribute); attributes.put(daoAttribute.getId(), attribute); } else { attribute.setDynamicStateFromDao(daoAttribute); } } } }
ZclCluster { public void setDao(ZclClusterDao dao) { clusterId = dao.getClusterId(); isClient = dao.getClient(); supportedAttributesKnown = dao.getSupportedAttributes() != null; if (supportedAttributesKnown) { supportedAttributes.addAll(dao.getSupportedAttributes()); } supportedCommandsGenerated.addAll(dao.getSupportedCommandsGenerated()); supportedCommandsReceived.addAll(dao.getSupportedCommandsReceived()); Map<Integer, ZclAttribute> attributes = isClient ? clientAttributes : serverAttributes; for (ZclAttributeDao daoAttribute : dao.getAttributes().values()) { daoAttribute .setLastValue(normalizer.normalizeZclData(daoAttribute.getDataType(), daoAttribute.getLastValue())); ZclAttribute attribute = attributes.get(daoAttribute.getId()); if (attribute == null || daoAttribute.getManufacturerCode() != null) { attribute = new ZclAttribute(); attribute.setDao(this, daoAttribute); attributes.put(daoAttribute.getId(), attribute); } else { attribute.setDynamicStateFromDao(daoAttribute); } } } protected  ZclCluster(ZigBeeEndpoint zigbeeEndpoint, int clusterId, String clusterName); }
ZclCluster { public void setDao(ZclClusterDao dao) { clusterId = dao.getClusterId(); isClient = dao.getClient(); supportedAttributesKnown = dao.getSupportedAttributes() != null; if (supportedAttributesKnown) { supportedAttributes.addAll(dao.getSupportedAttributes()); } supportedCommandsGenerated.addAll(dao.getSupportedCommandsGenerated()); supportedCommandsReceived.addAll(dao.getSupportedCommandsReceived()); Map<Integer, ZclAttribute> attributes = isClient ? clientAttributes : serverAttributes; for (ZclAttributeDao daoAttribute : dao.getAttributes().values()) { daoAttribute .setLastValue(normalizer.normalizeZclData(daoAttribute.getDataType(), daoAttribute.getLastValue())); ZclAttribute attribute = attributes.get(daoAttribute.getId()); if (attribute == null || daoAttribute.getManufacturerCode() != null) { attribute = new ZclAttribute(); attribute.setDao(this, daoAttribute); attributes.put(daoAttribute.getId(), attribute); } else { attribute.setDynamicStateFromDao(daoAttribute); } } } protected  ZclCluster(ZigBeeEndpoint zigbeeEndpoint, int clusterId, String clusterName); Future<CommandResult> sendCommand(ZclGeneralCommand command); void sendDefaultResponse(ZclCommand command, ZclStatus status); @Deprecated void sendDefaultResponse(Integer transactionId, Integer commandIdentifier, ZclStatus status,
            Integer manufacturerCode); @Deprecated void sendDefaultResponse(Integer transactionId, Integer commandIdentifier, ZclStatus status); Future<CommandResult> writeAttribute(final int attributeId, final ZclDataType dataType, final Object value); Future<CommandResult> writeAttributes(List<WriteAttributeRecord> attributes); Future<CommandResult> readAttribute(final int attributeId); Future<CommandResult> readAttributes(final List<Integer> attributeIds); Future<CommandResult> reportAttribute(final int attributeId, final ZclDataType dataType,
            final Object value); Future<CommandResult> reportAttributes(List<AttributeReport> attributes); Future<CommandResult> setReporting(final int attributeId, final int minInterval, final int maxInterval,
            Object reportableChange); Future<CommandResult> setReporting(final int attributeId, final int minInterval, final int maxInterval); Future<CommandResult> getReporting(final int attributeId); Collection<ZclAttribute> getAttributes(); ZclAttribute getAttribute(int attributeId); ZclAttribute getLocalAttribute(int attributeId); Collection<ZclAttribute> getLocalAttributes(); Integer getClusterId(); String getClusterName(); ZigBeeEndpointAddress getZigBeeAddress(); void setServer(); boolean isServer(); void setClient(); boolean isClient(); void setApsSecurityRequired(boolean requireApsSecurity); boolean getApsSecurityRequired(); Future<CommandResult> bind(IeeeAddress address, int endpointId); Future<CommandResult> unbind(IeeeAddress address, int endpointId); Set<Integer> getSupportedAttributes(); boolean isAttributeSupported(int attributeId); Future<Boolean> discoverAttributes(final boolean rediscover); Future<Boolean> discoverAttributes(final boolean rediscover, final Integer manufacturerCode); Set<Integer> getSupportedCommandsReceived(); boolean isReceivedCommandSupported(int commandId); Future<Boolean> discoverCommandsReceived(final boolean rediscover); Future<Boolean> discoverCommandsReceived(final boolean rediscover, final Integer manufacturerCode); Set<Integer> getSupportedCommandsGenerated(); boolean isGeneratedCommandSupported(int commandId); Future<Boolean> discoverCommandsGenerated(final boolean rediscover); Future<Boolean> discoverCommandsGenerated(final boolean rediscover, final Integer manufacturerCode); void addAttributeListener(ZclAttributeListener listener); void removeAttributeListener(final ZclAttributeListener listener); void addCommandListener(ZclCommandListener listener); void removeCommandListener(final ZclCommandListener listener); void handleCommand(ZclCommand command); ZclCommand getCommandFromId(ZclFrameType zclFrameType, int commandId); ZclCommand getResponseFromId(ZclFrameType zclFrameType, int commandId); ZclClusterDao getDao(); void setDao(ZclClusterDao dao); @Deprecated Future<CommandResult> write(final int attribute, final ZclDataType dataType, final Object value); @Deprecated Future<CommandResult> write(final ZclAttribute attribute, final Object value); @Deprecated Future<CommandResult> read(final int attribute); @Deprecated Future<CommandResult> read(final ZclAttribute attribute); @Deprecated Future<CommandResult> read(final List<Integer> attributes); @Deprecated Future<CommandResult> setReporting(final ZclAttribute attribute, final int minInterval,
            final int maxInterval, final Object reportableChange); @Deprecated Future<CommandResult> setReporting(final ZclAttribute attribute, final int minInterval,
            final int maxInterval); @Deprecated Future<CommandResult> getReporting(final ZclAttribute attribute); boolean isManufacturerSpecific(); Integer getManufacturerCode(); void addAttributes(Set<ZclAttribute> attributes); void addLocalAttributes(Set<ZclAttribute> attributes); void addClientCommands(Map<Integer, Class<? extends ZclCommand>> commands); void addServerCommands(Map<Integer, Class<? extends ZclCommand>> commands); static DefaultResponse createDefaultResponse(ZclCommand command, ZclStatus status); NotificationService getNotificationService(); }
ZclCluster { public void setDao(ZclClusterDao dao) { clusterId = dao.getClusterId(); isClient = dao.getClient(); supportedAttributesKnown = dao.getSupportedAttributes() != null; if (supportedAttributesKnown) { supportedAttributes.addAll(dao.getSupportedAttributes()); } supportedCommandsGenerated.addAll(dao.getSupportedCommandsGenerated()); supportedCommandsReceived.addAll(dao.getSupportedCommandsReceived()); Map<Integer, ZclAttribute> attributes = isClient ? clientAttributes : serverAttributes; for (ZclAttributeDao daoAttribute : dao.getAttributes().values()) { daoAttribute .setLastValue(normalizer.normalizeZclData(daoAttribute.getDataType(), daoAttribute.getLastValue())); ZclAttribute attribute = attributes.get(daoAttribute.getId()); if (attribute == null || daoAttribute.getManufacturerCode() != null) { attribute = new ZclAttribute(); attribute.setDao(this, daoAttribute); attributes.put(daoAttribute.getId(), attribute); } else { attribute.setDynamicStateFromDao(daoAttribute); } } } protected  ZclCluster(ZigBeeEndpoint zigbeeEndpoint, int clusterId, String clusterName); Future<CommandResult> sendCommand(ZclGeneralCommand command); void sendDefaultResponse(ZclCommand command, ZclStatus status); @Deprecated void sendDefaultResponse(Integer transactionId, Integer commandIdentifier, ZclStatus status,
            Integer manufacturerCode); @Deprecated void sendDefaultResponse(Integer transactionId, Integer commandIdentifier, ZclStatus status); Future<CommandResult> writeAttribute(final int attributeId, final ZclDataType dataType, final Object value); Future<CommandResult> writeAttributes(List<WriteAttributeRecord> attributes); Future<CommandResult> readAttribute(final int attributeId); Future<CommandResult> readAttributes(final List<Integer> attributeIds); Future<CommandResult> reportAttribute(final int attributeId, final ZclDataType dataType,
            final Object value); Future<CommandResult> reportAttributes(List<AttributeReport> attributes); Future<CommandResult> setReporting(final int attributeId, final int minInterval, final int maxInterval,
            Object reportableChange); Future<CommandResult> setReporting(final int attributeId, final int minInterval, final int maxInterval); Future<CommandResult> getReporting(final int attributeId); Collection<ZclAttribute> getAttributes(); ZclAttribute getAttribute(int attributeId); ZclAttribute getLocalAttribute(int attributeId); Collection<ZclAttribute> getLocalAttributes(); Integer getClusterId(); String getClusterName(); ZigBeeEndpointAddress getZigBeeAddress(); void setServer(); boolean isServer(); void setClient(); boolean isClient(); void setApsSecurityRequired(boolean requireApsSecurity); boolean getApsSecurityRequired(); Future<CommandResult> bind(IeeeAddress address, int endpointId); Future<CommandResult> unbind(IeeeAddress address, int endpointId); Set<Integer> getSupportedAttributes(); boolean isAttributeSupported(int attributeId); Future<Boolean> discoverAttributes(final boolean rediscover); Future<Boolean> discoverAttributes(final boolean rediscover, final Integer manufacturerCode); Set<Integer> getSupportedCommandsReceived(); boolean isReceivedCommandSupported(int commandId); Future<Boolean> discoverCommandsReceived(final boolean rediscover); Future<Boolean> discoverCommandsReceived(final boolean rediscover, final Integer manufacturerCode); Set<Integer> getSupportedCommandsGenerated(); boolean isGeneratedCommandSupported(int commandId); Future<Boolean> discoverCommandsGenerated(final boolean rediscover); Future<Boolean> discoverCommandsGenerated(final boolean rediscover, final Integer manufacturerCode); void addAttributeListener(ZclAttributeListener listener); void removeAttributeListener(final ZclAttributeListener listener); void addCommandListener(ZclCommandListener listener); void removeCommandListener(final ZclCommandListener listener); void handleCommand(ZclCommand command); ZclCommand getCommandFromId(ZclFrameType zclFrameType, int commandId); ZclCommand getResponseFromId(ZclFrameType zclFrameType, int commandId); ZclClusterDao getDao(); void setDao(ZclClusterDao dao); @Deprecated Future<CommandResult> write(final int attribute, final ZclDataType dataType, final Object value); @Deprecated Future<CommandResult> write(final ZclAttribute attribute, final Object value); @Deprecated Future<CommandResult> read(final int attribute); @Deprecated Future<CommandResult> read(final ZclAttribute attribute); @Deprecated Future<CommandResult> read(final List<Integer> attributes); @Deprecated Future<CommandResult> setReporting(final ZclAttribute attribute, final int minInterval,
            final int maxInterval, final Object reportableChange); @Deprecated Future<CommandResult> setReporting(final ZclAttribute attribute, final int minInterval,
            final int maxInterval); @Deprecated Future<CommandResult> getReporting(final ZclAttribute attribute); boolean isManufacturerSpecific(); Integer getManufacturerCode(); void addAttributes(Set<ZclAttribute> attributes); void addLocalAttributes(Set<ZclAttribute> attributes); void addClientCommands(Map<Integer, Class<? extends ZclCommand>> commands); void addServerCommands(Map<Integer, Class<? extends ZclCommand>> commands); static DefaultResponse createDefaultResponse(ZclCommand command, ZclStatus status); NotificationService getNotificationService();  }