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));
}
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);
}
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());
}
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);
}
Aggregations