Search in sources :

Example 1 with DefaultResponse

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

the class ZclResponseMatcherTest method testMatch.

@Test
public void testMatch() {
    ZclTransactionMatcher matcher = new ZclTransactionMatcher();
    ZclCommand zclCommand = new OnCommand();
    zclCommand.setDestinationAddress(new ZigBeeEndpointAddress(1234, 5));
    ZclCommand zclResponse = new DefaultResponse();
    zclResponse.setSourceAddress(new ZigBeeEndpointAddress(1234, 5));
    assertFalse(matcher.isTransactionMatch(zclCommand, zclResponse));
    zclCommand.setTransactionId(22);
    zclResponse.setTransactionId(22);
    assertTrue(matcher.isTransactionMatch(zclCommand, zclResponse));
    zclResponse.setTransactionId(222);
    assertFalse(matcher.isTransactionMatch(zclCommand, zclResponse));
    ZdoCommand zdoResponse = new DeviceAnnounce();
    assertFalse(matcher.isTransactionMatch(zclCommand, zdoResponse));
    zclResponse.setTransactionId(22);
    assertTrue(matcher.isTransactionMatch(zclCommand, zclResponse));
    zclResponse.setSourceAddress(new ZigBeeEndpointAddress(1234, 6));
    assertFalse(matcher.isTransactionMatch(zclCommand, zclResponse));
}
Also used : DefaultResponse(com.zsmartsystems.zigbee.zcl.clusters.general.DefaultResponse) OnCommand(com.zsmartsystems.zigbee.zcl.clusters.onoff.OnCommand) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZdoCommand(com.zsmartsystems.zigbee.zdo.ZdoCommand) DeviceAnnounce(com.zsmartsystems.zigbee.zdo.command.DeviceAnnounce) Test(org.junit.Test)

Example 2 with DefaultResponse

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

the class ZclGeneralCluster method defaultResponse.

/**
 * The Default Response
 * <p>
 * The default response command is generated when a device receives a unicast
 * command, there is no other relevant response specified for the command, and
 * either an error results or the Disable default response bit of its Frame control field
 * is set to 0.
 *
 * @param commandIdentifier {@link Integer} Command identifier
 * @param statusCode {@link ZclStatus} Status code
 * @return the {@link Future<CommandResult>} command result future
 */
public Future<CommandResult> defaultResponse(Integer commandIdentifier, ZclStatus statusCode) {
    DefaultResponse command = new DefaultResponse();
    // Set the fields
    command.setCommandIdentifier(commandIdentifier);
    command.setStatusCode(statusCode);
    return send(command);
}
Also used : DefaultResponse(com.zsmartsystems.zigbee.zcl.clusters.general.DefaultResponse)

Example 3 with DefaultResponse

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

the class CommandResultTest method testIsError.

@Test
public void testIsError() {
    CommandResult result = new CommandResult();
    assertTrue(result.isError());
    result = new CommandResult(new ZigBeeCommand());
    assertFalse(result.isError());
    assertTrue(result.isSuccess());
    DefaultResponse response = new DefaultResponse();
    response.setStatusCode(ZclStatus.SUCCESS);
    result = new CommandResult(response);
    assertFalse(result.isError());
    assertTrue(result.isSuccess());
    response = new DefaultResponse();
    response.setStatusCode(ZclStatus.FAILURE);
    result = new CommandResult(response);
    assertTrue(result.isError());
    assertFalse(result.isSuccess());
}
Also used : DefaultResponse(com.zsmartsystems.zigbee.zcl.clusters.general.DefaultResponse) Test(org.junit.Test)

Example 4 with DefaultResponse

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

the class ZclCluster method sendDefaultResponse.

/**
 * Sends a default response to the client
 *
 * @param commandIdentifier the command identifier to which this is a response
 * @param status the {@link ZclStatus} to send in the response
 */
public void sendDefaultResponse(Integer commandIdentifier, ZclStatus status) {
    DefaultResponse defaultResponse = new DefaultResponse();
    defaultResponse.setCommandIdentifier(commandIdentifier);
    defaultResponse.setDestinationAddress(zigbeeEndpoint.getEndpointAddress());
    defaultResponse.setClusterId(clusterId);
    defaultResponse.setStatusCode(status);
    zigbeeManager.sendCommand(defaultResponse);
}
Also used : DefaultResponse(com.zsmartsystems.zigbee.zcl.clusters.general.DefaultResponse)

Aggregations

DefaultResponse (com.zsmartsystems.zigbee.zcl.clusters.general.DefaultResponse)4 Test (org.junit.Test)2 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)1 OnCommand (com.zsmartsystems.zigbee.zcl.clusters.onoff.OnCommand)1 ZdoCommand (com.zsmartsystems.zigbee.zdo.ZdoCommand)1 DeviceAnnounce (com.zsmartsystems.zigbee.zdo.command.DeviceAnnounce)1