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

[chip-tool] Ensure that the event subscription success is dispatched … #17842

Merged
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
15 changes: 5 additions & 10 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac
ModelCommand(commandName, credsIssuerConfig), mBufferedReadAdapter(*this)
{}

virtual void OnAttributeSubscription(){};
virtual void OnEventSubscription(){};
virtual void OnSubscription(){};

/////////// ReadClient Callback Interface /////////
void OnAttributeData(const chip::app::ConcreteDataAttributePath & path, chip::TLV::TLVReader * data,
Expand Down Expand Up @@ -105,7 +104,7 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac
SetCommandExitStatus(mError);
}

void OnSubscriptionEstablished(uint64_t subscriptionId) override { OnAttributeSubscription(); }
void OnSubscriptionEstablished(uint64_t subscriptionId) override { OnSubscription(); }

protected:
CHIP_ERROR ReportAttribute(ChipDevice * device, std::vector<chip::EndpointId> endpointIds,
Expand Down Expand Up @@ -431,11 +430,9 @@ class SubscribeAttribute : public ReportCommand
mDataVersion);
}

chip::System::Clock::Timeout GetWaitDuration() const override { return ReportCommand::GetWaitDuration(); }

void OnAttributeSubscription() override
void OnSubscription() override
{
// The ReadClient instance can not be released directly into the OnAttributeSubscription
// The ReadClient instance can not be released directly into the OnSubscription
// callback since it happens to be called by ReadClient itself which is doing additional
// work after that.
chip::DeviceLayer::PlatformMgr().ScheduleWork(
Expand Down Expand Up @@ -547,9 +544,7 @@ class SubscribeEvent : public ReportCommand
chip::app::ReadClient::InteractionType::Subscribe, mMinInterval, mMaxInterval);
}

chip::System::Clock::Timeout GetWaitDuration() const override { return ReportCommand::GetWaitDuration(); }

void OnEventSubscription() override
void OnSubscription() override
{
// The ReadClient instance can not be released directly into the OnEventSubscription
// callback since it happens to be called by ReadClient itself which is doing additional
Expand Down