use of com.zsmartsystems.zigbee.zcl.field.ReadAttributeStatusRecord 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.zcl.field.ReadAttributeStatusRecord 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());
}
use of com.zsmartsystems.zigbee.zcl.field.ReadAttributeStatusRecord in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclCluster method readSync.
/**
* Read an attribute
*
* @param attribute the {@link ZclAttribute} to read
* @return
*/
protected Object readSync(final ZclAttribute attribute) {
logger.debug("readSync request: {}", attribute);
CommandResult result;
try {
result = read(attribute).get();
} catch (InterruptedException e) {
logger.debug("readSync interrupted");
return null;
} catch (ExecutionException e) {
logger.debug("readSync exception ", e);
return null;
}
if (!result.isSuccess()) {
return null;
}
ReadAttributesResponse response = result.getResponse();
if (response.getRecords().get(0).getStatus() == ZclStatus.SUCCESS) {
ReadAttributeStatusRecord attributeRecord = response.getRecords().get(0);
return normalizer.normalizeZclData(attribute.getDataType(), attributeRecord.getAttributeValue());
}
return null;
}
use of com.zsmartsystems.zigbee.zcl.field.ReadAttributeStatusRecord 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());
}
use of com.zsmartsystems.zigbee.zcl.field.ReadAttributeStatusRecord in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclCluster method handleAttributeStatus.
/**
* Processes a list of attribute status reports for this cluster
*
* @param reports {@List} of {@link ReadAttributeStatusRecord}
*/
public void handleAttributeStatus(List<ReadAttributeStatusRecord> records) {
for (ReadAttributeStatusRecord record : records) {
if (record.getStatus() != ZclStatus.SUCCESS) {
logger.debug("{}: Error reading attribute {} in cluster {} - {}", zigbeeEndpoint.getEndpointAddress(), record.getAttributeIdentifier(), clusterId, record.getStatus());
continue;
}
ZclAttribute attribute = attributes.get(record.getAttributeIdentifier());
if (attribute == null) {
logger.debug("{}: Unknown attribute {} in cluster {}", zigbeeEndpoint.getEndpointAddress(), record.getAttributeIdentifier(), clusterId);
} else {
attribute.updateValue(normalizer.normalizeZclData(attribute.getDataType(), record.getAttributeValue()));
notifyAttributeListener(attribute);
}
}
}
Aggregations