@Override public boolean isTransactionMatch(ZigBeeCommand request, ZigBeeCommand response) { if (!(response instanceof SimpleDescriptorResponse)) { return false; } return (((SimpleDescriptorRequest) request).getEndpoint() .equals(((SimpleDescriptorResponse) response).getSimpleDescriptor().getEndpoint())) && (((SimpleDescriptorRequest) request).getNwkAddrOfInterest() .equals(((SimpleDescriptorResponse) response).getNwkAddrOfInterest())); }
ZigBeeEndpoint endpoint = new ZigBeeEndpoint(node, endpointId); SimpleDescriptor simpleDescriptor = simpleDescriptorResponse.getSimpleDescriptor(); endpoint.setProfileId(simpleDescriptor.getProfileId()); endpoint.setDeviceId(simpleDescriptor.getDeviceId()); endpoint.setDeviceVersion(simpleDescriptor.getDeviceVersion()); endpoint.setInputClusterIds(simpleDescriptor.getInputClusterList()); endpoint.setOutputClusterIds(simpleDescriptor.getOutputClusterList());
@Test public void testReceive() { int[] packet = getPacketData("00 00 00 00 14 01 04 01 00 00 00 03 00 00 01 00 06 00 03 00 00 01 00 06 00"); SimpleDescriptorResponse descriptorResponse = new SimpleDescriptorResponse(); DefaultDeserializer deserializer = new DefaultDeserializer(packet); ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer); descriptorResponse.deserialize(fieldDeserializer); System.out.println(descriptorResponse); SimpleDescriptor simpleDescriptor = descriptorResponse.getSimpleDescriptor(); assertEquals(ZdoStatus.SUCCESS, descriptorResponse.getStatus()); assertEquals(0, (int) descriptorResponse.getNwkAddrOfInterest()); assertEquals(1, simpleDescriptor.getEndpoint()); assertEquals(0x104, simpleDescriptor.getProfileId()); assertEquals(3, simpleDescriptor.getInputClusterList().size()); assertTrue(simpleDescriptor.getInputClusterList().contains(0)); assertTrue(simpleDescriptor.getInputClusterList().contains(1)); assertTrue(simpleDescriptor.getInputClusterList().contains(6)); assertEquals(3, simpleDescriptor.getOutputClusterList().size()); } }
simpleResponse.setDestinationAddress(new ZigBeeEndpointAddress(0, 1)); simpleResponse.setNwkAddrOfInterest(0); SimpleDescriptor simpleDescriptor = new SimpleDescriptor(); simpleDescriptor.setDeviceId(0); simpleDescriptor.setDeviceVersion(0); simpleDescriptor.setEndpoint(1); simpleDescriptor.setProfileId(0x104); List<Integer> inputClusterList = new ArrayList<Integer>(); List<Integer> outputClusterList = new ArrayList<Integer>(); simpleDescriptor.setInputClusterList(inputClusterList); simpleDescriptor.setOutputClusterList(outputClusterList); simpleResponse.setSimpleDescriptor(simpleDescriptor); responses.put(ZdoCommandType.SIMPLE_DESCRIPTOR_REQUEST.getClusterId(), simpleResponse);
break; case SIMPLE_DESCRIPTOR: SimpleDescriptor simpleDescriptor = new SimpleDescriptor(); simpleDescriptor.deserialize(this); value[0] = simpleDescriptor; break;