17
17
18
18
#include " energy-preference-server.h"
19
19
20
- #include < app/util/attribute-storage.h>
20
+ #include < app/util/attribute-storage.h> // Needed for registerAttributeAccessOverride
21
21
22
22
#include < app-common/zap-generated/attributes/Accessors.h>
23
23
#include < app-common/zap-generated/callback.h>
24
24
#include < app-common/zap-generated/cluster-objects.h>
25
25
#include < app-common/zap-generated/ids/Attributes.h>
26
26
#include < app/ConcreteAttributePath.h>
27
+ #include < app/AttributeAccessInterface.h> // added in case we ever don't need app/util/attribute-storage.h at some point.
27
28
#include < app/util/error-mapping.h>
28
29
#include < lib/core/CHIPEncoding.h>
29
30
@@ -34,7 +35,7 @@ using namespace chip::app::Clusters::EnergyPreference;
34
35
using namespace chip ::app::Clusters::EnergyPreference::Structs;
35
36
using namespace chip ::app::Clusters::EnergyPreference::Attributes;
36
37
37
- using imcode = Protocols::InteractionModel::Status;
38
+ using Status = Protocols::InteractionModel::Status;
38
39
39
40
namespace {
40
41
@@ -159,7 +160,7 @@ Delegate * GetDelegate()
159
160
160
161
} // Set matter energy preferences delegate
161
162
162
- Protocols::InteractionModel:: Status
163
+ Status
163
164
MatterEnergyPreferenceClusterServerPreAttributeChangedCallback (const ConcreteAttributePath & attributePath,
164
165
EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
165
166
{
@@ -171,43 +172,45 @@ MatterEnergyPreferenceClusterServerPreAttributeChangedCallback(const ConcreteAtt
171
172
const bool lowPowerSupported = featureMapIsGood && ((ourFeatureMap & to_underlying (Feature::kLowPowerModeSensitivity )) != 0 );
172
173
173
174
if (delegate == nullptr )
174
- return imcode::UnsupportedWrite;
175
+ {
176
+ return Status::UnsupportedWrite;
177
+ }
175
178
176
179
switch (attributePath.mAttributeId )
177
180
{
178
181
case CurrentEnergyBalance::Id: {
179
182
if (balanceSupported == false )
180
183
{
181
- return imcode ::UnsupportedAttribute;
184
+ return Status ::UnsupportedAttribute;
182
185
}
183
186
184
187
uint8_t index = Encoding::Get8 (value);
185
188
size_t arraySize = delegate->GetNumEnergyBalances (endpoint);
186
189
if (index >= arraySize)
187
190
{
188
- return imcode ::ConstraintError;
191
+ return Status ::ConstraintError;
189
192
}
190
193
191
- return imcode ::Success;
194
+ return Status ::Success;
192
195
}
193
196
194
197
case CurrentLowPowerModeSensitivity::Id: {
195
198
if (lowPowerSupported == false )
196
199
{
197
- return imcode ::UnsupportedAttribute;
200
+ return Status ::UnsupportedAttribute;
198
201
}
199
202
200
203
uint8_t index = Encoding::Get8 (value);
201
- size_t arraySize = delegate->GetNumLowPowerModes (endpoint);
204
+ size_t arraySize = delegate->GetNumLowPowerModeSensitivities (endpoint);
202
205
if (index >= arraySize)
203
206
{
204
- return imcode ::ConstraintError;
207
+ return Status ::ConstraintError;
205
208
}
206
209
207
- return imcode ::Success;
210
+ return Status ::Success;
208
211
}
209
212
default :
210
- return imcode ::Success;
213
+ return Status ::Success;
211
214
}
212
215
}
213
216
0 commit comments