Search in sources :

Example 1 with OnCommand

use of com.zsmartsystems.zigbee.zcl.clusters.onoff.OnCommand 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 OnCommand

use of com.zsmartsystems.zigbee.zcl.clusters.onoff.OnCommand in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeNetworkManagerTest method testSendCommandZCL.

@Test
public void testSendCommandZCL() {
    ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
    networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
    ZigBeeEndpointAddress deviceAddress = new ZigBeeEndpointAddress(1234, 56);
    OnCommand cmd = new OnCommand();
    cmd.setClusterId(6);
    cmd.setDestinationAddress(deviceAddress);
    boolean error = false;
    networkManager.sendCommand(cmd);
    assertFalse(error);
    assertEquals(1, mockedApsFrameListener.getAllValues().size());
    ZigBeeApsFrame apsFrame = mockedApsFrameListener.getValue();
    assertEquals(ZigBeeNwkAddressMode.DEVICE, apsFrame.getAddressMode());
    assertEquals(1234, apsFrame.getDestinationAddress());
    assertEquals(0, apsFrame.getSourceAddress());
    assertEquals(0x104, apsFrame.getProfile());
    assertEquals(6, apsFrame.getCluster());
    assertEquals(56, apsFrame.getDestinationEndpoint());
}
Also used : OnCommand(com.zsmartsystems.zigbee.zcl.clusters.onoff.OnCommand) Test(org.junit.Test)

Aggregations

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