-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add Meter Identification cluster #33922
Closed
Michail-Antropov
wants to merge
8
commits into
project-chip:master
from
Michail-Antropov:meter_identification
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6efd031
Add Meter Identification cluster
Michail-Antropov abbe8ab
Fix build errors
Michail-Antropov 6729164
Restyled by clang-format
restyled-commits f79c1e1
Update generated files
Michail-Antropov b663c8e
Fix build cpp errors
Michail-Antropov 26e94b4
Update darwin and java generated files
Michail-Antropov c9bdb57
Restyled by whitespace
restyled-commits bf1ae81
Restyled by prettier-json
restyled-commits File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
Copyright (C) Connectivity Standards Alliance (2024). All rights reserved. | ||
The information within this document is the property of the Connectivity | ||
Standards Alliance and its use and disclosure are restricted, except as | ||
expressly set forth herein. | ||
|
||
Connectivity Standards Alliance hereby grants you a fully-paid, non-exclusive, | ||
nontransferable, worldwide, limited and revocable license (without the right to | ||
sublicense), under Connectivity Standards Alliance's applicable copyright | ||
rights, to view, download, save, reproduce and use the document solely for your | ||
own internal purposes and in accordance with the terms of the license set forth | ||
herein. This license does not authorize you to, and you expressly warrant that | ||
you shall not: (a) permit others (outside your organization) to use this | ||
document; (b) post or publish this document; (c) modify, adapt, translate, or | ||
otherwise change this document in any manner or create any derivative work | ||
based on this document; (d) remove or modify any notice or label on this | ||
document, including this Copyright Notice, License and Disclaimer. The | ||
Connectivity Standards Alliance does not grant you any license hereunder other | ||
than as expressly stated herein. | ||
|
||
Elements of this document may be subject to third party intellectual property | ||
rights, including without limitation, patent, copyright or trademark rights, | ||
and any such third party may or may not be a member of the Connectivity | ||
Standards Alliance. Connectivity Standards Alliance members grant other | ||
Connectivity Standards Alliance members certain intellectual property rights as | ||
set forth in the Connectivity Standards Alliance IPR Policy. Connectivity | ||
Standards Alliance members do not grant you any rights under this license. The | ||
Connectivity Standards Alliance is not responsible for, and shall not be held | ||
responsible in any manner for, identifying or failing to identify any or all | ||
such third party intellectual property rights. Please visit www.csa-iot.org for | ||
more information on how to become a member of the Connectivity Standards | ||
Alliance. | ||
|
||
This document and the information contained herein are provided on an “AS IS” | ||
basis and the Connectivity Standards Alliance DISCLAIMS ALL WARRANTIES EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO (A) ANY WARRANTY THAT THE USE OF THE | ||
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OF THIRD PARTIES (INCLUDING | ||
WITHOUT LIMITATION ANY INTELLECTUAL PROPERTY RIGHTS INCLUDING PATENT, COPYRIGHT | ||
OR TRADEMARK RIGHTS); OR (B) ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE, TITLE OR NONINFRINGEMENT. IN NO EVENT WILL THE | ||
CONNECTIVITY STANDARDS ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF | ||
BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR ANY OTHER | ||
DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL | ||
DAMAGES OF ANY KIND, IN CONTRACT OR IN TORT, IN CONNECTION WITH THIS DOCUMENT | ||
OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
LOSS OR DAMAGE. | ||
|
||
All company, brand and product names in this document may be trademarks that | ||
are the sole property of their respective owners. | ||
|
||
This notice and disclaimer must be included on all copies of this document. | ||
|
||
Connectivity Standards Alliance | ||
508 Second Street, Suite 206 | ||
Davis, CA 95616, USA | ||
|
||
:xrefstyle: short | ||
--> | ||
<cluster xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="types types.xsd cluster cluster.xsd" id="0x0B01" name="Meter Identification Cluster" revision="1"> | ||
<revisionHistory> | ||
<revision revision="1" summary="Initial version"/> | ||
</revisionHistory> | ||
<clusterIds> | ||
<clusterId id="0x0B01" name="Meter Identification"/> | ||
</clusterIds> | ||
<classification hierarchy="base" role="application" picsCode="MTRID" scope="Endpoint"/> | ||
<features> | ||
<feature bit="0" code="PWRTHLD" name="PowerThreshold" summary="Supports information about power threshold"> | ||
<optionalConform/> | ||
</feature> | ||
</features> | ||
<dataTypes> | ||
<enum name="MeterTypeEnum"> | ||
<item value="0" name="Utility" summary="Utility Meter"> | ||
<mandatoryConform/> | ||
</item> | ||
<item value="1" name="Private" summary="Private Meter"> | ||
<mandatoryConform/> | ||
</item> | ||
<item value="2" name="Generic" summary="Generic Meter"> | ||
<mandatoryConform/> | ||
</item> | ||
</enum> | ||
<enum name="PowerThresholdSourceEnum"> | ||
<item value="0" name="Contract" summary="The value comes from a signed contract"> | ||
<mandatoryConform/> | ||
</item> | ||
<item value="1" name="Regulator" summary="The value comes from a legal regulator"> | ||
<mandatoryConform/> | ||
</item> | ||
<item value="2" name="Equipment" summary="The value comes from a certified limits of the meter"> | ||
<mandatoryConform/> | ||
</item> | ||
</enum> | ||
</dataTypes> | ||
<attributes> | ||
<attribute id="0x0000" name="MeterType" type="MeterTypeEnum" default="null"> | ||
<access read="true" readPrivilege="view"/> | ||
<mandatoryConform/> | ||
</attribute> | ||
<attribute id="0x0001" name="CustomerName" type="string" default="null"> | ||
<access read="true" write="true" readPrivilege="view" writePrivilege="operate"/> | ||
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/> | ||
<mandatoryConform/> | ||
<constraint type="maxLength" value="64"/> | ||
</attribute> | ||
<attribute id="0x0002" name="UtilityName" type="string" default="null"> | ||
<access read="true" readPrivilege="view" /> | ||
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/> | ||
<mandatoryConform/> | ||
<constraint type="maxLength" value="16"/> | ||
</attribute> | ||
<attribute id="0x0003" name="PointOfDelivery" type="string" default="null"> | ||
<access read="true" readPrivilege="view" /> | ||
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/> | ||
<mandatoryConform/> | ||
<constraint type="maxLength" value="16"/> | ||
</attribute> | ||
<attribute id="0x0004" name="PowerThreshold" type="power-mW" default="null"> | ||
<access read="true" readPrivilege="view"/> | ||
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/> | ||
<mandatoryConform> | ||
<feature name="PWRTHLD"/> | ||
</mandatoryConform> | ||
</attribute> | ||
<attribute id="0x0005" name="PowerThresholdSource" type="PowerThresholdSourceEnum" default="null"> | ||
<access read="true" readPrivilege="view"/> | ||
<quality changeOmitted="false" nullable="true" scene="false" persistence="volatile" reportable="false"/> | ||
<mandatoryConform> | ||
<feature name="PWRTHLD"/> | ||
</mandatoryConform> | ||
</attribute> | ||
</attributes> | ||
</cluster> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
examples/all-clusters-app/all-clusters-common/src/meter-identification-stub.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <MeterIdentificationDelegate.h> | ||
|
||
using namespace chip; | ||
using namespace chip::app::Clusters; | ||
using namespace chip::app::Clusters::MeterIdentification; | ||
using Feature = chip::app::Clusters::MeterIdentification::Feature; | ||
|
||
static std::unique_ptr<MeterIdentificationDelegate> gMIDelegate; | ||
static std::unique_ptr<MeterIdentificationInstance> gMIInstance; | ||
|
||
void emberAfMeterIdentificationClusterInitCallback(chip::EndpointId endpointId) | ||
{ | ||
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. | ||
VerifyOrDie(!gMIInstance); | ||
|
||
gMIDelegate = std::make_unique<MeterIdentificationDelegate>(); | ||
if (gMIDelegate) | ||
{ | ||
gMIInstance = std::make_unique<MeterIdentificationInstance>(endpointId, *gMIDelegate, | ||
BitMask<Feature, uint32_t>(Feature::kPowerThreshold)); | ||
|
||
gMIInstance->Init(); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...ples/energy-management-app/energy-management-common/include/MeterIdentificationDelegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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/clusters/meter-identification-server/meter-identification-server.h> | ||
#include <app/util/af-types.h> | ||
#include <lib/core/CHIPError.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
namespace Clusters { | ||
namespace MeterIdentification { | ||
|
||
class MeterIdentificationDelegate : public MeterIdentification::Delegate | ||
{ | ||
public: | ||
~MeterIdentificationDelegate() = default; | ||
|
||
// Attribute Accessors | ||
|
||
DataModel::Nullable<MeterTypeEnum> GetMeterType() override { return mMeterType; }; | ||
CharSpan GetCustomerName() override { return mCustomerName; }; | ||
CharSpan GetUtilityName() override { return mUtilityName; }; | ||
CharSpan GetPointOfDelivery() override { return mPointOfDelivery; }; | ||
DataModel::Nullable<uint64_t> GetPowerThreshold() override { return mPowerThreshold; }; | ||
DataModel::Nullable<PowerThresholdSourceEnum> GetPowerThresholdSource() override { return mPowerThresholdSource; }; | ||
|
||
CHIP_ERROR SetCustomerName(CharSpan & value) override; | ||
|
||
// Internal Application API to set attribute values | ||
CHIP_ERROR SetMeterType(DataModel::Nullable<MeterTypeEnum>); | ||
CHIP_ERROR SetUtilityName(CharSpan & value); | ||
CHIP_ERROR SetPointOfDelivery(CharSpan & value); | ||
CHIP_ERROR SetPowerThreshold(DataModel::Nullable<uint64_t>); | ||
CHIP_ERROR SetPowerThresholdSource(DataModel::Nullable<PowerThresholdSourceEnum>); | ||
|
||
private: | ||
// Attribute storage | ||
DataModel::Nullable<MeterTypeEnum> mMeterType; | ||
CharSpan mCustomerName; | ||
CharSpan mUtilityName; | ||
CharSpan mPointOfDelivery; | ||
DataModel::Nullable<uint64_t> mPowerThreshold; | ||
DataModel::Nullable<PowerThresholdSourceEnum> mPowerThresholdSource; | ||
}; | ||
|
||
class MeterIdentificationInstance : public Instance | ||
{ | ||
public: | ||
MeterIdentificationInstance(EndpointId aEndpointId, MeterIdentificationDelegate & aDelegate, Feature aFeature) : | ||
MeterIdentification::Instance(aEndpointId, aDelegate, aFeature) | ||
{ | ||
mDelegate = &aDelegate; | ||
} | ||
|
||
// Delete copy constructor and assignment operator. | ||
MeterIdentificationInstance(const MeterIdentificationInstance &) = delete; | ||
MeterIdentificationInstance(const MeterIdentificationInstance &&) = delete; | ||
MeterIdentificationInstance & operator=(const MeterIdentificationInstance &) = delete; | ||
|
||
CHIP_ERROR Init(); | ||
void Shutdown(); | ||
|
||
MeterIdentificationDelegate * GetDelegate() { return mDelegate; }; | ||
|
||
private: | ||
MeterIdentificationDelegate * mDelegate; | ||
}; | ||
|
||
} // namespace MeterIdentification | ||
} // namespace Clusters | ||
} // namespace app | ||
} // namespace chip |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How was this added? data_model files are managed by a script and should be included only as part of script execution (i.e. from parsing asciidoc files)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the image and likeness of other clusters