From 3851064c6511cde1a656f6372ca6ff4416fc4cd4 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Fri, 29 Apr 2022 04:03:48 +0200 Subject: [PATCH] [chip-tool] Ensure that the event subscription success is dispatched to SubscribeEvent (#17842) --- .../chip-tool/commands/clusters/ReportCommand.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index dbe4e60174e231..5a3a3307020604 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -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, @@ -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 endpointIds, @@ -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( @@ -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