From 2b8ecf7279430e43b6967f4110a43486d2ac27ba Mon Sep 17 00:00:00 2001 From: Henning Sudbrock Date: Wed, 4 Mar 2020 09:34:11 +0100 Subject: [PATCH] Add the manufacturer code to the ZclAttributeDao This field has previously been missing in the DAO, but should be stored in the database as well. Signed-off-by: Henning Sudbrock --- .../zigbee/database/ZclAttributeDao.java | 20 +++++++++++++++++++ .../zigbee/zcl/ZclAttribute.java | 2 ++ .../zigbee/zcl/ZclAttributeTest.java | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/database/ZclAttributeDao.java b/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/database/ZclAttributeDao.java index e0182eb83..2676a2fe7 100644 --- a/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/database/ZclAttributeDao.java +++ b/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/database/ZclAttributeDao.java @@ -97,6 +97,12 @@ public class ZclAttributeDao { */ private int reportingTimeout; + /** + * The manufacturer code of the attribute, in case the attribute is + * manufacturer-specific. Otherwise, this field is null. + */ + private Integer manufacturerCode; + /** * Records the last time a report was received */ @@ -275,6 +281,20 @@ public void setReportingTimeout(int reportingTimeout) { this.reportingTimeout = reportingTimeout; } + /** + * @return the manufacturer code (or null, if attribute is not manufacturer-specific) + */ + public Integer getManufacturerCode() { + return manufacturerCode; + } + + /** + * @param manufacturerCode the manufacturer code to set (or null, if attribute is not manufacturer-specific) + */ + public void setManufacturerCode(Integer manufacturerCode) { + this.manufacturerCode = manufacturerCode; + } + /** * @return the lastReportTime */ diff --git a/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/zcl/ZclAttribute.java b/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/zcl/ZclAttribute.java index e5df67a4f..4cbf929f0 100644 --- a/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/zcl/ZclAttribute.java +++ b/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/zcl/ZclAttribute.java @@ -541,6 +541,7 @@ public void setDao(ZclCluster cluster, ZclAttributeDao dao) { maximumReportingPeriod = dao.getMaximumReportingPeriod(); reportingChange = dao.getReportingChange(); reportingTimeout = dao.getReportingTimeout(); + manufacturerCode = dao.getManufacturerCode(); } /** @@ -564,6 +565,7 @@ public ZclAttributeDao getDao() { dao.setReportable(reportable); dao.setReportingChange(reportingChange); dao.setReportingTimeout(reportingTimeout); + dao.setManufacturerCode(manufacturerCode); dao.setLastValue(lastValue); dao.setLastReportTime(lastReportTime); diff --git a/com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zcl/ZclAttributeTest.java b/com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zcl/ZclAttributeTest.java index 456bda326..cc9863a2f 100644 --- a/com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zcl/ZclAttributeTest.java +++ b/com.zsmartsystems.zigbee/src/test/java/com/zsmartsystems/zigbee/zcl/ZclAttributeTest.java @@ -131,7 +131,7 @@ public void setReporting() { public void dao() { ZclCluster cluster = Mockito.mock(ZclCluster.class); ZclAttribute attribute = new ZclAttribute(cluster, 123, "Test Name", ZclDataType.UNSIGNED_8_BIT_INTEGER, true, - false, true, false); + false, true, false, 0x1234); attribute.updateValue(Integer.valueOf(12345)); @@ -144,6 +144,7 @@ public void dao() { assertTrue(dao.isWritable()); assertFalse(dao.isReadable()); assertFalse(dao.isReportable()); + assertEquals(Integer.valueOf(0x1234), dao.getManufacturerCode()); assertEquals(12345, dao.getLastValue()); ZclAttribute daoAttribute = new ZclAttribute(); @@ -157,6 +158,7 @@ public void dao() { assertTrue(daoAttribute.isWritable()); assertFalse(daoAttribute.isReadable()); assertFalse(daoAttribute.isReportable()); + assertEquals(Integer.valueOf(0x1234), daoAttribute.getManufacturerCode()); assertEquals(12345, daoAttribute.getLastValue()); } }