Search in sources :

Example 21 with DefaultDeserializer

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

the class SimpleDescriptorResponseTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("00 00 00 00 14 01 04 01 00 00 00 03 00 00 01 00 06 00 03 00 00 01 00 06 00");
    SimpleDescriptorResponse descriptorResponse = new SimpleDescriptorResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    descriptorResponse.deserialize(fieldDeserializer);
    System.out.println(descriptorResponse);
    SimpleDescriptor simpleDescriptor = descriptorResponse.getSimpleDescriptor();
    assertEquals(ZdoStatus.SUCCESS, descriptorResponse.getStatus());
    assertEquals(0, (int) descriptorResponse.getNwkAddrOfInterest());
    assertEquals(1, simpleDescriptor.getEndpoint());
    assertEquals(0x104, simpleDescriptor.getProfileId());
    assertEquals(3, simpleDescriptor.getInputClusterList().size());
    assertTrue(simpleDescriptor.getInputClusterList().contains(0));
    assertTrue(simpleDescriptor.getInputClusterList().contains(1));
    assertTrue(simpleDescriptor.getInputClusterList().contains(6));
    assertEquals(3, simpleDescriptor.getOutputClusterList().size());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) SimpleDescriptor(com.zsmartsystems.zigbee.zdo.field.SimpleDescriptor) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 22 with DefaultDeserializer

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

the class NodeDescriptorTest method testNodeDescriptorDeserialize.

@Test
public void testNodeDescriptorDeserialize() {
    int[] packet = getPacketData("00 00 00 00 00 40 8F CD AB 52 80 00 41 2A 80 00 00");
    NodeDescriptor descriptor = new NodeDescriptor();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    descriptor.deserialize(deserializer);
    System.out.println(descriptor);
    assertEquals(0, descriptor.getManufacturerCode());
    assertEquals(LogicalType.COORDINATOR, descriptor.getLogicalType());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 23 with DefaultDeserializer

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

the class ConfigureReportingResponseTest method test.

@Test
public void test() {
    int[] packet = getPacketData("18 1B 07 00 00 00 00");
    ConfigureReportingResponse response = new ConfigureReportingResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
    System.out.println(zclHeader);
    response.deserialize(fieldDeserializer);
    System.out.println(response);
    assertNull(response.getStatus());
    assertEquals(1, response.getRecords().size());
    AttributeStatusRecord record = response.getRecords().get(0);
    assertEquals(0, record.getAttributeIdentifier());
    assertEquals(ZclStatus.SUCCESS, record.getStatus());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) AttributeStatusRecord(com.zsmartsystems.zigbee.zcl.field.AttributeStatusRecord) ZclHeader(com.zsmartsystems.zigbee.zcl.ZclHeader) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 24 with DefaultDeserializer

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

the class ConfigureReportingResponseTest method testStatusOnly.

@Test
public void testStatusOnly() {
    int[] packet = getPacketData("18 11 07 00");
    ConfigureReportingResponse response = new ConfigureReportingResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
    System.out.println(zclHeader);
    response.deserialize(fieldDeserializer);
    System.out.println(response);
    assertEquals(ZclStatus.SUCCESS, response.getStatus());
    assertNull(response.getRecords());
}
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)

Example 25 with DefaultDeserializer

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

the class ReadAttributesResponseTest method testReceiveOtaImageStatus.

@Test
public void testReceiveOtaImageStatus() {
    int[] packet = getPacketData("06 00 00 20 02");
    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.UNSIGNED_8_BIT_INTEGER, record.getAttributeDataType());
    assertEquals(6, record.getAttributeIdentifier());
    assertEquals(ZclStatus.SUCCESS, record.getStatus());
    assertEquals(2, 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