Skip to content

Commit

Permalink
Fix command line support in linux tv-casting-app (#24215)
Browse files Browse the repository at this point in the history
* Fix command line support in linux tv-casting-app

* Address comments

---------

Co-authored-by: Christopher DeCenzo <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jan 16, 2024
1 parent 61c225c commit 8221028
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/tv-casting-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ int main(int argc, char * argv[])
VerifyOrDie(CHIP_NO_ERROR == initParams.InitializeStaticResourcesBeforeServerInit());
VerifyOrDie(CHIP_NO_ERROR == chip::Server::GetInstance().Init(initParams));

if (ConnectToCachedVideoPlayer() == CHIP_NO_ERROR)
if (argc > 1)
{
ChipLogProgress(AppServer, "Command line parameters detected. Skipping auto-start.");
}
else if (ConnectToCachedVideoPlayer() == CHIP_NO_ERROR)
{
ChipLogProgress(AppServer, "Skipping commissioner discovery / User directed commissioning flow.");
}
Expand Down
16 changes: 16 additions & 0 deletions examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ CastingServer::GetDiscoveredCommissioner(int index, chip::Optional<TargetVideoPl
void CastingServer::ReadServerClustersForNode(NodeId nodeId)
{
ChipLogProgress(NotSpecified, "ReadServerClustersForNode nodeId=0x" ChipLogFormatX64, ChipLogValueX64(nodeId));
CHIP_ERROR err = Init();
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Init error: %" CHIP_ERROR_FORMAT, err.Format());
}

for (const auto & binding : BindingTable::GetInstance())
{
ChipLogProgress(NotSpecified,
Expand Down Expand Up @@ -471,6 +477,11 @@ void CastingServer::DeviceEventCallback(const DeviceLayer::ChipDeviceEvent * eve
// given a fabric index, try to determine the video-player nodeId by searching the binding table
NodeId CastingServer::GetVideoPlayerNodeForFabricIndex(FabricIndex fabricIndex)
{
CHIP_ERROR err = Init();
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "GetVideoPlayerNodeForFabricIndex Init error: %" CHIP_ERROR_FORMAT, err.Format());
}
for (const auto & binding : BindingTable::GetInstance())
{
ChipLogProgress(NotSpecified,
Expand All @@ -492,6 +503,11 @@ NodeId CastingServer::GetVideoPlayerNodeForFabricIndex(FabricIndex fabricIndex)
// given a nodeId, try to determine the video-player fabric index by searching the binding table
FabricIndex CastingServer::GetVideoPlayerFabricIndexForNode(NodeId nodeId)
{
CHIP_ERROR err = Init();
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "GetVideoPlayerFabricIndexForNode Init error: %" CHIP_ERROR_FORMAT, err.Format());
}
for (const auto & binding : BindingTable::GetInstance())
{
ChipLogProgress(NotSpecified,
Expand Down

0 comments on commit 8221028

Please sign in to comment.