Search in sources :

Example 6 with ZclFieldSerializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldSerializer 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()));
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) AttributeReportingConfigurationRecord(com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 7 with ZclFieldSerializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldSerializer 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()));
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) ZigBeeSerializer(com.zsmartsystems.zigbee.serialization.ZigBeeSerializer) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ArrayList(java.util.ArrayList) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 8 with ZclFieldSerializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldSerializer 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()));
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) ZigBeeSerializer(com.zsmartsystems.zigbee.serialization.ZigBeeSerializer) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ArrayList(java.util.ArrayList) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 9 with ZclFieldSerializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldSerializer 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()));
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 10 with ZclFieldSerializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldSerializer in project com.zsmartsystems.zigbee by zsmartsystems.

the class ImageNotifyCommandTest method testSend.

@Test
public void testSend() {
    ImageNotifyCommand command = new ImageNotifyCommand();
    command.setSourceAddress(new ZigBeeEndpointAddress(0, 1));
    command.setDestinationAddress(new ZigBeeEndpointAddress(57337, 3));
    command.setImageType(6);
    command.setQueryJitter(72);
    command.setManufacturerCode(4364);
    command.setNewFileVersion(16909063);
    System.out.println(command);
    ZigBeeSerializer serializer = new DefaultSerializer();
    ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
    command.setPayloadType(0);
    command.serialize(fieldSerializer);
    assertTrue(Arrays.equals(getPacketData("00 48"), serializer.getPayload()));
    serializer = new DefaultSerializer();
    fieldSerializer = new ZclFieldSerializer(serializer);
    command.setPayloadType(1);
    command.serialize(fieldSerializer);
    assertTrue(Arrays.equals(getPacketData("01 48 0C 11"), serializer.getPayload()));
    serializer = new DefaultSerializer();
    fieldSerializer = new ZclFieldSerializer(serializer);
    command.setPayloadType(1);
    command.serialize(fieldSerializer);
    assertTrue(Arrays.equals(getPacketData("01 48 0C 11"), serializer.getPayload()));
    serializer = new DefaultSerializer();
    fieldSerializer = new ZclFieldSerializer(serializer);
    command.setPayloadType(2);
    command.serialize(fieldSerializer);
    assertTrue(Arrays.equals(getPacketData("02 48 0C 11 06 00"), serializer.getPayload()));
    serializer = new DefaultSerializer();
    fieldSerializer = new ZclFieldSerializer(serializer);
    command.setPayloadType(3);
    command.serialize(fieldSerializer);
    assertTrue(Arrays.equals(getPacketData("03 48 0C 11 06 00 07 03 02 01"), serializer.getPayload()));
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) ZigBeeSerializer(com.zsmartsystems.zigbee.serialization.ZigBeeSerializer) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Aggregations

ZclFieldSerializer (com.zsmartsystems.zigbee.zcl.ZclFieldSerializer)11 DefaultSerializer (com.zsmartsystems.zigbee.serialization.DefaultSerializer)10 Test (org.junit.Test)10 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)8 CommandTest (com.zsmartsystems.zigbee.CommandTest)7 ZigBeeSerializer (com.zsmartsystems.zigbee.serialization.ZigBeeSerializer)4 ArrayList (java.util.ArrayList)3 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)2 EmberApsFrame (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberApsFrame)2 ZclHeader (com.zsmartsystems.zigbee.zcl.ZclHeader)2 ManagementPermitJoiningRequest (com.zsmartsystems.zigbee.zdo.command.ManagementPermitJoiningRequest)2 EzspSendBroadcastRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSendBroadcastRequest)1 ZclCommand (com.zsmartsystems.zigbee.zcl.ZclCommand)1 ReadAttributesCommand (com.zsmartsystems.zigbee.zcl.clusters.general.ReadAttributesCommand)1 AttributeReportingConfigurationRecord (com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord)1 ExtensionFieldSet (com.zsmartsystems.zigbee.zcl.field.ExtensionFieldSet)1 ZdoCommand (com.zsmartsystems.zigbee.zdo.ZdoCommand)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1