Skip to content

Commit d9aa826

Browse files
pjzander-signifypull[bot]
authored andcommitted
Use of external storage in Bridged Actions cluster (#11381)
* Use of external storage in Bridged Actions cluster * Processing review comments
1 parent fa1a5c4 commit d9aa826

File tree

5 files changed

+308
-333
lines changed

5 files changed

+308
-333
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

+5-5
Original file line numberDiff line numberDiff line change
@@ -8005,7 +8005,7 @@
80058005
"mfgCode": null,
80068006
"side": "server",
80078007
"included": 1,
8008-
"storageOption": "RAM",
8008+
"storageOption": "External",
80098009
"singleton": 0,
80108010
"bounded": 0,
80118011
"defaultValue": "",
@@ -8020,7 +8020,7 @@
80208020
"mfgCode": null,
80218021
"side": "server",
80228022
"included": 1,
8023-
"storageOption": "RAM",
8023+
"storageOption": "External",
80248024
"singleton": 0,
80258025
"bounded": 0,
80268026
"defaultValue": "",
@@ -8035,10 +8035,10 @@
80358035
"mfgCode": null,
80368036
"side": "server",
80378037
"included": 1,
8038-
"storageOption": "RAM",
8038+
"storageOption": "External",
80398039
"singleton": 0,
80408040
"bounded": 0,
8041-
"defaultValue": "www.signify.com",
8041+
"defaultValue": "",
80428042
"reportable": 0,
80438043
"minInterval": 0,
80448044
"maxInterval": 65344,
@@ -8050,7 +8050,7 @@
80508050
"mfgCode": null,
80518051
"side": "server",
80528052
"included": 1,
8053-
"storageOption": "RAM",
8053+
"storageOption": "External",
80548054
"singleton": 0,
80558055
"bounded": 0,
80568056
"defaultValue": "1",

examples/all-clusters-app/linux/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import("//build_overrides/chip.gni")
1717

1818
executable("chip-all-clusters-app") {
1919
sources = [
20+
"include/bridged-actions-stub.cpp",
2021
"include/tv-callbacks.cpp",
2122
"main.cpp",
2223
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include <app-common/zap-generated/af-structs.h>
19+
#include <app-common/zap-generated/cluster-objects.h>
20+
#include <app-common/zap-generated/ids/Attributes.h>
21+
#include <app-common/zap-generated/ids/Clusters.h>
22+
#include <app/AttributeAccessInterface.h>
23+
#include <app/util/attribute-storage.h>
24+
#include <lib/support/CodeUtils.h>
25+
#include <lib/support/logging/CHIPLogging.h>
26+
27+
using namespace chip;
28+
using namespace chip::app;
29+
using namespace chip::app::Clusters;
30+
using namespace chip::app::Clusters::BridgedActions::Attributes;
31+
32+
namespace {
33+
34+
class BridgedActionsAttrAccess : public AttributeAccessInterface
35+
{
36+
public:
37+
// Register for the Bridged Actions cluster on all endpoints.
38+
BridgedActionsAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), BridgedActions::Id) {}
39+
40+
CHIP_ERROR Read(const ConcreteAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
41+
42+
private:
43+
static constexpr uint16_t ClusterRevision = 1;
44+
45+
CHIP_ERROR ReadActionListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder);
46+
CHIP_ERROR ReadEndpointListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder);
47+
CHIP_ERROR ReadSetupUrlAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder);
48+
CHIP_ERROR ReadClusterRevision(EndpointId endpoint, AttributeValueEncoder & aEncoder);
49+
};
50+
51+
CHIP_ERROR BridgedActionsAttrAccess::ReadActionListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder)
52+
{
53+
// Just return an empty list
54+
return aEncoder.Encode(DataModel::List<BridgedActions::Structs::ActionStruct::Type>());
55+
}
56+
57+
CHIP_ERROR BridgedActionsAttrAccess::ReadEndpointListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder)
58+
{
59+
// Just return an empty list
60+
return aEncoder.Encode(DataModel::List<BridgedActions::Structs::EndpointListStruct::Type>());
61+
}
62+
63+
CHIP_ERROR BridgedActionsAttrAccess::ReadSetupUrlAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder)
64+
{
65+
const char SetupUrl[] = "https://example.com";
66+
return aEncoder.Encode(chip::Span<const char>(SetupUrl, strlen(SetupUrl)));
67+
}
68+
69+
CHIP_ERROR BridgedActionsAttrAccess::ReadClusterRevision(EndpointId endpoint, AttributeValueEncoder & aEncoder)
70+
{
71+
return aEncoder.Encode(ClusterRevision);
72+
}
73+
74+
BridgedActionsAttrAccess gAttrAccess;
75+
76+
CHIP_ERROR BridgedActionsAttrAccess::Read(const ConcreteAttributePath & aPath, AttributeValueEncoder & aEncoder)
77+
{
78+
VerifyOrDie(aPath.mClusterId == BridgedActions::Id);
79+
80+
switch (aPath.mAttributeId)
81+
{
82+
case ActionList::Id:
83+
return ReadActionListAttribute(aPath.mEndpointId, aEncoder);
84+
case EndpointList::Id:
85+
return ReadEndpointListAttribute(aPath.mEndpointId, aEncoder);
86+
case SetupUrl::Id:
87+
return ReadSetupUrlAttribute(aPath.mEndpointId, aEncoder);
88+
case ClusterRevision::Id:
89+
return ReadClusterRevision(aPath.mEndpointId, aEncoder);
90+
default:
91+
break;
92+
}
93+
return CHIP_NO_ERROR;
94+
}
95+
} // anonymous namespace
96+
97+
void MatterBridgedActionsPluginServerInitCallback(void)
98+
{
99+
registerAttributeAccessOverride(&gAttrAccess);
100+
}

src/controller/data_model/controller-clusters.zap

+5-5
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@
14811481
"mfgCode": null,
14821482
"side": "server",
14831483
"included": 1,
1484-
"storageOption": "RAM",
1484+
"storageOption": "External",
14851485
"singleton": 0,
14861486
"bounded": 0,
14871487
"defaultValue": "",
@@ -1496,7 +1496,7 @@
14961496
"mfgCode": null,
14971497
"side": "server",
14981498
"included": 1,
1499-
"storageOption": "RAM",
1499+
"storageOption": "External",
15001500
"singleton": 0,
15011501
"bounded": 0,
15021502
"defaultValue": "",
@@ -1511,10 +1511,10 @@
15111511
"mfgCode": null,
15121512
"side": "server",
15131513
"included": 1,
1514-
"storageOption": "RAM",
1514+
"storageOption": "External",
15151515
"singleton": 0,
15161516
"bounded": 0,
1517-
"defaultValue": "www.signify.com",
1517+
"defaultValue": "",
15181518
"reportable": 0,
15191519
"minInterval": 0,
15201520
"maxInterval": 65344,
@@ -1526,7 +1526,7 @@
15261526
"mfgCode": null,
15271527
"side": "server",
15281528
"included": 1,
1529-
"storageOption": "RAM",
1529+
"storageOption": "External",
15301530
"singleton": 0,
15311531
"bounded": 0,
15321532
"defaultValue": "1",

0 commit comments

Comments
 (0)