Search in sources :

Example 1 with DeviceAnnounce

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));
}
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 DeviceAnnounce

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());
    }
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) DeviceAnnounce(com.zsmartsystems.zigbee.zdo.command.DeviceAnnounce) ZclCommand(com.zsmartsystems.zigbee.zcl.ZclCommand)

Aggregations

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