Search in sources :

Example 11 with DefaultDeserializer

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

the class ManagementLqiResponseTest method testReceive.

@Test
public void testReceive() {
    // Short response - ie not extended
    int[] packet = getPacketData("00 00 02 00 02 14 D4 F1 02 00 4B 12 00 0B 88 DC 00 01 88 17 00 8F 22 15 02 01 3B 14 D4 F1 02 00 4B 12 00 EC A1 A5 01 00 8D 15 00 35 38 15 02 01 58");
    ManagementLqiResponse lqiResponse = new ManagementLqiResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    lqiResponse.deserialize(fieldDeserializer);
    System.out.println(lqiResponse);
    assertEquals(2, (int) lqiResponse.getNeighborTableEntries());
    assertEquals(0, (int) lqiResponse.getStartIndex());
    List<NeighborTable> neighbors = lqiResponse.getNeighborTableList();
    assertEquals(2, neighbors.size());
    assertEquals(59, (int) neighbors.get(0).getLqi());
    assertEquals(NeighborTableJoining.UNKNOWN, neighbors.get(0).getPermitJoining());
    assertEquals(1, (int) neighbors.get(0).getDepth());
    assertEquals(NeighborTableRelationship.CHILD, neighbors.get(0).getRelationship());
    assertEquals(LogicalType.ROUTER, neighbors.get(0).getDeviceType());
    assertEquals(NeighborTableRxState.RX_ON, neighbors.get(0).getRxOnWhenIdle());
    assertEquals(new IeeeAddress("0017880100DC880B"), neighbors.get(0).getExtendedAddress());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) NeighborTable(com.zsmartsystems.zigbee.zdo.field.NeighborTable) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 12 with DefaultDeserializer

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

the class NodeDescriptorResponseTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("00 00 00 00 00 40 8F CD AB 52 80 00 41 2A 80 00 00");
    // data=01 90 45 00 00 00 02 80 00 00 40 01 00 00 36 FF 00 00 00 FF FF 11 00 00 00 00 00 40 8F CD AB 52 80 00 41
    // 2A
    // 80 00 00]
    NodeDescriptorResponse descriptorResponse = new NodeDescriptorResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    descriptorResponse.deserialize(fieldDeserializer);
    System.out.println(descriptorResponse);
    NodeDescriptor nodeDescriptor = descriptorResponse.getNodeDescriptor();
    assertEquals(82, nodeDescriptor.getBufferSize());
    assertEquals(128, nodeDescriptor.getIncomingTransferSize());
    assertEquals(43981, nodeDescriptor.getManufacturerCode());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) NodeDescriptor(com.zsmartsystems.zigbee.zdo.field.NodeDescriptor) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 13 with DefaultDeserializer

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

the class PowerDescriptorResponseTest method testReceiveNotSupported.

@Test
public void testReceiveNotSupported() {
    int[] packet = getPacketData("84 84");
    PowerDescriptorResponse descriptorResponse = new PowerDescriptorResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    descriptorResponse.deserialize(fieldDeserializer);
    System.out.println(descriptorResponse);
    assertEquals(ZdoStatus.NOT_SUPPORTED, descriptorResponse.getStatus());
    PowerDescriptor powerDescriptor = descriptorResponse.getPowerDescriptor();
    assertEquals(null, powerDescriptor);
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) PowerDescriptor(com.zsmartsystems.zigbee.zdo.field.PowerDescriptor) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 14 with DefaultDeserializer

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

the class SimpleDescriptorResponseTest method testReceiveError.

@Test
public void testReceiveError() {
    // int[] packet = getPacketData("00 00 00 00 10 C1");
    int[] packet = getPacketData("00 81 00 01");
    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();
    assertNull(simpleDescriptor);
    assertEquals(ZdoStatus.DEVICE_NOT_FOUND, descriptorResponse.getStatus());
}
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 15 with DefaultDeserializer

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

the class NeighborTableTest method testDeserialize.

@Test
public void testDeserialize() {
    int[] packet = getPacketData("B1 68 DE 3A 00 00 00 00 86 06 00 00 00 EE 1F 00 A9 44 25 02 0F E2");
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    NeighborTable neighbor = new NeighborTable();
    neighbor.deserialize(deserializer);
    assertEquals(LogicalType.ROUTER, neighbor.getDeviceType());
    assertEquals(new IeeeAddress("001FEE0000000686"), neighbor.getExtendedAddress());
    assertEquals(new ExtendedPanId("3ADE68B1"), neighbor.getExtendedPanId());
    assertEquals(NeighborTableRelationship.SIBLING, neighbor.getRelationship());
    assertEquals(Integer.valueOf(17577), neighbor.getNetworkAddress());
    assertEquals(NeighborTableJoining.UNKNOWN, neighbor.getPermitJoining());
    assertEquals(NeighborTableRxState.RX_ON, neighbor.getRxOnWhenIdle());
    assertEquals(Integer.valueOf(15), neighbor.getDepth());
    assertEquals(Integer.valueOf(226), neighbor.getLqi());
}
Also used : ExtendedPanId(com.zsmartsystems.zigbee.ExtendedPanId) DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test) CommandTest(com.zsmartsystems.zigbee.CommandTest)

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