Skip to content

Commit

Permalink
Addressed comments by sharadb-amazon - 3nd review
Browse files Browse the repository at this point in the history
  • Loading branch information
pgregorr-amazon committed May 7, 2024
1 parent 908203d commit c965cde
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
13 changes: 7 additions & 6 deletions examples/tv-casting-app/tv-casting-common/core/CastingApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c965cde

Please sign in to comment.