Skip to content

Commit c965cde

Browse files
Addressed comments by sharadb-amazon - 3nd review
1 parent 908203d commit c965cde

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

examples/tv-casting-app/tv-casting-common/core/CastingApp.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ CHIP_ERROR CastingApp::Start()
118118
});
119119
}
120120

121-
// Set a handler for Commissioner's CommissionerDeclaration messages.
122-
chip::Server::GetInstance().GetUserDirectedCommissioningClient()->SetCommissionerDeclarationHandler(
123-
CommissionerDeclarationHandler::GetInstance());
124-
125121
return CHIP_NO_ERROR;
126122
}
127123

@@ -144,6 +140,10 @@ CHIP_ERROR CastingApp::PostStartRegistrations()
144140
// Register DeviceEvent Handler
145141
ReturnErrorOnFailure(chip::DeviceLayer::PlatformMgrImpl().AddEventHandler(ChipDeviceEventHandler::Handle, 0));
146142

143+
// Set a handler for Commissioner's CommissionerDeclaration messages.
144+
chip::Server::GetInstance().GetUserDirectedCommissioningClient()->SetCommissionerDeclarationHandler(
145+
CommissionerDeclarationHandler::GetInstance());
146+
147147
mState = CASTING_APP_RUNNING; // CastingApp started successfully, set state to RUNNING
148148
return CHIP_NO_ERROR;
149149
}
@@ -153,13 +153,14 @@ CHIP_ERROR CastingApp::Stop()
153153
ChipLogProgress(Discovery, "CastingApp::Stop() called");
154154
VerifyOrReturnError(mState == CASTING_APP_RUNNING, CHIP_ERROR_INCORRECT_STATE);
155155

156+
// Remove the handler previously set for Commissioner's CommissionerDeclaration messages.
157+
chip::Server::GetInstance().GetUserDirectedCommissioningClient()->SetCommissionerDeclarationHandler(nullptr);
158+
156159
// Shutdown the Matter server
157160
chip::Server::GetInstance().Shutdown();
158161

159162
mState = CASTING_APP_NOT_RUNNING; // CastingApp stopped successfully, set state to NOT_RUNNING
160163

161-
chip::Server::GetInstance().GetUserDirectedCommissioningClient()->RemoveCommissionerDeclarationHandler();
162-
163164
return CHIP_NO_ERROR;
164165
}
165166

examples/tv-casting-app/tv-casting-common/core/CommissionerDeclarationHandler.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ namespace casting {
2525
namespace core {
2626

2727
/**
28-
* @brief React to the Commissioner's CommissionerDeclaration messages with this singleton. This is the common handler across Linux,
29-
* Android and iOS.
28+
* @brief React to the Commissioner's CommissionerDeclaration messages with this singleton.
3029
*/
3130
class CommissionerDeclarationHandler : public chip::Protocols::UserDirectedCommissioning::CommissionerDeclarationHandler
3231
{

src/protocols/user_directed_commissioning/UserDirectedCommissioning.h

-6
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,6 @@ class DLL_EXPORT UserDirectedCommissioningClient : public TransportMgrDelegate
538538
mCommissionerDeclarationHandler = commissionerDeclarationHandler;
539539
}
540540

541-
/**
542-
* Remove the previously set Commissioner Declaration UDC request listener.
543-
*
544-
*/
545-
void RemoveCommissionerDeclarationHandler() { mCommissionerDeclarationHandler = nullptr; }
546-
547541
private:
548542
void OnMessageReceived(const Transport::PeerAddress & source, System::PacketBufferHandle && msgBuf,
549543
Transport::MessageTransportContext * ctxt = nullptr) override;

0 commit comments

Comments
 (0)