diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java index 38616434cc6a03..3e0ea69d8d82ec 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java @@ -58,7 +58,8 @@ public class ConnectionExampleFragment extends Fragment { private TextView connectionFragmentStatusTextView; private Button connectionFragmentNextButton; - // Get a singleton instance of the MatterCastingPlayerDiscovery. Which can be used to call stopDiscovery() during connection. + // Get a singleton instance of the MatterCastingPlayerDiscovery. Which can be used to call + // stopDiscovery() during connection. static final CastingPlayerDiscovery matterCastingPlayerDiscovery = MatterCastingPlayerDiscovery.getInstance(); @@ -369,15 +370,20 @@ public void onClick(DialogInterface dialog, int which) { } private void stopDiscovery() { - Log.i(TAG, "ConnectionExampleFragment stopDiscovery() called, calling MatterCastingPlayerDiscovery.stopDiscovery()"); + Log.i( + TAG, + "ConnectionExampleFragment stopDiscovery() called, calling MatterCastingPlayerDiscovery.stopDiscovery()"); MatterError err = matterCastingPlayerDiscovery.stopDiscovery(); if (err.hasError()) { Log.e( TAG, - "ConnectionExampleFragment stopDiscovery() MatterCastingPlayerDiscovery.stopDiscovery() called, err Stop: " + err); + "ConnectionExampleFragment stopDiscovery() MatterCastingPlayerDiscovery.stopDiscovery() called, err Stop: " + + err); } else { - Log.d(TAG, "ConnectionExampleFragment stopDiscovery() MatterCastingPlayerDiscovery.stopDiscovery() success"); + Log.d( + TAG, + "ConnectionExampleFragment stopDiscovery() MatterCastingPlayerDiscovery.stopDiscovery() success"); } } diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java index 3bb791375f8bfe..64130fa94cfe7b 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java @@ -67,7 +67,8 @@ public class DiscoveryExampleFragment extends Fragment { public void onAdded(CastingPlayer castingPlayer) { Log.i( TAG, - "DiscoveryExampleFragment onAdded() Discovered CastingPlayer deviceId: " + castingPlayer.getDeviceId()); + "DiscoveryExampleFragment onAdded() Discovered CastingPlayer deviceId: " + + castingPlayer.getDeviceId()); // Display CastingPlayer info on the screen new Handler(Looper.getMainLooper()) .post( @@ -216,7 +217,8 @@ public void onResume() { public void onPause() { super.onPause(); Log.i(TAG, "DiscoveryExampleFragment onPause() called, calling stopDiscovery()"); - // Stop discovery when leaving the fragment, for example, while displaying the ConnectionExampleFragment. + // Stop discovery when leaving the fragment, for example, while displaying the + // ConnectionExampleFragment. stopDiscovery(); } diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp index 4bddbd87422b81..e02e6e7c6946c9 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp @@ -122,7 +122,8 @@ void CastingPlayer::VerifyOrEstablishConnection(ConnectionCallbacks connectionCa nullptr, [](void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) { ChipLogProgress(AppServer, - "CastingPlayer::VerifyOrEstablishConnection() FindOrEstablishSession Connection to CastingPlayer successful"); + "CastingPlayer::VerifyOrEstablishConnection() FindOrEstablishSession Connection to " + "CastingPlayer successful"); CastingPlayer::GetTargetCastingPlayer()->mConnectionState = CASTING_PLAYER_CONNECTED; // this async call will Load all the endpoints with their respective attributes into the TargetCastingPlayer @@ -131,7 +132,9 @@ void CastingPlayer::VerifyOrEstablishConnection(ConnectionCallbacks connectionCa support::EndpointListLoader::GetInstance()->Load(); }, [](void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) { - ChipLogError(AppServer, "CastingPlayer::VerifyOrEstablishConnection() FindOrEstablishSession Connection to CastingPlayer failed"); + ChipLogError(AppServer, + "CastingPlayer::VerifyOrEstablishConnection() FindOrEstablishSession Connection to " + "CastingPlayer failed"); CastingPlayer::GetTargetCastingPlayer()->mConnectionState = CASTING_PLAYER_NOT_CONNECTED; CHIP_ERROR e = support::CastingStore::GetInstance()->Delete(*CastingPlayer::GetTargetCastingPlayer()); if (e != CHIP_NO_ERROR) @@ -197,7 +200,7 @@ CHIP_ERROR CastingPlayer::ContinueConnecting() "CastingPlayer::ContinueConnecting() mIdOptions.mCommissionerPasscode == false, ContinueConnecting() should " "only be called when the CastingPlayer/Commissioner-Generated passcode commissioning flow is in progress.");); - CHIP_ERROR err = CHIP_NO_ERROR; + CHIP_ERROR err = CHIP_NO_ERROR; mTargetCastingPlayer = weak_from_this(); ChipLogProgress(AppServer, "CastingPlayer::ContinueConnecting() calling OpenBasicCommissioningWindow()"); @@ -288,7 +291,7 @@ void CastingPlayer::resetState(CHIP_ERROR err) void CastingPlayer::Disconnect() { ChipLogProgress(AppServer, "CastingPlayer::Disconnect()"); - mConnectionState = CASTING_PLAYER_NOT_CONNECTED; + mConnectionState = CASTING_PLAYER_NOT_CONNECTED; mTargetCastingPlayer.reset(); CastingPlayerDiscovery::GetInstance()->ClearCastingPlayersInternal(); } @@ -487,10 +490,14 @@ ConnectionContext::ConnectionContext(void * clientContext, core::CastingPlayer * [](void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) { ChipLogProgress(AppServer, "CastingPlayer::ConnectionContext() Device Connection success callback called"); ConnectionContext * connectionContext = static_cast(context); - VerifyOrReturn(connectionContext != nullptr && connectionContext->mTargetCastingPlayer != nullptr, - ChipLogError(AppServer, "CastingPlayer::ConnectionContext() Invalid ConnectionContext received in DeviceConnection success callback")); + VerifyOrReturn( + connectionContext != nullptr && connectionContext->mTargetCastingPlayer != nullptr, + ChipLogError( + AppServer, + "CastingPlayer::ConnectionContext() Invalid ConnectionContext received in DeviceConnection success callback")); - ChipLogProgress(AppServer, "CastingPlayer::ConnectionContext() calling mConnectionState = core::CASTING_PLAYER_CONNECTED"); + ChipLogProgress(AppServer, + "CastingPlayer::ConnectionContext() calling mConnectionState = core::CASTING_PLAYER_CONNECTED"); connectionContext->mTargetCastingPlayer->mConnectionState = core::CASTING_PLAYER_CONNECTED; ChipLogProgress(AppServer, "CastingPlayer::ConnectionContext() calling mOnDeviceConnectedFn"); connectionContext->mOnDeviceConnectedFn(connectionContext->mClientContext, exchangeMgr, sessionHandle); @@ -501,10 +508,15 @@ ConnectionContext::ConnectionContext(void * clientContext, core::CastingPlayer * mOnConnectionFailureCallback = new chip::Callback::Callback( [](void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) { - ChipLogError(AppServer, "CastingPlayer::ConnectionContext() Device Connection failure callback called with %" CHIP_ERROR_FORMAT, error.Format()); + ChipLogError(AppServer, + "CastingPlayer::ConnectionContext() Device Connection failure callback called with %" CHIP_ERROR_FORMAT, + error.Format()); ConnectionContext * connectionContext = static_cast(context); - VerifyOrReturn(connectionContext != nullptr && connectionContext->mTargetCastingPlayer != nullptr, - ChipLogError(AppServer, "CastingPlayer::ConnectionContext() Invalid ConnectionContext received in DeviceConnection failure callback")); + VerifyOrReturn( + connectionContext != nullptr && connectionContext->mTargetCastingPlayer != nullptr, + ChipLogError( + AppServer, + "CastingPlayer::ConnectionContext() Invalid ConnectionContext received in DeviceConnection failure callback")); connectionContext->mTargetCastingPlayer->mConnectionState = CASTING_PLAYER_NOT_CONNECTED; connectionContext->mOnDeviceConnectionFailureFn(connectionContext->mClientContext, peerId, error); delete connectionContext; diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h index d4d5ae0d4232b0..4fcb1ea5ca60da 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h @@ -100,16 +100,25 @@ class CastingPlayer : public std::enable_shared_from_this /** * @brief Get the CastingPlayer object targeted currently (may not be connected) */ - static CastingPlayer * GetTargetCastingPlayer() { + static CastingPlayer * GetTargetCastingPlayer() + { ChipLogProgress(AppServer, "CastingPlayer::GetTargetCastingPlayer() called"); std::shared_ptr sharedPtr = mTargetCastingPlayer.lock(); - CastingPlayer* rawPtr = nullptr; - if (sharedPtr) { + CastingPlayer * rawPtr = nullptr; + if (sharedPtr) + { rawPtr = sharedPtr.get(); - ChipLogProgress(AppServer, "CastingPlayer::GetTargetCastingPlayer() Got rawPtr from mTargetCastingPlayer, sharedPtr reference count: %lu", sharedPtr.use_count()); + ChipLogProgress( + AppServer, + "CastingPlayer::GetTargetCastingPlayer() Got rawPtr from mTargetCastingPlayer, sharedPtr reference count: %lu", + sharedPtr.use_count()); sharedPtr.reset(); - } else { - ChipLogError(AppServer, "CastingPlayer::GetTargetCastingPlayer() The shared pointer observed by mTargetCastingPlayer has expired (become nullptr)"); + } + else + { + ChipLogError(AppServer, + "CastingPlayer::GetTargetCastingPlayer() The shared pointer observed by mTargetCastingPlayer has expired " + "(become nullptr)"); } return rawPtr; } @@ -272,9 +281,7 @@ class CastingPlayer : public std::enable_shared_from_this /** * @brief Return the current state of the CastingPlayer */ - ConnectionState GetConnectionState() const { - return mConnectionState; - } + ConnectionState GetConnectionState() const { return mConnectionState; } private: std::vector> mEndpoints; diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp index 4be75dfd6f8cc3..34018a06f90886 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp @@ -63,13 +63,14 @@ CHIP_ERROR CastingPlayerDiscovery::StartDiscovery(uint32_t deviceTypeFilter) CHIP_ERROR CastingPlayerDiscovery::StopDiscovery() { - ChipLogProgress(Discovery, "CastingPlayerDiscovery::StopDiscovery() mCastingPlayers: %lu, mCastingPlayersInternal: %lu", mCastingPlayers.size(), mCastingPlayersInternal.size()); + ChipLogProgress(Discovery, "CastingPlayerDiscovery::StopDiscovery() mCastingPlayers: %lu, mCastingPlayersInternal: %lu", + mCastingPlayers.size(), mCastingPlayersInternal.size()); VerifyOrReturnError(mState == DISCOVERY_RUNNING, CHIP_ERROR_INCORRECT_STATE); ReturnErrorOnFailure(mCommissionableNodeController.StopDiscovery()); // Clear mCastingPlayersInternal of disconnected CastingPlayers ClearDisconnectedCastingPlayersInternal(); - for (const auto& player : mCastingPlayers) + for (const auto & player : mCastingPlayers) { mCastingPlayersInternal.push_back(player); } @@ -82,21 +83,24 @@ CHIP_ERROR CastingPlayerDiscovery::StopDiscovery() void CastingPlayerDiscovery::ClearDisconnectedCastingPlayersInternal() { - ChipLogProgress(Discovery, "CastingPlayerDiscovery::ClearDisconnectedCastingPlayersInternal() mCastingPlayersInternal: %lu", mCastingPlayersInternal.size()); + ChipLogProgress(Discovery, "CastingPlayerDiscovery::ClearDisconnectedCastingPlayersInternal() mCastingPlayersInternal: %lu", + mCastingPlayersInternal.size()); // Only clear the CastingPlayers in mCastingPlayersInternal with ConnectionState == CASTING_PLAYER_NOT_CONNECTED ClearDisconnectedCastingPlayers(mCastingPlayersInternal); } -void CastingPlayerDiscovery::ClearDisconnectedCastingPlayers(std::vector>& castingPlayers) +void CastingPlayerDiscovery::ClearDisconnectedCastingPlayers(std::vector> & castingPlayers) { ChipLogProgress(Discovery, "CastingPlayerDiscovery::ClearDisconnectedCastingPlayers() called"); for (auto it = castingPlayers.begin(); it != castingPlayers.end();) { - auto& player = *it; + auto & player = *it; if (player->GetConnectionState() == CASTING_PLAYER_NOT_CONNECTED) { - ChipLogProgress(Discovery, "CastingPlayerDiscovery::ClearDisconnectedCastingPlayers() Removing disconnected CastingPlayer: %s with reference count: %lu", - player->GetDeviceName(), player.use_count()); + ChipLogProgress(Discovery, + "CastingPlayerDiscovery::ClearDisconnectedCastingPlayers() Removing disconnected CastingPlayer: %s " + "with reference count: %lu", + player->GetDeviceName(), player.use_count()); it = castingPlayers.erase(it); } else diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.h b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.h index 773939b7fe61ac..a4e349de190b07 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.h +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.h @@ -104,7 +104,7 @@ class CastingPlayerDiscovery * * @param castingPlayers vector of CastingPlayers to clear */ - void ClearDisconnectedCastingPlayers(std::vector>& castingPlayers); + void ClearDisconnectedCastingPlayers(std::vector> & castingPlayers); /** * @brief Clear all CastingPlayers in mCastingPlayersInternal @@ -113,7 +113,8 @@ class CastingPlayerDiscovery public: static CastingPlayerDiscovery * GetInstance(); - ~CastingPlayerDiscovery() { + ~CastingPlayerDiscovery() + { mCastingPlayers.clear(); mCastingPlayersInternal.clear(); } diff --git a/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp b/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp index c719b3b8b51383..2e8561d2e5aab1 100644 --- a/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp +++ b/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp @@ -40,7 +40,8 @@ CastingStore * CastingStore::GetInstance() CHIP_ERROR CastingStore::AddOrUpdate(core::CastingPlayer castingPlayer) { - ChipLogProgress(AppServer, "CastingStore::AddOrUpdate() called with CastingPlayer deviceName: %s", castingPlayer.GetDeviceName()); + ChipLogProgress(AppServer, "CastingStore::AddOrUpdate() called with CastingPlayer deviceName: %s", + castingPlayer.GetDeviceName()); // Read cache of CastingPlayers std::vector castingPlayers = ReadAll(); @@ -445,7 +446,8 @@ std::vector CastingStore::ReadAll() VerifyOrReturnValue(err == CHIP_NO_ERROR, std::vector(), ChipLogError(AppServer, "TLVReader.ExitContainer failed %" CHIP_ERROR_FORMAT, err.Format())); - ChipLogProgress(AppServer, "CastingStore::ReadAll() CastingPlayers size: %lu", static_cast(castingPlayers.size())); + ChipLogProgress(AppServer, "CastingStore::ReadAll() CastingPlayers size: %lu", + static_cast(castingPlayers.size())); return castingPlayers; } diff --git a/examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp b/examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp index 30746436256da9..cf8ca82366a7bb 100644 --- a/examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp +++ b/examples/tv-casting-app/tv-casting-common/support/ChipDeviceEventHandler.cpp @@ -100,7 +100,7 @@ void ChipDeviceEventHandler::HandleFailSafeTimerExpired() sUdcInProgress = false; CastingPlayer::GetTargetCastingPlayer()->mConnectionState = CASTING_PLAYER_NOT_CONNECTED; CastingPlayer::GetTargetCastingPlayer()->mOnCompleted(CHIP_ERROR_TIMEOUT, nullptr); - CastingPlayer::GetTargetCastingPlayer()->mOnCompleted = nullptr; + CastingPlayer::GetTargetCastingPlayer()->mOnCompleted = nullptr; CastingPlayer::GetTargetCastingPlayer()->mTargetCastingPlayer.reset(); return; }