Skip to content

Commit

Permalink
Remove wait option for subscribe in darwin-framework-tool (#21001)
Browse files Browse the repository at this point in the history
* Remove wait option from darwin-framework-tool

* Generated code
  • Loading branch information
krypton36 authored Jul 20, 2022
1 parent 6d693f7 commit 0c8cbf5
Show file tree
Hide file tree
Showing 3 changed files with 1,093 additions and 3,287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class SubscribeAttribute : public ModelCommand {
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("wait", 0, 1, &mWait);
ModelCommand::AddArguments();
}

Expand All @@ -107,7 +106,6 @@ class SubscribeAttribute : public ModelCommand {
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("wait", 0, 1, &mWait);
ModelCommand::AddArguments();
}

Expand All @@ -119,7 +117,6 @@ class SubscribeAttribute : public ModelCommand {
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("wait", 0, 1, &mWait);
ModelCommand::AddArguments();
}

Expand All @@ -144,9 +141,7 @@ class SubscribeAttribute : public ModelCommand {
NSLog(@"Response Item: %@", [item description]);
}
}
if (error || !mWait) {
SetCommandExitStatus(error);
}
SetCommandExitStatus(error);
}
subscriptionEstablished:^() {
mSubscriptionEstablished = YES;
Expand All @@ -155,18 +150,14 @@ class SubscribeAttribute : public ModelCommand {
return CHIP_NO_ERROR;
}

chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10);
}
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); }

protected:
chip::Optional<bool> mKeepSubscriptions;
chip::Optional<bool> mFabricFiltered;
bool mSubscriptionEstablished = NO;
uint16_t mMinInterval;
uint16_t mMaxInterval;
bool mWait;

void Shutdown() override
{
Expand All @@ -189,7 +180,6 @@ class SubscribeEvent : public ModelCommand {
AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval);
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("wait", 0, 1, &mWait);
ModelCommand::AddArguments();
}

Expand All @@ -208,22 +198,16 @@ class SubscribeEvent : public ModelCommand {
params:params
cacheContainer:nil
attributeReportHandler:^(NSArray * value) {
if (!mWait) {
SetCommandExitStatus(CHIP_NO_ERROR);
}
SetCommandExitStatus(CHIP_NO_ERROR);
}
eventReportHandler:^(NSArray * value) {
for (id item in value) {
NSLog(@"Response Item: %@", [item description]);
}
if (!mWait) {
SetCommandExitStatus(CHIP_NO_ERROR);
}
SetCommandExitStatus(CHIP_NO_ERROR);
}
errorHandler:^(NSError * error) {
if (error && !mWait) {
SetCommandExitStatus(error);
}
SetCommandExitStatus(error);
}
subscriptionEstablished:^() {
mSubscriptionEstablished = YES;
Expand All @@ -232,16 +216,12 @@ class SubscribeEvent : public ModelCommand {
return CHIP_NO_ERROR;
}

chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10);
}
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); }

protected:
chip::Optional<bool> mKeepSubscriptions;
chip::Optional<chip::EventNumber> mEventNumber;
bool mSubscriptionEstablished = NO;
uint16_t mMinInterval;
uint16_t mMaxInterval;
bool mWait;
};
4 changes: 1 addition & 3 deletions examples/darwin-framework-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ public:
subscriptionEstablished:^(){ mSubscriptionEstablished=YES; }
reportHandler:^({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error) {
NSLog(@"{{asUpperCamelCase parent.name}}.{{asUpperCamelCase name}} response %@", [value description]);
if (error || !mWait){
SetCommandExitStatus(error);
}
SetCommandExitStatus(error);
}];

return CHIP_NO_ERROR;
Expand Down
Loading

0 comments on commit 0c8cbf5

Please sign in to comment.