From c965cde9b9b53b67e599648028dcf027069c33ef Mon Sep 17 00:00:00 2001 From: Philip Gregor Date: Tue, 7 May 2024 09:32:21 -0700 Subject: [PATCH] Addressed comments by sharadb-amazon - 3nd review --- .../tv-casting-common/core/CastingApp.cpp | 13 +++++++------ .../core/CommissionerDeclarationHandler.h | 3 +-- .../UserDirectedCommissioning.h | 6 ------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingApp.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingApp.cpp index 3f0aabc2b0ec87..a8199d496a0cde 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingApp.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingApp.cpp @@ -118,10 +118,6 @@ CHIP_ERROR CastingApp::Start() }); } - // Set a handler for Commissioner's CommissionerDeclaration messages. - chip::Server::GetInstance().GetUserDirectedCommissioningClient()->SetCommissionerDeclarationHandler( - CommissionerDeclarationHandler::GetInstance()); - return CHIP_NO_ERROR; } @@ -144,6 +140,10 @@ CHIP_ERROR CastingApp::PostStartRegistrations() // Register DeviceEvent Handler ReturnErrorOnFailure(chip::DeviceLayer::PlatformMgrImpl().AddEventHandler(ChipDeviceEventHandler::Handle, 0)); + // Set a handler for Commissioner's CommissionerDeclaration messages. + chip::Server::GetInstance().GetUserDirectedCommissioningClient()->SetCommissionerDeclarationHandler( + CommissionerDeclarationHandler::GetInstance()); + mState = CASTING_APP_RUNNING; // CastingApp started successfully, set state to RUNNING return CHIP_NO_ERROR; } @@ -153,13 +153,14 @@ CHIP_ERROR CastingApp::Stop() ChipLogProgress(Discovery, "CastingApp::Stop() called"); VerifyOrReturnError(mState == CASTING_APP_RUNNING, CHIP_ERROR_INCORRECT_STATE); + // Remove the handler previously set for Commissioner's CommissionerDeclaration messages. + chip::Server::GetInstance().GetUserDirectedCommissioningClient()->SetCommissionerDeclarationHandler(nullptr); + // Shutdown the Matter server chip::Server::GetInstance().Shutdown(); mState = CASTING_APP_NOT_RUNNING; // CastingApp stopped successfully, set state to NOT_RUNNING - chip::Server::GetInstance().GetUserDirectedCommissioningClient()->RemoveCommissionerDeclarationHandler(); - return CHIP_NO_ERROR; } diff --git a/examples/tv-casting-app/tv-casting-common/core/CommissionerDeclarationHandler.h b/examples/tv-casting-app/tv-casting-common/core/CommissionerDeclarationHandler.h index 445b1d6667c7cf..e84ca59a59e23d 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CommissionerDeclarationHandler.h +++ b/examples/tv-casting-app/tv-casting-common/core/CommissionerDeclarationHandler.h @@ -25,8 +25,7 @@ namespace casting { namespace core { /** - * @brief React to the Commissioner's CommissionerDeclaration messages with this singleton. This is the common handler across Linux, - * Android and iOS. + * @brief React to the Commissioner's CommissionerDeclaration messages with this singleton. */ class CommissionerDeclarationHandler : public chip::Protocols::UserDirectedCommissioning::CommissionerDeclarationHandler { diff --git a/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h b/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h index 2e381662404447..7a496e5a2f0a33 100644 --- a/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h +++ b/src/protocols/user_directed_commissioning/UserDirectedCommissioning.h @@ -538,12 +538,6 @@ class DLL_EXPORT UserDirectedCommissioningClient : public TransportMgrDelegate mCommissionerDeclarationHandler = commissionerDeclarationHandler; } - /** - * Remove the previously set Commissioner Declaration UDC request listener. - * - */ - void RemoveCommissionerDeclarationHandler() { mCommissionerDeclarationHandler = nullptr; } - private: void OnMessageReceived(const Transport::PeerAddress & source, System::PacketBufferHandle && msgBuf, Transport::MessageTransportContext * ctxt = nullptr) override;