Skip to content

Commit

Permalink
Switch Darwin subscription APIs to using NSNumber for min/max interva…
Browse files Browse the repository at this point in the history
…l. (#15007)
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Aug 25, 2023
1 parent cece84f commit 67efa7a
Show file tree
Hide file tree
Showing 7 changed files with 4,325 additions and 3,802 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ - (void)reportFromUserEnteredSettings
if (chipDevice) {
CHIPTemperatureMeasurement * cluster =
[[CHIPTemperatureMeasurement alloc] initWithDevice:chipDevice endpoint:1 queue:dispatch_get_main_queue()];
[cluster subscribeAttributeMeasuredValueWithMinInterval:minIntervalSeconds
maxInterval:maxIntervalSeconds
[cluster subscribeAttributeMeasuredValueWithMinInterval:@(minIntervalSeconds)
maxInterval:@(maxIntervalSeconds)
subscriptionEstablished:^{

}
Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ using namespace chip::app::Clusters;

{{/if}}
{{#if isReportableAttribute}}
- (void) subscribe{{>attribute}}WithMinInterval:(uint16_t)minInterval maxInterval:(uint16_t)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 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
Expand All @@ -136,7 +136,7 @@ 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<CHIPDefaultFailureCallbackType>::FromCancelable(failure);
return self.cppCluster.SubscribeAttribute<TypeInfo>(successFn->mContext, successFn->mCall, failureFn->mCall, minInterval, maxInterval, CHIP{{>attribute_data_callback_name}}CallbackSubscriptionBridge::OnSubscriptionEstablished);
return self.cppCluster.SubscribeAttribute<TypeInfo>(successFn->mContext, successFn->mCall, failureFn->mCall, [minInterval unsignedShortValue], [maxInterval unsignedShortValue], CHIP{{>attribute_data_callback_name}}CallbackSubscriptionBridge::OnSubscriptionEstablished);
}, subscriptionEstablishedHandler);
}

Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/templates/CHIPClustersObjc.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)write{{>attribute}}WithValue:({{asObjectiveCType type parent.name}})value completionHandler:(StatusCompletion)completionHandler;
{{/if}}
{{#if isReportableAttribute}}
- (void) subscribe{{>attribute}}WithMinInterval:(uint16_t)minInterval maxInterval:(uint16_t)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 subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))reportHandler;
{{/if}}
{{/chip_server_cluster_attributes}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ ResponseHandler {{> subscribeDataCallback}} = nil;
{{#chip_tests_item_parameters}}
{{asObjectiveCBasicType type}} {{asLowerCamelCase name}}Argument = {{asTypedLiteral definedValue type}};
{{/chip_tests_item_parameters}}
[cluster subscribeAttribute{{asUpperCamelCase attribute}}WithMinInterval:minIntervalArgument
maxInterval:maxIntervalArgument
[cluster subscribeAttribute{{asUpperCamelCase attribute}}WithMinInterval:@(minIntervalArgument)
maxInterval:@(maxIntervalArgument)
subscriptionEstablished:^{
XCTAssertEqual(testSendCluster{{parent.filename}}_{{asTestIndex waitForReport.index}}_{{asUpperCamelCase waitForReport.command}}_Fulfilled, true);
[expectation fulfill];
Expand Down
Loading

0 comments on commit 67efa7a

Please sign in to comment.