use of com.zsmartsystems.zigbee.serialization.DefaultSerializer in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclHeaderTest method testDeserialize2.
@Test
public void testDeserialize2() {
int[] packet = getPacketData("08 99 88");
DefaultDeserializer deserializer = new DefaultDeserializer(packet);
ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
System.out.println(zclHeader);
assertEquals(0x88, zclHeader.getCommandId());
assertEquals(ZclFrameType.ENTIRE_PROFILE_COMMAND, zclHeader.getFrameType());
assertEquals(false, zclHeader.isManufacturerSpecific());
assertEquals(false, zclHeader.isDisableDefaultResponse());
assertEquals(0x99, zclHeader.getSequenceNumber());
DefaultSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
assertTrue(Arrays.equals(packet, zclHeader.serialize(fieldSerializer, new int[] {})));
}
use of com.zsmartsystems.zigbee.serialization.DefaultSerializer in project com.zsmartsystems.zigbee by zsmartsystems.
the class ConfigureReportingCommandTest method testSingle.
@Test
public void testSingle() {
int[] packet = getPacketData("00 00 00 10 01 00 58 02");
AttributeReportingConfigurationRecord record = new AttributeReportingConfigurationRecord();
record.setAttributeIdentifier(0);
record.setAttributeDataType(ZclDataType.BOOLEAN);
record.setDirection(0);
record.setTimeoutPeriod(0);
record.setMinimumReportingInterval(1);
record.setMaximumReportingInterval(600);
ConfigureReportingCommand command = new ConfigureReportingCommand();
command.setClusterId(6);
command.setDestinationAddress(new ZigBeeEndpointAddress(31084, 18));
command.setRecords(Arrays.asList(record));
command.setTransactionId(23);
System.out.println(command);
DefaultSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
command.serialize(fieldSerializer);
assertTrue(Arrays.equals(packet, serializer.getPayload()));
}
use of com.zsmartsystems.zigbee.serialization.DefaultSerializer in project com.zsmartsystems.zigbee by zsmartsystems.
the class MatchDescriptorResponseTest method testSendEndpoint2.
@Test
public void testSendEndpoint2() {
MatchDescriptorResponse matchResponse = new MatchDescriptorResponse();
matchResponse.setStatus(ZdoStatus.SUCCESS);
List<Integer> matchList = new ArrayList<Integer>();
matchList.add(1);
matchList.add(2);
matchResponse.setMatchList(matchList);
matchResponse.setDestinationAddress(new ZigBeeEndpointAddress(1234, 5));
matchResponse.setNwkAddrOfInterest(1234);
System.out.println(matchResponse);
ZigBeeSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
matchResponse.serialize(fieldSerializer);
assertTrue(Arrays.equals(getPacketData("00 00 D2 04 02 01 02"), serializer.getPayload()));
}
use of com.zsmartsystems.zigbee.serialization.DefaultSerializer in project com.zsmartsystems.zigbee by zsmartsystems.
the class MatchDescriptorResponseTest method testSendEndpoint1.
@Test
public void testSendEndpoint1() {
MatchDescriptorResponse matchResponse = new MatchDescriptorResponse();
matchResponse.setStatus(ZdoStatus.SUCCESS);
List<Integer> matchList = new ArrayList<Integer>();
matchList.add(1);
matchResponse.setMatchList(matchList);
matchResponse.setDestinationAddress(new ZigBeeEndpointAddress(1234, 5));
matchResponse.setNwkAddrOfInterest(1234);
System.out.println(matchResponse);
ZigBeeSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
matchResponse.serialize(fieldSerializer);
assertTrue(Arrays.equals(getPacketData("00 00 D2 04 01 01"), serializer.getPayload()));
}
use of com.zsmartsystems.zigbee.serialization.DefaultSerializer in project com.zsmartsystems.zigbee by zsmartsystems.
the class ReadAttributesCommandTest method testSingle.
@Test
public void testSingle() {
int[] packet = getPacketData("04 00");
ReadAttributesCommand command = new ReadAttributesCommand();
command.setClusterId(0);
command.setDestinationAddress(new ZigBeeEndpointAddress(57337, 3));
command.setIdentifiers(Arrays.asList(4));
command.setTransactionId(1);
DefaultSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
command.serialize(fieldSerializer);
assertTrue(Arrays.equals(packet, serializer.getPayload()));
}
Aggregations