use of com.zsmartsystems.zigbee.serialization.DefaultDeserializer in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclHeaderTest method testDeserialize.
@Test
public void testDeserialize() {
int[] packet = getPacketData("11 04 01");
DefaultDeserializer deserializer = new DefaultDeserializer(packet);
ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
ZclHeader zclHeader = new ZclHeader(fieldDeserializer);
System.out.println(zclHeader);
assertEquals(1, zclHeader.getCommandId());
assertEquals(ZclFrameType.CLUSTER_SPECIFIC_COMMAND, zclHeader.getFrameType());
assertEquals(false, zclHeader.isManufacturerSpecific());
assertEquals(true, zclHeader.isDisableDefaultResponse());
assertEquals(4, zclHeader.getSequenceNumber());
DefaultSerializer serializer = new DefaultSerializer();
ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
assertTrue(Arrays.equals(packet, zclHeader.serialize(fieldSerializer, new int[] {})));
}
use of com.zsmartsystems.zigbee.serialization.DefaultDeserializer 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());
}
use of com.zsmartsystems.zigbee.serialization.DefaultDeserializer 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());
}
use of com.zsmartsystems.zigbee.serialization.DefaultDeserializer 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());
}
use of com.zsmartsystems.zigbee.serialization.DefaultDeserializer 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());
}
Aggregations