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