Skip to content

Commit 2f17606

Browse files
authored
[Darwin] Fix for API changes and address post-merge comments for #32765 (#32778)
1 parent 68ebd09 commit 2f17606

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/darwin/Framework/CHIP/MTRBaseDevice.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
NS_ASSUME_NONNULL_BEGIN
2828

29-
typedef NSDictionary<NSString *, id> * MTRDeviceResponseValueDictionary;
30-
typedef NSDictionary<NSString *, id> * MTRDeviceDataValueDictionary;
31-
3229
/**
3330
* Handler for read attribute response, write attribute response, invoke command response and reports.
3431
*
@@ -99,7 +96,7 @@ typedef NSDictionary<NSString *, id> * MTRDeviceDataValueDictionary;
9996
*
10097
* MTRDataKey : Data-value NSDictionary object.
10198
*/
102-
typedef void (^MTRDeviceResponseHandler)(NSArray<MTRDeviceResponseValueDictionary> * _Nullable values, NSError * _Nullable error);
99+
typedef void (^MTRDeviceResponseHandler)(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error);
103100

104101
/**
105102
* Handler for -subscribeWithQueue: attribute and event reports

src/darwin/Framework/CHIP/MTRDevice.mm

+5-1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ - (NSString *)description
188188
return [NSString stringWithFormat:@"<MTRDeviceClusterData: dataVersion %@ attributes count %lu>", _dataVersion, static_cast<unsigned long>(_attributes.count)];
189189
}
190190

191+
// Attributes dictionary is: attributeID => data-value dictionary
191192
- (nullable instancetype)initWithDataVersion:(NSNumber * _Nullable)dataVersion attributes:(NSDictionary<NSNumber *, MTRDeviceDataValueDictionary> * _Nullable)attributes
192193
{
193194
self = [super init];
@@ -884,7 +885,10 @@ - (void)_handleReportBegin
884885
NSMutableDictionary * clusterDataToReturn = [NSMutableDictionary dictionary];
885886
for (MTRClusterPath * clusterPath in clusterPaths) {
886887
NSNumber * dataVersion = _clusterData[clusterPath].dataVersion;
887-
NSDictionary<NSNumber *, MTRDeviceDataValueDictionary> * attributes = [self _attributesForCluster:clusterPath];
888+
NSDictionary<NSNumber *, MTRDeviceDataValueDictionary> * attributes = nil;
889+
#if MTRDEVICE_ATTRIBUTE_CACHE_STORE_ATTRIBUTES_BY_CLUSTER
890+
attributes = [self _attributesForCluster:clusterPath];
891+
#endif
888892
if (dataVersion || attributes) {
889893
MTRDeviceClusterData * clusterData = [[MTRDeviceClusterData alloc] initWithDataVersion:dataVersion attributes:attributes];
890894
clusterDataToReturn[clusterPath] = clusterData;

src/darwin/Framework/CHIP/MTRDevice_Internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
2626

2727
@class MTRAsyncWorkQueue;
2828

29+
typedef NSDictionary<NSString *, id> * MTRDeviceDataValueDictionary;
30+
2931
typedef void (^MTRDevicePerformAsyncBlock)(MTRBaseDevice * baseDevice);
3032

3133
// Whether to store attributes by cluster instead of as individual entries for each attribute

0 commit comments

Comments
 (0)