use of com.zsmartsystems.zigbee.zdo.command.DeviceAnnounce 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.zdo.command.DeviceAnnounce in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkDiscoverer method commandReceived.
@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());
}
}
// Node has been announced.
if (command instanceof DeviceAnnounce) {
final DeviceAnnounce announce = (DeviceAnnounce) command;
// startNodeDiscovery(address.getNwkAddrOfInterest());
addNode(announce.getIeeeAddr(), announce.getNwkAddrOfInterest());
}
}
Aggregations