Search in sources :

Example 16 with DefaultDeserializer

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

the class ZigBeeNodeTest method getNeighborTable.

private NeighborTable getNeighborTable(int[] packet) {
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    NeighborTable neighbor = new NeighborTable();
    neighbor.deserialize(deserializer);
    return neighbor;
}
Also used : DefaultDeserializer(com.zsmartsystems.zigbee.serialization.DefaultDeserializer) NeighborTable(com.zsmartsystems.zigbee.zdo.field.NeighborTable)

Example 17 with DefaultDeserializer

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

the class ZclHeaderTest method testDeserialize2.

@Test
public void testDeserialize2() {
    int[] packet = getPacketData("08 99 88");
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
    System.out.println(zclHeader);
    assertEquals(0x88, zclHeader.getCommandId());
    assertEquals(ZclFrameType.ENTIRE_PROFILE_COMMAND, zclHeader.getFrameType());
    assertEquals(false, zclHeader.isManufacturerSpecific());
    assertEquals(false, zclHeader.isDisableDefaultResponse());
    assertEquals(0x99, 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 18 with DefaultDeserializer

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

the class ConfigureReportingResponseTest method testErrorInvalidDataType.

@Test
public void testErrorInvalidDataType() {
    int[] packet = getPacketData("08 6C 07 8D 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.INVALID_DATA_TYPE, 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 19 with DefaultDeserializer

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

the class NetworkAddressResponseTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("00 00 43 1D A5 00 AA 3E B0 7C 74 3B");
    NetworkAddressResponse addressResponse = new NetworkAddressResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    addressResponse.deserialize(fieldDeserializer);
    System.out.println(addressResponse);
    assertEquals(new IeeeAddress("7CB03EAA00A51D43"), addressResponse.getIeeeAddrRemoteDev());
    assertEquals(0x8000, (int) addressResponse.getClusterId());
    assertEquals(ZdoStatus.SUCCESS, addressResponse.getStatus());
}
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)

Example 20 with DefaultDeserializer

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

the class PowerDescriptorResponseTest method testReceive.

@Test
public void testReceive() {
    int[] packet = getPacketData("00 00 00 00 10 C1");
    PowerDescriptorResponse descriptorResponse = new PowerDescriptorResponse();
    DefaultDeserializer deserializer = new DefaultDeserializer(packet);
    ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
    descriptorResponse.deserialize(fieldDeserializer);
    System.out.println(descriptorResponse);
    PowerDescriptor powerDescriptor = descriptorResponse.getPowerDescriptor();
    assertEquals(ZdoStatus.SUCCESS, descriptorResponse.getStatus());
    assertEquals(PowerLevelType.FULL, powerDescriptor.getPowerLevel());
    assertEquals(CurrentPowerModeType.RECEIVER_ON_IDLE, powerDescriptor.getCurrentPowerMode());
    assertEquals(PowerSourceType.MAINS, powerDescriptor.getCurrentPowerSource());
}
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)

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