Search in sources :

Example 1 with AttributeReportingConfigurationRecord

use of com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclCluster method setReporting.

/**
 * Configures the reporting for the specified attribute ID for analog attributes.
 * <p>
 * <b>minInterval</b>:
 * The minimum reporting interval field is 16 bits in length and shall contain the
 * minimum interval, in seconds, between issuing reports of the specified attribute.
 * If minInterval is set to 0x0000, then there is no minimum limit, unless one is
 * imposed by the specification of the cluster using this reporting mechanism or by
 * the applicable profile.
 * <p>
 * <b>maxInterval</b>:
 * The maximum reporting interval field is 16 bits in length and shall contain the
 * maximum interval, in seconds, between issuing reports of the specified attribute.
 * If maxInterval is set to 0xffff, then the device shall not issue reports for the specified
 * attribute, and the configuration information for that attribute need not be
 * maintained.
 * <p>
 * <b>reportableChange</b>:
 * The reportable change field shall contain the minimum change to the attribute that
 * will result in a report being issued. This field is of variable length. For attributes
 * with 'analog' data type the field has the same data type as the attribute. The sign (if any) of the reportable
 * change field is ignored.
 *
 * @param attribute the {@link ZclAttribute} to configure reporting
 * @param minInterval the minimum reporting interval
 * @param maxInterval the maximum reporting interval
 * @param reportableChange the minimum change required to report an update
 * @return command future {@link CommandResult}
 */
public Future<CommandResult> setReporting(final ZclAttribute attribute, final int minInterval, final int maxInterval, final Object reportableChange) {
    final ConfigureReportingCommand command = new ConfigureReportingCommand();
    command.setClusterId(clusterId);
    final AttributeReportingConfigurationRecord record = new AttributeReportingConfigurationRecord();
    record.setDirection(0);
    record.setAttributeIdentifier(attribute.getId());
    record.setAttributeDataType(attribute.getDataType());
    record.setMinimumReportingInterval(minInterval);
    record.setMaximumReportingInterval(maxInterval);
    record.setReportableChange(reportableChange);
    record.setTimeoutPeriod(0);
    command.setRecords(Collections.singletonList(record));
    command.setDestinationAddress(zigbeeEndpoint.getEndpointAddress());
    return send(command);
}
Also used : AttributeReportingConfigurationRecord(com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord) ConfigureReportingCommand(com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand)

Example 2 with AttributeReportingConfigurationRecord

use of com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method setReporting.

@Test
public void setReporting() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    ZclAttribute attribute = cluster.getAttribute(0);
    cluster.setReporting(attribute, 22, 33);
    assertEquals(1, commandCapture.getAllValues().size());
    ZigBeeCommand command = commandCapture.getValue();
    assertNotNull(command);
    System.out.println(command);
    assertTrue(command instanceof ConfigureReportingCommand);
    ConfigureReportingCommand cfgCommand = (ConfigureReportingCommand) command;
    assertEquals(1, cfgCommand.getRecords().size());
    AttributeReportingConfigurationRecord record = cfgCommand.getRecords().get(0);
    assertEquals(0, record.getAttributeIdentifier());
    assertEquals(0, record.getDirection());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeCommand(com.zsmartsystems.zigbee.ZigBeeCommand) AttributeReportingConfigurationRecord(com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ConfigureReportingCommand(com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 3 with AttributeReportingConfigurationRecord

use of com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord in project com.zsmartsystems.zigbee by zsmartsystems.

the class ConfigureReportingCommandTest method testSingle.

@Test
public void testSingle() {
    int[] packet = getPacketData("00 00 00 10 01 00 58 02");
    AttributeReportingConfigurationRecord record = new AttributeReportingConfigurationRecord();
    record.setAttributeIdentifier(0);
    record.setAttributeDataType(ZclDataType.BOOLEAN);
    record.setDirection(0);
    record.setTimeoutPeriod(0);
    record.setMinimumReportingInterval(1);
    record.setMaximumReportingInterval(600);
    ConfigureReportingCommand command = new ConfigureReportingCommand();
    command.setClusterId(6);
    command.setDestinationAddress(new ZigBeeEndpointAddress(31084, 18));
    command.setRecords(Arrays.asList(record));
    command.setTransactionId(23);
    System.out.println(command);
    DefaultSerializer serializer = new DefaultSerializer();
    ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
    command.serialize(fieldSerializer);
    assertTrue(Arrays.equals(packet, serializer.getPayload()));
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) AttributeReportingConfigurationRecord(com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Aggregations

AttributeReportingConfigurationRecord (com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord)3 ConfigureReportingCommand (com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand)2 Test (org.junit.Test)2 CommandTest (com.zsmartsystems.zigbee.CommandTest)1 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)1 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)1 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)1 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)1 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)1 DefaultSerializer (com.zsmartsystems.zigbee.serialization.DefaultSerializer)1 ZclFieldSerializer (com.zsmartsystems.zigbee.zcl.ZclFieldSerializer)1 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)1