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
+ #include " meter-identification-server.h"
19
+
20
+ #include < protocols/interaction_model/StatusCode.h>
21
+
22
+ #include < app/AttributeAccessInterface.h>
23
+ #include < app/AttributeAccessInterfaceRegistry.h>
24
+ #include < app/EventLogging.h>
25
+ #include < app/reporting/reporting.h>
26
+ #include < app/util/attribute-storage.h>
27
+ #include < lib/support/CodeUtils.h>
28
+
29
+ using namespace chip ;
30
+ using namespace chip ::app;
31
+ using namespace chip ::app::DataModel;
32
+ using namespace chip ::app::Clusters;
33
+ using namespace chip ::app::Clusters::MeterIdentification;
34
+ using namespace chip ::app::Clusters::MeterIdentification::Attributes;
35
+
36
+ using chip::Protocols::InteractionModel::Status;
37
+
38
+ namespace chip {
39
+ namespace app {
40
+ namespace Clusters {
41
+ namespace MeterIdentification {
42
+
43
+ CHIP_ERROR Instance::Init ()
44
+ {
45
+ VerifyOrReturnError (AttributeAccessInterfaceRegistry::Instance ().Register (this ), CHIP_ERROR_INCORRECT_STATE);
46
+ return CHIP_NO_ERROR;
47
+ }
48
+
49
+ void Instance::Shutdown ()
50
+ {
51
+ AttributeAccessInterfaceRegistry::Instance ().Unregister (this );
52
+ }
53
+
54
+ bool Instance::HasFeature (const Feature & aFeature) const
55
+ {
56
+ return mFeature .Has (aFeature);
57
+ }
58
+
59
+ // static CHIP_ERROR EncodeStringOnSuccess(CHIP_ERROR status, AttributeValueEncoder & encoder, const char * buf, size_t maxBufSize)
60
+ // {
61
+ // ReturnErrorOnFailure(status);
62
+ // return encoder.Encode(chip::CharSpan(buf, strnlen(buf, maxBufSize)));
63
+ // }
64
+
65
+ // AttributeAccessInterface
66
+ CHIP_ERROR Instance::Read (const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
67
+ {
68
+ ChipLogProgress (Zcl, " Meter Indication read attr %d" , aPath.mAttributeId );
69
+
70
+ switch (aPath.mAttributeId )
71
+ {
72
+ case FeatureMap::Id:
73
+ ReturnErrorOnFailure (aEncoder.Encode (mFeature ));
74
+ break ;
75
+ case MeterType::Id:
76
+ ReturnErrorOnFailure (aEncoder.Encode (mDelegate .GetMeterType ()));
77
+ break ;
78
+
79
+ case PointOfDelivery::Id:
80
+ ReturnErrorOnFailure (aEncoder.Encode (mDelegate .GetPointOfDelivery ()));
81
+ break ;
82
+
83
+ case MeterSerialNumber::Id:
84
+ ReturnErrorOnFailure (aEncoder.Encode (mDelegate .GetMeterSerialNumber ()));
85
+ break ;
86
+
87
+ case ProtocolVersion::Id:
88
+ ReturnErrorOnFailure (aEncoder.Encode (mDelegate .GetProtocolVersion ()));
89
+ break ;
90
+
91
+ case PowerThreshold::Id:
92
+ if (HasFeature (Feature::kPowerThreshold ))
93
+ ReturnErrorOnFailure (aEncoder.Encode (mDelegate .GetPowerThreshold ()));
94
+ else
95
+ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
96
+ break ;
97
+ }
98
+ return CHIP_NO_ERROR;
99
+ }
100
+
101
+ CHIP_ERROR Instance::Write (const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
102
+ {
103
+ /*
104
+
105
+ switch (aPath.mAttributeId)
106
+ {
107
+
108
+ default:
109
+ break;
110
+ }
111
+ */
112
+ return CHIP_NO_ERROR;
113
+ }
114
+
115
+ } // namespace MeterIdentification
116
+ } // namespace Clusters
117
+ } // namespace app
118
+ } // namespace chip
119
+
120
+ // -----------------------------------------------------------------------------
121
+ // Plugin initialization
122
+
123
+ void MatterMeterIdentificationPluginServerInitCallback () {}
0 commit comments