@@ -93,39 +93,6 @@ - (id)strongObject
93
93
}
94
94
@end
95
95
96
- // convenience object for commonly-logged device attributes
97
- @interface MTRDeviceInformationalAttributes : NSObject
98
- @property (readonly ) UInt16 vendorID;
99
- @property (readonly ) UInt16 productID;
100
- @property (readonly ) BOOL usesThread;
101
-
102
- - (void )addInformationalAttributesToCurrentMetricScope ;
103
-
104
- @end
105
-
106
- @implementation MTRDeviceInformationalAttributes
107
-
108
- - (instancetype )initWithVendorID : (UInt16 )vendorID productID : (UInt16 )productID usesThread : (BOOL )usesThread {
109
- self = [super init ];
110
-
111
- if (self) {
112
- _vendorID = vendorID;
113
- _productID = productID;
114
- _usesThread = usesThread;
115
- }
116
-
117
- return self;
118
- }
119
-
120
- - (void )addInformationalAttributesToCurrentMetricScope {
121
- using namespace chip ::Tracing::DarwinFramework;
122
- MATTER_LOG_METRIC (kMetricDeviceVendorID , _vendorID);
123
- MATTER_LOG_METRIC (kMetricDeviceProductID , _productID);
124
- MATTER_LOG_METRIC (kMetricDeviceUsesThread , _usesThread);
125
- }
126
-
127
- @end
128
-
129
96
NSNumber * MTRClampedNumber (NSNumber * aNumber, NSNumber * min, NSNumber * max)
130
97
{
131
98
if ([aNumber compare: min] == NSOrderedAscending) {
@@ -1896,7 +1863,7 @@ - (void)_setCachedAttributeValue:(MTRDeviceDataValueDictionary _Nullable)value f
1896
1863
}
1897
1864
1898
1865
[clusterData storeValue: value forAttribute: path.attribute];
1899
-
1866
+
1900
1867
if (value != nil
1901
1868
&& isFromSubscription
1902
1869
&& !_receivingPrimingReport
@@ -1906,11 +1873,9 @@ - (void)_setCachedAttributeValue:(MTRDeviceDataValueDictionary _Nullable)value f
1906
1873
// (removals are OK)
1907
1874
1908
1875
// log when a device violates expectations for Changes Omitted Quality attributes.
1909
- MTRDeviceInformationalAttributes * attributes = [self _informationalAttributesForCurrentState ];
1910
-
1911
1876
using namespace chip ::Tracing::DarwinFramework;
1912
1877
MATTER_LOG_METRIC_BEGIN (kMetricUnexpectedCQualityUpdate );
1913
- [attributes addInformationalAttributesToCurrentMetricScope ];
1878
+ [self _addInformationalAttributesToCurrentMetricScope ];
1914
1879
MATTER_LOG_METRIC_END (kMetricUnexpectedCQualityUpdate );
1915
1880
1916
1881
return ;
@@ -3567,18 +3532,40 @@ - (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID
3567
3532
3568
3533
#pragma mark Log Help
3569
3534
3570
- - (MTRDeviceInformationalAttributes *)_informationalAttributesForCurrentState {
3571
- MTRClusterPath * basicInfoClusterPath = [MTRClusterPath clusterPathWithEndpointID: @(kRootEndpointId ) clusterID: @(MTRClusterIDTypeBasicInformationID)];
3572
- MTRDeviceClusterData * basicInfoClusterData = [self _clusterDataForPath: basicInfoClusterPath];
3535
+ - (NSNumber *)_informationalNumberAtAttributePath : (MTRAttributePath *)attributePath {
3536
+ auto * cachedData = [self _cachedAttributeValueForPath: attributePath];
3573
3537
3574
- NSNumber * vidObj = basicInfoClusterData.attributes [@(MTRAttributeIDTypeClusterBasicInformationAttributeVendorIDID)][MTRValueKey];
3575
- UInt16 vendorID = vidObj.unsignedShortValue ;
3576
- NSNumber * pidObj = basicInfoClusterData.attributes [@(MTRAttributeIDTypeClusterBasicInformationAttributeProductIDID)][MTRValueKey];
3577
- UInt16 productID = pidObj.unsignedShortValue ;
3538
+ auto * attrReport = [[MTRAttributeReport alloc ] initWithResponseValue: @{
3539
+ MTRAttributePathKey : attributePath,
3540
+ MTRDataKey : cachedData,
3541
+ } error: nil ];
3542
+ // REVIEWERS: is it worth logging the `error` above?
3578
3543
3579
- BOOL usesThread = [self _deviceUsesThread ];
3544
+ return attrReport.value ;
3545
+ }
3546
+
3547
+ - (NSNumber *)_informationalVendorID {
3548
+ auto * vendorIDPath = [MTRAttributePath attributePathWithEndpointID: @(kRootEndpointId )
3549
+ clusterID: @(MTRClusterIDTypeBasicInformationID)
3550
+ attributeID: @(MTRClusterBasicAttributeVendorIDID)];
3580
3551
3581
- return [[MTRDeviceInformationalAttributes alloc ] initWithVendorID: vendorID productID: productID usesThread: usesThread];
3552
+ return [self _informationalNumberAtAttributePath: vendorIDPath];
3553
+ }
3554
+
3555
+ - (NSNumber *)_informationalProductID {
3556
+ auto * productIDPath = [MTRAttributePath attributePathWithEndpointID: @(kRootEndpointId )
3557
+ clusterID: @(MTRClusterIDTypeBasicInformationID)
3558
+ attributeID: @(MTRClusterBasicAttributeProductIDID)];
3559
+
3560
+ return [self _informationalNumberAtAttributePath: productIDPath];
3561
+ }
3562
+
3563
+ - (void )_addInformationalAttributesToCurrentMetricScope {
3564
+ using namespace chip ::Tracing::DarwinFramework;
3565
+ MATTER_LOG_METRIC (kMetricDeviceVendorID , [self _informationalVendorID ].unsignedShortValue );
3566
+ MATTER_LOG_METRIC (kMetricDeviceProductID , [self _informationalProductID ].unsignedShortValue );
3567
+ BOOL usesThread = [self _deviceUsesThread ];
3568
+ MATTER_LOG_METRIC (kMetricDeviceUsesThread , usesThread);
3582
3569
}
3583
3570
3584
3571
@end
0 commit comments