Skip to content

Commit ead3862

Browse files
Fix data version handling in test033_TestMTRDeviceDeviceConfigurationChanged (#35628)
Data versions are per-cluster, not per-attribute, so every time we inject an attribute report for a given cluster we need to bump the data version. Also: * Fixes checkAttributeReportTriggersConfigurationChanged to be an instance method, since it was taking the instance as an argument anyway. * Fixes checkAttributeReportTriggersConfigurationChanged to provide descriptions for its expectations and assertions that identify the callsite. * Adds some logging to MTRDevice to make it a little easier to tell which parts of attribute reporting are or are not happening and in which order.
1 parent 31894f6 commit ead3862

File tree

2 files changed

+122
-132
lines changed

2 files changed

+122
-132
lines changed

src/darwin/Framework/CHIP/MTRDevice_Concrete.mm

+10-2
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,8 @@ - (void)setStorageBehaviorConfiguration:(MTRDeviceStorageBehaviorConfiguration *
17371737

17381738
- (void)_handleReportEnd
17391739
{
1740+
MTR_LOG("%@ handling report end", self);
1741+
17401742
std::lock_guard lock(_lock);
17411743
_receivingReport = NO;
17421744
_receivingPrimingReport = NO;
@@ -1853,6 +1855,11 @@ - (void)_reportAttributes:(NSArray<NSDictionary<NSString *, id> *> *)attributes
18531855

18541856
- (void)_handleAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport fromSubscription:(BOOL)isFromSubscription
18551857
{
1858+
// Note: %p to avoid double-logging the whole big structure; can be matched
1859+
// up to where we receive the attribute report, which logs pointer value and
1860+
// actual value.
1861+
MTR_LOG("%@ handling attribute report %p, fromSubscription: %@", self, attributeReport, MTR_YES_NO(isFromSubscription));
1862+
18561863
std::lock_guard lock(_lock);
18571864

18581865
// _getAttributesToReportWithReportedValues will log attribute paths reported
@@ -1863,6 +1870,7 @@ - (void)_handleAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attrib
18631870
- (void)_injectAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport fromSubscription:(BOOL)isFromSubscription
18641871
{
18651872
[_deviceController asyncDispatchToMatterQueue:^{
1873+
MTR_LOG("%@ injected attribute report (%p) %@", self, attributeReport, attributeReport);
18661874
[self _handleReportBegin];
18671875
dispatch_async(self.queue, ^{
18681876
[self _handleAttributeReport:attributeReport fromSubscription:isFromSubscription];
@@ -2396,7 +2404,7 @@ - (void)_setupSubscriptionWithReason:(NSString *)reason
23962404

23972405
auto callback = std::make_unique<SubscriptionCallback>(
23982406
^(NSArray * value) {
2399-
MTR_LOG("%@ got attribute report %@", self, value);
2407+
MTR_LOG("%@ got attribute report (%p) %@", self, value, value);
24002408
dispatch_async(self.queue, ^{
24012409
// OnAttributeData
24022410
[self _handleAttributeReport:value fromSubscription:YES];
@@ -2823,7 +2831,7 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath)
28232831
if (values) {
28242832
// Since the format is the same data-value dictionary, this looks like an
28252833
// attribute report
2826-
MTR_LOG("Read attribute work item [%llu] result: %@ [0x%016llX:%@:0x%llX:0x%llX]", workItemID, values, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
2834+
MTR_LOG("Read attribute work item [%llu] result: (%p) %@ [0x%016llX:%@:0x%llX:0x%llX]", workItemID, values, values, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
28272835
[self _handleAttributeReport:values fromSubscription:NO];
28282836
}
28292837

0 commit comments

Comments
 (0)