Search in sources :

Example 6 with DefaultSerializer

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[] {})));
}
Also used : DefaultSerializer(com.zsmartsystems.zigbee.serialization.DefaultSerializer) DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 7 with DefaultSerializer

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()));
}
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 8 with DefaultSerializer

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

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()));
}
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 10 with DefaultSerializer

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

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