use of com.zsmartsystems.zigbee.app.ZigBeeApplication in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeEndpoint method commandReceived.
/**
* Incoming command handler. The endpoint will process any commands addressed to this endpoint ID and pass o
* clusters and applications
*
* @param command the {@link ZclCommand} received
*/
public void commandReceived(ZclCommand command) {
if (!command.getSourceAddress().equals(getEndpointAddress())) {
return;
}
// Pass all commands received from this endpoint to any registered applications
synchronized (applications) {
for (ZigBeeApplication application : applications.values()) {
application.commandReceived(command);
}
}
// Get the cluster
ZclCluster cluster = getReceiveCluster(command.getClusterId(), command.getCommandDirection());
if (cluster == null) {
logger.debug("{}: Cluster {} not found for attribute response", getEndpointAddress(), command.getClusterId());
return;
}
if (command instanceof ReportAttributesCommand) {
ReportAttributesCommand attributeCommand = (ReportAttributesCommand) command;
// Pass the reports to the cluster
cluster.handleAttributeReport(attributeCommand.getReports());
return;
}
if (command instanceof ReadAttributesResponse) {
ReadAttributesResponse attributeCommand = (ReadAttributesResponse) command;
// Pass the reports to the cluster
cluster.handleAttributeStatus(attributeCommand.getRecords());
return;
}
// If this is a specific cluster command, pass the command to the cluster command handler
if (!command.isGenericCommand()) {
cluster.handleCommand(command);
}
}
Aggregations