Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove wait option for subscribe in darwin-framework-tool #21001

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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