Search in sources :

Example 11 with DefaultSerializer

use of com.zsmartsystems.zigbee.serialization.DefaultSerializer 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)

Example 12 with DefaultSerializer

use of com.zsmartsystems.zigbee.serialization.DefaultSerializer in project com.zsmartsystems.zigbee by zsmartsystems.

the class AddScenesCommandTest method testAddSceneCommand.

@Test
public void testAddSceneCommand() throws Exception {
    int[] packet = getPacketData("01 00 02 03 00 0A 54 65 73 74 20 53 63 65 6E 65 04 00 05 06");
    AddSceneCommand request = new AddSceneCommand();
    request.setGroupId(1);
    request.setSceneId(2);
    request.setSceneName("Test Scene");
    request.setTransitionTime(3);
    final List<ExtensionFieldSet> list = new ArrayList<ExtensionFieldSet>();
    final ExtensionFieldSet data = new ExtensionFieldSet();
    data.setClusterId(4);
    data.setData(new int[] { 5, 6 });
    list.add(data);
    request.setExtensionFieldSets(list);
    System.out.println(request);
    DefaultSerializer serializer = new DefaultSerializer();
    ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
    request.serialize(fieldSerializer);
    assertTrue(Arrays.equals(packet, serializer.getPayload()));
}
Also used : ExtensionFieldSet(com.zsmartsystems.zigbee.zcl.field.ExtensionFieldSet) DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) ArrayList(java.util.ArrayList) ZclFieldSerializer(com.zsmartsystems.zigbee.zcl.ZclFieldSerializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Aggregations

DefaultSerializer (com.zsmartsystems.zigbee.serialization.DefaultSerializer)12 Test (org.junit.Test)12 ZclFieldSerializer (com.zsmartsystems.zigbee.zcl.ZclFieldSerializer)10 CommandTest (com.zsmartsystems.zigbee.CommandTest)9 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)8 ZigBeeSerializer (com.zsmartsystems.zigbee.serialization.ZigBeeSerializer)3 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 DefaultDeserializer (com.zsmartsystems.zigbee.serialization.DefaultDeserializer)2 ManagementPermitJoiningRequest (com.zsmartsystems.zigbee.zdo.command.ManagementPermitJoiningRequest)2 EzspSendBroadcastRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSendBroadcastRequest)1 ZclHeader (com.zsmartsystems.zigbee.zcl.ZclHeader)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