From e39e16f64f678aafc90088ea5eecfb30e1edc5d4 Mon Sep 17 00:00:00 2001 From: Artur Tynecki <77382963+ATmobica@users.noreply.github.com> Date: Fri, 23 Jun 2023 16:44:41 +0200 Subject: [PATCH] [Examples] Create common tv-app sources (#27408) Move cluster handlers, app platform and shell command implementations, ZCL callbacks from Linux to tv-common directory. Create source set with tv-app source files. Create cmake macro to add common tv-app sources to the specific target. Use common tv-app sources in Linux tv-app example. Sources can now be easily shared across platform implementations. Signed-off-by: ATmobica --- examples/tv-app/linux/BUILD.gn | 36 +--- examples/tv-app/linux/README.md | 17 +- examples/tv-app/linux/ZclCallbacks.cpp | 70 ------- .../include/cluster-change-attribute.cpp | 67 ------- .../tv-app/linux/include/cluster-init.cpp | 54 ------ examples/tv-app/linux/main.cpp | 113 +----------- examples/tv-app/tv-common/BUILD.gn | 57 ++++++ .../account-login/AccountLoginManager.cpp | 1 + .../account-login/AccountLoginManager.h | 0 .../ApplicationBasicManager.cpp | 0 .../ApplicationBasicManager.h | 0 .../ApplicationLauncherManager.cpp | 0 .../ApplicationLauncherManager.h | 0 .../audio-output/AudioOutputManager.cpp | 0 .../audio-output/AudioOutputManager.h | 0 .../clusters}/channel/ChannelManager.cpp | 0 .../clusters}/channel/ChannelManager.h | 0 .../ContentLauncherManager.cpp | 4 +- .../content-launcher/ContentLauncherManager.h | 1 - .../keypad-input/KeypadInputManager.cpp | 0 .../keypad-input/KeypadInputManager.h | 0 .../clusters}/low-power/LowPowerManager.cpp | 1 + .../clusters}/low-power/LowPowerManager.h | 0 .../media-input/MediaInputManager.cpp | 0 .../clusters}/media-input/MediaInputManager.h | 0 .../media-playback/MediaPlaybackManager.cpp | 0 .../media-playback/MediaPlaybackManager.h | 0 .../TargetNavigatorManager.cpp | 0 .../target-navigator/TargetNavigatorManager.h | 0 .../wake-on-lan/WakeOnLanManager.cpp | 0 .../clusters}/wake-on-lan/WakeOnLanManager.h | 0 .../AppImpl.h => tv-common/include/AppTv.h} | 22 +-- .../tv-common/include/CHIPProjectAppConfig.h | 5 +- .../shell/AppTvShellCommands.cpp} | 74 ++++---- .../shell/AppTvShellCommands.h} | 4 +- .../AppImpl.cpp => tv-common/src/AppTv.cpp} | 19 +- .../tv-app/tv-common/src/ZCLCallbacks.cpp | 174 ++++++++++++++++++ examples/tv-app/tv-common/tv-app.cmake | 86 +++++++++ 38 files changed, 405 insertions(+), 400 deletions(-) delete mode 100644 examples/tv-app/linux/ZclCallbacks.cpp delete mode 100644 examples/tv-app/linux/include/cluster-change-attribute.cpp delete mode 100644 examples/tv-app/linux/include/cluster-init.cpp rename examples/tv-app/{linux/include => tv-common/clusters}/account-login/AccountLoginManager.cpp (97%) rename examples/tv-app/{linux/include => tv-common/clusters}/account-login/AccountLoginManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/application-basic/ApplicationBasicManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/application-basic/ApplicationBasicManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/application-launcher/ApplicationLauncherManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/application-launcher/ApplicationLauncherManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/audio-output/AudioOutputManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/audio-output/AudioOutputManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/channel/ChannelManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/channel/ChannelManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/content-launcher/ContentLauncherManager.cpp (98%) rename examples/tv-app/{linux/include => tv-common/clusters}/content-launcher/ContentLauncherManager.h (98%) rename examples/tv-app/{linux/include => tv-common/clusters}/keypad-input/KeypadInputManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/keypad-input/KeypadInputManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/low-power/LowPowerManager.cpp (93%) rename examples/tv-app/{linux/include => tv-common/clusters}/low-power/LowPowerManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/media-input/MediaInputManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/media-input/MediaInputManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/media-playback/MediaPlaybackManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/media-playback/MediaPlaybackManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/target-navigator/TargetNavigatorManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/target-navigator/TargetNavigatorManager.h (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/wake-on-lan/WakeOnLanManager.cpp (100%) rename examples/tv-app/{linux/include => tv-common/clusters}/wake-on-lan/WakeOnLanManager.h (100%) rename examples/tv-app/{linux/AppImpl.h => tv-common/include/AppTv.h} (93%) rename examples/tv-app/{linux/AppPlatformShellCommands.cpp => tv-common/shell/AppTvShellCommands.cpp} (88%) rename examples/tv-app/{linux/AppPlatformShellCommands.h => tv-common/shell/AppTvShellCommands.h} (87%) rename examples/tv-app/{linux/AppImpl.cpp => tv-common/src/AppTv.cpp} (97%) create mode 100644 examples/tv-app/tv-common/src/ZCLCallbacks.cpp create mode 100644 examples/tv-app/tv-common/tv-app.cmake diff --git a/examples/tv-app/linux/BUILD.gn b/examples/tv-app/linux/BUILD.gn index c77a4feb75407d..74838682a5072c 100644 --- a/examples/tv-app/linux/BUILD.gn +++ b/examples/tv-app/linux/BUILD.gn @@ -20,43 +20,12 @@ import("${chip_root}/src/lib/lib.gni") assert(chip_build_tools) executable("chip-tv-app") { - sources = [ - "${chip_root}/examples/tv-app/tv-common/include/CHIPProjectAppConfig.h", - "AppImpl.cpp", - "AppImpl.h", - "ZclCallbacks.cpp", - "include/account-login/AccountLoginManager.cpp", - "include/account-login/AccountLoginManager.h", - "include/application-basic/ApplicationBasicManager.cpp", - "include/application-basic/ApplicationBasicManager.h", - "include/application-launcher/ApplicationLauncherManager.cpp", - "include/application-launcher/ApplicationLauncherManager.h", - "include/audio-output/AudioOutputManager.cpp", - "include/audio-output/AudioOutputManager.h", - "include/channel/ChannelManager.cpp", - "include/channel/ChannelManager.h", - "include/cluster-change-attribute.cpp", - "include/cluster-init.cpp", - "include/content-launcher/ContentLauncherManager.cpp", - "include/content-launcher/ContentLauncherManager.h", - "include/keypad-input/KeypadInputManager.cpp", - "include/keypad-input/KeypadInputManager.h", - "include/low-power/LowPowerManager.cpp", - "include/low-power/LowPowerManager.h", - "include/media-input/MediaInputManager.cpp", - "include/media-input/MediaInputManager.h", - "include/media-playback/MediaPlaybackManager.cpp", - "include/media-playback/MediaPlaybackManager.h", - "include/target-navigator/TargetNavigatorManager.cpp", - "include/target-navigator/TargetNavigatorManager.h", - "include/wake-on-lan/WakeOnLanManager.cpp", - "include/wake-on-lan/WakeOnLanManager.h", - "main.cpp", - ] + sources = [ "main.cpp" ] deps = [ "${chip_root}/examples/platform/linux:app-main", "${chip_root}/examples/tv-app/tv-common", + "${chip_root}/examples/tv-app/tv-common:tv-common-sources", "${chip_root}/src/lib", "${chip_root}/third_party/inipp", ] @@ -71,7 +40,6 @@ executable("chip-tv-app") { if (chip_build_libshell) { defines += [ "ENABLE_CHIP_SHELL" ] - sources += [ "AppPlatformShellCommands.cpp" ] } output_dir = root_out_dir diff --git a/examples/tv-app/linux/README.md b/examples/tv-app/linux/README.md index 547069f1960f37..46e04564e3f924 100644 --- a/examples/tv-app/linux/README.md +++ b/examples/tv-app/linux/README.md @@ -74,14 +74,15 @@ As an app platform, Content Apps can be launched and assigned to endpoints following (see Video Player Architecture in the Device Library spec). There is a dummy app platform included in the linux tv-app which includes a -small number of hardcoded apps. See AppImpl.h/.cpp for this dummy -implementation. These apps have hardcoded values for many operations - on a real -device, these apps would usually be developed by streaming video content -providers and the native platform may or may not provide Matter interfaces to -these apps. In some cases, the video player platform will bridge its existing -internal interfaces to Matter, allowing apps to continue to not be Matter-aware, -while other platforms may provide Matter interfaces to Content Apps so that they -can directly respond to each Matter cluster. +small number of hardcoded apps. See `examples/tv-app/tv-common/src/AppTv.h` and +`examples/tv-app/tv-common/src/AppTv.cpp` for this dummy implementation. These +apps have hardcoded values for many operations - on a real device, these apps +would usually be developed by streaming video content providers and the native +platform may or may not provide Matter interfaces to these apps. In some cases, +the video player platform will bridge its existing internal interfaces to +Matter, allowing apps to continue to not be Matter-aware, while other platforms +may provide Matter interfaces to Content Apps so that they can directly respond +to each Matter cluster. On Linux, there are shell commands to start and stop the dummy apps (by vendor id): diff --git a/examples/tv-app/linux/ZclCallbacks.cpp b/examples/tv-app/linux/ZclCallbacks.cpp deleted file mode 100644 index 0fe95c9aef6642..00000000000000 --- a/examples/tv-app/linux/ZclCallbacks.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * 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. - */ - -/** - * @file - * This file implements the handler for data model messages. - */ - -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::Clusters; - -void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, - uint8_t * value) -{ - ClusterId clusterId = attributePath.mClusterId; - AttributeId attributeId = attributePath.mAttributeId; - ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); - - if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id) - { - ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", ChipLogValueMEI(attributeId), - type, *value, size); - } - else if (clusterId == LevelControl::Id) - { - ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", - ChipLogValueMEI(attributeId), type, *value, size); - - // WIP Apply attribute change to Light - } -} - -/** @brief OnOff Cluster Init - * - * This function is called when a specific cluster is initialized. It gives the - * application an opportunity to take care of cluster initialization procedures. - * It is called exactly once for each endpoint where cluster is present. - * - * @param endpoint Ver.: always - * - * TODO Issue #3841 - * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster - * attributes to the default value. - * The logic here expects something similar to the deprecated Plugins callback - * emberAfPluginOnOffClusterServerPostInitCallback. - * - */ -void emberAfOnOffClusterInitCallback(EndpointId endpoint) -{ - // TODO: implement any additional Cluster Server init actions -} diff --git a/examples/tv-app/linux/include/cluster-change-attribute.cpp b/examples/tv-app/linux/include/cluster-change-attribute.cpp deleted file mode 100644 index 0a6c8deca6969c..00000000000000 --- a/examples/tv-app/linux/include/cluster-change-attribute.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * 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. - */ - -#include -#include -#include -#include - -using namespace chip; -using namespace ::chip::app::Clusters; - -enum TvCommand -{ - PowerToggle, - MuteToggle -}; - -void runTvCommand(TvCommand command) -{ - switch (command) - { - case PowerToggle: - // TODO: Insert your code here to send power toggle command - break; - case MuteToggle: - // TODO: Insert your code here to send mute toggle command - break; - - default: - break; - } -} - -void MatterAfPostAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, - uint8_t * value) -{ - if (attributePath.mClusterId == OnOff::Id && attributePath.mAttributeId == OnOff::Attributes::OnOff::Id) - { - ChipLogProgress(Zcl, "Received on/off command for cluster id: " ChipLogFormatMEI, ChipLogValueMEI(OnOff::Id)); - - if (attributePath.mEndpointId == 0) - { - ChipLogProgress(Zcl, "Execute POWER_TOGGLE"); - runTvCommand(PowerToggle); - } - else if (attributePath.mEndpointId == 1) - { - ChipLogProgress(Zcl, "Execute MUTE_TOGGLE"); - runTvCommand(MuteToggle); - } - } -} diff --git a/examples/tv-app/linux/include/cluster-init.cpp b/examples/tv-app/linux/include/cluster-init.cpp deleted file mode 100644 index 496aa1c3288288..00000000000000 --- a/examples/tv-app/linux/include/cluster-init.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * 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. - */ - -#include "application-basic/ApplicationBasicManager.h" -#include "application-launcher/ApplicationLauncherManager.h" -#include "audio-output/AudioOutputManager.h" -#include "channel/ChannelManager.h" -#include "content-launcher/ContentLauncherManager.h" -#include "media-input/MediaInputManager.h" -#include "target-navigator/TargetNavigatorManager.h" -#include "wake-on-lan/WakeOnLanManager.h" - -#include -#include -#include -#include -#include - -using namespace chip; - -namespace { -template -class TvAttrAccess : public app::AttributeAccessInterface -{ -public: - TvAttrAccess() : app::AttributeAccessInterface(Optional::Missing(), AttrTypeInfo::GetClusterId()) {} - - CHIP_ERROR Read(const app::ConcreteReadAttributePath & aPath, app::AttributeValueEncoder & aEncoder) override - { - if (aPath.mAttributeId == AttrTypeInfo::GetAttributeId()) - { - return (Manager().*Getter)(aPath.mEndpointId, aEncoder); - } - - return CHIP_NO_ERROR; - } -}; - -} // anonymous namespace diff --git a/examples/tv-app/linux/main.cpp b/examples/tv-app/linux/main.cpp index 2609d9a2f3c6f4..ffdd5e00bc5513 100644 --- a/examples/tv-app/linux/main.cpp +++ b/examples/tv-app/linux/main.cpp @@ -16,9 +16,8 @@ * limitations under the License. */ -#include "AppImpl.h" #include "AppMain.h" -#include "AppPlatformShellCommands.h" +#include "AppTv.h" #include #include @@ -27,21 +26,8 @@ #include #include -#include "include/account-login/AccountLoginManager.h" -#include "include/application-basic/ApplicationBasicManager.h" -#include "include/application-launcher/ApplicationLauncherManager.h" -#include "include/audio-output/AudioOutputManager.h" -#include "include/channel/ChannelManager.h" -#include "include/content-launcher/ContentLauncherManager.h" -#include "include/keypad-input/KeypadInputManager.h" -#include "include/low-power/LowPowerManager.h" -#include "include/media-input/MediaInputManager.h" -#include "include/media-playback/MediaPlaybackManager.h" -#include "include/target-navigator/TargetNavigatorManager.h" -#include "include/wake-on-lan/WakeOnLanManager.h" - #if defined(ENABLE_CHIP_SHELL) -#include // nogncheck +#include "AppTvShellCommands.h" #endif using namespace chip; @@ -50,25 +36,6 @@ using namespace chip::DeviceLayer; using namespace chip::AppPlatform; using namespace chip::app::Clusters; -namespace { -static AccountLoginManager accountLoginManager; -static ApplicationBasicManager applicationBasicManager; -#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED -static ApplicationLauncherManager applicationLauncherManager(true); -#else // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED -static ApplicationLauncherManager applicationLauncherManager(false); -#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED -static AudioOutputManager audioOutputManager; -static ChannelManager channelManager; -static ContentLauncherManager contentLauncherManager; -static KeypadInputManager keypadInputManager; -static LowPowerManager lowPowerManager; -static MediaInputManager mediaInputManager; -static MediaPlaybackManager mediaPlaybackManager; -static TargetNavigatorManager targetNavigatorManager; -static WakeOnLanManager wakeOnLanManager; -} // namespace - void ApplicationInit() { ChipLogProgress(Zcl, "TV Linux App: ApplicationInit()"); @@ -85,11 +52,11 @@ int main(int argc, char * argv[]) VerifyOrDie(ChipLinuxAppInit(argc, argv) == 0); - InitVideoPlayerPlatform(); + AppTvInit(); #if defined(ENABLE_CHIP_SHELL) #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED - Shell::RegisterAppPlatformCommands(); + Shell::RegisterAppTvCommands(); #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED #endif @@ -97,75 +64,3 @@ int main(int argc, char * argv[]) return 0; } - -void emberAfContentLauncherClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: ContentLauncher::SetDefaultDelegate"); - ContentLauncher::SetDefaultDelegate(endpoint, &contentLauncherManager); -} - -void emberAfAccountLoginClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: AccountLogin::SetDefaultDelegate"); - AccountLogin::SetDefaultDelegate(endpoint, &accountLoginManager); -} - -void emberAfApplicationBasicClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: ApplicationBasic::SetDefaultDelegate"); - ApplicationBasic::SetDefaultDelegate(endpoint, &applicationBasicManager); -} - -void emberAfApplicationLauncherClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: ApplicationLauncher::SetDefaultDelegate"); - ApplicationLauncher::SetDefaultDelegate(endpoint, &applicationLauncherManager); -} - -void emberAfAudioOutputClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: AudioOutput::SetDefaultDelegate"); - AudioOutput::SetDefaultDelegate(endpoint, &audioOutputManager); -} - -void emberAfChannelClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: Channel::SetDefaultDelegate"); - Channel::SetDefaultDelegate(endpoint, &channelManager); -} - -void emberAfKeypadInputClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: KeypadInput::SetDefaultDelegate"); - KeypadInput::SetDefaultDelegate(endpoint, &keypadInputManager); -} - -void emberAfLowPowerClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: LowPower::SetDefaultDelegate"); - LowPower::SetDefaultDelegate(endpoint, &lowPowerManager); -} - -void emberAfMediaInputClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: MediaInput::SetDefaultDelegate"); - MediaInput::SetDefaultDelegate(endpoint, &mediaInputManager); -} - -void emberAfMediaPlaybackClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: MediaPlayback::SetDefaultDelegate"); - MediaPlayback::SetDefaultDelegate(endpoint, &mediaPlaybackManager); -} - -void emberAfTargetNavigatorClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: TargetNavigator::SetDefaultDelegate"); - TargetNavigator::SetDefaultDelegate(endpoint, &targetNavigatorManager); -} - -void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint) -{ - ChipLogProgress(Zcl, "TV Linux App: WakeOnLanManager::SetDefaultDelegate"); - WakeOnLan::SetDefaultDelegate(endpoint, &wakeOnLanManager); -} diff --git a/examples/tv-app/tv-common/BUILD.gn b/examples/tv-app/tv-common/BUILD.gn index f723e6f0db12f1..03d98b3227c82d 100644 --- a/examples/tv-app/tv-common/BUILD.gn +++ b/examples/tv-app/tv-common/BUILD.gn @@ -15,6 +15,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/app/chip_data_model.gni") +import("${chip_root}/src/lib/lib.gni") chip_data_model("tv-common") { zap_file = "tv-app.zap" @@ -22,3 +23,59 @@ chip_data_model("tv-common") { zap_pregenerated_dir = "${chip_root}/zzz_generated/tv-app/zap-generated" is_server = true } + +config("config") { + include_dirs = [ + "include", + "clusters", + ] + if (chip_build_libshell) { + include_dirs += [ "shell" ] + } +} + +source_set("tv-common-sources") { + deps = [ + "${chip_root}/examples/platform/linux:app-main", + "${chip_root}/examples/tv-app/tv-common", + "${chip_root}/src/lib", + ] + public_configs = [ ":config" ] + sources = [ + "clusters/account-login/AccountLoginManager.cpp", + "clusters/account-login/AccountLoginManager.h", + "clusters/application-basic/ApplicationBasicManager.cpp", + "clusters/application-basic/ApplicationBasicManager.h", + "clusters/application-launcher/ApplicationLauncherManager.cpp", + "clusters/application-launcher/ApplicationLauncherManager.h", + "clusters/audio-output/AudioOutputManager.cpp", + "clusters/audio-output/AudioOutputManager.h", + "clusters/channel/ChannelManager.cpp", + "clusters/channel/ChannelManager.h", + "clusters/content-launcher/ContentLauncherManager.cpp", + "clusters/content-launcher/ContentLauncherManager.h", + "clusters/keypad-input/KeypadInputManager.cpp", + "clusters/keypad-input/KeypadInputManager.h", + "clusters/low-power/LowPowerManager.cpp", + "clusters/low-power/LowPowerManager.h", + "clusters/media-input/MediaInputManager.cpp", + "clusters/media-input/MediaInputManager.h", + "clusters/media-playback/MediaPlaybackManager.cpp", + "clusters/media-playback/MediaPlaybackManager.h", + "clusters/target-navigator/TargetNavigatorManager.cpp", + "clusters/target-navigator/TargetNavigatorManager.h", + "clusters/wake-on-lan/WakeOnLanManager.cpp", + "clusters/wake-on-lan/WakeOnLanManager.h", + "include/AppTv.h", + "include/CHIPProjectAppConfig.h", + "src/AppTv.cpp", + "src/ZCLCallbacks.cpp", + ] + + if (chip_build_libshell) { + sources += [ + "shell/AppTvShellCommands.cpp", + "shell/AppTvShellCommands.h", + ] + } +} diff --git a/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp b/examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.cpp similarity index 97% rename from examples/tv-app/linux/include/account-login/AccountLoginManager.cpp rename to examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.cpp index 7a27ce2d3660f6..d5f70305716d29 100644 --- a/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp +++ b/examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.cpp @@ -48,6 +48,7 @@ bool AccountLoginManager::HandleLogin(const CharSpan & tempAccountIdentifier, co bool AccountLoginManager::HandleLogout() { // TODO: Insert your code here to send logout request + ChipLogProgress(Zcl, "AccountLoginManager::HandleLogout success"); return true; } diff --git a/examples/tv-app/linux/include/account-login/AccountLoginManager.h b/examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.h similarity index 100% rename from examples/tv-app/linux/include/account-login/AccountLoginManager.h rename to examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.h diff --git a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp b/examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.cpp similarity index 100% rename from examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp rename to examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.cpp diff --git a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.h b/examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.h similarity index 100% rename from examples/tv-app/linux/include/application-basic/ApplicationBasicManager.h rename to examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.h diff --git a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp b/examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.cpp similarity index 100% rename from examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp rename to examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.cpp diff --git a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h b/examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.h similarity index 100% rename from examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h rename to examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.h diff --git a/examples/tv-app/linux/include/audio-output/AudioOutputManager.cpp b/examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.cpp similarity index 100% rename from examples/tv-app/linux/include/audio-output/AudioOutputManager.cpp rename to examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.cpp diff --git a/examples/tv-app/linux/include/audio-output/AudioOutputManager.h b/examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.h similarity index 100% rename from examples/tv-app/linux/include/audio-output/AudioOutputManager.h rename to examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.h diff --git a/examples/tv-app/linux/include/channel/ChannelManager.cpp b/examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp similarity index 100% rename from examples/tv-app/linux/include/channel/ChannelManager.cpp rename to examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp diff --git a/examples/tv-app/linux/include/channel/ChannelManager.h b/examples/tv-app/tv-common/clusters/channel/ChannelManager.h similarity index 100% rename from examples/tv-app/linux/include/channel/ChannelManager.h rename to examples/tv-app/tv-common/clusters/channel/ChannelManager.h diff --git a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp b/examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.cpp similarity index 98% rename from examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp rename to examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.cpp index 79ae11b8a57d37..60d38f5549e4b1 100644 --- a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp +++ b/examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.cpp @@ -97,10 +97,10 @@ void ContentLauncherManager::HandleLaunchContent(CommandResponseHelper & parameterList, bool autoplay, const CharSpan & data) { - ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchContent for endpoint %d", mEndpointId); + ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchContent"); string dataString(data.data(), data.size()); - ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchUrl TEST CASE autoplay=%d data=%s ", (autoplay ? 1 : 0), + ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchContent TEST CASE autoplay=%d data=%s ", (autoplay ? 1 : 0), dataString.c_str()); bool foundMatch = false; diff --git a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.h b/examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.h similarity index 98% rename from examples/tv-app/linux/include/content-launcher/ContentLauncherManager.h rename to examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.h index b19663d2f11e8e..d08e708a4158da 100644 --- a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.h +++ b/examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.h @@ -59,7 +59,6 @@ class ContentLauncherManager : public ContentLauncherDelegate std::vector mContentList; private: - EndpointId mEndpointId; // TODO: set this based upon meta data from app uint32_t mDynamicEndpointFeatureMap = 3; }; diff --git a/examples/tv-app/linux/include/keypad-input/KeypadInputManager.cpp b/examples/tv-app/tv-common/clusters/keypad-input/KeypadInputManager.cpp similarity index 100% rename from examples/tv-app/linux/include/keypad-input/KeypadInputManager.cpp rename to examples/tv-app/tv-common/clusters/keypad-input/KeypadInputManager.cpp diff --git a/examples/tv-app/linux/include/keypad-input/KeypadInputManager.h b/examples/tv-app/tv-common/clusters/keypad-input/KeypadInputManager.h similarity index 100% rename from examples/tv-app/linux/include/keypad-input/KeypadInputManager.h rename to examples/tv-app/tv-common/clusters/keypad-input/KeypadInputManager.h diff --git a/examples/tv-app/linux/include/low-power/LowPowerManager.cpp b/examples/tv-app/tv-common/clusters/low-power/LowPowerManager.cpp similarity index 93% rename from examples/tv-app/linux/include/low-power/LowPowerManager.cpp rename to examples/tv-app/tv-common/clusters/low-power/LowPowerManager.cpp index 57399c0ba1de5c..7f11971f21c9fb 100644 --- a/examples/tv-app/linux/include/low-power/LowPowerManager.cpp +++ b/examples/tv-app/tv-common/clusters/low-power/LowPowerManager.cpp @@ -21,5 +21,6 @@ bool LowPowerManager::HandleSleep() { // TODO: Insert code here + ChipLogProgress(Zcl, "LowPowerManager::HandleSleep"); return true; } diff --git a/examples/tv-app/linux/include/low-power/LowPowerManager.h b/examples/tv-app/tv-common/clusters/low-power/LowPowerManager.h similarity index 100% rename from examples/tv-app/linux/include/low-power/LowPowerManager.h rename to examples/tv-app/tv-common/clusters/low-power/LowPowerManager.h diff --git a/examples/tv-app/linux/include/media-input/MediaInputManager.cpp b/examples/tv-app/tv-common/clusters/media-input/MediaInputManager.cpp similarity index 100% rename from examples/tv-app/linux/include/media-input/MediaInputManager.cpp rename to examples/tv-app/tv-common/clusters/media-input/MediaInputManager.cpp diff --git a/examples/tv-app/linux/include/media-input/MediaInputManager.h b/examples/tv-app/tv-common/clusters/media-input/MediaInputManager.h similarity index 100% rename from examples/tv-app/linux/include/media-input/MediaInputManager.h rename to examples/tv-app/tv-common/clusters/media-input/MediaInputManager.h diff --git a/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp b/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.cpp similarity index 100% rename from examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp rename to examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.cpp diff --git a/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.h b/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.h similarity index 100% rename from examples/tv-app/linux/include/media-playback/MediaPlaybackManager.h rename to examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.h diff --git a/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp b/examples/tv-app/tv-common/clusters/target-navigator/TargetNavigatorManager.cpp similarity index 100% rename from examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp rename to examples/tv-app/tv-common/clusters/target-navigator/TargetNavigatorManager.cpp diff --git a/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.h b/examples/tv-app/tv-common/clusters/target-navigator/TargetNavigatorManager.h similarity index 100% rename from examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.h rename to examples/tv-app/tv-common/clusters/target-navigator/TargetNavigatorManager.h diff --git a/examples/tv-app/linux/include/wake-on-lan/WakeOnLanManager.cpp b/examples/tv-app/tv-common/clusters/wake-on-lan/WakeOnLanManager.cpp similarity index 100% rename from examples/tv-app/linux/include/wake-on-lan/WakeOnLanManager.cpp rename to examples/tv-app/tv-common/clusters/wake-on-lan/WakeOnLanManager.cpp diff --git a/examples/tv-app/linux/include/wake-on-lan/WakeOnLanManager.h b/examples/tv-app/tv-common/clusters/wake-on-lan/WakeOnLanManager.h similarity index 100% rename from examples/tv-app/linux/include/wake-on-lan/WakeOnLanManager.h rename to examples/tv-app/tv-common/clusters/wake-on-lan/WakeOnLanManager.h diff --git a/examples/tv-app/linux/AppImpl.h b/examples/tv-app/tv-common/include/AppTv.h similarity index 93% rename from examples/tv-app/linux/AppImpl.h rename to examples/tv-app/tv-common/include/AppTv.h index 46cdb650bd38c8..e63a4ff5d57e88 100644 --- a/examples/tv-app/linux/AppImpl.h +++ b/examples/tv-app/tv-common/include/AppTv.h @@ -30,15 +30,15 @@ #include #include -#include "CommissionerMain.h" -#include "include/account-login/AccountLoginManager.h" -#include "include/application-basic/ApplicationBasicManager.h" -#include "include/application-launcher/ApplicationLauncherManager.h" -#include "include/channel/ChannelManager.h" -#include "include/content-launcher/ContentLauncherManager.h" -#include "include/keypad-input/KeypadInputManager.h" -#include "include/media-playback/MediaPlaybackManager.h" -#include "include/target-navigator/TargetNavigatorManager.h" +#include "account-login/AccountLoginManager.h" +#include "application-basic/ApplicationBasicManager.h" +#include "application-launcher/ApplicationLauncherManager.h" +#include "channel/ChannelManager.h" +#include "content-launcher/ContentLauncherManager.h" +#include "keypad-input/KeypadInputManager.h" +#include "media-playback/MediaPlaybackManager.h" +#include "target-navigator/TargetNavigatorManager.h" + #include #include #include @@ -48,8 +48,6 @@ #include #include -CHIP_ERROR InitVideoPlayerPlatform(); - #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED namespace chip { @@ -155,3 +153,5 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory chip::AppPlatform::ContentAppFactoryImpl * GetContentAppFactoryImpl(); #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED + +CHIP_ERROR AppTvInit(void); diff --git a/examples/tv-app/tv-common/include/CHIPProjectAppConfig.h b/examples/tv-app/tv-common/include/CHIPProjectAppConfig.h index 395be25eebba1a..99274da0114257 100644 --- a/examples/tv-app/tv-common/include/CHIPProjectAppConfig.h +++ b/examples/tv-app/tv-common/include/CHIPProjectAppConfig.h @@ -70,8 +70,5 @@ // Change port to make it easy to run against tv-casting-app #define CHIP_PORT 5640 -// Create a dedicated file for storage to make it easy to run against other apps -// #define CHIP_CONFIG_KVS_PATH "/tmp/chip_tv_kvs" - -// include the CHIPProjectConfig from config/standalone +// Include the CHIPProjectConfig from platform implementation config #include diff --git a/examples/tv-app/linux/AppPlatformShellCommands.cpp b/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp similarity index 88% rename from examples/tv-app/linux/AppPlatformShellCommands.cpp rename to examples/tv-app/tv-common/shell/AppTvShellCommands.cpp index b70c7b6f0d36b0..c66beb94e1dd7f 100644 --- a/examples/tv-app/linux/AppPlatformShellCommands.cpp +++ b/examples/tv-app/tv-common/shell/AppTvShellCommands.cpp @@ -19,10 +19,9 @@ * @file Contains shell commands for a ContentApp relating to Content App platform of the Video Player. */ -#include "AppPlatformShellCommands.h" -#include "AppImpl.h" -#include "ControllerShellCommands.h" -#include +#include "AppTvShellCommands.h" +#include "AppTv.h" + #include #include #include @@ -36,20 +35,24 @@ #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED #include -#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED - -using namespace ::chip::Controller; -#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED using namespace chip::AppPlatform; using namespace chip::Access; #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED -using namespace chip::app::Clusters; -#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE +#include +#include +using namespace ::chip::Controller; +extern DeviceCommissioner * GetDeviceCommissioner(); +extern CHIP_ERROR CommissionerPairUDC(uint32_t pincode, size_t index); +#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE + +using namespace chip::app::Clusters; namespace chip { namespace Shell { +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE static CHIP_ERROR pairApp(bool printHeader, size_t index) { streamer_t * sout = streamer_get(); @@ -181,23 +184,28 @@ static CHIP_ERROR DumpAccessControlEntry(const Access::AccessControl::Entry & en ChipLogError(DeviceLayer, "DumpAccessControlEntry: dump failed %" CHIP_ERROR_FORMAT, err.Format()); return err; } +#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE static CHIP_ERROR PrintAllCommands() { streamer_t * sout = streamer_get(); - streamer_printf(sout, " help Usage: app \r\n"); - streamer_printf(sout, " add [] Add app with given vendor ID [1, 2, 9050]. Usage: app add 9050\r\n"); - streamer_printf(sout, " remove Remove app at given endpoint [6, 7, etc]. Usage: app remove 6\r\n"); - streamer_printf(sout, - " setpin Set pincode for app with given endpoint ID. Usage: app setpin 6 34567890\r\n"); - streamer_printf(sout, - " commission Commission given udc-entry using given pincode from corresponding app. Usage: " - "app commission 0\r\n"); + streamer_printf(sout, " help Usage: app \r\n"); +#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED + streamer_printf(sout, " add [] Add app with given vendor ID [1, 2, 9050]. Usage: app add 9050\r\n"); + streamer_printf(sout, " remove Remove app at given endpoint [6, 7, etc]. Usage: app remove 6\r\n"); + streamer_printf( + sout, " setpin Set pincode for app with given endpoint ID. Usage: app setpin 6 34567890\r\n"); streamer_printf(sout, - " add-admin-vendor Add vendor ID to list which will receive admin privileges. Usage: app " + " add-admin-vendor Add vendor ID to list which will receive admin privileges. Usage: app " "add-admin-vendor 65521\r\n"); +#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE streamer_printf(sout, " print-app-access Print all ACLs for app platform fabric. Usage: app print-app-access\r\n"); streamer_printf(sout, " remove-app-access Remove all ACLs for app platform fabric. Usage: app remove-app-access\r\n"); + streamer_printf(sout, + " commission Commission given udc-entry using given pincode from corresponding app. Usage: " + "app commission 0\r\n"); +#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE streamer_printf(sout, "\r\n"); return CHIP_NO_ERROR; @@ -211,6 +219,7 @@ static CHIP_ERROR AppPlatformHandler(int argc, char ** argv) { return PrintAllCommands(); } +#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED else if (strcmp(argv[0], "add-admin-vendor") == 0) { if (argc < 2) @@ -295,16 +304,8 @@ static CHIP_ERROR AppPlatformHandler(int argc, char ** argv) return CHIP_NO_ERROR; } - else if (strcmp(argv[0], "commission") == 0) - { - if (argc < 2) - { - return PrintAllCommands(); - } - char * eptr; - size_t index = (size_t) strtol(argv[1], &eptr, 10); - return error = pairApp(true, index); - } +#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE else if (strcmp(argv[0], "print-app-access") == 0) { Access::AccessControl::EntryIterator iterator; @@ -322,6 +323,17 @@ static CHIP_ERROR AppPlatformHandler(int argc, char ** argv) Access::GetAccessControl().DeleteAllEntriesForFabric(GetDeviceCommissioner()->GetFabricIndex()); return CHIP_NO_ERROR; } + else if (strcmp(argv[0], "commission") == 0) + { + if (argc < 2) + { + return PrintAllCommands(); + } + char * eptr; + size_t index = (size_t) strtol(argv[1], &eptr, 10); + return error = pairApp(true, index); + } +#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE else { return CHIP_ERROR_INVALID_ARGUMENT; @@ -329,7 +341,7 @@ static CHIP_ERROR AppPlatformHandler(int argc, char ** argv) return error; } -void RegisterAppPlatformCommands() +void RegisterAppTvCommands() { static const shell_command_t sDeviceComand = { &AppPlatformHandler, "app", "App commands. Usage: app [command_name]" }; @@ -341,5 +353,3 @@ void RegisterAppPlatformCommands() } // namespace Shell } // namespace chip - -#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED diff --git a/examples/tv-app/linux/AppPlatformShellCommands.h b/examples/tv-app/tv-common/shell/AppTvShellCommands.h similarity index 87% rename from examples/tv-app/linux/AppPlatformShellCommands.h rename to examples/tv-app/tv-common/shell/AppTvShellCommands.h index bee89009f17d16..4be0bae7f40492 100644 --- a/examples/tv-app/linux/AppPlatformShellCommands.h +++ b/examples/tv-app/tv-common/shell/AppTvShellCommands.h @@ -22,12 +22,10 @@ #include -#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED namespace chip { namespace Shell { -void RegisterAppPlatformCommands(); +void RegisterAppTvCommands(); } // namespace Shell } // namespace chip -#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED diff --git a/examples/tv-app/linux/AppImpl.cpp b/examples/tv-app/tv-common/src/AppTv.cpp similarity index 97% rename from examples/tv-app/linux/AppImpl.cpp rename to examples/tv-app/tv-common/src/AppTv.cpp index a07eeadaeb029a..9dc840af319a98 100644 --- a/examples/tv-app/linux/AppImpl.cpp +++ b/examples/tv-app/tv-common/src/AppTv.cpp @@ -19,7 +19,7 @@ * @file Contains Implementation of the ContentApp and the ContentAppPlatform. */ -#include "AppImpl.h" +#include "AppTv.h" #include #include @@ -40,6 +40,14 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE +#include +#include +using namespace ::chip::Controller; +extern DeviceCommissioner * GetDeviceCommissioner(); +extern CommissionerDiscoveryController * GetCommissionerDiscoveryController(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE + using namespace chip; using namespace chip::AppPlatform; using namespace chip::app::Clusters; @@ -70,9 +78,7 @@ class MyUserPrompter : public UserPrompter }; MyUserPrompter gMyUserPrompter; -#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE -#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED class MyPincodeService : public PincodeService { uint32_t FetchCommissionPincodeFromContentApp(uint16_t vendorId, uint16_t productId, CharSpan rotatingId) override @@ -205,6 +211,9 @@ class MyPostCommissioningListener : public PostCommissioningListener }; MyPostCommissioningListener gMyPostCommissioningListener; +#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE + +#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED ContentAppFactoryImpl gFactory; ContentAppFactoryImpl * GetContentAppFactoryImpl() @@ -528,7 +537,7 @@ std::list ContentAppFactoryImpl::GetAllowedClusterListForStaticEndpoi #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED -CHIP_ERROR InitVideoPlayerPlatform() +CHIP_ERROR AppTvInit() { #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED ContentAppPlatform::GetInstance().SetupAppPlatform(); @@ -536,7 +545,7 @@ CHIP_ERROR InitVideoPlayerPlatform() uint16_t value; if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetVendorId(value) != CHIP_NO_ERROR) { - ChipLogDetail(Discovery, "AppImpl InitVideoPlayerPlatform Vendor ID not known"); + ChipLogDetail(Discovery, "AppTvInit Vendor ID not known"); } else { diff --git a/examples/tv-app/tv-common/src/ZCLCallbacks.cpp b/examples/tv-app/tv-common/src/ZCLCallbacks.cpp new file mode 100644 index 00000000000000..d980811a6c09ad --- /dev/null +++ b/examples/tv-app/tv-common/src/ZCLCallbacks.cpp @@ -0,0 +1,174 @@ +/* + * + * 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. + */ + +/** + * @file + * This file implements the handler for data model messages. + */ + +#include +#include +#include +#include + +#include "account-login/AccountLoginManager.h" +#include "application-basic/ApplicationBasicManager.h" +#include "application-launcher/ApplicationLauncherManager.h" +#include "audio-output/AudioOutputManager.h" +#include "channel/ChannelManager.h" +#include "content-launcher/ContentLauncherManager.h" +#include "keypad-input/KeypadInputManager.h" +#include "low-power/LowPowerManager.h" +#include "media-input/MediaInputManager.h" +#include "media-playback/MediaPlaybackManager.h" +#include "target-navigator/TargetNavigatorManager.h" +#include "wake-on-lan/WakeOnLanManager.h" + +namespace { +static AccountLoginManager accountLoginManager; +static ApplicationBasicManager applicationBasicManager; +#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +static ApplicationLauncherManager applicationLauncherManager(true); +#else // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +static ApplicationLauncherManager applicationLauncherManager(false); +#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +static AudioOutputManager audioOutputManager; +static ChannelManager channelManager; +static ContentLauncherManager contentLauncherManager; +static KeypadInputManager keypadInputManager; +static LowPowerManager lowPowerManager; +static MediaInputManager mediaInputManager; +static MediaPlaybackManager mediaPlaybackManager; +static TargetNavigatorManager targetNavigatorManager; +static WakeOnLanManager wakeOnLanManager; +} // namespace + +using namespace ::chip; +using namespace ::chip::app::Clusters; + +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) +{ + ClusterId clusterId = attributePath.mClusterId; + AttributeId attributeId = attributePath.mAttributeId; + ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); + + if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id) + { + ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", ChipLogValueMEI(attributeId), + type, *value, size); + } + else if (clusterId == LevelControl::Id) + { + ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", + ChipLogValueMEI(attributeId), type, *value, size); + + // WIP Apply attribute change to Light + } +} + +/** @brief OnOff Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + * @param endpoint Ver.: always + * + * TODO Issue #3841 + * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster + * attributes to the default value. + * The logic here expects something similar to the deprecated Plugins callback + * emberAfPluginOnOffClusterServerPostInitCallback. + * + */ +void emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + // TODO: implement any additional Cluster Server init actions +} + +void emberAfContentLauncherClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: ContentLauncher::SetDefaultDelegate"); + ContentLauncher::SetDefaultDelegate(endpoint, &contentLauncherManager); +} + +void emberAfAccountLoginClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: AccountLogin::SetDefaultDelegate"); + AccountLogin::SetDefaultDelegate(endpoint, &accountLoginManager); +} + +void emberAfApplicationBasicClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: ApplicationBasic::SetDefaultDelegate"); + ApplicationBasic::SetDefaultDelegate(endpoint, &applicationBasicManager); +} + +void emberAfApplicationLauncherClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: ApplicationLauncher::SetDefaultDelegate"); + ApplicationLauncher::SetDefaultDelegate(endpoint, &applicationLauncherManager); +} + +void emberAfAudioOutputClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: AudioOutput::SetDefaultDelegate"); + AudioOutput::SetDefaultDelegate(endpoint, &audioOutputManager); +} + +void emberAfChannelClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: Channel::SetDefaultDelegate"); + Channel::SetDefaultDelegate(endpoint, &channelManager); +} + +void emberAfKeypadInputClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: KeypadInput::SetDefaultDelegate"); + KeypadInput::SetDefaultDelegate(endpoint, &keypadInputManager); +} + +void emberAfLowPowerClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: LowPower::SetDefaultDelegate"); + LowPower::SetDefaultDelegate(endpoint, &lowPowerManager); +} + +void emberAfMediaInputClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: MediaInput::SetDefaultDelegate"); + MediaInput::SetDefaultDelegate(endpoint, &mediaInputManager); +} + +void emberAfMediaPlaybackClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: MediaPlayback::SetDefaultDelegate"); + MediaPlayback::SetDefaultDelegate(endpoint, &mediaPlaybackManager); +} + +void emberAfTargetNavigatorClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: TargetNavigator::SetDefaultDelegate"); + TargetNavigator::SetDefaultDelegate(endpoint, &targetNavigatorManager); +} + +void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "TV Linux App: WakeOnLanManager::SetDefaultDelegate"); + WakeOnLan::SetDefaultDelegate(endpoint, &wakeOnLanManager); +} diff --git a/examples/tv-app/tv-common/tv-app.cmake b/examples/tv-app/tv-common/tv-app.cmake new file mode 100644 index 00000000000000..cf257b8073fd1b --- /dev/null +++ b/examples/tv-app/tv-common/tv-app.cmake @@ -0,0 +1,86 @@ +# +# Copyright (c) 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) + +set(CHIP_TV_COMMON_BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) +if (NOT CHIP_ROOT) + get_filename_component(CHIP_ROOT ${CHIP_TV_COMMON_BASE_DIR}/../../.. REALPATH) +endif() + +# Add common lock sources to the specific target +# [Args]: +# target - target name + # Available options are: +# SCOPE sources scope for the target, PRIVATE as default +# SHELL_CMD add shell commands support +macro(chip_add_tv_app_common target) + set(SCOPE PRIVATE) + set(oneValueArgs + SCOPE + SHELL_CMD + ) + cmake_parse_arguments(ARG "" "${oneValueArgs}" "" ${ARGN}) + if (ARG_SCOPE) + set(SCOPE ${ARG_SCOPE}) + endif() + + target_include_directories(${target} + ${SCOPE} + ${CHIP_TV_COMMON_BASE_DIR}/include + ${CHIP_TV_COMMON_BASE_DIR}/clusters + ${CHIP_ROOT}/src/app/app-platform + ) + + target_sources(${target} + ${SCOPE} + ${CHIP_TV_COMMON_BASE_DIR}/src/AppTv.cpp + ${CHIP_TV_COMMON_BASE_DIR}/src/ZCLCallbacks.cpp + + ${CHIP_TV_COMMON_BASE_DIR}/clusters/account-login/AccountLoginManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/application-basic/ApplicationBasicManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/application-launcher/ApplicationLauncherManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/audio-output/AudioOutputManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/channel/ChannelManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/content-launcher/ContentLauncherManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/keypad-input/KeypadInputManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/low-power/LowPowerManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/media-input/MediaInputManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/media-playback/MediaPlaybackManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/target-navigator/TargetNavigatorManager.cpp + ${CHIP_TV_COMMON_BASE_DIR}/clusters/wake-on-lan/WakeOnLanManager.cpp + + ${CHIP_ROOT}/src/app/app-platform/ContentAppPlatform.cpp + ${CHIP_ROOT}/src/app/app-platform/ContentApp.cpp + ) + + if (${ARG_SHELL_CMD}) + target_include_directories(${target} + ${SCOPE} + ${CHIP_TV_COMMON_BASE_DIR}/shell + ) + + target_sources(${target} + ${SCOPE} + ${CHIP_TV_COMMON_BASE_DIR}/shell/AppTvShellCommands.cpp + ) + + target_compile_definitions(${target} + ${SCOPE} + CHIP_TV_APP_SHELL_CMD_ENABLE + ) + endif() +endmacro()