Skip to content

Commit

Permalink
readCacheValueChanged and expectedValue are not mutually exclusive. F…
Browse files Browse the repository at this point in the history
…ix the check
  • Loading branch information
nivi-apple committed Apr 16, 2024
1 parent 00c9c59 commit dfcfe9f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2342,9 +2342,10 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
[attributesToPersist addObject:attributeResponseValueToPersist];
#endif
}
NSArray * expectedValue = _expectedValueCache[attributePath];

// Report the attribute if the attribute value is different from the read cache value.
if (readCacheValueChanged) {
// Report the attribute if read attribute would get a value that is changing and no expected value exists.
if (readCacheValueChanged && !expectedValue) {
previousValue = _readCache[attributePath];
shouldReportAttribute = YES;
}
Expand All @@ -2353,12 +2354,11 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
_readCache[attributePath] = attributeDataValue;

if (!shouldReportAttribute) {
NSArray * expectedValue = _expectedValueCache[attributePath];

// If an expected value exists, the attribute will not be reported at this time.
// When the expected value interval expires, the correct value will be reported.
if (expectedValue) {
MTR_LOG_INFO("%@ report %@ value filtered - new expected value present. Do not report old value", self, attributePath);
MTR_LOG_INFO("%@ report %@ value filtered - expected value still present", self, attributePath);
} else
{
MTR_LOG_INFO("%@ report %@ value filtered - same as read cache", self, attributePath);
Expand Down

0 comments on commit dfcfe9f

Please sign in to comment.