Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the manufacturer code to the ZclAttributeDao #994

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ public void setDao(ZclCluster cluster, ZclAttributeDao dao) {
maximumReportingPeriod = dao.getMaximumReportingPeriod();
reportingChange = dao.getReportingChange();
reportingTimeout = dao.getReportingTimeout();
manufacturerCode = dao.getManufacturerCode();
}

/**
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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();
Expand All @@ -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());
}
}