Search in sources :

Example 1 with ConfigureReportingCommand

use of com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand 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 ConfigureReportingCommand

use of com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclGeneralCluster method configureReportingCommand.

/**
 * The Configure Reporting Command
 * <p>
 * The Configure Reporting command is used to configure the reporting mechanism
 * for one or more of the attributes of a cluster.
 * <br>
 * The individual cluster definitions specify which attributes shall be available to this
 * reporting mechanism, however specific implementations of a cluster may make
 * additional attributes available.
 *
 * @param records {@link List<AttributeReportingConfigurationRecord>} Records
 * @return the {@link Future<CommandResult>} command result future
 */
public Future<CommandResult> configureReportingCommand(List<AttributeReportingConfigurationRecord> records) {
    ConfigureReportingCommand command = new ConfigureReportingCommand();
    // Set the fields
    command.setRecords(records);
    return send(command);
}
Also used : ConfigureReportingCommand(com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand)

Example 3 with ConfigureReportingCommand

use of com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand 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)

Aggregations

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