Skip to content

Commit b0ca102

Browse files
committed
Remove expected value check from the _getAttributesToReportWithReportedValues
- Report the attribute only when the value has changed from the read cache. - Fix logging for use cases where we didn't report since there was an expected value or the attribute value didn't change from the read cache value.
1 parent 90732b2 commit b0ca102

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+13-12
Original file line numberDiff line numberDiff line change
@@ -2343,24 +2343,25 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
23432343
#endif
23442344
}
23452345

2346-
// if expected values exists, purge and update read cache
2347-
NSArray * expectedValue = _expectedValueCache[attributePath];
2348-
if (expectedValue) {
2349-
previousValue = expectedValue[MTRDeviceExpectedValueFieldValueIndex];
2350-
_readCache[attributePath] = attributeDataValue;
2351-
shouldReportAttribute = NO;
2352-
} else if (readCacheValueChanged) {
2353-
// otherwise compare and update read cache
2346+
// Report the attribute if the attribute value is different from the read cache value.
2347+
if (readCacheValueChanged) {
23542348
previousValue = _readCache[attributePath];
2355-
_readCache[attributePath] = attributeDataValue;
23562349
shouldReportAttribute = YES;
23572350
}
23582351

2352+
// Update the readCache with the attribute value.
2353+
_readCache[attributePath] = attributeDataValue;
2354+
23592355
if (!shouldReportAttribute) {
2356+
NSArray * expectedValue = _expectedValueCache[attributePath];
2357+
2358+
// If an expected value exists, do not report the attribute during this time.
2359+
// When the expected value interval expires, the correct value will be reported.
23602360
if (expectedValue) {
2361-
MTR_LOG_INFO("%@ report %@ value filtered - same as expected values", self, attributePath);
2362-
} else {
2363-
MTR_LOG_INFO("%@ report %@ value filtered - same values as cache", self, attributePath);
2361+
MTR_LOG_INFO("%@ report %@ value filtered - new expected value present. Do not report old value", self, attributePath);
2362+
} else
2363+
{
2364+
MTR_LOG_INFO("%@ report %@ value filtered - same as read cache", self, attributePath);
23642365
}
23652366
}
23662367

0 commit comments

Comments
 (0)