Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing CLI tv-casting-app for Linux #8824

Merged
merged 9 commits into from
Aug 24, 2021
15 changes: 15 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
enable_linux_tv_app_build =
enable_default_builds && (host_os == "linux" || host_os == "mac")

# Build the Linux tv casting app example.
enable_linux_tv_casting_app_build =
enable_default_builds && (host_os == "linux" || host_os == "mac")

# Build the Linux bridge app example.
enable_linux_bridge_app_build =
enable_default_builds && (host_os == "linux" || host_os == "mac")
Expand Down Expand Up @@ -366,6 +370,14 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
}
}

if (enable_linux_tv_casting_app_build) {
group("linux_tv_casting_app") {
deps = [
"${chip_root}/examples/tv-casting-app/linux(${standalone_toolchain})",
]
}
}

if (enable_linux_bridge_app_build) {
group("linux_bridge_app") {
deps =
Expand Down Expand Up @@ -469,6 +481,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
if (enable_linux_tv_app_build) {
deps += [ ":linux_tv_app" ]
}
if (enable_linux_tv_casting_app_build) {
deps += [ ":linux_tv_casting_app" ]
}
if (enable_linux_bridge_app_build) {
deps += [ ":linux_bridge_app" ]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,45 +34,12 @@ void DiscoverCommissionersCommand::Shutdown()
const Mdns::DiscoveredNodeData * commissioner = mCommissionableNodeController.GetDiscoveredCommissioner(i);
if (commissioner != nullptr)
{
printf("Discovered Commisioner #%d\n", ++commissionerCount);
if (strcmp(commissioner->deviceName, "") != 0)
{
printf("Device Name: %s\n", commissioner->deviceName);
}
if (commissioner->vendorId > 0)
{
printf("Vendor ID: %d\n", commissioner->vendorId);
}
if (commissioner->productId > 0)
{
printf("Product ID: %d\n", commissioner->productId);
}
if (commissioner->deviceType > 0)
{
printf("Device Type: %d\n", commissioner->deviceType);
}
if (commissioner->longDiscriminator > 0)
{
printf("Long Discriminator: %d\n", commissioner->longDiscriminator);
}
if (!commissioner->IsHost(""))
{
printf("Hostname: %s\n", commissioner->hostName);
}
if (commissioner->numIPs > 0)
{
printf("Number of IP addresses: %d. IP Adddress(es): ", commissioner->numIPs);
for (int j = 0; j < commissioner->numIPs; j++)
{
char ipAddress[Inet::kMaxIPAddressStringLength];
printf("%s, ", commissioner->ipAddress[j].ToString(ipAddress, sizeof(ipAddress)));
}
printf("\n");
}

printf("\n");
ChipLogProgress(chipTool, "Discovered Commisioner #%d", commissionerCount);
commissioner->LogDetail();
commissionerCount++;
}
}

printf("Total of %d commissioner(s) discovered in %" PRIu16 " sec\n", commissionerCount, GetWaitDurationInSeconds());
ChipLogProgress(chipTool, "Total of %d commissioner(s) discovered in %" PRIu16 " sec", commissionerCount,
GetWaitDurationInSeconds());
}
25 changes: 25 additions & 0 deletions examples/tv-casting-app/linux/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2020 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.

import("//build_overrides/build.gni")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
import("//args.gni")
}
42 changes: 42 additions & 0 deletions examples/tv-casting-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) 2020 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.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/tools.gni")

assert(chip_build_tools)

executable("chip-tv-casting-app") {
sources = [
"${chip_root}/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h",
"main.cpp",
]

deps = [
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/examples/tv-casting-app/tv-casting-common",
"${chip_root}/src/lib",
"${chip_root}/third_party/inipp",
]

cflags = [ "-Wconversion" ]

output_dir = root_out_dir
}

group("linux") {
deps = [ ":chip-tv-casting-app" ]
}
23 changes: 23 additions & 0 deletions examples/tv-casting-app/linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2020 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.
#

from generic_node_image
RUN apt-get install -y libglib2.0
COPY out/debug/chip-tv-casting-app /usr/bin/
COPY entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh", "server"]
53 changes: 53 additions & 0 deletions examples/tv-casting-app/linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# CHIP TV Casting App Example

This is a CHIP TV Casting app that can be used to cast content to a TV. This app
discovers TVs on the local network that act as commissioners, lets the user
select one, sends the TV a User Directed Commissioning request, enters
commisioning mode, advertises itself as a Commissionable Node and gets
commissioned. Then it allows the user to send CHIP ContentLauncher commands to
the TV.

<hr>

- [CHIP TV Casting App Example](#chip-tv-casting-app-example)
- [Building](#building)
- [Running the Complete Example on Linux](#running-the-complete-example-on-linux)

<hr>

<a name="building"></a>

## Building

- Install tool chain

$ sudo apt-get install git gcc g++ python pkg-config libssl-dev libdbus-1-dev libglib2.0-dev ninja-build python3-venv python3-dev unzip

- Build the example application:

$ cd ~/connectedhomeip/examples/tv-casting-app/linux
$ git submodule update --init
$ source third_party/connectedhomeip/scripts/activate.sh
$ gn gen out/debug
$ ninja -C out/debug

- To delete generated executable, libraries and object files use:

$ cd ~/connectedhomeip/examples/tv-casting-app/linux
$ rm -rf out/

<a name="running-the-complete-example-on-linux"></a>

## Running the Complete Example on Linux

- Pre-requisite: Build and run the tv-app

$ cd ~/connectedhomeip/examples/tv-app/linux
$ out/debug/chip-tv-app

- Run the tv-casting-app

$ cd ~/connectedhomeip/examples/tv-casting-app/linux
$ out/debug/chip-tv-casting-app

Follow the on-screen prompts on the tv-casting-app console
25 changes: 25 additions & 0 deletions examples/tv-casting-app/linux/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2020 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.

import("//build_overrides/chip.gni")

import("${chip_root}/config/standalone/args.gni")

chip_device_project_config_include = "<CHIPProjectAppConfig.h>"
chip_project_config_include = "<CHIPProjectAppConfig.h>"
chip_system_project_config_include = "<SystemProjectConfig.h>"

chip_project_config_include_dirs =
[ "${chip_root}/examples/tv-casting-app/tv-casting-common/include" ]
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]
1 change: 1 addition & 0 deletions examples/tv-casting-app/linux/build_overrides
29 changes: 29 additions & 0 deletions examples/tv-casting-app/linux/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

#
# Copyright (c) 2020 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.
#

set -ex

service dbus start
sleep 1
/usr/sbin/otbr-agent -I wpan0 spinel+hdlc+uart:///dev/ttyUSB0 &
sleep 1
ot-ctl panid 0x1234
ot-ctl ifconfig up
ot-ctl thread start

chip-tv-casting-app
Loading