15
15
* limitations under the License.
16
16
*/
17
17
18
- #include < utility>
19
18
#include < app-common/zap-generated/ids/Attributes.h>
20
19
#include < app-common/zap-generated/ids/Clusters.h>
21
20
#include < app/clusters/resource-monitoring-server/resource-monitoring-cluster-objects.h>
22
21
#include < app/clusters/resource-monitoring-server/resource-monitoring-server.h>
23
- #include < resource-monitoring/chef-resource-monitoring-delegates.h>
24
22
#include < lib/core/TLVReader.h>
23
+ #include < resource-monitoring/chef-resource-monitoring-delegates.h>
24
+ #include < utility>
25
25
26
26
using namespace chip ;
27
27
using namespace chip ::app;
@@ -98,49 +98,47 @@ void HepaFilterMonitoring::Shutdown()
98
98
gHepaFilterDelegate .reset ();
99
99
}
100
100
101
- chip::Protocols::InteractionModel::Status ChefResourceMonitorInstance::ExternalAttributeWrite (const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
101
+ chip::Protocols::InteractionModel::Status
102
+ ChefResourceMonitorInstance::ExternalAttributeWrite (const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
102
103
{
103
104
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
104
- AttributeId attributeId = attributeMetadata->attributeId ;
105
+ AttributeId attributeId = attributeMetadata->attributeId ;
105
106
106
- switch (attributeId) {
107
- case HepaFilterMonitoring::Attributes::Condition::Id:
107
+ switch (attributeId)
108
108
{
109
- uint8_t newCondition = *(uint8_t *)buffer;
110
- ret = UpdateCondition (newCondition);
109
+ case HepaFilterMonitoring::Attributes::Condition::Id: {
110
+ uint8_t newCondition = *(uint8_t *) buffer;
111
+ ret = UpdateCondition (newCondition);
111
112
}
112
- break ;
113
- case HepaFilterMonitoring::Attributes::ChangeIndication::Id:
114
- {
115
- ResourceMonitoring::ChangeIndicationEnum newIndication = static_cast <ResourceMonitoring::ChangeIndicationEnum>(*(uint8_t *)buffer);
116
- ret = UpdateChangeIndication (newIndication);
113
+ break ;
114
+ case HepaFilterMonitoring::Attributes::ChangeIndication::Id: {
115
+ ResourceMonitoring::ChangeIndicationEnum newIndication =
116
+ static_cast <ResourceMonitoring::ChangeIndicationEnum>(*(uint8_t *) buffer);
117
+ ret = UpdateChangeIndication (newIndication);
117
118
}
118
- break ;
119
- case HepaFilterMonitoring::Attributes::InPlaceIndicator::Id:
120
- {
121
- bool newInPlaceIndicator = *(bool *)buffer;
122
- ret = UpdateInPlaceIndicator (newInPlaceIndicator);
119
+ break ;
120
+ case HepaFilterMonitoring::Attributes::InPlaceIndicator::Id: {
121
+ bool newInPlaceIndicator = *(bool *) buffer;
122
+ ret = UpdateInPlaceIndicator (newInPlaceIndicator);
123
123
}
124
- break ;
125
- case HepaFilterMonitoring::Attributes::LastChangedTime::Id:
126
- {
127
- uint32_t newValue = 0 ;
128
- uint16_t tlvLen = *(uint16_t *) buffer;
124
+ break ;
125
+ case HepaFilterMonitoring::Attributes::LastChangedTime::Id: {
126
+ uint32_t newValue = 0 ;
127
+ uint16_t tlvLen = *(uint16_t *) buffer;
129
128
chip::TLV::TLVReader reader;
130
129
reader.Init (buffer + sizeof (uint16_t ), tlvLen);
131
130
reader.Next ();
132
131
reader.Get (newValue);
133
132
DataModel::Nullable<uint32_t > newLastChangedTime = DataModel::MakeNullable (newValue);
134
- ret = UpdateLastChangedTime (newLastChangedTime);
133
+ ret = UpdateLastChangedTime (newLastChangedTime);
135
134
}
136
- break ;
135
+ break ;
137
136
case HepaFilterMonitoring::Attributes::DegradationDirection::Id:
138
- default :
139
- {
137
+ default : {
140
138
ChipLogError (Zcl, " Unsupported External Attribute Read: %d" , static_cast <int >(attributeId));
141
- ret = Protocols::InteractionModel::Status::UnsupportedWrite;
139
+ ret = Protocols::InteractionModel::Status::UnsupportedWrite;
142
140
}
143
- break ;
141
+ break ;
144
142
}
145
143
146
144
return ret;
@@ -159,81 +157,89 @@ void emberAfActivatedCarbonFilterMonitoringClusterInitCallback(chip::EndpointId
159
157
gActivatedCarbonFilterInstance ->Init ();
160
158
}
161
159
162
- chip::Protocols::InteractionModel::Status chefResourceMonitoringExternalWriteCallback (chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
160
+ chip::Protocols::InteractionModel::Status
161
+ chefResourceMonitoringExternalWriteCallback (chip::EndpointId endpoint, chip::ClusterId clusterId,
162
+ const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
163
163
{
164
164
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
165
- AttributeId attributeId = attributeMetadata->attributeId ;
166
- ChipLogProgress (Zcl, " chefResourceMonitoringExternalWriteCallback EP: %d, Cluster: %d, Att: %d" , static_cast <int >(endpoint), static_cast <int >(clusterId), static_cast <int >(attributeId));
165
+ AttributeId attributeId = attributeMetadata->attributeId ;
166
+ ChipLogProgress (Zcl, " chefResourceMonitoringExternalWriteCallback EP: %d, Cluster: %d, Att: %d" , static_cast <int >(endpoint),
167
+ static_cast <int >(clusterId), static_cast <int >(attributeId));
167
168
168
- switch (clusterId) {
169
+ switch (clusterId)
170
+ {
169
171
case HepaFilterMonitoring::Id:
170
- ret = gHepaFilterInstance ->ExternalAttributeWrite (attributeMetadata, buffer);
172
+ ret = gHepaFilterInstance ->ExternalAttributeWrite (attributeMetadata, buffer);
171
173
break ;
172
174
case ActivatedCarbonFilterMonitoring::Id:
173
- ret = gActivatedCarbonFilterInstance ->ExternalAttributeWrite (attributeMetadata, buffer);
175
+ ret = gActivatedCarbonFilterInstance ->ExternalAttributeWrite (attributeMetadata, buffer);
174
176
break ;
175
177
default :
176
- ret = Protocols::InteractionModel::Status::UnsupportedWrite;
178
+ ret = Protocols::InteractionModel::Status::UnsupportedWrite;
177
179
break ;
178
180
}
179
181
180
182
return ret;
181
183
}
182
184
183
- chip::Protocols::InteractionModel::Status chefResourceMonitoringExternalReadCallback (chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength)
185
+ chip::Protocols::InteractionModel::Status
186
+ chefResourceMonitoringExternalReadCallback (chip::EndpointId endpoint, chip::ClusterId clusterId,
187
+ const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
188
+ uint16_t maxReadLength)
184
189
{
185
190
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
186
- AttributeId attributeId = attributeMetadata->attributeId ;
187
- ChipLogProgress (Zcl, " chefResourceMonitoringExternalReadCallback EP: %d, Cluster: %d, Att: %d" , static_cast <int >(endpoint), static_cast <int >(clusterId), static_cast <int >(attributeId));
191
+ AttributeId attributeId = attributeMetadata->attributeId ;
192
+ ChipLogProgress (Zcl, " chefResourceMonitoringExternalReadCallback EP: %d, Cluster: %d, Att: %d" , static_cast <int >(endpoint),
193
+ static_cast <int >(clusterId), static_cast <int >(attributeId));
188
194
189
- switch (clusterId) {
195
+ switch (clusterId)
196
+ {
190
197
case HepaFilterMonitoring::Id:
191
- ret = gHepaFilterInstance ->ExternalAttributeRead (attributeMetadata, buffer, maxReadLength);
198
+ ret = gHepaFilterInstance ->ExternalAttributeRead (attributeMetadata, buffer, maxReadLength);
192
199
break ;
193
200
case ActivatedCarbonFilterMonitoring::Id:
194
- ret = gActivatedCarbonFilterInstance ->ExternalAttributeRead (attributeMetadata, buffer, maxReadLength);
201
+ ret = gActivatedCarbonFilterInstance ->ExternalAttributeRead (attributeMetadata, buffer, maxReadLength);
195
202
break ;
196
203
default :
197
- ret = Protocols::InteractionModel::Status::UnsupportedRead;
204
+ ret = Protocols::InteractionModel::Status::UnsupportedRead;
198
205
break ;
199
206
}
200
207
201
208
return ret;
202
209
}
203
210
204
- chip::Protocols::InteractionModel::Status ChefResourceMonitorInstance::ExternalAttributeRead (const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength)
211
+ chip::Protocols::InteractionModel::Status
212
+ ChefResourceMonitorInstance::ExternalAttributeRead (const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
213
+ uint16_t maxReadLength)
205
214
{
206
215
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
207
- AttributeId attributeId = attributeMetadata->attributeId ;
216
+ AttributeId attributeId = attributeMetadata->attributeId ;
208
217
209
- switch (attributeId) {
210
- case HepaFilterMonitoring::Attributes::Condition::Id:
218
+ switch (attributeId)
211
219
{
220
+ case HepaFilterMonitoring::Attributes::Condition::Id: {
212
221
*buffer = GetCondition ();
213
222
}
214
- break ;
215
- case HepaFilterMonitoring::Attributes::ChangeIndication::Id:
216
- {
223
+ break ;
224
+ case HepaFilterMonitoring::Attributes::ChangeIndication::Id: {
217
225
ResourceMonitoring::ChangeIndicationEnum changeIndication = GetChangeIndication ();
218
226
// The underlying type of ResourceMonitoring::ChangeIndicationEnum is uint8_t
219
227
*buffer = to_underlying (changeIndication);
220
228
}
221
- break ;
222
- case HepaFilterMonitoring::Attributes::InPlaceIndicator::Id:
223
- {
224
- *(bool *)buffer = GetInPlaceIndicator ();
229
+ break ;
230
+ case HepaFilterMonitoring::Attributes::InPlaceIndicator::Id: {
231
+ *(bool *) buffer = GetInPlaceIndicator ();
225
232
}
226
- break ;
227
- case HepaFilterMonitoring::Attributes::LastChangedTime::Id:
228
- {
233
+ break ;
234
+ case HepaFilterMonitoring::Attributes::LastChangedTime::Id: {
229
235
DataModel::Nullable<uint32_t > lastChangedTime = GetLastChangedTime ();
230
- *(uint32_t *)buffer = lastChangedTime.IsNull () ? 0 : lastChangedTime.Value ();
236
+ *(uint32_t *) buffer = lastChangedTime.IsNull () ? 0 : lastChangedTime.Value ();
231
237
}
232
- break ;
238
+ break ;
233
239
case HepaFilterMonitoring::Attributes::DegradationDirection::Id:
234
240
default :
235
241
ChipLogError (Zcl, " Unsupported External Attribute Read: %d" , static_cast <int >(attributeId));
236
- ret = Protocols::InteractionModel::Status::UnsupportedRead;
242
+ ret = Protocols::InteractionModel::Status::UnsupportedRead;
237
243
break ;
238
244
}
239
245
0 commit comments