Skip to content

Commit

Permalink
[chip-tool] Ensure that the event subscription success is dispatched …
Browse files Browse the repository at this point in the history
…to SubscribeEvent (#17842)
  • Loading branch information
vivien-apple authored and pull[bot] committed Nov 16, 2023
1 parent 3091883 commit 1543788
Showing 1 changed file with 5 additions and 10 deletions.
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

0 comments on commit 1543788

Please sign in to comment.