@@ -1107,42 +1107,10 @@ - (void)_reportAttributes:(NSArray<NSDictionary<NSString *, id> *> *)attributes
1107
1107
}
1108
1108
}
1109
1109
1110
- // When we receive an attribute report, check if there are any changes in parts list, server list, device type list, accepted commands list,
1111
- // attribute list, cluster revision or feature map attributes of the descriptor cluster. If yes, make a note that the device configuration changed.
1112
- - (void)_noteDeviceConfigurationChanged:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport
1113
- {
1114
- for (NSDictionary<NSString *, id> * attribute in attributeReport) {
1115
- MTRAttributePath * attributePath = attribute[MTRAttributePathKey];
1116
-
1117
- if (attributePath.cluster.unsignedLongValue != MTRClusterDescriptorID) {
1118
- return;
1119
- }
1120
-
1121
- switch (attributePath.attribute.unsignedLongValue) {
1122
- case MTRClusterDescriptorAttributePartsListID:
1123
- case MTRClusterDescriptorAttributeServerListID:
1124
- case MTRClusterDescriptorAttributeDeviceTypeListID:
1125
- case MTRClusterDescriptorAttributeAcceptedCommandListID:
1126
- case MTRClusterDescriptorAttributeAttributeListID:
1127
- case MTRClusterDescriptorAttributeClusterRevisionID:
1128
- case MTRClusterDescriptorAttributeFeatureMapID: {
1129
- // If changes are detected, note that the device configuration has changed.
1130
- MTRDeviceDataValueDictionary cachedAttributeDataValue = [self _cachedAttributeValueForPath:attributePath];
1131
- if (cachedAttributeDataValue != nil && ![self _attributeDataValue:attribute[MTRDataKey] isEqualToDataValue:cachedAttributeDataValue]) {
1132
- _deviceConfigurationChanged = YES;
1133
- break;
1134
- }
1135
- }
1136
- }
1137
- }
1138
- }
1139
-
1140
1110
- (void )_handleAttributeReport : (NSArray <NSDictionary<NSString *, id> *> *)attributeReport
1141
1111
{
1142
1112
std::lock_guard lock (_lock);
1143
1113
1144
- [self _noteDeviceConfigurationChanged:attributeReport];
1145
-
1146
1114
// _getAttributesToReportWithReportedValues will log attribute paths reported
1147
1115
[self _reportAttributes: [self _getAttributesToReportWithReportedValues: attributeReport]];
1148
1116
}
@@ -2421,6 +2389,31 @@ - (void)_noteChangeForClusterPath:(MTRClusterPath *)clusterPath
2421
2389
[_clustersToPersist addObject: clusterPath];
2422
2390
}
2423
2391
2392
+ - (BOOL )_isAttributeAffectingDeviceConfigurationChanged : (MTRAttributePath *)attributePath
2393
+ {
2394
+ // Check for attributes in the descriptor cluster that affect device configuration changed.
2395
+ if (attributePath.cluster .unsignedLongValue == MTRClusterIDTypeDescriptorID)
2396
+ {
2397
+ switch (attributePath.attribute .unsignedLongValue ) {
2398
+ case MTRAttributeIDTypeClusterDescriptorAttributePartsListID:
2399
+ case MTRAttributeIDTypeClusterDescriptorAttributeServerListID:
2400
+ case MTRAttributeIDTypeClusterDescriptorAttributeDeviceTypeListID: {
2401
+ return YES ;
2402
+ }
2403
+ }
2404
+ }
2405
+
2406
+ // Check for global attributes that affect device configuration changed.
2407
+ switch (attributePath.attribute .unsignedLongValue ) {
2408
+ case MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID:
2409
+ case MTRAttributeIDTypeGlobalAttributeAttributeListID:
2410
+ case MTRAttributeIDTypeGlobalAttributeClusterRevisionID:
2411
+ case MTRAttributeIDTypeGlobalAttributeFeatureMapID:
2412
+ return YES ;
2413
+ }
2414
+ return NO ;
2415
+ }
2416
+
2424
2417
// assume lock is held
2425
2418
- (NSArray *)_getAttributesToReportWithReportedValues : (NSArray <NSDictionary<NSString *, id> *> *)reportedAttributeValues
2426
2419
{
@@ -2493,6 +2486,11 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray<NSDictionary<NSSt
2493
2486
// when our cached value changes and no expected value exists.
2494
2487
if (readCacheValueChanged && !expectedValue) {
2495
2488
shouldReportAttribute = YES ;
2489
+
2490
+ _deviceConfigurationChanged = [self _isAttributeAffectingDeviceConfigurationChanged: attributePath];
2491
+ if (_deviceConfigurationChanged) {
2492
+ MTR_LOG_INFO (" Device configuration changed due to changes in attribute %@" , attributePath);
2493
+ }
2496
2494
}
2497
2495
2498
2496
// Now that we have grabbed previousValue, update our cache with the attribute value.
0 commit comments