Search in sources :

Example 1 with ZclFieldDeserializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer 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 2 with ZclFieldDeserializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer 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 3 with ZclFieldDeserializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer 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 4 with ZclFieldDeserializer

use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer 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)

Example 5 with ZclFieldDeserializer

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

the class ZoneEnrollRequestCommandTest method test.

@Test
public void test() {
    int[] packet = getPacketData("09 63 01 0D 00 4E 10");
    ZoneEnrollRequestCommand command = new ZoneEnrollRequestCommand();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
    System.out.println(zclHeader);
    command.deserialize(fieldDeserializer);
    System.out.println(command);
    assertEquals(Integer.valueOf(0x500), command.getClusterId());
    assertEquals(Integer.valueOf(13), command.getZoneType());
    assertEquals(Integer.valueOf(4174), command.getManufacturerCode());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) ZclHeader(com.zsmartsystems.zigbee.zcl.ZclHeader) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Aggregations

ZclFieldDeserializer (com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer)29 CommandTest (com.zsmartsystems.zigbee.CommandTest)28 DefaultDeserializer (com.zsmartsystems.zigbee.serialization.DefaultDeserializer)28 Test (org.junit.Test)28 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)6 ZclHeader (com.zsmartsystems.zigbee.zcl.ZclHeader)6 ReadAttributeStatusRecord (com.zsmartsystems.zigbee.zcl.field.ReadAttributeStatusRecord)3 AttributeStatusRecord (com.zsmartsystems.zigbee.zcl.field.AttributeStatusRecord)2 PowerDescriptor (com.zsmartsystems.zigbee.zdo.field.PowerDescriptor)2 SimpleDescriptor (com.zsmartsystems.zigbee.zdo.field.SimpleDescriptor)2 ZigBeeDeserializer (com.zsmartsystems.zigbee.serialization.ZigBeeDeserializer)1 AttributeInformation (com.zsmartsystems.zigbee.zcl.field.AttributeInformation)1 BindingTable (com.zsmartsystems.zigbee.zdo.field.BindingTable)1 NeighborTable (com.zsmartsystems.zigbee.zdo.field.NeighborTable)1 NodeDescriptor (com.zsmartsystems.zigbee.zdo.field.NodeDescriptor)1 RoutingTable (com.zsmartsystems.zigbee.zdo.field.RoutingTable)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1