Search in sources :

Example 21 with ZclFieldDeserializer

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

Example 22 with ZclFieldDeserializer

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

the class QueryNextImageCommandTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("00 0C 11 62 00 03 05 02 01");
    QueryNextImageCommand command = new QueryNextImageCommand();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    command.deserialize(fieldDeserializer);
    System.out.println(command);
    assertEquals(Integer.valueOf(4364), command.getManufacturerCode());
    assertEquals(Integer.valueOf(98), command.getImageType());
    assertEquals(Integer.valueOf(0x1020503), command.getFileVersion());
    assertNull(command.getHardwareVersion());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 23 with ZclFieldDeserializer

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

the class QueryNextImageCommandTest method testReceiveHwVersion.

@Test
public void testReceiveHwVersion() {
    int[] packet = getPacketData("01 0C 11 62 00 03 05 02 01 33 44");
    QueryNextImageCommand command = new QueryNextImageCommand();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    command.deserialize(fieldDeserializer);
    System.out.println(command);
    assertEquals(Integer.valueOf(4364), command.getManufacturerCode());
    assertEquals(Integer.valueOf(98), command.getImageType());
    assertEquals(Integer.valueOf(0x1020503), command.getFileVersion());
    assertEquals(Integer.valueOf(0x4433), command.getHardwareVersion());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 24 with ZclFieldDeserializer

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

the class ActiveEndpointsResponseTest method testReceive2.

@Test
public void testReceive2() {
    int[] packet = getPacketData("00 00 BD 97 06 01 02 03 04 C8 E8");
    ActiveEndpointsResponse endpointsResponse = new ActiveEndpointsResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    endpointsResponse.deserialize(fieldDeserializer);
    System.out.println(endpointsResponse);
    assertEquals(6, endpointsResponse.getActiveEpList().size());
    assertEquals(0x8005, (int) endpointsResponse.getClusterId());
    assertEquals(ZdoStatus.SUCCESS, endpointsResponse.getStatus());
    assertEquals(0x97bd, (int) endpointsResponse.getNwkAddrOfInterest());
    assertEquals(1, (int) endpointsResponse.getActiveEpList().get(0));
    assertEquals(2, (int) endpointsResponse.getActiveEpList().get(1));
    assertEquals(3, (int) endpointsResponse.getActiveEpList().get(2));
    assertEquals(4, (int) endpointsResponse.getActiveEpList().get(3));
    assertEquals(0xc8, (int) endpointsResponse.getActiveEpList().get(4));
    assertEquals(0xe8, (int) endpointsResponse.getActiveEpList().get(5));
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) CommandTest(com.zsmartsystems.zigbee.CommandTest) Test(org.junit.Test)

Example 25 with ZclFieldDeserializer

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

the class IeeeAddressResponseTest method testReceiveVeryShort.

@Test
public void testReceiveVeryShort() {
    // Short response - ie not extended. This is from the Ember response!
    int[] packet = getPacketData("00 00 42 CC 12 00 00 24 E5 7C AD B8");
    IeeeAddressResponse addressResponse = new IeeeAddressResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    addressResponse.deserialize(fieldDeserializer);
    System.out.println(addressResponse);
    assertEquals(ZdoStatus.SUCCESS, addressResponse.getStatus());
    assertEquals(new IeeeAddress("7CE524000012CC42"), addressResponse.getIeeeAddrRemoteDev());
    assertEquals(Integer.valueOf(47277), addressResponse.getNwkAddrRemoteDev());
    assertEquals(0x8001, (int) addressResponse.getClusterId());
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) ZclFieldDeserializer(com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) 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