From 2221682d9af366b1c0480197bcf189041ae11952 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 18 Feb 2022 16:10:13 -0500 Subject: [PATCH] Add a way to do non-fabric-filtered reads on Darwin. (#15353) We only add the new ReadParams for attributes that are actually fabric-scoped lists for now. --- src/darwin/Framework/CHIP/CHIPCluster.h | 15 ++ src/darwin/Framework/CHIP/CHIPCluster.mm | 11 ++ .../CHIP/templates/CHIPClustersObjc-src.zapt | 26 ++- .../CHIP/templates/CHIPClustersObjc.zapt | 14 +- .../CHIP/templates/partials/test_cluster.zapt | 16 +- .../CHIP/zap-generated/CHIPClustersObjc.h | 33 ++-- .../CHIP/zap-generated/CHIPClustersObjc.mm | 75 ++++++--- .../Framework/CHIPTests/CHIPClustersTests.m | 151 +++++++++++------- 8 files changed, 238 insertions(+), 103 deletions(-) diff --git a/src/darwin/Framework/CHIP/CHIPCluster.h b/src/darwin/Framework/CHIP/CHIPCluster.h index 0bd903c6a49884..f94eb611452b36 100644 --- a/src/darwin/Framework/CHIP/CHIPCluster.h +++ b/src/darwin/Framework/CHIP/CHIPCluster.h @@ -33,4 +33,19 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)new NS_UNAVAILABLE; @end +/** + * CHIPReadParams + * This is used to control the behavior of attribute reads. + */ +@interface CHIPReadParams : NSObject + +/** + * Whether the read is fabric-filtered. nil (the default), or YES value, + * means fabric-filtered. NO means not fabric-filtered. + */ +@property (strong, nonatomic, nullable) NSNumber * fabricFiltered; + +- (instancetype)init; +@end + NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/CHIPCluster.mm b/src/darwin/Framework/CHIP/CHIPCluster.mm index ab231c5a488870..9e4fe74b5019de 100644 --- a/src/darwin/Framework/CHIP/CHIPCluster.mm +++ b/src/darwin/Framework/CHIP/CHIPCluster.mm @@ -59,3 +59,14 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); } @end + +@implementation CHIPReadParams +- (instancetype)init +{ + if (self = [super init]) { + _fabricFiltered = nil; + } + return self; +} + +@end diff --git a/src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt b/src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt index a4627a53c49f6b..5346682969bb43 100644 --- a/src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt +++ b/src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt @@ -83,7 +83,13 @@ using namespace chip::app::Clusters; {{#chip_server_cluster_attributes}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name}}{{/inline}} -- (void)read{{>attribute}}WithCompletionHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))completionHandler +- (void)read{{>attribute}}With +{{~#if_is_fabric_scoped_struct type~}} + Params:(CHIPReadParams * _Nullable)params completionHandler: +{{~else~}} + CompletionHandler: +{{~/if_is_fabric_scoped_struct~}} +(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))completionHandler { new CHIP{{>attribute_data_callback_name}}CallbackBridge(self.callbackQueue, {{! This treats completionHandler as taking an id for the data. This is @@ -93,7 +99,11 @@ using namespace chip::app::Clusters; using TypeInfo = {{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo; auto successFn = Callback<{{>attribute_data_callback_name}}Callback>::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall + {{~#if_is_fabric_scoped_struct type~}} + , params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue] + {{~/if_is_fabric_scoped_struct~}} + ); }); } @@ -126,7 +136,11 @@ using namespace chip::app::Clusters; {{/if}} {{#if isReportableAttribute}} -- (void) subscribe{{>attribute}}WithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))reportHandler +- (void) subscribe{{>attribute}}WithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval +{{#if_is_fabric_scoped_struct type}} +params:(CHIPReadParams * _Nullable)params +{{/if_is_fabric_scoped_struct}} +subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))reportHandler { new CHIP{{>attribute_data_callback_name}}CallbackSubscriptionBridge(self.callbackQueue, {{! This treats reportHandler as taking an id for the data. This is @@ -136,7 +150,11 @@ using namespace chip::app::Clusters; using TypeInfo = {{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo; auto successFn = Callback<{{>attribute_data_callback_name}}Callback>::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], CHIP{{>attribute_data_callback_name}}CallbackSubscriptionBridge::OnSubscriptionEstablished); + return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], CHIP{{>attribute_data_callback_name}}CallbackSubscriptionBridge::OnSubscriptionEstablished + {{~#if_is_fabric_scoped_struct type~}} + , params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue] + {{~/if_is_fabric_scoped_struct~}} + ); }, subscriptionEstablishedHandler); } diff --git a/src/darwin/Framework/CHIP/templates/CHIPClustersObjc.zapt b/src/darwin/Framework/CHIP/templates/CHIPClustersObjc.zapt index f30f7159cb46fa..b621a3b30418e3 100644 --- a/src/darwin/Framework/CHIP/templates/CHIPClustersObjc.zapt +++ b/src/darwin/Framework/CHIP/templates/CHIPClustersObjc.zapt @@ -39,12 +39,22 @@ NS_ASSUME_NONNULL_BEGIN {{#chip_server_cluster_attributes}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name}}{{/inline}} -- (void)read{{>attribute}}WithCompletionHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)read{{>attribute}}With +{{~#if_is_fabric_scoped_struct type~}} + Params:(CHIPReadParams * _Nullable)params completionHandler: +{{~else~}} + CompletionHandler: +{{~/if_is_fabric_scoped_struct~}} +(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))completionHandler; {{#if isWritableAttribute}} - (void)write{{>attribute}}WithValue:({{asObjectiveCType type parent.name}})value completionHandler:(StatusCompletion)completionHandler; {{/if}} {{#if isReportableAttribute}} -- (void) subscribe{{>attribute}}WithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))reportHandler; +- (void) subscribe{{>attribute}}WithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval +{{#if_is_fabric_scoped_struct type}} +params:(CHIPReadParams * _Nullable)params +{{/if_is_fabric_scoped_struct}} +subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))reportHandler; {{/if}} {{/chip_server_cluster_attributes}} diff --git a/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt b/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt index a1910a8b65c27c..c74496fa8d8a53 100644 --- a/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt @@ -53,8 +53,15 @@ ResponseHandler {{> subscribeDataCallback}} = nil; {{#chip_tests_item_parameters}} {{asObjectiveCBasicType type}} {{asLowerCamelCase name}}Argument = {{asTypedLiteral definedValue type}}; {{/chip_tests_item_parameters}} + {{#if_is_fabric_scoped_struct attributeObject.type}} + CHIPReadParams * params = [[CHIPReadParams alloc] init]; + params.fabricFiltered = [NSNumber numberWithBool:{{fabricFiltered}}]; + {{/if_is_fabric_scoped_struct}} [cluster subscribeAttribute{{asUpperCamelCase attribute}}WithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument) + {{#if_is_fabric_scoped_struct attributeObject.type}} + params:params + {{/if_is_fabric_scoped_struct}} subscriptionEstablished:^{ XCTAssertEqual(testSendCluster{{parent.filename}}_{{asTestIndex waitForReport.index}}_{{asUpperCamelCase waitForReport.command}}_Fulfilled, true); [expectation fulfill]; @@ -63,7 +70,14 @@ ResponseHandler {{> subscribeDataCallback}} = nil; {{else if isWaitForReport}} {{> subscribeDataCallback }} = ^({{asObjectiveCClass attributeObject.type cluster forceList=attributeObject.isArray}} * _Nullable value, NSError * _Nullable err) { {{else if isReadAttribute}} - [cluster readAttribute{{asUpperCamelCase attribute}}WithCompletionHandler:^({{asObjectiveCClass attributeObject.type cluster forceList=attributeObject.isArray}} * _Nullable value, NSError * _Nullable err) { + {{#if_is_fabric_scoped_struct attributeObject.type}} + CHIPReadParams * params = [[CHIPReadParams alloc] init]; + params.fabricFiltered = [NSNumber numberWithBool:{{fabricFiltered}}]; + [cluster readAttribute{{asUpperCamelCase attribute}}WithParams:params completionHandler: + {{else}} + [cluster readAttribute{{asUpperCamelCase attribute}}WithCompletionHandler: + {{/if_is_fabric_scoped_struct}} + ^({{asObjectiveCClass attributeObject.type cluster forceList=attributeObject.isArray}} * _Nullable value, NSError * _Nullable err) { {{else if isWriteAttribute}} {{#chip_tests_item_parameters}} id {{asLowerCamelCase name}}Argument; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h index c556321f139699..e3748c3d234c6b 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h @@ -37,18 +37,21 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPAccessControl : CHIPCluster -- (void)readAttributeAclWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)readAttributeAclWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)writeAttributeAclWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)subscribeAttributeAclWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; -- (void)readAttributeExtensionWithCompletionHandler:(void (^)( - NSArray * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)readAttributeExtensionWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)writeAttributeExtensionWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)subscribeAttributeExtensionWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; @@ -2700,18 +2703,20 @@ NS_ASSUME_NONNULL_BEGIN - (void)keySetWriteWithParams:(CHIPGroupKeyManagementClusterKeySetWriteParams *)params completionHandler:(StatusCompletion)completionHandler; -- (void)readAttributeGroupKeyMapWithCompletionHandler:(void (^)( - NSArray * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)readAttributeGroupKeyMapWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)writeAttributeGroupKeyMapWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)subscribeAttributeGroupKeyMapWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; -- (void)readAttributeGroupTableWithCompletionHandler:(void (^)( - NSArray * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)readAttributeGroupTableWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)subscribeAttributeGroupTableWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; @@ -3734,11 +3739,13 @@ NS_ASSUME_NONNULL_BEGIN - (void)announceOtaProviderWithParams:(CHIPOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderParams *)params completionHandler:(StatusCompletion)completionHandler; -- (void)readAttributeDefaultOtaProvidersWithCompletionHandler:(void (^)(NSArray * _Nullable value, - NSError * _Nullable error))completionHandler; +- (void)readAttributeDefaultOtaProvidersWithParams:(CHIPReadParams * _Nullable)params + completionHandler: + (void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)writeAttributeDefaultOtaProvidersWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)subscribeAttributeDefaultOtaProvidersWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished: (SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler: @@ -4039,15 +4046,19 @@ NS_ASSUME_NONNULL_BEGIN completionHandler:(void (^)(CHIPOperationalCredentialsClusterNOCResponseParams * _Nullable data, NSError * _Nullable error))completionHandler; -- (void)readAttributeNOCsWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)readAttributeNOCsWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)subscribeAttributeNOCsWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; -- (void)readAttributeFabricsWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)readAttributeFabricsWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler; - (void)subscribeAttributeFabricsWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm index e50ecc56a230a1..a3a99a5a31e814 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm @@ -41,14 +41,16 @@ @implementation CHIPAccessControl return &_cppCluster; } -- (void)readAttributeAclWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler +- (void)readAttributeAclWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { new CHIPAccessControlAclListAttributeCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = AccessControl::Attributes::Acl::TypeInfo; auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }); } @@ -170,6 +172,7 @@ new CHIPDefaultSuccessCallbackBridge( - (void)subscribeAttributeAclWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler { @@ -181,20 +184,22 @@ new CHIPAccessControlAclListAttributeCallbackSubscriptionBridge( auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], - CHIPAccessControlAclListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + CHIPAccessControlAclListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }, subscriptionEstablishedHandler); } -- (void)readAttributeExtensionWithCompletionHandler:(void (^)( - NSArray * _Nullable value, NSError * _Nullable error))completionHandler +- (void)readAttributeExtensionWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { new CHIPAccessControlExtensionListAttributeCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = AccessControl::Attributes::Extension::TypeInfo; auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }); } @@ -240,6 +245,7 @@ new CHIPDefaultSuccessCallbackBridge( - (void)subscribeAttributeExtensionWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler { @@ -251,7 +257,8 @@ new CHIPAccessControlExtensionListAttributeCallbackSubscriptionBridge( auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], - CHIPAccessControlExtensionListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + CHIPAccessControlExtensionListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }, subscriptionEstablishedHandler); } @@ -11306,15 +11313,16 @@ new CHIPCommandSuccessCallbackBridge( }); } -- (void)readAttributeGroupKeyMapWithCompletionHandler:(void (^)( - NSArray * _Nullable value, NSError * _Nullable error))completionHandler +- (void)readAttributeGroupKeyMapWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { new CHIPGroupKeyManagementGroupKeyMapListAttributeCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = GroupKeyManagement::Attributes::GroupKeyMap::TypeInfo; auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }); } @@ -11361,6 +11369,7 @@ new CHIPDefaultSuccessCallbackBridge( - (void)subscribeAttributeGroupKeyMapWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler { @@ -11372,25 +11381,28 @@ new CHIPGroupKeyManagementGroupKeyMapListAttributeCallbackSubscriptionBridge( auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], - CHIPGroupKeyManagementGroupKeyMapListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + CHIPGroupKeyManagementGroupKeyMapListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }, subscriptionEstablishedHandler); } -- (void)readAttributeGroupTableWithCompletionHandler:(void (^)( - NSArray * _Nullable value, NSError * _Nullable error))completionHandler +- (void)readAttributeGroupTableWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { new CHIPGroupKeyManagementGroupTableListAttributeCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = GroupKeyManagement::Attributes::GroupTable::TypeInfo; auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }); } - (void)subscribeAttributeGroupTableWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler { @@ -11402,7 +11414,8 @@ new CHIPGroupKeyManagementGroupTableListAttributeCallbackSubscriptionBridge( auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], - CHIPGroupKeyManagementGroupTableListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + CHIPGroupKeyManagementGroupTableListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }, subscriptionEstablishedHandler); } @@ -15596,15 +15609,16 @@ new CHIPCommandSuccessCallbackBridge( }); } -- (void)readAttributeDefaultOtaProvidersWithCompletionHandler:(void (^)(NSArray * _Nullable value, - NSError * _Nullable error))completionHandler +- (void)readAttributeDefaultOtaProvidersWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { new CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }); } @@ -15651,6 +15665,7 @@ new CHIPDefaultSuccessCallbackBridge( - (void)subscribeAttributeDefaultOtaProvidersWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished: (SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler: @@ -15664,8 +15679,8 @@ new CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackSubscr auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], - CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackSubscriptionBridge:: - OnSubscriptionEstablished); + CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }, subscriptionEstablishedHandler); } @@ -16907,19 +16922,22 @@ new CHIPOperationalCredentialsClusterNOCResponseCallbackBridge( }); } -- (void)readAttributeNOCsWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler +- (void)readAttributeNOCsWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { new CHIPOperationalCredentialsNOCsListAttributeCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = OperationalCredentials::Attributes::NOCs::TypeInfo; auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }); } - (void)subscribeAttributeNOCsWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler { @@ -16931,24 +16949,28 @@ new CHIPOperationalCredentialsNOCsListAttributeCallbackSubscriptionBridge( auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], - CHIPOperationalCredentialsNOCsListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + CHIPOperationalCredentialsNOCsListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }, subscriptionEstablishedHandler); } -- (void)readAttributeFabricsWithCompletionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler +- (void)readAttributeFabricsWithParams:(CHIPReadParams * _Nullable)params + completionHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completionHandler { new CHIPOperationalCredentialsFabricsListAttributeCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = OperationalCredentials::Attributes::Fabrics::TypeInfo; auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }); } - (void)subscribeAttributeFabricsWithMinInterval:(NSNumber * _Nonnull)minInterval maxInterval:(NSNumber * _Nonnull)maxInterval + params:(CHIPReadParams * _Nullable)params subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler { @@ -16960,7 +16982,8 @@ new CHIPOperationalCredentialsFabricsListAttributeCallbackSubscriptionBridge( auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], - CHIPOperationalCredentialsFabricsListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + CHIPOperationalCredentialsFabricsListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished, + params == nil || params.fabricFiltered == nil || [params.fabricFiltered boolValue]); }, subscriptionEstablishedHandler); } diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 77947aa74dfac7..5c627c9a991eaa 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -43970,26 +43970,39 @@ - (void)testSendClusterTestGroupKeyManagementCluster_000009_ReadAttribute CHIPTestGroupKeyManagement * cluster = [[CHIPTestGroupKeyManagement alloc] initWithDevice:device endpoint:0 queue:queue]; XCTAssertNotNil(cluster); - [cluster readAttributeGroupKeyMapWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read Group Keys Error: %@", err); + CHIPReadParams * params = [[CHIPReadParams alloc] init]; + params.fabricFiltered = [NSNumber numberWithBool:true]; + [cluster readAttributeGroupKeyMapWithParams:params + completionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read Group Keys Error: %@", err); - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - { - id actualValue = value; - XCTAssertEqual([actualValue count], 2); - XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[0]).fabricIndex unsignedCharValue], 1); - XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[0]).groupId unsignedShortValue], 257U); - XCTAssertEqual( - [((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[0]).groupKeySetID unsignedShortValue], 417U); - XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[1]).fabricIndex unsignedCharValue], 1); - XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[1]).groupId unsignedShortValue], 258U); - XCTAssertEqual( - [((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[1]).groupKeySetID unsignedShortValue], 418U); - } + { + id actualValue = value; + XCTAssertEqual([actualValue count], 2); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) + actualValue[0]).fabricIndex unsignedCharValue], + 1); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) + actualValue[0]).groupId unsignedShortValue], + 257U); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) + actualValue[0]).groupKeySetID unsignedShortValue], + 417U); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) + actualValue[1]).fabricIndex unsignedCharValue], + 1); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) + actualValue[1]).groupId unsignedShortValue], + 258U); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupKeyMapStruct *) + actualValue[1]).groupKeySetID unsignedShortValue], + 418U); + } - [expectation fulfill]; - }]; + [expectation fulfill]; + }]; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } @@ -44002,26 +44015,37 @@ - (void)testSendClusterTestGroupKeyManagementCluster_000010_ReadAttribute CHIPTestGroupKeyManagement * cluster = [[CHIPTestGroupKeyManagement alloc] initWithDevice:device endpoint:0 queue:queue]; XCTAssertNotNil(cluster); - [cluster readAttributeGroupTableWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read GroupTable Error: %@", err); + CHIPReadParams * params = [[CHIPReadParams alloc] init]; + params.fabricFiltered = [NSNumber numberWithBool:true]; + [cluster readAttributeGroupTableWithParams:params + completionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read GroupTable Error: %@", err); - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - { - id actualValue = value; - XCTAssertEqual([actualValue count], 2); - XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) actualValue[0]).fabricIndex unsignedCharValue], 1); - XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) actualValue[0]).groupId unsignedShortValue], 257U); - XCTAssertTrue( - [((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) actualValue[0]).groupName isEqualToString:@"Group #1"]); - XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) actualValue[1]).fabricIndex unsignedCharValue], 1); - XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) actualValue[1]).groupId unsignedShortValue], 258U); - XCTAssertTrue( - [((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) actualValue[1]).groupName isEqualToString:@"Group #2"]); - } + { + id actualValue = value; + XCTAssertEqual([actualValue count], 2); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) + actualValue[0]).fabricIndex unsignedCharValue], + 1); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) + actualValue[0]).groupId unsignedShortValue], + 257U); + XCTAssertTrue([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) actualValue[0]).groupName + isEqualToString:@"Group #1"]); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) + actualValue[1]).fabricIndex unsignedCharValue], + 1); + XCTAssertEqual([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) + actualValue[1]).groupId unsignedShortValue], + 258U); + XCTAssertTrue([((CHIPGroupKeyManagementClusterGroupInfoMapStruct *) actualValue[1]).groupName + isEqualToString:@"Group #2"]); + } - [expectation fulfill]; - }]; + [expectation fulfill]; + }]; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } @@ -44374,21 +44398,26 @@ - (void)testSendClusterTestOperationalCredentialsCluster_000005_ReadAttribute queue:queue]; XCTAssertNotNil(cluster); - [cluster readAttributeFabricsWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read fabric list before setting label Error: %@", err); + CHIPReadParams * params = [[CHIPReadParams alloc] init]; + params.fabricFiltered = [NSNumber numberWithBool:true]; + [cluster readAttributeFabricsWithParams:params + completionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read fabric list before setting label Error: %@", err); - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - { - id actualValue = value; - XCTAssertEqual([actualValue count], 1); - XCTAssertEqualObjects( - ((CHIPOperationalCredentialsClusterFabricDescriptor *) actualValue[0]).fabricIndex, ourFabricIndex); - XCTAssertTrue([((CHIPOperationalCredentialsClusterFabricDescriptor *) actualValue[0]).label isEqualToString:@""]); - } + { + id actualValue = value; + XCTAssertEqual([actualValue count], 1); + XCTAssertEqualObjects( + ((CHIPOperationalCredentialsClusterFabricDescriptor *) actualValue[0]).fabricIndex, + ourFabricIndex); + XCTAssertTrue([((CHIPOperationalCredentialsClusterFabricDescriptor *) actualValue[0]).label + isEqualToString:@""]); + } - [expectation fulfill]; - }]; + [expectation fulfill]; + }]; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } @@ -44437,22 +44466,26 @@ - (void)testSendClusterTestOperationalCredentialsCluster_000007_ReadAttribute queue:queue]; XCTAssertNotNil(cluster); - [cluster readAttributeFabricsWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read fabric list after setting label Error: %@", err); + CHIPReadParams * params = [[CHIPReadParams alloc] init]; + params.fabricFiltered = [NSNumber numberWithBool:true]; + [cluster readAttributeFabricsWithParams:params + completionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Read fabric list after setting label Error: %@", err); - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - { - id actualValue = value; - XCTAssertEqual([actualValue count], 1); - XCTAssertEqualObjects( - ((CHIPOperationalCredentialsClusterFabricDescriptor *) actualValue[0]).fabricIndex, ourFabricIndex); - XCTAssertTrue( - [((CHIPOperationalCredentialsClusterFabricDescriptor *) actualValue[0]).label isEqualToString:@"Batcave"]); - } + { + id actualValue = value; + XCTAssertEqual([actualValue count], 1); + XCTAssertEqualObjects( + ((CHIPOperationalCredentialsClusterFabricDescriptor *) actualValue[0]).fabricIndex, + ourFabricIndex); + XCTAssertTrue([((CHIPOperationalCredentialsClusterFabricDescriptor *) actualValue[0]).label + isEqualToString:@"Batcave"]); + } - [expectation fulfill]; - }]; + [expectation fulfill]; + }]; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; }