Skip to content

Commit

Permalink
Do not update previous value if there is an expected value when repor…
Browse files Browse the repository at this point in the history
…ting attributes

- Fix the logs for the case when we do not report the attribute
  • Loading branch information
nivi-apple committed Apr 16, 2024
1 parent 90732b2 commit 683ea37
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2343,24 +2343,24 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
#endif
}

// if expected values exists, purge and update read cache
// If expected values exists, do not report the attribute. On expiry of the expected value interval,
// the correct value will be reported anyways.
NSArray * expectedValue = _expectedValueCache[attributePath];
if (expectedValue) {
previousValue = expectedValue[MTRDeviceExpectedValueFieldValueIndex];
_readCache[attributePath] = attributeDataValue;
shouldReportAttribute = NO;
} else if (readCacheValueChanged) {
// otherwise compare and update read cache
previousValue = _readCache[attributePath];
_readCache[attributePath] = attributeDataValue;
shouldReportAttribute = YES;
}
_readCache[attributePath] = attributeDataValue;

if (!shouldReportAttribute) {
if (expectedValue) {
MTR_LOG_INFO("%@ report %@ value filtered - same as expected values", self, attributePath);
} else {
MTR_LOG_INFO("%@ report %@ value filtered - same values as cache", self, attributePath);
MTR_LOG_INFO("%@ report %@ value filtered - new expected value present. Do not report old value", self, attributePath);
} else
{
MTR_LOG_INFO("%@ report %@ value filtered - same as read cache", self, attributePath);
}
}

Expand Down

0 comments on commit 683ea37

Please sign in to comment.