-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 17211: TV Casting does not work on Mac (#17214)
* Fix MDns instance filter and iPK storage * Fix commissioning when BLE disabled * Add proper shell to tv-casting-app * Fix re-use of discovery controller * Add shell commands for launching content and printing bindings * Address comments * Address comments * Address comments * Address comments, formatting * fix resolve by service name * Restyled by clang-format (#17218) Co-authored-by: Restyled.io <[email protected]> * fix TIDY Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
Showing
10 changed files
with
330 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app/server/Dnssd.h> | ||
#include <app/server/Server.h> | ||
#include <lib/core/CHIPError.h> | ||
#include <lib/core/NodeId.h> | ||
|
||
CHIP_ERROR DiscoverCommissioners(); | ||
CHIP_ERROR RequestCommissioning(int index); | ||
void ReadServerClustersForNode(chip::NodeId nodeId); | ||
CHIP_ERROR ContentLauncherLaunchURL(const char * contentUrl, const char * contentDisplayStr); | ||
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT | ||
CHIP_ERROR SendUDC(chip::Transport::PeerAddress commissioner); | ||
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @file Contains shell commands for a ContentApp relating to Content App platform of the Video Player. | ||
*/ | ||
|
||
#include "CastingShellCommands.h" | ||
#include "Casting.h" | ||
#include <inttypes.h> | ||
#include <lib/core/CHIPCore.h> | ||
#include <lib/shell/Commands.h> | ||
#include <lib/shell/Engine.h> | ||
#include <lib/shell/commands/Help.h> | ||
#include <lib/support/CHIPArgParser.hpp> | ||
#include <lib/support/CHIPMem.h> | ||
#include <lib/support/CodeUtils.h> | ||
#include <platform/CHIPDeviceLayer.h> | ||
|
||
namespace chip { | ||
namespace Shell { | ||
|
||
static CHIP_ERROR PrintAllCommands() | ||
{ | ||
streamer_t * sout = streamer_get(); | ||
streamer_printf(sout, " help Usage: app <subcommand>\r\n"); | ||
streamer_printf(sout, " discover Discover commissioners. Usage: cast discover\r\n"); | ||
streamer_printf( | ||
sout, " request <index> Request commissioning from discovered commissioner with [index]. Usage: cast request 0\r\n"); | ||
streamer_printf(sout, " launch <url> <display> Launch content. Usage: cast launc https://www.yahoo.com Hello\r\n"); | ||
streamer_printf( | ||
sout, | ||
" access <node> Read and display clusters on each endpoint for <node>. Usage: cast access 0xFFFFFFEFFFFFFFFF\r\n"); | ||
streamer_printf(sout, " sendudc <address> <port> Send UDC message to address. Usage: cast sendudc ::1 5543\r\n"); | ||
streamer_printf(sout, "\r\n"); | ||
|
||
return CHIP_NO_ERROR; | ||
} | ||
|
||
static CHIP_ERROR CastingHandler(int argc, char ** argv) | ||
{ | ||
if (argc == 0 || strcmp(argv[0], "help") == 0) | ||
{ | ||
return PrintAllCommands(); | ||
} | ||
if (strcmp(argv[0], "discover") == 0) | ||
{ | ||
ChipLogProgress(DeviceLayer, "discover"); | ||
|
||
return DiscoverCommissioners(); | ||
} | ||
if (strcmp(argv[0], "request") == 0) | ||
{ | ||
ChipLogProgress(DeviceLayer, "request"); | ||
if (argc < 2) | ||
{ | ||
return PrintAllCommands(); | ||
} | ||
char * eptr; | ||
int index = (int) strtol(argv[1], &eptr, 10); | ||
return RequestCommissioning(index); | ||
} | ||
if (strcmp(argv[0], "launch") == 0) | ||
{ | ||
ChipLogProgress(DeviceLayer, "launch"); | ||
if (argc < 3) | ||
{ | ||
return PrintAllCommands(); | ||
} | ||
char * url = argv[1]; | ||
char * display = argv[2]; | ||
return ContentLauncherLaunchURL(url, display); | ||
} | ||
if (strcmp(argv[0], "access") == 0) | ||
{ | ||
ChipLogProgress(DeviceLayer, "access"); | ||
if (argc < 2) | ||
{ | ||
return PrintAllCommands(); | ||
} | ||
char * eptr; | ||
chip::NodeId node = (chip::NodeId) strtoull(argv[1], &eptr, 0); | ||
ReadServerClustersForNode(node); | ||
return CHIP_NO_ERROR; | ||
} | ||
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT | ||
if (strcmp(argv[0], "sendudc") == 0) | ||
{ | ||
char * eptr; | ||
chip::Inet::IPAddress commissioner; | ||
chip::Inet::IPAddress::FromString(argv[1], commissioner); | ||
uint16_t port = (uint16_t) strtol(argv[2], &eptr, 10); | ||
return SendUDC(chip::Transport::PeerAddress::UDP(commissioner, port)); | ||
} | ||
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT | ||
return CHIP_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
void RegisterCastingCommands() | ||
{ | ||
|
||
static const shell_command_t sDeviceComand = { &CastingHandler, "cast", "Casting commands. Usage: cast [command_name]" }; | ||
|
||
// Register the root `device` command with the top-level shell. | ||
Engine::Root().RegisterCommands(&sDeviceComand, 1); | ||
} | ||
|
||
} // namespace Shell | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @brief Contains shell commands for a Casting App. | ||
*/ | ||
|
||
#include <platform/CHIPDeviceLayer.h> | ||
|
||
namespace chip { | ||
namespace Shell { | ||
|
||
void RegisterCastingCommands(); | ||
|
||
} // namespace Shell | ||
} // namespace chip |
Oops, something went wrong.