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));
}
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());
}
Aggregations