Search in sources :

Example 1 with DefaultDeserializer

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

the class ZclHeaderTest method testDeserialize.

@Test
public void testDeserialize() {
    int[] packet = getPacketData("11 04 01");
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
    System.out.println(zclHeader);
    assertEquals(1, zclHeader.getCommandId());
    assertEquals(ZclFrameType.CLUSTER_SPECIFIC_COMMAND, zclHeader.getFrameType());
    assertEquals(false, zclHeader.isManufacturerSpecific());
    assertEquals(true, zclHeader.isDisableDefaultResponse());
    assertEquals(4, 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 2 with DefaultDeserializer

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

the class DiscoverAttributesResponseTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("00 02 00 21 03 00 21 04 00 21 07 00 21 08 00 30");
    DiscoverAttributesResponse response = new DiscoverAttributesResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    response.deserialize(fieldDeserializer);
    System.out.println(response);
    List<AttributeInformation> records = response.getAttributeInformation();
    assertEquals(5, records.size());
    AttributeInformation record = records.get(0);
    assertEquals(ZclDataType.UNSIGNED_16_BIT_INTEGER, record.getDataType());
    assertEquals(2, record.getIdentifier());
}
Also used : AttributeInformation(com.zsmartsystems.zigbee.zcl.field.AttributeInformation) DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 3 with DefaultDeserializer

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

the class DiscoverCommandsGeneratedResponseTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("01");
    DiscoverCommandsGeneratedResponse response = new DiscoverCommandsGeneratedResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    response.deserialize(fieldDeserializer);
    System.out.println(response);
    assertNull(response.getCommandIdentifiers());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 4 with DefaultDeserializer

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

the class ReadAttributesResponseTest method testReceiveNull.

@Test
public void testReceiveNull() {
    int[] packet = getPacketData("01 00 86");
    ReadAttributesResponse response = new ReadAttributesResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    response.deserialize(fieldDeserializer);
    System.out.println(response);
    List<ReadAttributeStatusRecord> records = response.getRecords();
    ReadAttributeStatusRecord record = records.get(0);
    assertEquals(ZclStatus.UNSUPPORTED_ATTRIBUTE, record.getStatus());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ReadAttributeStatusRecord(com.zsmartsystems.zigbee.zcl.field.ReadAttributeStatusRecord) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 5 with DefaultDeserializer

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

the class ReadAttributesResponseTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("05 00 00 42 06 4C 43 54 30 30 33 21 00 1D");
    ReadAttributesResponse response = new ReadAttributesResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    response.deserialize(fieldDeserializer);
    System.out.println(response);
    List<ReadAttributeStatusRecord> records = response.getRecords();
    ReadAttributeStatusRecord record = records.get(0);
    assertEquals(ZclDataType.CHARACTER_STRING, record.getAttributeDataType());
    assertEquals(5, record.getAttributeIdentifier());
    assertEquals(ZclStatus.SUCCESS, record.getStatus());
    assertEquals("LCT003", record.getAttributeValue());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ReadAttributeStatusRecord(com.zsmartsystems.zigbee.zcl.field.ReadAttributeStatusRecord) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Aggregations

DefaultDeserializer (com.zsmartsystems.zigbee.serialization.DefaultDeserializer)33 CommandTest (com.zsmartsystems.zigbee.CommandTest)32 Test (org.junit.Test)32 ZclFieldDeserializer (com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer)28 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)7 ZclHeader (com.zsmartsystems.zigbee.zcl.ZclHeader)6 ReadAttributeStatusRecord (com.zsmartsystems.zigbee.zcl.field.ReadAttributeStatusRecord)3 DefaultSerializer (com.zsmartsystems.zigbee.serialization.DefaultSerializer)2 AttributeStatusRecord (com.zsmartsystems.zigbee.zcl.field.AttributeStatusRecord)2 NeighborTable (com.zsmartsystems.zigbee.zdo.field.NeighborTable)2 PowerDescriptor (com.zsmartsystems.zigbee.zdo.field.PowerDescriptor)2 SimpleDescriptor (com.zsmartsystems.zigbee.zdo.field.SimpleDescriptor)2 ExtendedPanId (com.zsmartsystems.zigbee.ExtendedPanId)1 AttributeInformation (com.zsmartsystems.zigbee.zcl.field.AttributeInformation)1 BindingTable (com.zsmartsystems.zigbee.zdo.field.BindingTable)1 NodeDescriptor (com.zsmartsystems.zigbee.zdo.field.NodeDescriptor)1 RoutingTable (com.zsmartsystems.zigbee.zdo.field.RoutingTable)1