use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer 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());
}
use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer 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);
}
use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer 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());
}
use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkManager method receiveCommand.
@Override
public void receiveCommand(final ZigBeeApsFrame apsFrame) {
logger.debug("RX APS: {}", apsFrame);
// Create the deserialiser
Constructor<? extends ZigBeeDeserializer> constructor;
ZigBeeDeserializer deserializer;
try {
constructor = deserializerClass.getConstructor(int[].class);
deserializer = constructor.newInstance(new Object[] { apsFrame.getPayload() });
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
logger.debug("Error creating deserializer", e);
return;
}
ZclFieldDeserializer fieldDeserializer = new ZclFieldDeserializer(deserializer);
ZigBeeCommand command = null;
switch(// TODO: Use ZigBeeProfileType
apsFrame.getProfile()) {
case 0x0000:
command = receiveZdoCommand(fieldDeserializer, apsFrame);
break;
case 0x0104:
case 0xC05E:
command = receiveZclCommand(fieldDeserializer, apsFrame);
break;
default:
logger.debug("Received message with unknown profile {}", String.format("%04X", apsFrame.getProfile()));
break;
}
if (command == null) {
logger.debug("Incoming message did not translate to command.");
return;
}
// Create an address from the sourceAddress and endpoint
command.setSourceAddress(new ZigBeeEndpointAddress(apsFrame.getSourceAddress(), apsFrame.getSourceEndpoint()));
command.setDestinationAddress(new ZigBeeEndpointAddress(apsFrame.getDestinationAddress(), apsFrame.getDestinationEndpoint()));
logger.debug("RX CMD: {}", command);
// Notify the listeners
commandNotifier.notifyCommandListeners(command);
}
use of com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer 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());
}
Aggregations