Skip to content

Commit

Permalink
[OIS] Add tv-app Matter example (#27838)
Browse files Browse the repository at this point in the history
* [OIS] Add CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS

Add a new item of Matter build settings that
pass extra include dirs for project configurations.
It's used in common GN arguments function.

Signed-off-by: ATmobica <[email protected]>

* [OIS] Add tv-app Matter example

Add tv-app implementation for OIS.
Create tv-app integration tests.
Extend build script, Vscode tasks, CI with tv-app.

Signed-off-by: ATmobica <[email protected]>

---------

Signed-off-by: ATmobica <[email protected]>
  • Loading branch information
ATmobica authored and pull[bot] committed Feb 1, 2024
1 parent 23e44f5 commit 119d495
Show file tree
Hide file tree
Showing 15 changed files with 1,409 additions and 1 deletion.
21 changes: 20 additions & 1 deletion .github/workflows/examples-openiotsdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ concurrency:

env:
CHIP_NO_LOG_TIMESTAMPS: true

jobs:
openiotsdk:
name: Open IoT SDK examples building
Expand Down Expand Up @@ -81,6 +81,16 @@ jobs:
examples/lock-app/openiotsdk/build/chip-openiotsdk-lock-app-example.elf \
/tmp/bloat_reports/
- name: Build tv-app example
id: build_tv_app
timeout-minutes: 10
run: |
scripts/examples/openiotsdk_example.sh tv-app
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
openiotsdk release tv-app \
examples/tv-app/openiotsdk/build/chip-openiotsdk-tv-app-example.elf \
/tmp/bloat_reports/
- name: Build unit tests (mbedtls)
id: build_unit_tests_mbedtls
run: |
Expand All @@ -100,6 +110,15 @@ jobs:
'scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns scripts/examples/openiotsdk_example.sh --no-activate -C test -n ${TEST_NETWORK_NAME}tap lock-app'
scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME down
- name: "Test: tv-app example"
if: steps.build_tv_app.outcome == 'success'
timeout-minutes: 10
run: |
scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME up
scripts/run_in_python_env.sh out/venv \
'scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns scripts/examples/openiotsdk_example.sh --no-activate -C test -n ${TEST_NETWORK_NAME}tap tv-app'
scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME down
- name: "Test: unit-tests (mbedtls)"
if: steps.build_unit_tests_mbedtls.outcome == 'success'
run: |
Expand Down
1 change: 1 addition & 0 deletions config/openiotsdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ matter_common_gn_args(
LIB_SHELL CONFIG_CHIP_LIB_SHELL
LIB_TESTS CONFIG_CHIP_LIB_TESTS
PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG}
PROJECT_CONFIG_INC_DIR ${CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS}
)
matter_add_gn_arg_string("target_cpu" "${CMAKE_SYSTEM_PROCESSOR}")
matter_add_gn_arg_string("openiotsdk_ar" ${CMAKE_AR})
Expand Down
1 change: 1 addition & 0 deletions config/openiotsdk/cmake/chip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)

# Default CHIP build configuration
set(CONFIG_CHIP_PROJECT_CONFIG "main/include/CHIPProjectConfig.h" CACHE STRING "")
set(CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS "" CACHE STRING "")
set(CONFIG_CHIP_LIB_TESTS NO CACHE BOOL "")
set(CONFIG_CHIP_LIB_SHELL NO CACHE BOOL "")

Expand Down
1 change: 1 addition & 0 deletions docs/guides/openiotsdk_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The list of currently supported Matter examples:
```
shell
lock-app
tv-app
```

You can use these examples as a reference for creating your own applications.
Expand Down
1 change: 1 addition & 0 deletions examples/platform/openiotsdk/supported_examples.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
shell
lock-app
tv-app
1 change: 1 addition & 0 deletions examples/tv-app/openiotsdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
79 changes: 79 additions & 0 deletions examples/tv-app/openiotsdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# Copyright (c) 2022-2023 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.
#

cmake_minimum_required(VERSION 3.21)

get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
get_filename_component(OPEN_IOT_SDK_CONFIG ${CHIP_ROOT}/config/openiotsdk REALPATH)
get_filename_component(OPEN_IOT_SDK_EXAMPLE_COMMON ${CHIP_ROOT}/examples/platform/openiotsdk REALPATH)
get_filename_component(TV_APP_COMMON ${CHIP_ROOT}/examples/tv-app/tv-common REALPATH)

list(APPEND CMAKE_MODULE_PATH ${OPEN_IOT_SDK_CONFIG}/cmake)
list(APPEND CMAKE_MODULE_PATH ${TV_APP_COMMON})

set(APP_TARGET chip-openiotsdk-tv-app-example_ns)

