本文整理了Java中com.zsmartsystems.zigbee.zcl.ZclCommand
类的一些代码示例,展示了ZclCommand
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZclCommand
类的具体详情如下:
包路径:com.zsmartsystems.zigbee.zcl.ZclCommand
类名称:ZclCommand
[英]Base class for value object classes holding ZCL commands, extended from ZigBeeCommand.
[中]包含ZCL命令的值对象类的基类,从ZigBeeCommand扩展而来。
代码示例来源:origin: openhab/org.openhab.binding.zigbee
public boolean matchesCommand(ZclCommand command) {
boolean commandIdMatches = command.getCommandId().intValue() == commandId;
boolean commandParameterMatches = commandParameterName == null || commandParameterValue == null
|| matchesParameter(command);
return commandIdMatches && commandParameterMatches;
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
if (!command.getSourceAddress().equals(getEndpointAddress())) {
return;
ZclCluster cluster = getReceiveCluster(command.getClusterId(), command.getCommandDirection());
if (cluster == null) {
logger.debug("{}: Cluster {} not found for attribute response", getEndpointAddress(),
command.getClusterId());
return;
if (!command.isGenericCommand()) {
cluster.handleCommand(command);
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public boolean isTransactionMatch(ZigBeeCommand request, ZigBeeCommand response) {
if (!request.getDestinationAddress().equals(response.getSourceAddress())) {
return false;
}
if (response instanceof ZclCommand && ((ZclCommand) request).getTransactionId() != null) {
final int transactionId = ((ZclCommand) request).getTransactionId();
return Integer.valueOf(transactionId).equals(((ZclCommand) response).getTransactionId());
} else {
return false;
}
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
private ZigBeeCommand receiveZclCommand(final ZclFieldDeserializer fieldDeserializer,
final ZigBeeApsFrame apsFrame) {
// Process the ZCL header
ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
logger.debug("RX ZCL: {}", zclHeader);
// Get the command type
ZclCommandType commandType = null;
if (zclHeader.getFrameType() == ZclFrameType.ENTIRE_PROFILE_COMMAND) {
commandType = ZclCommandType.getGeneric(zclHeader.getCommandId());
} else {
commandType = ZclCommandType.getCommandType(apsFrame.getCluster(), zclHeader.getCommandId(),
zclHeader.getDirection());
}
if (commandType == null) {
logger.debug("No command type found for {}, cluster={}, command={}, direction={}", zclHeader.getFrameType(),
apsFrame.getCluster(), zclHeader.getCommandId(), zclHeader.getDirection());
return null;
}
ZclCommand command = commandType.instantiateCommand();
if (command == null) {
logger.debug("No command found for {}, cluster={}, command={}", zclHeader.getFrameType(),
apsFrame.getCluster(), zclHeader.getCommandId());
return null;
}
command.setCommandDirection(zclHeader.getDirection());
command.deserialize(fieldDeserializer);
command.setClusterId(apsFrame.getCluster());
command.setTransactionId(zclHeader.getSequenceNumber());
return command;
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@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));
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
zclHeader.setFrameType(zclCommand.isGenericCommand() ? ZclFrameType.ENTIRE_PROFILE_COMMAND
: ZclFrameType.CLUSTER_SPECIFIC_COMMAND);
zclHeader.setCommandId(zclCommand.getCommandId());
zclHeader.setSequenceNumber(command.getTransactionId());
zclHeader.setDirection(zclCommand.getCommandDirection());
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void commandReceived(ZigBeeCommand command) {
// This gets called for all received commands
// Check if it's our address
if (command.getSourceAddress().getAddress() != networkAddress) {
return;
}
if (!(command instanceof ZclCommand)) {
return;
}
logger.trace("{}: ZigBeeEndpoint.commandReceived({})", ieeeAddress, command);
ZclCommand zclCommand = (ZclCommand) command;
ZigBeeEndpointAddress endpointAddress = (ZigBeeEndpointAddress) zclCommand.getSourceAddress();
ZigBeeEndpoint endpoint = endpoints.get(endpointAddress.getEndpoint());
if (endpoint != null) {
endpoint.commandReceived(zclCommand);
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
Mockito.when(invalidSourceAddress.getEndpoint()).thenReturn(1);
ZclCommand zigbeeCommand = Mockito.mock(ZclCommand.class);
Mockito.when(zigbeeCommand.getSourceAddress()).thenReturn(invalidSourceAddress);
node.commandReceived(zigbeeCommand);
Mockito.verify(endpoint1, Mockito.times(0)).commandReceived(ArgumentMatchers.any(ZclCommand.class));
Mockito.when(unicastDestination.getAddress()).thenReturn(123);
Mockito.when(unicastDestination.getEndpoint()).thenReturn(1);
Mockito.when(unicast.getSourceAddress()).thenReturn(sourceAddress);
Mockito.when(unicast.getDestinationAddress()).thenReturn(unicastDestination);
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Sends {@link ZclCommand} command to {@link ZigBeeAddress}.
*
* @param destination the destination
* @param command the {@link ZclCommand}
* @return the command result future
*/
public Future<CommandResult> send(ZigBeeAddress destination, ZclCommand command) {
command.setDestinationAddress(destination);
if (destination.isGroup()) {
return broadcast(command);
} else {
final ZigBeeTransactionMatcher responseMatcher = new ZclTransactionMatcher();
return sendTransaction(command, responseMatcher);
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public String toString() {
Integer resolvedClusterId = getClusterId();
final StringBuilder builder = new StringBuilder();
builder.append(ZclClusterType.getValueById(resolvedClusterId).getLabel());
builder.append(": ");
builder.append(super.toString());
return builder.toString();
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void commandReceived(final ZigBeeCommand command) {
// ZCL command received from remote node. Perform discovery if it is not yet known.
if (command instanceof ZclCommand) {
final ZclCommand zclCommand = (ZclCommand) command;
if (networkManager.getNode(zclCommand.getSourceAddress().getAddress()) == null) {
// TODO: Protect against group address?
ZigBeeEndpointAddress address = (ZigBeeEndpointAddress) zclCommand.getSourceAddress();
startNodeDiscovery(address.getAddress());
}
return;
}
// Node has been announced.
if (command instanceof DeviceAnnounce) {
final DeviceAnnounce announce = (DeviceAnnounce) command;
logger.debug("{}: Device announce received. NWK={}", announce.getIeeeAddr(),
announce.getNwkAddrOfInterest());
addNode(announce.getIeeeAddr(), announce.getNwkAddrOfInterest());
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void testNodeAddressUpdate() {
IeeeAddress ieeeAddress = new IeeeAddress("123456890ABCDEF");
ZigBeeNode node = Mockito.mock(ZigBeeNode.class);// new ZigBeeNode(networkManager, ieeeAddress);
Mockito.doReturn(node).when(networkManager).getNode(ArgumentMatchers.any(IeeeAddress.class));
DeviceAnnounce announce = new DeviceAnnounce();
announce.setIeeeAddr(ieeeAddress);
announce.setNwkAddrOfInterest(12345);
ZigBeeNetworkDiscoverer discoverer = new ZigBeeNetworkDiscoverer(networkManager);
discoverer.setRetryPeriod(0);
discoverer.setRequeryPeriod(0);
discoverer.setRetryCount(0);
discoverer.commandReceived(announce);
Mockito.verify(node, Mockito.times(1)).setNetworkAddress(ArgumentMatchers.anyInt());
ZigBeeEndpointAddress address = Mockito.mock(ZigBeeEndpointAddress.class);
Mockito.when(address.getAddress()).thenReturn(12345);
ZclCommand zclCommand = Mockito.mock(ZclCommand.class);
Mockito.when(zclCommand.getSourceAddress()).thenReturn(address);
discoverer.commandReceived(zclCommand);
}
}
内容来源于网络,如有侵权,请联系作者删除!