Skip to content

Commit

Permalink
[chip-tool] Allow setting the KeepSubscriptions flag (#16706)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored Apr 1, 2022
1 parent 1ded008 commit 37094b5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac
{
params.mMinIntervalFloorSeconds = minInterval;
params.mMaxIntervalCeilingSeconds = maxInterval;
if (mKeepSubscriptions.HasValue())
{
params.mKeepSubscriptions = mKeepSubscriptions.Value();
}
}

mReadClient = std::make_unique<chip::app::ReadClient>(chip::app::InteractionModelEngine::GetInstance(),
Expand Down Expand Up @@ -297,6 +301,10 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac
{
params.mMinIntervalFloorSeconds = minInterval;
params.mMaxIntervalCeilingSeconds = maxInterval;
if (mKeepSubscriptions.HasValue())
{
params.mKeepSubscriptions = mKeepSubscriptions.Value();
}
}

mReadClient = std::make_unique<chip::app::ReadClient>(chip::app::InteractionModelEngine::GetInstance(),
Expand All @@ -318,6 +326,9 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac
// up needing it in our class's shared code.
chip::Optional<bool> mFabricFiltered;

// mKeepSubscriptions is really only used by the subscribe commands, but we end
// up needing it in our class's shared code.
chip::Optional<bool> mKeepSubscriptions;
chip::Optional<chip::EventNumber> mEventNumber;

CHIP_ERROR mError = CHIP_NO_ERROR;
Expand Down Expand Up @@ -380,6 +391,7 @@ class SubscribeAttribute : public ReportCommand
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("data-version", 0, UINT32_MAX, &mDataVersion);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
ReportCommand::AddArguments();
}

Expand All @@ -391,6 +403,7 @@ class SubscribeAttribute : public ReportCommand
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("data-version", 0, UINT32_MAX, &mDataVersion);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
ReportCommand::AddArguments();
}

Expand All @@ -404,6 +417,7 @@ class SubscribeAttribute : public ReportCommand
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("data-version", 0, UINT32_MAX, &mDataVersion);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
ReportCommand::AddArguments();
}

Expand Down Expand Up @@ -495,6 +509,7 @@ class SubscribeEvent : public ReportCommand
AddArgument("event-id", 0, UINT32_MAX, &mEventIds);
AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval);
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("event-min", 0, UINT64_MAX, &mEventNumber);
ReportCommand::AddArguments();
}
Expand All @@ -505,6 +520,7 @@ class SubscribeEvent : public ReportCommand
AddArgument("event-id", 0, UINT32_MAX, &mEventIds);
AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval);
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("event-min", 0, UINT64_MAX, &mEventNumber);
ReportCommand::AddArguments();
}
Expand All @@ -517,6 +533,7 @@ class SubscribeEvent : public ReportCommand
AddArgument("attr-name", eventName);
AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval);
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("event-min", 0, UINT64_MAX, &mEventNumber);
ReportCommand::AddArguments();
}
Expand Down

0 comments on commit 37094b5

Please sign in to comment.