Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions: Add generic implementation for the actions cluster. #35568

Merged
merged 25 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1cac8ce
Regenerate zap for actions cluster
jadhavrohit924 Sep 13, 2024
ae306d3
Add generic implementation for action cluster
jadhavrohit924 Sep 13, 2024
5240da9
Example changes
jadhavrohit924 Sep 13, 2024
5a4459c
Add documentation and fix pipeline
jadhavrohit924 Sep 17, 2024
e501d3a
Some example changes
jadhavrohit924 Sep 17, 2024
8c065fd
Add comment about scope of name
jadhavrohit924 Sep 24, 2024
9f5ecff
Restyled by clang-format
restyled-commits Sep 24, 2024
24aa6f8
Add generic struct to copy the ActionStruct and EndpointListStruct al…
jadhavrohit924 Oct 4, 2024
a03eb9c
Address review comments
jadhavrohit924 Oct 7, 2024
aed08c2
Fix CI and apps should use emberAfActionsClusterInitCallback instead …
jadhavrohit924 Oct 10, 2024
520e8d6
Try to fix CI
jadhavrohit924 Oct 20, 2024
91461d9
Address review changes
jadhavrohit924 Dec 19, 2024
f7c8c4c
Change implementation to accomodate actions server on multiple endpoi…
jadhavrohit924 Dec 20, 2024
c402325
Restructured the storage structs, command handler and removed vector …
jadhavrohit924 Dec 24, 2024
ca3b650
Add unit tests for the actions cluster.
jadhavrohit924 Jan 27, 2025
283cfee
Add API to mark dirty attribute and changed delegate impl.
jadhavrohit924 Jan 29, 2025
a15ee11
Addressed review changes.
jadhavrohit924 Jan 31, 2025
d09a5a0
Update the docs, changed API name as suggested, and fix CI for esp32
jadhavrohit924 Feb 3, 2025
3df36ec
Removed the notify delegates API on existing ActionList, EndpointList…
jadhavrohit924 Feb 3, 2025
e24d753
Fix API signature in linux/bridge-app.
jadhavrohit924 Feb 4, 2025
6113905
Removed public MatterContext APIs, added todo to remove global delega…
jadhavrohit924 Feb 11, 2025
bfe646f
Address some minor comments from code review.
jadhavrohit924 Feb 13, 2025
ffca294
Address review comments.
jadhavrohit924 Feb 14, 2025
cc22f3e
Update API docs, command handling to return InvalidCommand, update Mo…
jadhavrohit924 Feb 19, 2025
9ec4acf
Fix clang-tidy validation
jadhavrohit924 Feb 19, 2025
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 @@ -8167,9 +8167,22 @@ endpoint 1 {
server cluster Actions {
callback attribute actionList;
callback attribute endpointLists;
callback attribute setupURL;
ram attribute setupURL default = "https://example.com";
ram attribute featureMap default = 0;
callback attribute clusterRevision default = 1;
ram attribute clusterRevision default = 1;

handle command InstantAction;
handle command InstantActionWithTransition;
handle command StartAction;
handle command StartActionWithDuration;
handle command StopAction;
handle command PauseAction;
handle command PauseActionWithDuration;
handle command ResumeAction;
handle command EnableAction;
handle command EnableActionWithDuration;
handle command DisableAction;
handle command DisableActionWithDuration;
}

server cluster PowerSource {
Expand Down
104 changes: 101 additions & 3 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -7061,6 +7061,104 @@
"define": "ACTIONS_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "InstantAction",
"code": 0,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "InstantActionWithTransition",
"code": 1,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "StartAction",
"code": 2,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "StartActionWithDuration",
"code": 3,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "StopAction",
"code": 4,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "PauseAction",
"code": 5,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "PauseActionWithDuration",
"code": 6,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "ResumeAction",
"code": 7,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "EnableAction",
"code": 8,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "EnableActionWithDuration",
"code": 9,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "DisableAction",
"code": 10,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "DisableActionWithDuration",
"code": 11,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
}
],
"attributes": [
{
"name": "ActionList",
Expand Down Expand Up @@ -7101,10 +7199,10 @@
"side": "server",
"type": "long_char_string",
"included": 1,
"storageOption": "External",
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "https://example.com",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down Expand Up @@ -7133,7 +7231,7 @@
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "External",
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
*
* Copyright (c) 2024 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-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/AttributeAccessInterface.h>
#include <app/AttributeAccessInterfaceRegistry.h>
#include <app/clusters/actions-server/actions-server.h>
#include <app/util/attribute-storage.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <vector>

namespace chip {
namespace app {
namespace Clusters {
namespace Actions {
class ActionsDelegateImpl : public Delegate
{
private:
std::vector<ActionStructStorage> kActionList = {
ActionStructStorage(0, CharSpan::fromCharString("TurnOnLight"), ActionTypeEnum::kScene, 0, 0, ActionStateEnum::kInactive),
ActionStructStorage(1, CharSpan::fromCharString("TurnOffLight"), ActionTypeEnum::kScene, 1, 0, ActionStateEnum::kInactive),
ActionStructStorage(2, CharSpan::fromCharString("ToggleLight"), ActionTypeEnum::kScene, 2, 0, ActionStateEnum::kInactive)
};

std::vector<EndpointId> firstEpList = { 0 };
std::vector<EndpointId> secondEpList = { 0, 1 };
std::vector<EndpointId> thirdEpList = { 1, 2, 3 };

std::vector<EndpointListStorage> kEndpointList = {
EndpointListStorage(0, CharSpan::fromCharString("On"), EndpointListTypeEnum::kOther,
DataModel::List<const EndpointId>(firstEpList.data(), firstEpList.size())),
EndpointListStorage(1, CharSpan::fromCharString("Off"), EndpointListTypeEnum::kOther,
DataModel::List<const EndpointId>(secondEpList.data(), secondEpList.size())),
EndpointListStorage(2, CharSpan::fromCharString("Toggle"), EndpointListTypeEnum::kOther,
DataModel::List<const EndpointId>(thirdEpList.data(), thirdEpList.size()))
};

CHIP_ERROR ReadActionAtIndex(uint16_t index, ActionStructStorage & action) override;
CHIP_ERROR ReadEndpointListAtIndex(uint16_t index, EndpointListStorage & epList) override;
bool HaveActionWithId(uint16_t actionId, uint16_t & actionIndex) override;

Protocols::InteractionModel::Status HandleInstantAction(uint16_t actionId, Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleInstantActionWithTransition(uint16_t actionId, uint16_t transitionTime,
Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleStartAction(uint16_t actionId, Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleStartActionWithDuration(uint16_t actionId, uint32_t duration,
Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleStopAction(uint16_t actionId, Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandlePauseAction(uint16_t actionId, Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandlePauseActionWithDuration(uint16_t actionId, uint32_t duration,
Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleResumeAction(uint16_t actionId, Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleEnableAction(uint16_t actionId, Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleEnableActionWithDuration(uint16_t actionId, uint32_t duration,
Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleDisableAction(uint16_t actionId, Optional<uint32_t> invokeId) override;
Protocols::InteractionModel::Status HandleDisableActionWithDuration(uint16_t actionId, uint32_t duration,
Optional<uint32_t> invokeId) override;
};
} // namespace Actions
} // namespace Clusters
} // namespace app
} // namespace chip
Loading
Loading