Skip to content

Commit aa74a1c

Browse files
committed
Update code to set _deviceConfigurationChanged correctly in _getAttributesToReportWithReportedValues
- Add more tests to verify that for attributes that don't affect device configuration changed, the delegate callback is not called. Also add tests for testing an attribute report having multiple attributes one of which causes device configuration changed.
1 parent d873d21 commit aa74a1c

File tree

3 files changed

+151
-42
lines changed

3 files changed

+151
-42
lines changed

src/darwin/Framework/CHIP/MTRDevice.h

-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ MTR_EXTERN NSString * const MTRDataVersionKey MTR_NEWLY_AVAILABLE;
428428
*
429429
* Device configuration is the set of functionality implemented by the device.
430430
*
431-
* The intention is that this is called whenever any of the things that usually don't change about a device might have changed.
432431
*/
433432
- (void)deviceConfigurationChanged:(MTRDevice *)device MTR_NEWLY_AVAILABLE;
434433

src/darwin/Framework/CHIP/MTRDevice.mm

+7-5
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,13 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
25452545
// Now that we have grabbed previousValue, update our cache with the attribute value.
25462546
if (readCacheValueChanged) {
25472547
[self _setCachedAttributeValue:attributeDataValue forPath:attributePath];
2548+
if (!_deviceConfigurationChanged)
2549+
{
2550+
_deviceConfigurationChanged = [self _attributeAffectsDeviceConfiguration:attributePath];
2551+
if (_deviceConfigurationChanged) {
2552+
MTR_LOG_INFO("Device configuration changed due to changes in attribute %@", attributePath);
2553+
}
2554+
}
25482555
}
25492556

25502557
#ifdef DEBUG
@@ -2565,11 +2572,6 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
25652572
// when our cached value changes and no expected value exists.
25662573
if (readCacheValueChanged && !expectedValue) {
25672574
shouldReportAttribute = YES;
2568-
2569-
_deviceConfigurationChanged = [self _isAttributeAffectingDeviceConfigurationChanged:attributePath];
2570-
if (_deviceConfigurationChanged) {
2571-
MTR_LOG_INFO("Device configuration changed due to changes in attribute %@", attributePath);
2572-
}
25732575
}
25742576

25752577
if (!shouldReportAttribute) {

0 commit comments

Comments
 (0)