Skip to content

Commit

Permalink
Update code to set _deviceConfigurationChanged correctly in _getAttri…
Browse files Browse the repository at this point in the history
…butesToReportWithReportedValues

- 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.
  • Loading branch information
nivi-apple committed May 1, 2024
1 parent d873d21 commit aa74a1c
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 42 deletions.
1 change: 0 additions & 1 deletion src/darwin/Framework/CHIP/MTRDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ MTR_EXTERN NSString * const MTRDataVersionKey MTR_NEWLY_AVAILABLE;
*
* Device configuration is the set of functionality implemented by the device.
*
* The intention is that this is called whenever any of the things that usually don't change about a device might have changed.
*/
- (void)deviceConfigurationChanged:(MTRDevice *)device MTR_NEWLY_AVAILABLE;

Expand Down
12 changes: 7 additions & 5 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2545,6 +2545,13 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
// Now that we have grabbed previousValue, update our cache with the attribute value.
if (readCacheValueChanged) {
[self _setCachedAttributeValue:attributeDataValue forPath:attributePath];
if (!_deviceConfigurationChanged)
{
_deviceConfigurationChanged = [self _attributeAffectsDeviceConfiguration:attributePath];
if (_deviceConfigurationChanged) {
MTR_LOG_INFO("Device configuration changed due to changes in attribute %@", attributePath);
}
}
}

#ifdef DEBUG
Expand All @@ -2565,11 +2572,6 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
// when our cached value changes and no expected value exists.
if (readCacheValueChanged && !expectedValue) {
shouldReportAttribute = YES;

_deviceConfigurationChanged = [self _isAttributeAffectingDeviceConfigurationChanged:attributePath];
if (_deviceConfigurationChanged) {
MTR_LOG_INFO("Device configuration changed due to changes in attribute %@", attributePath);
}
}

if (!shouldReportAttribute) {
Expand Down
Loading

0 comments on commit aa74a1c

Please sign in to comment.