Skip to content

Commit

Permalink
Added Clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Dec 21, 2023
1 parent 763424e commit 45bb224
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 209 deletions.
3 changes: 1 addition & 2 deletions examples/tv-casting-app/linux/simple-app-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
#include "simple-app-helper.h"

#include "clusters/ContentLauncherCluster.h"
#include "clusters/MediaPlaybackCluster.h"
#include "clusters/Clusters.h"

#include "app/clusters/bindings/BindingManager.h"
#include <inttypes.h>
Expand Down
7 changes: 2 additions & 5 deletions examples/tv-casting-app/tv-casting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,15 @@ chip_data_model("tv-casting-common") {

# Add simplified casting API files here
sources += [
"clusters/ContentLauncherCluster.cpp",
"clusters/ContentLauncherCluster.h",
"clusters/MediaPlaybackCluster.h",
"clusters/TargetNavigatorCluster.h",
"clusters/Clusters.h",
"core/Attribute.h",
"core/BaseCluster.h",
"core/CastingApp.cpp",
"core/CastingApp.h",
"core/CastingPlayer.cpp",
"core/CastingPlayer.h",
"core/CastingPlayerDiscovery.cpp",
"core/CastingPlayerDiscovery.h",
"core/Cluster.h",
"core/Command.h",
"core/Endpoint.h",
"core/Types.h",
Expand Down
153 changes: 153 additions & 0 deletions examples/tv-casting-app/tv-casting-common/clusters/Clusters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
*
* Copyright (c) 2023 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.
*/

#pragma once

#include "core/Attribute.h"
#include "core/Command.h"
#include "core/Endpoint.h"

namespace matter {
namespace casting {
namespace clusters {
namespace application_basic {
class ApplicationBasicCluster : public core::BaseCluster
{
public:
ApplicationBasicCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up ApplicationBasicCluster on EndpointId: %d", GetEndpoint().lock()->GetId());
}
};
}; // namespace application_basic

namespace application_launcher {
class ApplicationLauncherCluster : public core::BaseCluster
{
public:
ApplicationLauncherCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up ApplicationLauncherCluster on EndpointId: %d", GetEndpoint().lock()->GetId());
}
};
}; // namespace application_launcher

namespace content_launcher {
class ContentLauncherCluster : public core::BaseCluster
{
public:
ContentLauncherCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up ContentLauncherCluster on EndpointId: %d", GetEndpoint().lock()->GetId());

RegisterCommand(chip::app::Clusters::ContentLauncher::Commands::LaunchURL::Id,
new core::Command<chip::app::Clusters::ContentLauncher::Commands::LaunchURL::Type>(GetEndpoint()));
}
};
}; // namespace content_launcher

namespace keypad_input {
class KeypadInputCluster : public core::BaseCluster
{
public:
KeypadInputCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up KeypadInputCluster on EndpointId: %d", GetEndpoint().lock()->GetId());
}
};
}; // namespace keypad_input

namespace level_control {
class LevelControlCluster : public core::BaseCluster
{
public:
LevelControlCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up LevelControlCluster on EndpointId: %d", GetEndpoint().lock()->GetId());
}
};
}; // namespace level_control

namespace media_playback {
class MediaPlaybackCluster : public core::BaseCluster
{
public:
MediaPlaybackCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up MediaPlaybackCluster on EndpointId: %d", GetEndpoint().lock()->GetId());

RegisterAttribute(chip::app::Clusters::MediaPlayback::Attributes::CurrentState::Id,
new core::Attribute<chip::app::Clusters::MediaPlayback::Attributes::CurrentState::TypeInfo>(GetEndpoint()));
}
};
}; // namespace media_playback

namespace on_off {
class OnOffCluster : public core::BaseCluster
{
public:
OnOffCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up OnOffCluster on EndpointId: %d", GetEndpoint().lock()->GetId());
}
};
}; // namespace on_off

namespace target_navigator {
class TargetNavigatorCluster : public core::BaseCluster
{
public:
TargetNavigatorCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up TargetNavigatorCluster on EndpointId: %d", GetEndpoint().lock()->GetId());
}
};
}; // namespace target_navigator

namespace wake_on_lan {
class WakeOnLanCluster : public core::BaseCluster
{
public:
WakeOnLanCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

void SetUp()
{
ChipLogProgress(AppServer, "Setting up WakeOnLanCluster on EndpointId: %d", GetEndpoint().lock()->GetId());
}
};
}; // namespace wake_on_lan

}; // namespace clusters
}; // namespace casting
}; // namespace matter

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions examples/tv-casting-app/tv-casting-common/core/Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#pragma once

#include "Cluster.h"
#include "BaseCluster.h"
#include "Types.h"

#include "core/Command.h"
Expand Down Expand Up @@ -233,7 +233,8 @@ class Attribute
if (endpoint)
{
SubscribeAttributeContext<typename TypeInfo::DecodableArgType> * attributeContext =
new SubscribeAttributeContext<typename TypeInfo::DecodableArgType>(this, endpoint, context, successCb, failureCb, minIntervalFloorSeconds, maxIntervalCeilingSeconds);
new SubscribeAttributeContext<typename TypeInfo::DecodableArgType>(
this, endpoint, context, successCb, failureCb, minIntervalFloorSeconds, maxIntervalCeilingSeconds);

endpoint->GetCastingPlayer()->FindOrEstablishSession(
attributeContext,
Expand Down
Loading

0 comments on commit 45bb224

Please sign in to comment.