Search in sources :

Example 1 with ZigBeeEndpointAddress

use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method unbind.

@Test
public void unbind() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    cluster.unbind(new IeeeAddress("1234567890ABCDEF"), 11);
    assertEquals(1, commandCapture.getAllValues().size());
    ZigBeeCommand command = commandCapture.getValue();
    assertNotNull(command);
    System.out.println(command);
    assertTrue(command instanceof UnbindRequest);
    UnbindRequest unbindCommand = (UnbindRequest) command;
    assertEquals(new ZigBeeEndpointAddress(1234, 0), unbindCommand.getDestinationAddress());
    assertEquals(new IeeeAddress("1234567890ABCDEF"), unbindCommand.getDstAddress());
    assertEquals(Integer.valueOf(5), unbindCommand.getSrcEndpoint());
    assertEquals(Integer.valueOf(11), unbindCommand.getDstEndpoint());
    assertEquals(Integer.valueOf(3), unbindCommand.getDstAddrMode());
    assertEquals(Integer.valueOf(0x0022), unbindCommand.getClusterId());
    assertEquals(Integer.valueOf(6), unbindCommand.getBindCluster());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeCommand(com.zsmartsystems.zigbee.ZigBeeCommand) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) UnbindRequest(com.zsmartsystems.zigbee.zdo.command.UnbindRequest) Test(org.junit.Test)

Example 2 with ZigBeeEndpointAddress

use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress 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 3 with ZigBeeEndpointAddress

use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ClusterMatcherTest method testMatcherMatchIn.

@Test
public void testMatcherMatchIn() {
    ClusterMatcher matcher = getMatcher();
    matcher.addCluster(0x500);
    matcher.addCluster(0x600);
    List<Integer> clusterListIn = new ArrayList<Integer>();
    List<Integer> clusterListOut = new ArrayList<Integer>();
    clusterListIn.add(0x500);
    MatchDescriptorRequest request = new MatchDescriptorRequest();
    request.setSourceAddress(new ZigBeeEndpointAddress(1234, 5));
    request.setProfileId(0x104);
    request.setInClusterList(clusterListIn);
    request.setOutClusterList(clusterListOut);
    matcher.commandReceived(request);
    assertEquals(1, mockedCommandCaptor.getAllValues().size());
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ArrayList(java.util.ArrayList) MatchDescriptorRequest(com.zsmartsystems.zigbee.zdo.command.MatchDescriptorRequest) Test(org.junit.Test)

Example 4 with ZigBeeEndpointAddress

use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ClusterMatcherTest method testMatcherNoMatch.

@Test
public void testMatcherNoMatch() {
    ClusterMatcher matcher = getMatcher();
    matcher.addCluster(0x500);
    List<Integer> clusterListIn = new ArrayList<Integer>();
    List<Integer> clusterListOut = new ArrayList<Integer>();
    MatchDescriptorRequest request = new MatchDescriptorRequest();
    request.setSourceAddress(new ZigBeeEndpointAddress(1234, 5));
    request.setProfileId(0x104);
    request.setInClusterList(clusterListIn);
    request.setOutClusterList(clusterListOut);
    matcher.commandReceived(request);
    assertEquals(0, mockedCommandCaptor.getAllValues().size());
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ArrayList(java.util.ArrayList) MatchDescriptorRequest(com.zsmartsystems.zigbee.zdo.command.MatchDescriptorRequest) Test(org.junit.Test)

Example 5 with ZigBeeEndpointAddress

use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZdoResponseMatcherTest method testMatch.

@Test
public void testMatch() {
    ZdoTransactionMatcher matcher = new ZdoTransactionMatcher();
    ZdoRequest zdoCommand = new BindRequest();
    BindResponse zdoResponse = new BindResponse();
    zdoCommand.setDestinationAddress(new ZigBeeEndpointAddress(1234));
    zdoResponse.setSourceAddress(new ZigBeeEndpointAddress(1234));
    assertTrue(matcher.isTransactionMatch(zdoCommand, zdoResponse));
    zdoResponse.setSourceAddress(new ZigBeeEndpointAddress(5678));
    assertFalse(matcher.isTransactionMatch(zdoCommand, zdoResponse));
    ZclCommand zclResponse = new OffCommand();
    assertFalse(matcher.isTransactionMatch(zdoCommand, zclResponse));
}
Also used : ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) BindRequest(com.zsmartsystems.zigbee.zdo.command.BindRequest) OffCommand(com.zsmartsystems.zigbee.zcl.clusters.onoff.OffCommand) BindResponse(com.zsmartsystems.zigbee.zdo.command.BindResponse) ZclCommand(com.zsmartsystems.zigbee.zcl.ZclCommand) Test(org.junit.Test)

Aggregations

ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)35 Test (org.junit.Test)20 CommandResult (com.zsmartsystems.zigbee.CommandResult)10 ArrayList (java.util.ArrayList)10 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)9 DefaultSerializer (com.zsmartsystems.zigbee.serialization.DefaultSerializer)8 ZclFieldSerializer (com.zsmartsystems.zigbee.zcl.ZclFieldSerializer)8 CommandTest (com.zsmartsystems.zigbee.CommandTest)6 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)6 HashSet (java.util.HashSet)5 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)4 MatchDescriptorRequest (com.zsmartsystems.zigbee.zdo.command.MatchDescriptorRequest)4 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)3 ZigBeeSerializer (com.zsmartsystems.zigbee.serialization.ZigBeeSerializer)3 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)3 BindRequest (com.zsmartsystems.zigbee.zdo.command.BindRequest)3 IeeeAddressResponse (com.zsmartsystems.zigbee.zdo.command.IeeeAddressResponse)3 ConBeeEnqueueSendDataRequest (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeEnqueueSendDataRequest)2 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)2 EmberApsFrame (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberApsFrame)2