-
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.
- Loading branch information
1 parent
017daa6
commit 5c5b357
Showing
37 changed files
with
12,440 additions
and
55 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
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,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") | ||
} |
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,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" ] | ||
} |
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,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"] |
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,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 | ||
$ sudo out/debug/chip-tv-app | ||
|
||
- Run the tv-casting-app | ||
|
||
$ cd ~/connectedhomeip/examples/tv-casting-app/linux | ||
$ sudo out/debug/chip-tv-casting-app | ||
|
||
Follow the on-screen prompts on the tv-casting-app console |
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,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" ] |
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 @@ | ||
../../build_overrides |
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,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 |
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,107 @@ | ||
/* | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <controller/CHIPCommissionableNodeController.h> | ||
#include <platform/CHIPDeviceLayer.h> | ||
#include <setup_payload/SetupPayload.h> | ||
#include <support/CHIPMem.h> | ||
|
||
using namespace chip; | ||
|
||
#define TV_DEVICE_TYPE 35 | ||
|
||
CHIP_ERROR RunTimedEventLoop(uint32_t aDelayMilliseconds) | ||
{ | ||
System::Timer * timer = nullptr; | ||
if (DeviceLayer::SystemLayer.NewTimer(timer) == CHIP_NO_ERROR) | ||
{ | ||
timer->Start( | ||
aDelayMilliseconds, | ||
[](System::Layer *, void *, CHIP_ERROR err) { | ||
DeviceLayer::PlatformMgr().StopEventLoopTask(); | ||
DeviceLayer::PlatformMgr().Shutdown(); | ||
}, | ||
nullptr); | ||
} | ||
else | ||
{ | ||
return CHIP_ERROR_INTERNAL; | ||
} | ||
DeviceLayer::PlatformMgr().RunEventLoop(); | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
void printOnboardingPayload(chip::SetupPayload payload) | ||
{ | ||
printf("Onboarding Payload::\n"); | ||
printf("PIN: %d\n", payload.setUpPINCode); | ||
printf("Discriminator: %d\n", payload.discriminator); | ||
printf("Vendor ID: %d\n", payload.vendorID); | ||
printf("Product ID: %d\n", payload.productID); | ||
} | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
int commissionerCount = 0, selectedCommissioner = CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES; | ||
chip::Controller::CommissionableNodeController mCommissionableNodeController; | ||
Mdns::DiscoveryFilter filter(Mdns::DiscoveryFilterType::kDeviceType, TV_DEVICE_TYPE); | ||
chip::SetupPayload payload; | ||
SuccessOrExit(chip::Platform::MemoryInit()); | ||
SuccessOrExit(chip::DeviceLayer::PlatformMgr().InitChipStack()); | ||
|
||
// Discover commissioner TVs | ||
SuccessOrExit(mCommissionableNodeController.DiscoverCommissioners(filter)); | ||
SuccessOrExit(RunTimedEventLoop(2 * 1000)); | ||
|
||
// Display discovered commissioner TVs | ||
for (int i = 0; i < CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES; i++) | ||
{ | ||
const Mdns::DiscoveredNodeData * commissioner = mCommissionableNodeController.GetDiscoveredCommissioner(i); | ||
if (commissioner != nullptr) | ||
{ | ||
printf("Discovered Commisioner #%d\n", ++commissionerCount); | ||
commissioner->Print(); | ||
printf("\n"); | ||
} | ||
} | ||
printf("%d commissioner(s) discovered\n", commissionerCount); | ||
|
||
// Accept user selection for commissioner TV | ||
VerifyOrExit(commissionerCount > 0, err = CHIP_NO_ERROR); | ||
printf("Choose a commissioner TV (by number# above) to request commissioning from: "); | ||
scanf("%d", &selectedCommissioner); | ||
|
||
// Initiate commissionning with selected commissioner TV | ||
SuccessOrExit(chip::DeviceLayer::PlatformMgr().InitChipStack()); | ||
SuccessOrExit(mCommissionableNodeController.RequestCommissioning(selectedCommissioner)); | ||
SuccessOrExit(mCommissionableNodeController.GetOnboardingPayload(payload)); | ||
printOnboardingPayload(payload); | ||
SuccessOrExit(RunTimedEventLoop(3 * 60 * 1000)); | ||
|
||
// TBD: Implement casting to TV | ||
|
||
exit: | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
ChipLogError(Zcl, "Failed to run TV Casting App:: %s", ErrorStr(err)); | ||
// End the program with non zero error code to indicate an error. | ||
return 1; | ||
} | ||
return 0; | ||
} |
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 @@ | ||
../../../../ |
Oops, something went wrong.