Search in sources :

Example 1 with ReadAttributesCommand

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

the class ZigBeeNetworkManagerTest method testReceiveZclCommand.

@Test
public void testReceiveZclCommand() {
    ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
    networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
    ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
    apsFrame.setSourceAddress(1234);
    apsFrame.setDestinationAddress(0);
    apsFrame.setSequence(1);
    apsFrame.setCluster(6);
    apsFrame.setDestinationEndpoint(2);
    apsFrame.setProfile(0x104);
    apsFrame.setSourceEndpoint(5);
    ZclHeader zclHeader = new ZclHeader();
    zclHeader.setCommandId(0);
    zclHeader.setFrameType(ZclFrameType.ENTIRE_PROFILE_COMMAND);
    zclHeader.setSequenceNumber(1);
    DefaultSerializer serializer = new DefaultSerializer();
    ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
    apsFrame.setPayload(zclHeader.serialize(fieldSerializer, new int[] {}));
    networkManager.receiveCommand(apsFrame);
    org.awaitility.Awaitility.await().until(commandListenerUpdated(), org.hamcrest.Matchers.equalTo(1));
    ReadAttributesCommand response = (ReadAttributesCommand) commandListenerCapture.get(0);
    assertEquals(6, (int) response.getClusterId());
    assertEquals(0, (int) response.getCommandId());
    assertEquals(1, (int) response.getTransactionId());
    assertEquals(new ZigBeeEndpointAddress(1234, 5), response.getSourceAddress());
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) ReadAttributesCommand(com.zsmartsystems.zigbee.zcl.clusters.general.ReadAttributesCommand) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) ZclHeader(com.zsmartsystems.zigbee.zcl.ZclHeader) Test(org.junit.Test)

Example 2 with ReadAttributesCommand

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

the class ZclCluster method read.

/**
 * Read an attribute
 *
 * @param attribute the attribute to read
 * @return command future
 */
public Future<CommandResult> read(final int attribute) {
    final ReadAttributesCommand command = new ReadAttributesCommand();
    command.setClusterId(clusterId);
    command.setIdentifiers(Collections.singletonList(attribute));
    command.setDestinationAddress(zigbeeEndpoint.getEndpointAddress());
    return send(command);
}
Also used : ReadAttributesCommand(com.zsmartsystems.zigbee.zcl.clusters.general.ReadAttributesCommand)

Example 3 with ReadAttributesCommand

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

the class ZclGeneralCluster method readAttributesCommand.

/**
 * The Read Attributes Command
 * <p>
 * The read attributes command is generated when a device wishes to determine the
 * values of one or more attributes located on another device. Each attribute
 * identifier field shall contain the identifier of the attribute to be read.
 *
 * @param identifiers {@link List<Integer>} Identifiers
 * @return the {@link Future<CommandResult>} command result future
 */
public Future<CommandResult> readAttributesCommand(List<Integer> identifiers) {
    ReadAttributesCommand command = new ReadAttributesCommand();
    // Set the fields
    command.setIdentifiers(identifiers);
    return send(command);
}
Also used : ReadAttributesCommand(com.zsmartsystems.zigbee.zcl.clusters.general.ReadAttributesCommand)

Aggregations

ReadAttributesCommand (com.zsmartsystems.zigbee.zcl.clusters.general.ReadAttributesCommand)3 DefaultSerializer (com.zsmartsystems.zigbee.serialization.DefaultSerializer)1 ZclFieldSerializer (com.zsmartsystems.zigbee.zcl.ZclFieldSerializer)1 ZclHeader (com.zsmartsystems.zigbee.zcl.ZclHeader)1 Test (org.junit.Test)1