Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ void MatterAccessControlClusterInitCallback(chip::EndpointId endpointId);

void MatterAccessControlClusterShutdownCallback(chip::EndpointId endpointId, MatterClusterShutdownType shutdownType);

void MatterActionsClusterInitCallback(chip::EndpointId endpointId);

void MatterActionsClusterShutdownCallback(chip::EndpointId endpointId, MatterClusterShutdownType shutdownType);

void MatterBasicInformationClusterInitCallback(chip::EndpointId endpointId);

void MatterBasicInformationClusterShutdownCallback(chip::EndpointId endpointId, MatterClusterShutdownType shutdownType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ void MatterClusterServerInitCallback(EndpointId endpoint, ClusterId clusterId)
case app::Clusters::AccessControl::Id:
MatterAccessControlClusterInitCallback(endpoint);
break;
case app::Clusters::Actions::Id:
MatterActionsClusterInitCallback(endpoint);
break;
case app::Clusters::BasicInformation::Id:
MatterBasicInformationClusterInitCallback(endpoint);
break;
Expand Down Expand Up @@ -173,6 +176,9 @@ void MatterClusterServerShutdownCallback(EndpointId endpoint, ClusterId clusterI
case app::Clusters::AccessControl::Id:
MatterAccessControlClusterShutdownCallback(endpoint, shutdownType);
break;
case app::Clusters::Actions::Id:
MatterActionsClusterShutdownCallback(endpoint, shutdownType);
break;
case app::Clusters::BasicInformation::Id:
MatterBasicInformationClusterShutdownCallback(endpoint, shutdownType);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ if (chip_build_tests) {
"${chip_root}/src/app/clusters/administrator-commissioning-server/tests",
"${chip_root}/src/app/clusters/air-quality-server/tests",
"${chip_root}/src/app/clusters/basic-information/tests",
"${chip_root}/src/app/clusters/actions-server/tests",
"${chip_root}/src/app/clusters/bindings/tests",
"${chip_root}/src/app/clusters/boolean-state-configuration-server/tests",
"${chip_root}/src/app/clusters/boolean-state-server/tests",
Expand Down Expand Up @@ -153,6 +154,7 @@ if (chip_build_tests) {
if (chip_device_platform == "darwin" || chip_device_platform == "linux") {
tests += [
# keep-sorted: start
"${chip_root}/src/app/clusters/actions-server/tests:tests-backwards-compatibility",
"${chip_root}/src/app/clusters/chime-server/tests:tests-backwards-compatibility",
"${chip_root}/src/app/clusters/device-energy-management-server/tests:tests-backwards-compatibility",
"${chip_root}/src/app/clusters/electrical-energy-measurement-server/tests:tests-backwards-compatibility",
Expand Down
1 change: 1 addition & 0 deletions src/app/clusters/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ source_set("clusters") {
public_deps = [
# keep-sorted: start
"access-control-server",
"actions-server",
"administrator-commissioning-server",
"air-quality-server",
"basic-information",
Expand Down
405 changes: 166 additions & 239 deletions src/app/clusters/actions-server/ActionsCluster.cpp

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions src/app/clusters/actions-server/ActionsCluster.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
*
* Copyright (c) 2026 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.
*/

#pragma once

#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/clusters/actions-server/ActionsDelegate.h>
#include <app/server-cluster/DefaultServerCluster.h>
#include <app/server-cluster/OptionalAttributeSet.h>
#include <clusters/Actions/Attributes.h>
#include <clusters/Actions/Events.h>

namespace chip::app::Clusters {

class ActionsCluster : public DefaultServerCluster
{
public:
using OptionalAttributesSet = OptionalAttributeSet<Actions::Attributes::SetupURL::Id>;

ActionsCluster(EndpointId endpointId, Actions::Delegate & delegate, OptionalAttributesSet optionalAttributes = {},
std::optional<CharSpan> setupURL = std::nullopt) :
DefaultServerCluster({ endpointId, Actions::Id }),
mDelegate(delegate), mOptionalAttributes(optionalAttributes), mSetupURL(setupURL)
{}

~ActionsCluster() = default;

void ActionListModified();

void EndpointListsModified();

/**
* Public helper API for the Application/Delegate to call asynchronously to emit a Matter event to the fabric.
* Use these when an action's state changes or an action fails.
*/
void GenerateEvent(const Actions::Events::StateChanged::Type & event);
void GenerateEvent(const Actions::Events::ActionFailed::Type & event);

DataModel::ActionReturnStatus ReadAttribute(const DataModel::ReadAttributeRequest & request,
AttributeValueEncoder & encoder) override;

std::optional<DataModel::ActionReturnStatus> InvokeCommand(const DataModel::InvokeRequest & request,
chip::TLV::TLVReader & input_arguments,
CommandHandler * handler) override;

CHIP_ERROR Attributes(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<DataModel::AttributeEntry> & builder) override;

CHIP_ERROR AcceptedCommands(const ConcreteClusterPath & path,
ReadOnlyBufferBuilder<DataModel::AcceptedCommandEntry> & builder) override;

private:
Actions::Delegate & mDelegate;
const OptionalAttributesSet mOptionalAttributes;
const std::optional<CharSpan> mSetupURL;

CHIP_ERROR ReadActionListAttribute(const DataModel::ReadAttributeRequest & request,
const AttributeValueEncoder::ListEncodeHelper & aEncoder);

CHIP_ERROR ReadEndpointListAttribute(const DataModel::ReadAttributeRequest & request,
const AttributeValueEncoder::ListEncodeHelper & aEncoder);

Protocols::InteractionModel::Status ValidateActionExists(uint16_t actionID, uint16_t & outActionIndex);

Protocols::InteractionModel::Status ValidateCommandSupported(uint16_t actionIndex, CommandId commandId);
};

} // namespace chip::app::Clusters
6 changes: 2 additions & 4 deletions src/app/clusters/actions-server/ActionsDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
*/

#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/clusters/actions-server/ActionsStructs.h>
#include <clusters/Actions/Commands.h>
#include <lib/core/CHIPError.h>
#include <lib/support/Span.h>

#include "ActionsStructs.h"

namespace chip {
namespace app {
namespace Clusters {
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/actions-server/ActionsStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <clusters/Actions/Structs.h>
#include <lib/support/CodeUtils.h>

namespace chip {
Expand Down
17 changes: 16 additions & 1 deletion src/app/clusters/actions-server/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,20 @@
# 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.
group("actions-server") {
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

static_library("actions-server") {
sources = [
"ActionsCluster.cpp",
"ActionsCluster.h",
"ActionsDelegate.h",
"ActionsStructs.h",
]

public_deps = [
"${chip_root}/src/app/server-cluster",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
]
}
Loading
Loading