@@ -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) {
@@ -1910,7 +1877,7 @@ - (void)_setCachedAttributeValue:(MTRDeviceDataValueDictionary _Nullable)value f
1910
1877
}
1911
1878
1912
1879
[clusterData storeValue: value forAttribute: path.attribute];
1913
-
1880
+
1914
1881
if (value != nil
1915
1882
&& isFromSubscription
1916
1883
&& !_receivingPrimingReport
@@ -1920,11 +1887,9 @@ - (void)_setCachedAttributeValue:(MTRDeviceDataValueDictionary _Nullable)value f
1920
1887
// (removals are OK)
1921
1888
1922
1889
// log when a device violates expectations for Changes Omitted Quality attributes.
1923
- MTRDeviceInformationalAttributes * attributes = [self _informationalAttributesForCurrentState ];
1924
-
1925
1890
using namespace chip ::Tracing::DarwinFramework;
1926
1891
MATTER_LOG_METRIC_BEGIN (kMetricUnexpectedCQualityUpdate );
1927
- [attributes addInformationalAttributesToCurrentMetricScope ];
1892
+ [self _addInformationalAttributesToCurrentMetricScope ];
1928
1893
MATTER_LOG_METRIC_END (kMetricUnexpectedCQualityUpdate );
1929
1894
1930
1895
return ;
@@ -3539,18 +3504,40 @@ - (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID
3539
3504
3540
3505
#pragma mark Log Help
3541
3506
3542
- - (MTRDeviceInformationalAttributes *)_informationalAttributesForCurrentState {
3543
- MTRClusterPath * basicInfoClusterPath = [MTRClusterPath clusterPathWithEndpointID: @(kRootEndpointId ) clusterID: @(MTRClusterIDTypeBasicInformationID)];
3544
- MTRDeviceClusterData * basicInfoClusterData = [self _clusterDataForPath: basicInfoClusterPath];
3507
+ - (NSNumber *)_informationalNumberAtAttributePath : (MTRAttributePath *)attributePath {
3508
+ auto * cachedData = [self _cachedAttributeValueForPath: attributePath];
3545
3509
3546
- NSNumber * vidObj = basicInfoClusterData.attributes [@(MTRAttributeIDTypeClusterBasicInformationAttributeVendorIDID)][MTRValueKey];
3547
- UInt16 vendorID = vidObj.unsignedShortValue ;
3548
- NSNumber * pidObj = basicInfoClusterData.attributes [@(MTRAttributeIDTypeClusterBasicInformationAttributeProductIDID)][MTRValueKey];
3549
- UInt16 productID = pidObj.unsignedShortValue ;
3510
+ auto * attrReport = [[MTRAttributeReport alloc ] initWithResponseValue: @{
3511
+ MTRAttributePathKey : attributePath,
3512
+ MTRDataKey : cachedData,
3513
+ } error: nil ];
3514
+ // REVIEWERS: is it worth logging the `error` above?
3550
3515
3551
- BOOL usesThread = [self _deviceUsesThread ];
3516
+ return attrReport.value ;
3517
+ }
3518
+
3519
+ - (NSNumber *)_informationalVendorID {
3520
+ auto * vendorIDPath = [MTRAttributePath attributePathWithEndpointID: @(kRootEndpointId )
3521
+ clusterID: @(MTRClusterIDTypeBasicInformationID)
3522
+ attributeID: @(MTRClusterBasicAttributeVendorIDID)];
3552
3523
3553
- return [[MTRDeviceInformationalAttributes alloc ] initWithVendorID: vendorID productID: productID usesThread: usesThread];
3524
+ return [self _informationalNumberAtAttributePath: vendorIDPath];
3525
+ }
3526
+
3527
+ - (NSNumber *)_informationalProductID {
3528
+ auto * productIDPath = [MTRAttributePath attributePathWithEndpointID: @(kRootEndpointId )
3529
+ clusterID: @(MTRClusterIDTypeBasicInformationID)
3530
+ attributeID: @(MTRClusterBasicAttributeProductIDID)];
3531
+
3532
+ return [self _informationalNumberAtAttributePath: productIDPath];
3533
+ }
3534
+
3535
+ - (void )_addInformationalAttributesToCurrentMetricScope {
3536
+ using namespace chip ::Tracing::DarwinFramework;
3537
+ MATTER_LOG_METRIC (kMetricDeviceVendorID , [self _informationalVendorID ].unsignedShortValue );
3538
+ MATTER_LOG_METRIC (kMetricDeviceProductID , [self _informationalProductID ].unsignedShortValue );
3539
+ BOOL usesThread = [self _deviceUsesThread ];
3540
+ MATTER_LOG_METRIC (kMetricDeviceUsesThread , usesThread);
3554
3541
}
3555
3542
3556
3543
@end
0 commit comments