Skip to content

Commit 6efd031

Browse files
Add Meter Identification cluster
1 parent 60ae46d commit 6efd031

File tree

13 files changed

+661
-0
lines changed

13 files changed

+661
-0
lines changed

.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ jobs:
202202
src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml \
203203
src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml \
204204
src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml \
205+
src/app/zap-templates/zcl/data-model/chip/meter-identification-cluster.xml \
205206
"
206207
- name: Build Apps
207208
run: |
+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (C) Connectivity Standards Alliance (2023). All rights reserved.
4+
The information within this document is the property of the Connectivity
5+
Standards Alliance and its use and disclosure are restricted, except as
6+
expressly set forth herein.
7+
8+
Connectivity Standards Alliance hereby grants you a fully-paid, non-exclusive,
9+
nontransferable, worldwide, limited and revocable license (without the right to
10+
sublicense), under Connectivity Standards Alliance's applicable copyright
11+
rights, to view, download, save, reproduce and use the document solely for your
12+
own internal purposes and in accordance with the terms of the license set forth
13+
herein. This license does not authorize you to, and you expressly warrant that
14+
you shall not: (a) permit others (outside your organization) to use this
15+
document; (b) post or publish this document; (c) modify, adapt, translate, or
16+
otherwise change this document in any manner or create any derivative work
17+
based on this document; (d) remove or modify any notice or label on this
18+
document, including this Copyright Notice, License and Disclaimer. The
19+
Connectivity Standards Alliance does not grant you any license hereunder other
20+
than as expressly stated herein.
21+
22+
Elements of this document may be subject to third party intellectual property
23+
rights, including without limitation, patent, copyright or trademark rights,
24+
and any such third party may or may not be a member of the Connectivity
25+
Standards Alliance. Connectivity Standards Alliance members grant other
26+
Connectivity Standards Alliance members certain intellectual property rights as
27+
set forth in the Connectivity Standards Alliance IPR Policy. Connectivity
28+
Standards Alliance members do not grant you any rights under this license. The
29+
Connectivity Standards Alliance is not responsible for, and shall not be held
30+
responsible in any manner for, identifying or failing to identify any or all
31+
such third party intellectual property rights. Please visit www.csa-iot.org for
32+
more information on how to become a member of the Connectivity Standards
33+
Alliance.
34+
35+
This document and the information contained herein are provided on an “AS IS”
36+
basis and the Connectivity Standards Alliance DISCLAIMS ALL WARRANTIES EXPRESS
37+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO (A) ANY WARRANTY THAT THE USE OF THE
38+
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OF THIRD PARTIES (INCLUDING
39+
WITHOUT LIMITATION ANY INTELLECTUAL PROPERTY RIGHTS INCLUDING PATENT, COPYRIGHT
40+
OR TRADEMARK RIGHTS); OR (B) ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
41+
FOR A PARTICULAR PURPOSE, TITLE OR NONINFRINGEMENT. IN NO EVENT WILL THE
42+
CONNECTIVITY STANDARDS ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF
43+
BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR ANY OTHER
44+
DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
45+
DAMAGES OF ANY KIND, IN CONTRACT OR IN TORT, IN CONNECTION WITH THIS DOCUMENT
46+
OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
47+
LOSS OR DAMAGE.
48+
49+
All company, brand and product names in this document may be trademarks that
50+
are the sole property of their respective owners.
51+
52+
This notice and disclaimer must be included on all copies of this document.
53+
54+
Connectivity Standards Alliance
55+
508 Second Street, Suite 206
56+
Davis, CA 95616, USA
57+
58+
:xrefstyle: short
59+
-->
60+
<cluster xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="types types.xsd cluster cluster.xsd" id="0x0B01" name="Meter Identification" revision="1">
61+
<revisionHistory>
62+
<revision revision="1" summary="Initial version"/>
63+
</revisionHistory>
64+
<clusterIds>
65+
<clusterId id="0x0B01" name="Meter Identification"/>
66+
</clusterIds>
67+
<classification hierarchy="base" role="application" picsCode="MTRID" scope="Endpoint"/>
68+
<features>
69+
<feature bit="0" code="PWRTHLD" name="PowerThreshold" summary="Supports information about power threshold">
70+
<optionalConform/>
71+
</feature>
72+
</features>
73+
<dataTypes>
74+
<enum name="MeterTypeEnum">
75+
<item value="0" name="Utility" summary="Utility Meter">
76+
<mandatoryConform/>
77+
</item>
78+
<item value="1" name="Private" summary="Private Meter">
79+
<mandatoryConform/>
80+
</item>
81+
<item value="2" name="Generic" summary="Generic Meter">
82+
<mandatoryConform/>
83+
</item>
84+
</enum>
85+
<enum name="PowerThresholdSourceEnum">
86+
<item value="0" name="Contract" summary="The value comes from a signed contract">
87+
<mandatoryConform/>
88+
</item>
89+
<item value="1" name="Regulator" summary="The value comes from a legal regulator">
90+
<mandatoryConform/>
91+
</item>
92+
<item value="2" name="Equipment" summary="The value comes from a certified limits of the meter">
93+
<mandatoryConform/>
94+
</item>
95+
</enum>
96+
</dataTypes>
97+
<attributes>
98+
<attribute id="0x0000" name="MeterType" type="MeterTypeEnum" default="null">
99+
<access read="true" readPrivilege="view"/>
100+
<mandatoryConform/>
101+
</attribute>
102+
<attribute id="0x0001" name="CustomerName" type="string" default="null">
103+
<access read="true" write="true" readPrivilege="view" writePrivilege="operate"/>
104+
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/>
105+
<mandatoryConform/>
106+
<constraint type="maxLength" value="64"/>
107+
</attribute>
108+
<attribute id="0x0002" name="UtilityName" type="string" default="null">
109+
<access read="true" readPrivilege="view" />
110+
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/>
111+
<mandatoryConform/>
112+
<constraint type="maxLength" value="16"/>
113+
</attribute>
114+
<attribute id="0x0003" name="PointOfDelivery" type="string" default="null">
115+
<access read="true" readPrivilege="view" />
116+
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/>
117+
<mandatoryConform/>
118+
<constraint type="maxLength" value="16"/>
119+
</attribute>
120+
<attribute id="0x0004" name="PowerThreshold" type="power-mW" default="null">
121+
<access read="true" readPrivilege="view"/>
122+
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/>
123+
<mandatoryConform>
124+
<feature name="PWRTHLD"/>
125+
</mandatoryConform>
126+
</attribute>
127+
<attribute id="0x0005" name="PowerThresholdSource" type="PowerThresholdSourceEnum" default="null">
128+
<access read="true" readPrivilege="view"/>
129+
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/>
130+
<mandatoryConform>
131+
<feature name="PWRTHLD"/>
132+
</mandatoryConform>
133+
</attribute>
134+
</attributes>
135+
</cluster>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 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 <MeterIdentificationDelegate.h>
20+
21+
using namespace chip;
22+
using namespace chip::app::Clusters;
23+
using namespace chip::app::Clusters::MeterIdentification;
24+
25+
static std::unique_ptr<MeterIdentificationDelegate> gMIDelegate;
26+
static std::unique_ptr<MeterIdentificationInstance> gMIInstance;
27+
28+
void emberAfMeterIdentificationClusterInitCallback(chip::EndpointId endpointId)
29+
{
30+
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
31+
VerifyOrDie(!gMIInstance);
32+
33+
gMIDelegate = std::make_unique<MeterIdentificationDelegate>();
34+
if (gMIDelegate)
35+
{
36+
gMIInstance = std::make_unique<MeterIdentificationInstance>(
37+
endpointId, *gMIDelegate,
38+
BitMask<Feature, uint32_t>(Feature::kPowerThreshold));
39+
40+
gMIInstance->Init();
41+
42+
gMIDelegate->SetPowerMode(PowerModeEnum::kAc);
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 <lib/core/CHIPError.h>
23+
24+
namespace chip {
25+
namespace app {
26+
namespace Clusters {
27+
namespace MeterIdentification {
28+
29+
class MeterIdentificationDelegate : public MeterIdentification::Delegate
30+
{
31+
public:
32+
~MeterIdentificationDelegate() = default;
33+
34+
// Attribute Accessors
35+
36+
DataModel::Nullable<MeterTypeEnum> GetMeterType() override { return mMeterType; };
37+
CharSpan GetCustomerName() override { return mCustomerName; };
38+
CharSpan GetUtilityName() override { return mUtilityName; };
39+
CharSpan GetPointOfDelivery() override { return mPointOfDelivery; };
40+
DataModel::Nullable<uint64_t> GetPowerThreshold() override { return mPowerThreshold; };
41+
DataModel::Nullable<PowerThresholdSourceEnum> GetPowerThresholdSource() override { return mPowerThresholdSource; };
42+
43+
CHIP_ERROR SetCustomerName(CharSpan &value) override;
44+
45+
// Internal Application API to set attribute values
46+
CHIP_ERROR SetMeterType(DataModel::Nullable<MeterTypeEnum>);
47+
CHIP_ERROR SetUtilityName(CharSpan &value);
48+
CHIP_ERROR SetPointOfDelivery(CharSpan &value);
49+
CHIP_ERROR GetPowerThreshold(DataModel::Nullable<uint64_t>);
50+
CHIP_ERROR GetPowerThresholdSource(DataModel::Nullable<PowerThresholdSourceEnum>);
51+
52+
private:
53+
// Attribute storage
54+
DataModel::Nullable<MeterTypeEnum> mMeterType;
55+
CharSpan mCustomerName;
56+
CharSpan mUtilityName;
57+
CharSpan mPointOfDelivery;
58+
DataModel::Nullable<uint64_t> mPowerThreshold;
59+
DataModel::Nullable<PowerThresholdSourceEnum> mPowerThresholdSource;
60+
};
61+
62+
class MeterIdentificationInstance : public Instance
63+
{
64+
public:
65+
MeterIdentificationInstance(EndpointId aEndpointId, MeterIdentificationDelegate & aDelegate, Feature aFeature) :
66+
MeterIdentification::Instance(aEndpointId, aDelegate, aFeature)
67+
{
68+
mDelegate = &aDelegate;
69+
}
70+
71+
// Delete copy constructor and assignment operator.
72+
MeterIdentificationInstance(const MeterIdentificationInstance &) = delete;
73+
MeterIdentificationInstance(const MeterIdentificationInstance &&) = delete;
74+
MeterIdentificationInstance & operator=(const MeterIdentificationInstance &) = delete;
75+
76+
CHIP_ERROR Init();
77+
void Shutdown();
78+
79+
MeterIdentificationDelegate * GetDelegate() { return mDelegate; };
80+
81+
private:
82+
MeterIdentificationDelegate * mDelegate;
83+
};
84+
85+
} // namespace MeterIdentification
86+
} // namespace Clusters
87+
} // namespace app
88+
} // namespace chip

0 commit comments

Comments
 (0)