Skip to content

Commit f374193

Browse files
committed
Meter Identification Cluster added
1 parent e8fc667 commit f374193

18 files changed

+1282
-6
lines changed

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

+52
Original file line numberDiff line numberDiff line change
@@ -7036,6 +7036,45 @@ provisional cluster Chime = 1366 {
70367036
command PlayChimeSound(): DefaultSuccess = 0;
70377037
}
70387038

7039+
/** */
7040+
cluster MeterIdentification = 2822 {
7041+
revision 1;
7042+
7043+
enum MeterTypeEnum : enum8 {
7044+
kUtility = 0;
7045+
kPrivate = 1;
7046+
kGeneric = 2;
7047+
}
7048+
7049+
enum PowerThresholdSourceEnum : enum8 {
7050+
kContract = 0;
7051+
kRegulator = 1;
7052+
kEquipment = 2;
7053+
}
7054+
7055+
bitmap Feature : bitmap32 {
7056+
kPowerThreshold = 0x1;
7057+
}
7058+
7059+
struct PowerThresholdStruct {
7060+
optional int64s powerThreshold = 0;
7061+
optional int64s apparentPowerThreshold = 1;
7062+
nullable PowerThresholdSourceEnum powerThresholdSource = 2;
7063+
}
7064+
7065+
readonly attribute nullable MeterTypeEnum meterType = 0;
7066+
readonly attribute nullable char_string<64> pointOfDelivery = 1;
7067+
readonly attribute nullable char_string<64> meterSerialNumber = 2;
7068+
readonly attribute optional nullable char_string<64> protocolVersion = 3;
7069+
readonly attribute optional nullable PowerThresholdStruct powerThreshold = 4;
7070+
readonly attribute command_id generatedCommandList[] = 65528;
7071+
readonly attribute command_id acceptedCommandList[] = 65529;
7072+
readonly attribute event_id eventList[] = 65530;
7073+
readonly attribute attrib_id attributeList[] = 65531;
7074+
readonly attribute bitmap32 featureMap = 65532;
7075+
readonly attribute int16u clusterRevision = 65533;
7076+
}
7077+
70397078
/** The Test Cluster is meant to validate the generated code */
70407079
internal cluster UnitTesting = 4294048773 {
70417080
revision 1; // NOTE: Default/not specifically set
@@ -9326,6 +9365,19 @@ endpoint 1 {
93269365
handle command PlayChimeSound;
93279366
}
93289367

9368+
server cluster MeterIdentification {
9369+
ram attribute meterType;
9370+
ram attribute pointOfDelivery;
9371+
ram attribute meterSerialNumber;
9372+
ram attribute protocolVersion;
9373+
callback attribute powerThreshold;
9374+
callback attribute generatedCommandList;
9375+
callback attribute acceptedCommandList;
9376+
callback attribute attributeList;
9377+
ram attribute featureMap default = 0;
9378+
ram attribute clusterRevision default = 1;
9379+
}
9380+
93299381
server cluster UnitTesting {
93309382
emits event TestEvent;
93319383
emits event TestFabricScopedEvent;

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

+175-5
Original file line numberDiff line numberDiff line change
@@ -20987,7 +20987,7 @@
2098720987
"storageOption": "External",
2098820988
"singleton": 0,
2098920989
"bounded": 0,
20990-
"defaultValue": "",
20990+
"defaultValue": null,
2099120991
"reportable": 1,
2099220992
"minInterval": 1,
2099320993
"maxInterval": 65534,
@@ -21003,7 +21003,7 @@
2100321003
"storageOption": "External",
2100421004
"singleton": 0,
2100521005
"bounded": 0,
21006-
"defaultValue": "",
21006+
"defaultValue": null,
2100721007
"reportable": 1,
2100821008
"minInterval": 1,
2100921009
"maxInterval": 65534,
@@ -21019,7 +21019,7 @@
2101921019
"storageOption": "External",
2102021020
"singleton": 0,
2102121021
"bounded": 0,
21022-
"defaultValue": "",
21022+
"defaultValue": null,
2102321023
"reportable": 1,
2102421024
"minInterval": 1,
2102521025
"maxInterval": 65534,
@@ -21035,7 +21035,7 @@
2103521035
"storageOption": "External",
2103621036
"singleton": 0,
2103721037
"bounded": 0,
21038-
"defaultValue": "",
21038+
"defaultValue": null,
2103921039
"reportable": 1,
2104021040
"minInterval": 1,
2104121041
"maxInterval": 65534,
@@ -21051,7 +21051,7 @@
2105121051
"storageOption": "External",
2105221052
"singleton": 0,
2105321053
"bounded": 0,
21054-
"defaultValue": "",
21054+
"defaultValue": null,
2105521055
"reportable": 1,
2105621056
"minInterval": 1,
2105721057
"maxInterval": 65534,
@@ -21067,12 +21067,182 @@
2106721067
"storageOption": "External",
2106821068
"singleton": 0,
2106921069
"bounded": 0,
21070+
"defaultValue": null,
21071+
"reportable": 1,
21072+
"minInterval": 1,
21073+
"maxInterval": 65534,
21074+
"reportableChange": 0
21075+
},
21076+
{
21077+
"name": "FeatureMap",
21078+
"code": 65532,
21079+
"mfgCode": null,
21080+
"side": "server",
21081+
"type": "bitmap32",
21082+
"included": 1,
21083+
"storageOption": "RAM",
21084+
"singleton": 0,
21085+
"bounded": 0,
21086+
"defaultValue": "0",
21087+
"reportable": 1,
21088+
"minInterval": 1,
21089+
"maxInterval": 65534,
21090+
"reportableChange": 0
21091+
},
21092+
{
21093+
"name": "ClusterRevision",
21094+
"code": 65533,
21095+
"mfgCode": null,
21096+
"side": "server",
21097+
"type": "int16u",
21098+
"included": 1,
21099+
"storageOption": "RAM",
21100+
"singleton": 0,
21101+
"bounded": 0,
21102+
"defaultValue": "1",
21103+
"reportable": 1,
21104+
"minInterval": 1,
21105+
"maxInterval": 65534,
21106+
"reportableChange": 0
21107+
}
21108+
]
21109+
},
21110+
{
21111+
"name": "Meter Identification",
21112+
"code": 2822,
21113+
"mfgCode": null,
21114+
"define": "METER_IDENTIFICATION_CLUSTER",
21115+
"side": "server",
21116+
"enabled": 1,
21117+
"attributes": [
21118+
{
21119+
"name": "MeterType",
21120+
"code": 0,
21121+
"mfgCode": null,
21122+
"side": "server",
21123+
"type": "MeterTypeEnum",
21124+
"included": 1,
21125+
"storageOption": "RAM",
21126+
"singleton": 0,
21127+
"bounded": 0,
21128+
"defaultValue": "",
21129+
"reportable": 1,
21130+
"minInterval": 1,
21131+
"maxInterval": 65534,
21132+
"reportableChange": 0
21133+
},
21134+
{
21135+
"name": "PointOfDelivery",
21136+
"code": 1,
21137+
"mfgCode": null,
21138+
"side": "server",
21139+
"type": "char_string",
21140+
"included": 1,
21141+
"storageOption": "RAM",
21142+
"singleton": 0,
21143+
"bounded": 0,
21144+
"defaultValue": "",
21145+
"reportable": 1,
21146+
"minInterval": 1,
21147+
"maxInterval": 65534,
21148+
"reportableChange": 0
21149+
},
21150+
{
21151+
"name": "MeterSerialNumber",
21152+
"code": 2,
21153+
"mfgCode": null,
21154+
"side": "server",
21155+
"type": "char_string",
21156+
"included": 1,
21157+
"storageOption": "RAM",
21158+
"singleton": 0,
21159+
"bounded": 0,
21160+
"defaultValue": "",
21161+
"reportable": 1,
21162+
"minInterval": 1,
21163+
"maxInterval": 65534,
21164+
"reportableChange": 0
21165+
},
21166+
{
21167+
"name": "ProtocolVersion",
21168+
"code": 3,
21169+
"mfgCode": null,
21170+
"side": "server",
21171+
"type": "char_string",
21172+
"included": 1,
21173+
"storageOption": "RAM",
21174+
"singleton": 0,
21175+
"bounded": 0,
21176+
"defaultValue": "",
21177+
"reportable": 1,
21178+
"minInterval": 1,
21179+
"maxInterval": 65534,
21180+
"reportableChange": 0
21181+
},
21182+
{
21183+
"name": "PowerThreshold",
21184+
"code": 4,
21185+
"mfgCode": null,
21186+
"side": "server",
21187+
"type": "PowerThresholdStruct",
21188+
"included": 1,
21189+
"storageOption": "External",
21190+
"singleton": 0,
21191+
"bounded": 0,
2107021192
"defaultValue": "",
2107121193
"reportable": 1,
2107221194
"minInterval": 1,
2107321195
"maxInterval": 65534,
2107421196
"reportableChange": 0
2107521197
},
21198+
{
21199+
"name": "GeneratedCommandList",
21200+
"code": 65528,
21201+
"mfgCode": null,
21202+
"side": "server",
21203+
"type": "array",
21204+
"included": 1,
21205+
"storageOption": "External",
21206+
"singleton": 0,
21207+
"bounded": 0,
21208+
"defaultValue": null,
21209+
"reportable": 1,
21210+
"minInterval": 1,
21211+
"maxInterval": 65534,
21212+
"reportableChange": 0
21213+
},
21214+
{
21215+
"name": "AcceptedCommandList",
21216+
"code": 65529,
21217+
"mfgCode": null,
21218+
"side": "server",
21219+
"type": "array",
21220+
"included": 1,
21221+
"storageOption": "External",
21222+
"singleton": 0,
21223+
"bounded": 0,
21224+
"defaultValue": null,
21225+
"reportable": 1,
21226+
"minInterval": 1,
21227+
"maxInterval": 65534,
21228+
"reportableChange": 0
21229+
},
21230+
{
21231+
"name": "AttributeList",
21232+
"code": 65531,
21233+
"mfgCode": null,
21234+
"side": "server",
21235+
"type": "array",
21236+
"included": 1,
21237+
"storageOption": "External",
21238+
"singleton": 0,
21239+
"bounded": 0,
21240+
"defaultValue": null,
21241+
"reportable": 1,
21242+
"minInterval": 1,
21243+
"maxInterval": 65534,
21244+
"reportableChange": 0
21245+
},
2107621246
{
2107721247
"name": "FeatureMap",
2107821248
"code": 65532,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
#pragma once
19+
20+
#include <app/clusters/meter-identification-server/meter-identification-server.h>
21+
#include <app/util/af-types.h>
22+
#include <json/value.h>
23+
#include <lib/core/CHIPError.h>
24+
25+
namespace chip {
26+
namespace app {
27+
namespace Clusters {
28+
namespace MeterIdentification {
29+
30+
class MeterIdentificationDelegate : public MeterIdentification::Delegate
31+
{
32+
// Attribute storage
33+
DataModel::Nullable<MeterTypeEnum> mMeterType;
34+
DataModel::Nullable<CharSpan> mPointOfDelivery;
35+
DataModel::Nullable<CharSpan> mMeterSerialNumber;
36+
DataModel::Nullable<CharSpan> mProtocolVersion;
37+
DataModel::Nullable<Structs::PowerThresholdStruct::Type> mPowerThreshold;
38+
39+
private:
40+
41+
static bool NullableCharSpanCompare(const DataModel::Nullable<CharSpan> & a, const DataModel::Nullable<CharSpan> & b);
42+
static CHIP_ERROR NullableCharSpanCopy(const DataModel::Nullable<CharSpan> & src, DataModel::Nullable<CharSpan> & dst);
43+
static CHIP_ERROR JsonToPowerThreshold(const Json::Value & root, Structs::PowerThresholdStruct::Type & value);
44+
45+
public:
46+
47+
virtual ~MeterIdentificationDelegate();
48+
49+
void Init();
50+
51+
CHIP_ERROR LoadJson(const Json::Value & root);
52+
53+
// Attribute Accessors
54+
55+
DataModel::Nullable<MeterTypeEnum> GetMeterType() override { return mMeterType; }
56+
DataModel::Nullable<CharSpan> GetPointOfDelivery() override { return mPointOfDelivery; }
57+
DataModel::Nullable<CharSpan> GetMeterSerialNumber() override { return mMeterSerialNumber; }
58+
DataModel::Nullable<CharSpan> GetProtocolVersion() override { return mProtocolVersion; }
59+
DataModel::Nullable<Structs::PowerThresholdStruct::Type> GetPowerThreshold() override { return mPowerThreshold; }
60+
61+
// Internal Application API to set attribute values
62+
CHIP_ERROR SetMeterType(const DataModel::Nullable<MeterTypeEnum> & value);
63+
CHIP_ERROR SetPointOfDelivery(const DataModel::Nullable<CharSpan> & value);
64+
CHIP_ERROR SetMeterSerialNumber(const DataModel::Nullable<CharSpan> & value);
65+
CHIP_ERROR SetProtocolVersion(const DataModel::Nullable<CharSpan> & value);
66+
CHIP_ERROR SetPowerThreshold(const DataModel::Nullable<Structs::PowerThresholdStruct::Type> & value);
67+
};
68+
69+
class MeterIdentificationInstance : public Instance
70+
{
71+
MeterIdentificationDelegate * mDelegate;
72+
73+
public:
74+
75+
MeterIdentificationInstance(EndpointId aEndpointId, MeterIdentificationDelegate & aDelegate, const Feature & aFeature) :
76+
MeterIdentification::Instance(aEndpointId, aDelegate, aFeature), mDelegate(&aDelegate) {}
77+
78+
// Delete copy constructor and assignment operator.
79+
MeterIdentificationInstance(const MeterIdentificationInstance &) = delete;
80+
MeterIdentificationInstance(const MeterIdentificationInstance &&) = delete;
81+
MeterIdentificationInstance & operator=(const MeterIdentificationInstance &) = delete;
82+
83+
CHIP_ERROR Init();
84+
void Shutdown();
85+
86+
MeterIdentificationDelegate * GetDelegate() { return mDelegate; };
87+
};
88+
89+
MeterIdentificationDelegate * GetDelegate();
90+
91+
} // namespace MeterIdentification
92+
} // namespace Clusters
93+
} // namespace app
94+
} // namespace chip

0 commit comments

Comments
 (0)