Skip to content

Commit

Permalink
[chip-tv-casting-app] Update the TV casting app in order to share mor…
Browse files Browse the repository at this point in the history
…e code with chip-tool when it comes to commands parsing (#19575)
  • Loading branch information
vivien-apple authored and pull[bot] committed Oct 30, 2023
1 parent 75af13c commit 77cafa5
Show file tree
Hide file tree
Showing 25 changed files with 48 additions and 3,483 deletions.
4 changes: 4 additions & 0 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ config("config") {
]

defines = [
"CONFIG_USE_LOCAL_STORAGE=${config_use_local_storage}",
"CONFIG_USE_SEPARATE_EVENTLOOP=${config_use_separate_eventloop}",
"CONFIG_USE_INTERACTIVE_MODE=${config_use_interactive_mode}",
"CONFIG_ENABLE_YAML_TESTS=${config_enable_yaml_tests}",
Expand All @@ -49,10 +50,13 @@ static_library("chip-tool-utils") {
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp",
"commands/clusters/ModelCommand.cpp",
"commands/clusters/ModelCommand.h",
"commands/common/CHIPCommand.cpp",
"commands/common/CHIPCommand.h",
"commands/common/Command.cpp",
"commands/common/Command.h",
"commands/common/Commands.cpp",
"commands/common/Commands.h",
"commands/common/CredentialIssuerCommands.h",
"commands/discover/DiscoverCommand.cpp",
"commands/discover/DiscoverCommissionablesCommand.cpp",
Expand Down
1 change: 1 addition & 0 deletions examples/chip-tool/chip-tool.gni
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ declare_args() {
config_use_separate_eventloop = true
config_use_interactive_mode = true
config_enable_yaml_tests = true
config_use_local_storage = true
}
3 changes: 3 additions & 0 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

#pragma once

#ifdef CONFIG_USE_LOCAL_STORAGE
#include "../../config/PersistentStorage.h"
#endif // CONFIG_USE_LOCAL_STORAGE

#include "../common/CHIPCommand.h"
#include <lib/core/CHIPEncoding.h>

Expand Down
5 changes: 5 additions & 0 deletions examples/chip-tool/commands/clusters/SubscriptionsCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

#pragma once

#include <lib/core/CHIPError.h>

#include <commands/common/CHIPCommand.h>
#include <commands/common/Commands.h>

class ShutdownSubscription : public CHIPCommand
{
public:
Expand Down
8 changes: 6 additions & 2 deletions examples/chip-tool/commands/common/CHIPCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@

#pragma once

#ifdef CONFIG_USE_LOCAL_STORAGE
#include "../../config/PersistentStorage.h"
#endif // CONFIG_USE_LOCAL_STORAGE

#include "Command.h"

#include <commands/common/CredentialIssuerCommands.h>
#include <commands/example/ExampleCredentialIssuerCommands.h>
#include <credentials/GroupDataProviderImpl.h>
#include <crypto/PersistentStorageOperationalKeystore.h>

#pragma once

class PersistentStorage;

constexpr const char kIdentityAlpha[] = "alpha";
constexpr const char kIdentityBeta[] = "beta";
constexpr const char kIdentityGamma[] = "gamma";
Expand Down Expand Up @@ -114,8 +116,10 @@ class CHIPCommand : public Command
// Execute any deferred cleanups. Used when exiting interactive mode.
void ExecuteDeferredCleanups();

#ifdef CONFIG_USE_LOCAL_STORAGE
PersistentStorage mDefaultStorage;
PersistentStorage mCommissionerStorage;
#endif // CONFIG_USE_LOCAL_STORAGE
chip::PersistentStorageOperationalKeystore mOperationalKeystore;

chip::Credentials::GroupDataProviderImpl mGroupDataProvider{ kMaxGroupsPerFabric, kMaxGroupKeysPerFabric };
Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/commands/common/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ int Commands::Run(int argc, char ** argv)
err = chip::Platform::MemoryInit();
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init Memory failure: %s", chip::ErrorStr(err)));

#ifdef CONFIG_USE_LOCAL_STORAGE
err = mStorage.Init();
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init Storage failure: %s", chip::ErrorStr(err)));

chip::Logging::SetLogFilter(mStorage.GetLoggingLevel());
#endif // CONFIG_USE_LOCAL_STORAGE

err = RunCommand(argc, argv);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(chipTool, "Run command failure: %s", chip::ErrorStr(err)));
Expand Down
5 changes: 5 additions & 0 deletions examples/chip-tool/commands/common/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

#pragma once

#ifdef CONFIG_USE_LOCAL_STORAGE
#include "../../config/PersistentStorage.h"
#endif // CONFIG_USE_LOCAL_STORAGE

#include "Command.h"
#include <map>

Expand Down Expand Up @@ -48,5 +51,7 @@ class Commands
void ShowCommand(std::string executable, std::string clusterName, Command * command);

std::map<std::string, CommandsVector> mClusters;
#ifdef CONFIG_USE_LOCAL_STORAGE
PersistentStorage mStorage;
#endif // CONFIG_USE_LOCAL_STORAGE
};
17 changes: 12 additions & 5 deletions examples/tv-casting-app/tv-casting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import("${chip_root}/src/lib/lib.gni")
config("config") {
include_dirs = [
".",
"${chip_root}/examples/chip-tool",
"${chip_root}/zzz_generated/chip-tool",
"${chip_root}/zzz_generated/tv-casting-app",
"${chip_root}/src/lib",
Expand All @@ -35,14 +36,17 @@ chip_data_model("tv-casting-common") {
"${chip_root}/zzz_generated/tv-casting-app/zap-generated"

sources = [
"${chip_root}/examples/chip-tool/commands/clusters/ModelCommand.h",
"${chip_root}/examples/chip-tool/commands/common/CHIPCommand.h",
"${chip_root}/examples/chip-tool/commands/common/Command.cpp",
"${chip_root}/examples/chip-tool/commands/common/Command.h",
"${chip_root}/examples/chip-tool/commands/common/Commands.cpp",
"${chip_root}/examples/chip-tool/commands/common/Commands.h",
"${chip_root}/examples/chip-tool/commands/common/CredentialIssuerCommands.h",
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp",
"commands/clusters/ModelCommand.cpp",
"commands/common/CHIPCommand.cpp",
"commands/common/CHIPCommand.h",
"commands/common/Command.cpp",
"commands/common/Commands.cpp",
"commands/common/CredentialIssuerCommands.h",
"include/CastingServer.h",
"include/TargetEndpointInfo.h",
"include/TargetVideoPlayerInfo.h",
Expand All @@ -51,7 +55,10 @@ chip_data_model("tv-casting-common") {
"src/TargetVideoPlayerInfo.cpp",
]

deps = [ "${chip_root}/third_party/jsoncpp" ]
deps = [
"${chip_root}/src/app/tests/suites/commands/interaction_model",
"${chip_root}/third_party/jsoncpp",
]

if (chip_enable_transport_trace) {
public_deps =
Expand Down

This file was deleted.

Loading

0 comments on commit 77cafa5

Please sign in to comment.