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/ConcreteCommandPath.h>
28
27
#include < app/util/error-mapping.h>
29
28
#include < lib/core/CHIPEncoding.h>
30
29
@@ -45,7 +44,6 @@ class EnergyPrefAttrAccess : public AttributeAccessInterface
45
44
EnergyPrefAttrAccess () : AttributeAccessInterface(Optional<EndpointId>::Missing(), EnergyPreference::Id) {}
46
45
47
46
CHIP_ERROR Read (const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override ;
48
- CHIP_ERROR Write (const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override ;
49
47
};
50
48
51
49
EnergyPrefAttrAccess gEnergyPrefAttrAccess ;
@@ -56,16 +54,16 @@ CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
56
54
VerifyOrDie (aPath.mClusterId == EnergyPreference::Id);
57
55
EndpointId endpoint = aPath.mEndpointId ;
58
56
uint32_t ourFeatureMap;
59
- bool balanceSupported = ( FeatureMap::Get (aPath.mEndpointId , &ourFeatureMap) == EMBER_ZCL_STATUS_SUCCESS) &&
60
- ((ourFeatureMap & to_underlying (Feature::kEnergyBalance )) != 0 );
61
- bool lowPowerSupported = ( ourFeatureMap & to_underlying (Feature::kLowPowerModeSensitivity )) != 0 ;
57
+ const bool featureMapIsGood = FeatureMap::Get (aPath.mEndpointId , &ourFeatureMap) == EMBER_ZCL_STATUS_SUCCESS;
58
+ const bool balanceSupported = featureMapIsGood && ((ourFeatureMap & to_underlying (Feature::kEnergyBalance )) != 0 );
59
+ const bool lowPowerSupported = featureMapIsGood && (( ourFeatureMap & to_underlying (Feature::kLowPowerModeSensitivity )) != 0 ) ;
62
60
63
61
switch (aPath.mAttributeId )
64
62
{
65
63
case EnergyBalances::Id:
66
64
if (!balanceSupported)
67
65
{
68
- return aEncoder. EncodeNull ( );
66
+ return CHIP_IM_GLOBAL_STATUS (UnsupportedAttribute );
69
67
}
70
68
71
69
if (gsDelegate != nullptr )
@@ -90,7 +88,7 @@ CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
90
88
case EnergyPriorities::Id:
91
89
if (balanceSupported == false )
92
90
{
93
- return aEncoder. EncodeNull ( );
91
+ return CHIP_IM_GLOBAL_STATUS (UnsupportedAttribute );
94
92
}
95
93
96
94
if (gsDelegate != nullptr )
@@ -115,7 +113,7 @@ CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
115
113
case LowPowerModeSensitivities::Id:
116
114
if (lowPowerSupported == false )
117
115
{
118
- return aEncoder. EncodeNull ( );
116
+ return CHIP_IM_GLOBAL_STATUS (UnsupportedAttribute );
119
117
}
120
118
121
119
if (gsDelegate != nullptr )
@@ -144,14 +142,6 @@ CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
144
142
return CHIP_NO_ERROR;
145
143
}
146
144
147
- CHIP_ERROR EnergyPrefAttrAccess::Write (const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
148
- {
149
- VerifyOrDie (aPath.mClusterId == EnergyPreference::Id);
150
-
151
- // return CHIP_NO_ERROR and just write to the attribute store in default
152
- return CHIP_NO_ERROR;
153
- }
154
-
155
145
} // anonymous namespace
156
146
157
147
namespace chip ::app::Clusters::EnergyPreference
@@ -170,15 +160,15 @@ Delegate * GetDelegate()
170
160
} // Set matter energy preferences delegate
171
161
172
162
Protocols::InteractionModel::Status
173
- MatterEnergyPreferenceClusterServerPreAttributeChangedCallback (const app:: ConcreteAttributePath & attributePath,
163
+ MatterEnergyPreferenceClusterServerPreAttributeChangedCallback (const ConcreteAttributePath & attributePath,
174
164
EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
175
165
{
176
166
EndpointId endpoint = attributePath.mEndpointId ;
177
167
Delegate * delegate = GetDelegate ();
178
168
uint32_t ourFeatureMap;
179
- bool balanceSupported = ( FeatureMap::Get (attributePath.mEndpointId , &ourFeatureMap) == EMBER_ZCL_STATUS_SUCCESS) &&
180
- ((ourFeatureMap & to_underlying (Feature::kEnergyBalance )) != 0 );
181
- bool lowPowerSupported = ( ourFeatureMap & to_underlying (Feature::kLowPowerModeSensitivity )) != 0 ;
169
+ const bool featureMapIsGood = FeatureMap::Get (attributePath.mEndpointId , &ourFeatureMap) == EMBER_ZCL_STATUS_SUCCESS;
170
+ const bool balanceSupported = featureMapIsGood && ((ourFeatureMap & to_underlying (Feature::kEnergyBalance )) != 0 );
171
+ const bool lowPowerSupported = featureMapIsGood && (( ourFeatureMap & to_underlying (Feature::kLowPowerModeSensitivity )) != 0 ) ;
182
172
183
173
if (delegate == nullptr )
184
174
return imcode::UnsupportedWrite;
0 commit comments