@Test public void handleDiscoverAttributes() { createEndpoint(); ZclOnOffCluster cluster = new ZclOnOffCluster(endpoint); Set<ZclAttribute> attributes = new HashSet<>(); attributes.add(new ZclAttribute(cluster, 1, "Attribute-1", ZclDataType.UNSIGNED_8_BIT_INTEGER, true, true, false, true)); attributes.add(new ZclAttribute(cluster, 2, "Attribute-2", ZclDataType.BOOLEAN, true, true, false, true)); attributes.add( new ZclAttribute(cluster, 10, "Attribute-10", ZclDataType.CHARACTER_STRING, true, true, false, true)); attributes.add(new ZclAttribute(cluster, 11, "Attribute-11", ZclDataType.BOOLEAN, true, true, false, true)); attributes.add(new ZclAttribute(cluster, 13, "Attribute-13", ZclDataType.BOOLEAN, true, true, false, true)); assertFalse(attributes.iterator().next().isImplemented()); cluster.addLocalAttributes(attributes); assertTrue(attributes.iterator().next().isImplemented()); DiscoverAttributesCommand discoverCommand = new DiscoverAttributesCommand(0, 10); discoverCommand.setClusterId(ZclBasicCluster.CLUSTER_ID); discoverCommand.setSourceAddress(new ZigBeeEndpointAddress(1234)); discoverCommand.setDestinationAddress(new ZigBeeEndpointAddress(5678)); discoverCommand.setCommandDirection(ZclCommandDirection.CLIENT_TO_SERVER); discoverCommand.setTransactionId(55); cluster.handleCommand(discoverCommand); assertEquals(1, commandCapture.getAllValues().size()); DiscoverAttributesResponse discoverResponse = (DiscoverAttributesResponse) commandCapture.getValue(); System.out.println(discoverResponse); assertEquals(5, discoverResponse.getAttributeInformation().size()); assertEquals(1, discoverResponse.getAttributeInformation().get(0).getIdentifier()); assertEquals(ZclDataType.UNSIGNED_8_BIT_INTEGER, discoverResponse.getAttributeInformation().get(0).getDataType()); assertTrue(discoverResponse.getDiscoveryComplete()); cluster.getLocalAttribute(1).setImplemented(false); cluster.handleCommand(discoverCommand); assertEquals(2, commandCapture.getAllValues().size()); discoverResponse = (DiscoverAttributesResponse) commandCapture.getValue(); System.out.println(discoverResponse); assertEquals(4, discoverResponse.getAttributeInformation().size()); assertEquals(2, discoverResponse.getAttributeInformation().get(0).getIdentifier()); assertEquals(ZclDataType.BOOLEAN, discoverResponse.getAttributeInformation().get(0).getDataType()); discoverCommand = new DiscoverAttributesCommand(3, 2); discoverCommand.setClusterId(ZclBasicCluster.CLUSTER_ID); discoverCommand.setSourceAddress(new ZigBeeEndpointAddress(1234)); discoverCommand.setDestinationAddress(new ZigBeeEndpointAddress(5678)); discoverCommand.setCommandDirection(ZclCommandDirection.CLIENT_TO_SERVER); discoverCommand.setTransactionId(55); cluster.handleCommand(discoverCommand); assertEquals(3, commandCapture.getAllValues().size()); discoverResponse = (DiscoverAttributesResponse) commandCapture.getValue(); System.out.println(discoverResponse); assertEquals(2, discoverResponse.getAttributeInformation().size()); assertEquals(10, discoverResponse.getAttributeInformation().get(0).getIdentifier()); assertEquals(ZclDataType.CHARACTER_STRING, discoverResponse.getAttributeInformation().get(0).getDataType()); assertFalse(discoverResponse.getDiscoveryComplete()); }
private void handleDiscoverAttributes(DiscoverAttributesCommand command) { List<AttributeInformation> attributeInformation = new ArrayList<>(); for (ZclAttribute attribute : getLocalAttributes()) { if (!attribute.isImplemented() || attribute.getId() < command.getStartAttributeIdentifier()) { continue; } AttributeInformation attributeInfo = new AttributeInformation(); attributeInfo.setIdentifier(attribute.getId()); attributeInfo.setDataType(attribute.getDataType()); attributeInformation.add(attributeInfo); if (attributeInformation.size() >= command.getMaximumAttributeIdentifiers()) { break; } } DiscoverAttributesResponse response = new DiscoverAttributesResponse( attributeInformation.size() == getLocalAttributes().size(), attributeInformation); sendResponse(command, response); }
ZclCluster { private void handleDiscoverAttributes(DiscoverAttributesCommand command) { List<AttributeInformation> attributeInformation = new ArrayList<>(); for (ZclAttribute attribute : getLocalAttributes()) { if (!attribute.isImplemented() || attribute.getId() < command.getStartAttributeIdentifier()) { continue; } AttributeInformation attributeInfo = new AttributeInformation(); attributeInfo.setIdentifier(attribute.getId()); attributeInfo.setDataType(attribute.getDataType()); attributeInformation.add(attributeInfo); if (attributeInformation.size() >= command.getMaximumAttributeIdentifiers()) { break; } } DiscoverAttributesResponse response = new DiscoverAttributesResponse( attributeInformation.size() == getLocalAttributes().size(), attributeInformation); sendResponse(command, response); } }
ZclCluster { private void handleDiscoverAttributes(DiscoverAttributesCommand command) { List<AttributeInformation> attributeInformation = new ArrayList<>(); for (ZclAttribute attribute : getLocalAttributes()) { if (!attribute.isImplemented() || attribute.getId() < command.getStartAttributeIdentifier()) { continue; } AttributeInformation attributeInfo = new AttributeInformation(); attributeInfo.setIdentifier(attribute.getId()); attributeInfo.setDataType(attribute.getDataType()); attributeInformation.add(attributeInfo); if (attributeInformation.size() >= command.getMaximumAttributeIdentifiers()) { break; } } DiscoverAttributesResponse response = new DiscoverAttributesResponse( attributeInformation.size() == getLocalAttributes().size(), attributeInformation); sendResponse(command, response); } protected  ZclCluster(ZigBeeEndpoint zigbeeEndpoint, int clusterId, String clusterName); }
ZclCluster { private void handleDiscoverAttributes(DiscoverAttributesCommand command) { List<AttributeInformation> attributeInformation = new ArrayList<>(); for (ZclAttribute attribute : getLocalAttributes()) { if (!attribute.isImplemented() || attribute.getId() < command.getStartAttributeIdentifier()) { continue; } AttributeInformation attributeInfo = new AttributeInformation(); attributeInfo.setIdentifier(attribute.getId()); attributeInfo.setDataType(attribute.getDataType()); attributeInformation.add(attributeInfo); if (attributeInformation.size() >= command.getMaximumAttributeIdentifiers()) { break; } } DiscoverAttributesResponse response = new DiscoverAttributesResponse( attributeInformation.size() == getLocalAttributes().size(), attributeInformation); sendResponse(command, response); } 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 { private void handleDiscoverAttributes(DiscoverAttributesCommand command) { List<AttributeInformation> attributeInformation = new ArrayList<>(); for (ZclAttribute attribute : getLocalAttributes()) { if (!attribute.isImplemented() || attribute.getId() < command.getStartAttributeIdentifier()) { continue; } AttributeInformation attributeInfo = new AttributeInformation(); attributeInfo.setIdentifier(attribute.getId()); attributeInfo.setDataType(attribute.getDataType()); attributeInformation.add(attributeInfo); if (attributeInformation.size() >= command.getMaximumAttributeIdentifiers()) { break; } } DiscoverAttributesResponse response = new DiscoverAttributesResponse( attributeInformation.size() == getLocalAttributes().size(), attributeInformation); sendResponse(command, response); } 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();  }