Skip to content

Commit cc5b41a

Browse files
hastyrobszewczyk
andauthored
[Feature] Power Topology server & all-clusters-app stub (#31783)
* Initial XML for Power Topology cluster * Regen * Restyled really wants newlines at the end of every JSON file * Rename LeafTopology to TreeTopology * [Feature] Power Topology server & all-clusters-app stub * Make endpointId a constructor arg for PowerTopologyDelegate * Change PowerTopologyDelegate to not return std::vectors * Remove unneeded entries in attributeAccessInterfaceAttributes for Power Topology cluster * Typo in python/chip/clusters/__init__.py * Format zcl.json * Add DynamicPowerFlow feature to PowerTopology stub * Updates based on comments * Remove unneeded using from power-topology-server.h * Regen * Regen * Undo submodule changes --------- Co-authored-by: Robert Szewczyk <szewczyk@google.com>
1 parent 077d4fc commit cc5b41a

File tree

18 files changed

+521
-45
lines changed

18 files changed

+521
-45
lines changed

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

+32
Original file line numberDiff line numberDiff line change
@@ -4455,6 +4455,27 @@ provisional cluster EnergyEvse = 153 {
44554455
timed command ClearTargets(): DefaultSuccess = 7;
44564456
}
44574457

4458+
/** The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints. */
4459+
provisional cluster PowerTopology = 156 {
4460+
revision 1;
4461+
4462+
bitmap Feature : bitmap32 {
4463+
kNodeTopology = 0x1;
4464+
kTreeTopology = 0x2;
4465+
kSetTopology = 0x4;
4466+
kDynamicPowerFlow = 0x8;
4467+
}
4468+
4469+
readonly attribute optional endpoint_no availableEndpoints[] = 0;
4470+
readonly attribute optional endpoint_no activeEndpoints[] = 1;
4471+
readonly attribute command_id generatedCommandList[] = 65528;
4472+
readonly attribute command_id acceptedCommandList[] = 65529;
4473+
readonly attribute event_id eventList[] = 65530;
4474+
readonly attribute attrib_id attributeList[] = 65531;
4475+
readonly attribute bitmap32 featureMap = 65532;
4476+
readonly attribute int16u clusterRevision = 65533;
4477+
}
4478+
44584479
/** Attributes and commands for selecting a mode from a list of supported options. */
44594480
provisional cluster EnergyEvseMode = 157 {
44604481
revision 1;
@@ -8340,6 +8361,17 @@ endpoint 1 {
83408361
handle command ClearTargets;
83418362
}
83428363

8364+
server cluster PowerTopology {
8365+
callback attribute availableEndpoints;
8366+
callback attribute activeEndpoints;
8367+
callback attribute generatedCommandList;
8368+
callback attribute acceptedCommandList;
8369+
callback attribute eventList;
8370+
callback attribute attributeList;
8371+
callback attribute featureMap;
8372+
ram attribute clusterRevision default = 1;
8373+
}
8374+
83438375
server cluster EnergyEvseMode {
83448376
callback attribute supportedModes;
83458377
callback attribute currentMode;

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

+138
Original file line numberDiff line numberDiff line change
@@ -14240,6 +14240,144 @@
1424014240
}
1424114241
]
1424214242
},
14243+
{
14244+
"name": "Power Topology",
14245+
"code": 156,
14246+
"mfgCode": null,
14247+
"define": "POWER_TOPOLOGY_CLUSTER",
14248+
"side": "server",
14249+
"enabled": 1,
14250+
"attributes": [
14251+
{
14252+
"name": "AvailableEndpoints",
14253+
"code": 0,
14254+
"mfgCode": null,
14255+
"side": "server",
14256+
"type": "array",
14257+
"included": 1,
14258+
"storageOption": "External",
14259+
"singleton": 0,
14260+
"bounded": 0,
14261+
"defaultValue": null,
14262+
"reportable": 1,
14263+
"minInterval": 1,
14264+
"maxInterval": 65534,
14265+
"reportableChange": 0
14266+
},
14267+
{
14268+
"name": "ActiveEndpoints",
14269+
"code": 1,
14270+
"mfgCode": null,
14271+
"side": "server",
14272+
"type": "array",
14273+
"included": 1,
14274+
"storageOption": "External",
14275+
"singleton": 0,
14276+
"bounded": 0,
14277+
"defaultValue": null,
14278+
"reportable": 1,
14279+
"minInterval": 1,
14280+
"maxInterval": 65534,
14281+
"reportableChange": 0
14282+
},
14283+
{
14284+
"name": "GeneratedCommandList",
14285+
"code": 65528,
14286+
"mfgCode": null,
14287+
"side": "server",
14288+
"type": "array",
14289+
"included": 1,
14290+
"storageOption": "External",
14291+
"singleton": 0,
14292+
"bounded": 0,
14293+
"defaultValue": null,
14294+
"reportable": 1,
14295+
"minInterval": 1,
14296+
"maxInterval": 65534,
14297+
"reportableChange": 0
14298+
},
14299+
{
14300+
"name": "AcceptedCommandList",
14301+
"code": 65529,
14302+
"mfgCode": null,
14303+
"side": "server",
14304+
"type": "array",
14305+
"included": 1,
14306+
"storageOption": "External",
14307+
"singleton": 0,
14308+
"bounded": 0,
14309+
"defaultValue": null,
14310+
"reportable": 1,
14311+
"minInterval": 1,
14312+
"maxInterval": 65534,
14313+
"reportableChange": 0
14314+
},
14315+
{
14316+
"name": "EventList",
14317+
"code": 65530,
14318+
"mfgCode": null,
14319+
"side": "server",
14320+
"type": "array",
14321+
"included": 1,
14322+
"storageOption": "External",
14323+
"singleton": 0,
14324+
"bounded": 0,
14325+
"defaultValue": null,
14326+
"reportable": 1,
14327+
"minInterval": 1,
14328+
"maxInterval": 65534,
14329+
"reportableChange": 0
14330+
},
14331+
{
14332+
"name": "AttributeList",
14333+
"code": 65531,
14334+
"mfgCode": null,
14335+
"side": "server",
14336+
"type": "array",
14337+
"included": 1,
14338+
"storageOption": "External",
14339+
"singleton": 0,
14340+
"bounded": 0,
14341+
"defaultValue": null,
14342+
"reportable": 1,
14343+
"minInterval": 1,
14344+
"maxInterval": 65534,
14345+
"reportableChange": 0
14346+
},
14347+
{
14348+
"name": "FeatureMap",
14349+
"code": 65532,
14350+
"mfgCode": null,
14351+
"side": "server",
14352+
"type": "bitmap32",
14353+
"included": 1,
14354+
"storageOption": "External",
14355+
"singleton": 0,
14356+
"bounded": 0,
14357+
"defaultValue": null,
14358+
"reportable": 1,
14359+
"minInterval": 1,
14360+
"maxInterval": 65534,
14361+
"reportableChange": 0
14362+
},
14363+
{
14364+
"name": "ClusterRevision",
14365+
"code": 65533,
14366+
"mfgCode": null,
14367+
"side": "server",
14368+
"type": "int16u",
14369+
"included": 1,
14370+
"storageOption": "RAM",
14371+
"singleton": 0,
14372+
"bounded": 0,
14373+
"defaultValue": "1",
14374+
"reportable": 1,
14375+
"minInterval": 1,
14376+
"maxInterval": 65534,
14377+
"reportableChange": 0
14378+
}
14379+
]
14380+
},
1424314381
{
1424414382
"name": "Energy EVSE Mode",
1424514383
"code": 157,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <app/clusters/power-topology-server/power-topology-server.h>
20+
21+
using namespace chip;
22+
using namespace chip::app::Clusters;
23+
using namespace chip::app::Clusters::PowerTopology;
24+
25+
namespace chip {
26+
namespace app {
27+
namespace Clusters {
28+
namespace PowerTopology {
29+
30+
class PowerTopologyDelegate : public Delegate
31+
{
32+
public:
33+
~PowerTopologyDelegate() = default;
34+
35+
CHIP_ERROR GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId) override;
36+
CHIP_ERROR GetActiveEndpointAtIndex(size_t index, EndpointId & endpointId) override;
37+
};
38+
39+
CHIP_ERROR PowerTopologyDelegate::GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId)
40+
{
41+
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
42+
}
43+
44+
CHIP_ERROR PowerTopologyDelegate::GetActiveEndpointAtIndex(size_t index, EndpointId & endpointId)
45+
{
46+
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
47+
}
48+
49+
} // namespace PowerTopology
50+
} // namespace Clusters
51+
} // namespace app
52+
} // namespace chip
53+
54+
static std::unique_ptr<PowerTopology::Delegate> gDelegate;
55+
static std::unique_ptr<PowerTopology::Instance> gInstance;
56+
57+
void emberAfPowerTopologyClusterInitCallback(chip::EndpointId endpointId)
58+
{
59+
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
60+
VerifyOrDie(!gInstance);
61+
62+
gDelegate = std::make_unique<PowerTopologyDelegate>();
63+
if (gDelegate)
64+
{
65+
gInstance = std::make_unique<Instance>(
66+
endpointId, *gDelegate, BitMask<Feature, uint32_t>(Feature::kSetTopology, Feature::kDynamicPowerFlow),
67+
BitMask<OptionalAttributes, uint32_t>(OptionalAttributes::kOptionalAttributeAvailableEndpoints,
68+
OptionalAttributes::kOptionalAttributeActiveEndpoints));
69+
70+
gInstance->Init();
71+
}
72+
}

examples/all-clusters-app/esp32/main/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ set(SRC_DIRS_LIST
9090
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/pump-configuration-and-control-server"
9191
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server"
9292
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-server"
93+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-topology-server"
9394
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/resource-monitoring-server"
9495
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/temperature-control-server"
9596
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-synchronization-server"

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

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ source_set("chip-all-clusters-common") {
4848
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp",
4949
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp",
5050
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp",
51+
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/power-topology-stub.cpp",
5152
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp",
5253
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp",
5354
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/rvc-operational-state-delegate-impl.cpp",

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

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ source_set("chip-all-clusters-common") {
3333
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp",
3434
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp",
3535
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp",
36+
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/power-topology-stub.cpp",
3637
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp",
3738
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp",
3839
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",

0 commit comments

Comments
 (0)