set(TFM_PROJECT_CONFIG_HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/tf-m-config/TfmProjectConfig.h")

# Toolchain files need to exist before first call to project
include(toolchain)

project(${APP_TARGET} LANGUAGES C CXX ASM)

include(sdk)

add_executable(${APP_TARGET})

# Application CHIP build configuration
set(CONFIG_CHIP_LIB_SHELL YES)
set(CONFIG_CHIP_PROJECT_CONFIG "../tv-common/include/CHIPProjectAppConfig.h")
set(CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS "\"${CMAKE_CURRENT_SOURCE_DIR}/main/include\"" )
include(chip)

add_subdirectory(${OPEN_IOT_SDK_EXAMPLE_COMMON}/app ./app_build)
target_include_directories(openiotsdk-app
PRIVATE
main/include
)

chip_add_data_model(openiotsdk-app PUBLIC tv)

# Add common lock-app sources
include(tv-app)
chip_add_tv_app_common(openiotsdk-app
SCOPE PUBLIC
SHELL_CMD CONFIG_CHIP_LIB_SHELL
)

target_include_directories(${APP_TARGET}
PRIVATE
main/include
)

target_sources(${APP_TARGET}
PRIVATE
main/main_ns.cpp
)

target_link_libraries(${APP_TARGET}
openiotsdk-startup
openiotsdk-app
)

include(linker)
set_target_link(${APP_TARGET})

sdk_post_build(${APP_TARGET})
163 changes: 163 additions & 0 deletions examples/tv-app/openiotsdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Matter Open IoT SDK TV-App Example Application

The Open IoT SDK TV Example is an example implementation of the Casting Video
Player device (refer to Video Player Architecture in the Matter Device Library
Specification document). It supports basic and content launching features. The
example includes a dummy application platform with a few hardcoded apps which
use the pre-defined settings to work.

The TV example also functions as a commissionable node, device that can be
paired into an existing Matter network and can be controlled by it.

> 💡 **Notes**: The Open IoT SDK platform implementation does not yet support
> the commissioner role, which means that some of its features are unavailable
> for this example. Therefore, it does not work properly with the Casting Video
> Client node like
> [CHIP TV Casting App Example](../../tv-casting-app/linux/README.md).
## Build-run-test-debug

For information on how to build, run, test and debug this example and further
information about the platform it is run on see
[Open IoT SDK examples](../../../docs/guides/openiotsdk_examples.md).

The example name to use in the scripts is `tv-app`.

## Example output

When the example runs, these lines should be visible:

```
[INF] [-] Open IoT SDK tv-app example application start
...
[INF] [-] Open IoT SDK tv-app example application run
```

This means the `tv-app` application launched correctly and you can follow traces
in the terminal.

## Shell commands

The application supports Matter shell commands that allow managing the
application platform (see `examples/tv-app/tv-common/src/AppTvShellCommands.cpp`
implementation). Pass commands to the terminal and wait for the response.

Example:

```
> app add 1
[INF] [DL] GetLoadContentAppByVendorId() - vendorId 1, productId 0
[INF] [DL] ContentAppFactoryImpl: LoadContentAppByAppId catalogVendorId=65521 applicationId=1
[INF] [DL] Looking next=1
[INF] [DL] Adding ContentApp with appid 1
[INF] [ZCL] TV Linux App: ApplicationBasic::SetDefaultDelegate
[INF] [ZCL] TV Linux App: KeypadInput::SetDefaultDelegate
[INF] [ZCL] TV Linux App: ApplicationLauncher::SetDefaultDelegate
[INF] [ZCL] TV Linux App: AccountLogin::SetDefaultDelegate
[INF] [ZCL] TV Linux App: ContentLauncher::SetDefaultDelegate
[INF] [ZCL] TV Linux App: MediaPlayback::SetDefaultDelegate
[INF] [ZCL] TV Linux App: TargetNavigator::SetDefaultDelegate
[INF] [ZCL] TV Linux App: Channel::SetDefaultDelegate
[INF] [DL] Added ContentApp 1 to dynamic endpoint 4 (index=0)
[INF] [DL] added app
Done
```

Run the `app help` command to get all supported commands and their usage.

## Commissioning

Read the
[Open IoT SDK commissioning guide](../../../docs/guides/openiotsdk_commissioning.md)
to see how to use the Matter controller to commission and control the
application.

### ApplicationBasic cluster usage

One of the fully supported clusters by this example is `ApplicationBasic`
cluster. Use cluster commands to trigger actions on the device. You can issue
commands through the same Matter controller you used to perform the
commissioning step above.

Before using the cluster commands, you need to add the application to the
platform using shell commands:

```
> app add 1
```

Example command:

```
chip-tool applicationbasic read vendor-name 123 4
```

The numeric arguments are: device node ID and device endpoint ID, respectively.

The endpoint ID argument is the dynamically assigned endpoint that is associated
with the added application. You can refer to the output logs after completing
the application adding step to find this value, for example:

```
[INF] [DL] Added ContentApp 1 to dynamic endpoint 4 (index=0)
```

The device send a response with its vendor name and you should see this line in
the controller output:

```
CHIP:TOO: VendorName: Vendor1
```

The `Vendor1` is the hardcoded value for this example.

### ApplicationLauncher cluster usage

The `Application Launcher` is the next example of the supported cluster. Use its
commands to trigger actions on the device. You can issue commands through the
same Matter controller you used to perform the commissioning step above.

Before using the cluster commands, you need to add the application to the
platform using shell commands:

```
> app add 1
```

Example command:

```
chip-tool applicationlauncher launch-app '{"catalogVendorID": 1, "applicationID": "1"}' 123 4
```

The numeric arguments are: device node ID and device endpoint ID, respectively.

The endpoint ID argument is the dynamically assigned endpoint that is associated
with the added application. You can refer to the output logs after completing
the application adding step to find this value, for example:

```
[INF] [DL] Added ContentApp 1 to dynamic endpoint 4 (index=0)
```

`catalogVendorID` and `applicationID` parameters are also printed after
completing the application adding step, for example:

```
[INF] [DL] ContentAppFactoryImpl: LoadContentAppByAppId catalogVendorId=65521 applicationId=1
```

The device send a response that is printed to the controller output:

```
CHIP:TOO: LauncherResponse: {
CHIP:TOO: status: 0
CHIP:TOO: data: 64617461
CHIP:TOO: }
```

The example application confirms handling the command with the log:

```
[INF] [ZCL] ApplicationLauncherManager::HandleLaunchApp
```
22 changes: 22 additions & 0 deletions examples/tv-app/openiotsdk/cmsis-config/RTE_Components.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
*
* Copyright (c) 2022 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.
*/

#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H

#endif // RTE_COMPONENTS_H
Loading

0 comments on commit 119d495

Please sign in to comment.