@@ -58,6 +58,9 @@ void CastingPlayer::VerifyOrEstablishConnection(ConnectionCallbacks connectionCa
5858 mIdOptions = idOptions;
5959 castingPlayerDiscovery->ClearDisconnectedCastingPlayersInternal ();
6060
61+ // Set CastingPlayer as AppDelegate
62+ chip::Server::GetInstance ().GetCommissioningWindowManager ().SetAppDelegate (this );
63+
6164 // Register the handler for Commissioner's CommissionerDeclaration messages. The CommissionerDeclaration messages provide
6265 // information indicating the Commissioner's pre-commissioning state.
6366 if (connectionCallbacks.mCommissionerDeclarationCallback != nullptr )
@@ -329,6 +332,10 @@ void CastingPlayer::resetState(CHIP_ERROR err)
329332 support::ChipDeviceEventHandler::SetUdcStatus (false );
330333 mConnectionState = CASTING_PLAYER_NOT_CONNECTED;
331334 mCommissioningWindowTimeoutSec = kCommissioningWindowTimeoutSec ;
335+
336+ // Unregister from CommissioningWindowManager when unsetting mTargetCastingPlayer
337+ chip::Server::GetInstance ().GetCommissioningWindowManager ().SetAppDelegate (nullptr );
338+
332339 mTargetCastingPlayer .reset ();
333340 if (mOnCompleted )
334341 {
@@ -342,6 +349,10 @@ void CastingPlayer::Disconnect()
342349{
343350 ChipLogProgress (AppServer, " CastingPlayer::Disconnect()" );
344351 mConnectionState = CASTING_PLAYER_NOT_CONNECTED;
352+
353+ // Unregister from CommissioningWindowManager when unsetting mTargetCastingPlayer
354+ chip::Server::GetInstance ().GetCommissioningWindowManager ().SetAppDelegate (nullptr );
355+
345356 mTargetCastingPlayer .reset ();
346357 CastingPlayerDiscovery::GetInstance ()->ClearCastingPlayersInternal ();
347358}
@@ -604,6 +615,46 @@ ConnectionContext::~ConnectionContext()
604615 }
605616}
606617
618+ // AppDelegate implementation
619+ void CastingPlayer::OnCommissioningSessionEstablishmentStarted ()
620+ {
621+ ChipLogProgress (AppServer, " CastingPlayer::OnCommissioningSessionEstablishmentStarted()" );
622+ }
623+
624+ void CastingPlayer::OnCommissioningSessionStarted ()
625+ {
626+ ChipLogProgress (AppServer, " CastingPlayer::OnCommissioningSessionStarted()" );
627+ }
628+
629+ void CastingPlayer::OnCommissioningSessionEstablishmentError (CHIP_ERROR err)
630+ {
631+ ChipLogProgress (AppServer, " CastingPlayer::OnCommissioningSessionEstablishmentError() err: %" CHIP_ERROR_FORMAT, err.Format ());
632+ if (mOnCompleted != nullptr )
633+ {
634+ // err = 0x38 = CHIP_ERROR_INVALID_PASE_PARAMETER upon bad passcode
635+ mOnCompleted (err, nullptr );
636+ }
637+ }
638+
639+ void CastingPlayer::OnCommissioningSessionStopped ()
640+ {
641+ ChipLogProgress (AppServer, " CastingPlayer::OnCommissioningSessionStopped()" );
642+ if (mOnCompleted != nullptr )
643+ {
644+ mOnCompleted (CHIP_ERROR_CANCELLED, nullptr );
645+ }
646+ }
647+
648+ void CastingPlayer::OnCommissioningWindowOpened ()
649+ {
650+ ChipLogProgress (AppServer, " CastingPlayer::OnCommissioningWindowOpened()" );
651+ }
652+
653+ void CastingPlayer::OnCommissioningWindowClosed ()
654+ {
655+ ChipLogProgress (AppServer, " CastingPlayer::OnCommissioningWindowClosed()" );
656+ }
657+
607658}; // namespace core
608659}; // namespace casting
609660}; // namespace matter
0 commit comments