Skip to content

Commit cc89503

Browse files
restyled-commitserwinpan1
authored andcommitted
Restyled by clang-format
1 parent 47e9eb7 commit cc89503

File tree

3 files changed

+86
-78
lines changed

3 files changed

+86
-78
lines changed

examples/chef/common/clusters/resource-monitoring/chef-resource-monitoring-delegates.cpp

+66-60
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include <utility>
1918
#include <app-common/zap-generated/ids/Attributes.h>
2019
#include <app-common/zap-generated/ids/Clusters.h>
2120
#include <app/clusters/resource-monitoring-server/resource-monitoring-cluster-objects.h>
2221
#include <app/clusters/resource-monitoring-server/resource-monitoring-server.h>
23-
#include <resource-monitoring/chef-resource-monitoring-delegates.h>
2422
#include <lib/core/TLVReader.h>
23+
#include <resource-monitoring/chef-resource-monitoring-delegates.h>
24+
#include <utility>
2525

2626
using namespace chip;
2727
using namespace chip::app;
@@ -98,49 +98,47 @@ void HepaFilterMonitoring::Shutdown()
9898
gHepaFilterDelegate.reset();
9999
}
100100

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)
102103
{
103104
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
104-
AttributeId attributeId = attributeMetadata->attributeId;
105+
AttributeId attributeId = attributeMetadata->attributeId;
105106

106-
switch (attributeId) {
107-
case HepaFilterMonitoring::Attributes::Condition::Id:
107+
switch (attributeId)
108108
{
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);
111112
}
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);
117118
}
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);
123123
}
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;
129128
chip::TLV::TLVReader reader;
130129
reader.Init(buffer + sizeof(uint16_t), tlvLen);
131130
reader.Next();
132131
reader.Get(newValue);
133132
DataModel::Nullable<uint32_t> newLastChangedTime = DataModel::MakeNullable(newValue);
134-
ret = UpdateLastChangedTime(newLastChangedTime);
133+
ret = UpdateLastChangedTime(newLastChangedTime);
135134
}
136-
break;
135+
break;
137136
case HepaFilterMonitoring::Attributes::DegradationDirection::Id:
138-
default:
139-
{
137+
default: {
140138
ChipLogError(Zcl, "Unsupported External Attribute Read: %d", static_cast<int>(attributeId));
141-
ret = Protocols::InteractionModel::Status::UnsupportedWrite;
139+
ret = Protocols::InteractionModel::Status::UnsupportedWrite;
142140
}
143-
break;
141+
break;
144142
}
145143

146144
return ret;
@@ -159,81 +157,89 @@ void emberAfActivatedCarbonFilterMonitoringClusterInitCallback(chip::EndpointId
159157
gActivatedCarbonFilterInstance->Init();
160158
}
161159

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)
163163
{
164164
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));
167168

168-
switch (clusterId) {
169+
switch (clusterId)
170+
{
169171
case HepaFilterMonitoring::Id:
170-
ret = gHepaFilterInstance->ExternalAttributeWrite(attributeMetadata, buffer);
172+
ret = gHepaFilterInstance->ExternalAttributeWrite(attributeMetadata, buffer);
171173
break;
172174
case ActivatedCarbonFilterMonitoring::Id:
173-
ret = gActivatedCarbonFilterInstance->ExternalAttributeWrite(attributeMetadata, buffer);
175+
ret = gActivatedCarbonFilterInstance->ExternalAttributeWrite(attributeMetadata, buffer);
174176
break;
175177
default:
176-
ret = Protocols::InteractionModel::Status::UnsupportedWrite;
178+
ret = Protocols::InteractionModel::Status::UnsupportedWrite;
177179
break;
178180
}
179181

180182
return ret;
181183
}
182184

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)
184189
{
185190
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));
188194

189-
switch (clusterId) {
195+
switch (clusterId)
196+
{
190197
case HepaFilterMonitoring::Id:
191-
ret = gHepaFilterInstance->ExternalAttributeRead(attributeMetadata, buffer, maxReadLength);
198+
ret = gHepaFilterInstance->ExternalAttributeRead(attributeMetadata, buffer, maxReadLength);
192199
break;
193200
case ActivatedCarbonFilterMonitoring::Id:
194-
ret = gActivatedCarbonFilterInstance->ExternalAttributeRead(attributeMetadata, buffer, maxReadLength);
201+
ret = gActivatedCarbonFilterInstance->ExternalAttributeRead(attributeMetadata, buffer, maxReadLength);
195202
break;
196203
default:
197-
ret = Protocols::InteractionModel::Status::UnsupportedRead;
204+
ret = Protocols::InteractionModel::Status::UnsupportedRead;
198205
break;
199206
}
200207

201208
return ret;
202209
}
203210

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)
205214
{
206215
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
207-
AttributeId attributeId = attributeMetadata->attributeId;
216+
AttributeId attributeId = attributeMetadata->attributeId;
208217

209-
switch (attributeId) {
210-
case HepaFilterMonitoring::Attributes::Condition::Id:
218+
switch (attributeId)
211219
{
220+
case HepaFilterMonitoring::Attributes::Condition::Id: {
212221
*buffer = GetCondition();
213222
}
214-
break;
215-
case HepaFilterMonitoring::Attributes::ChangeIndication::Id:
216-
{
223+
break;
224+
case HepaFilterMonitoring::Attributes::ChangeIndication::Id: {
217225
ResourceMonitoring::ChangeIndicationEnum changeIndication = GetChangeIndication();
218226
// The underlying type of ResourceMonitoring::ChangeIndicationEnum is uint8_t
219227
*buffer = to_underlying(changeIndication);
220228
}
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();
225232
}
226-
break;
227-
case HepaFilterMonitoring::Attributes::LastChangedTime::Id:
228-
{
233+
break;
234+
case HepaFilterMonitoring::Attributes::LastChangedTime::Id: {
229235
DataModel::Nullable<uint32_t> lastChangedTime = GetLastChangedTime();
230-
*(uint32_t *)buffer = lastChangedTime.IsNull() ? 0 : lastChangedTime.Value();
236+
*(uint32_t *) buffer = lastChangedTime.IsNull() ? 0 : lastChangedTime.Value();
231237
}
232-
break;
238+
break;
233239
case HepaFilterMonitoring::Attributes::DegradationDirection::Id:
234240
default:
235241
ChipLogError(Zcl, "Unsupported External Attribute Read: %d", static_cast<int>(attributeId));
236-
ret = Protocols::InteractionModel::Status::UnsupportedRead;
242+
ret = Protocols::InteractionModel::Status::UnsupportedRead;
237243
break;
238244
}
239245

examples/chef/common/clusters/resource-monitoring/chef-resource-monitoring-delegates.h

+17-11
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,18 @@ class ChefResourceMonitorInstance : public ResourceMonitoring::Instance
3131
{
3232
public:
3333
ChefResourceMonitorInstance(Delegate * aDelegate, EndpointId aEndpointId, ClusterId aClusterId, uint32_t aFeatureMap,
34-
ResourceMonitoring::Attributes::DegradationDirection::TypeInfo::Type aDegradationDirection,
35-
bool aResetConditionCommandSupported) : ResourceMonitoring::Instance(aDelegate, aEndpointId, aClusterId, aFeatureMap,
36-
aDegradationDirection, aResetConditionCommandSupported) { };
37-
38-
chip::Protocols::InteractionModel::Status ExternalAttributeWrite(const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer);
39-
chip::Protocols::InteractionModel::Status ExternalAttributeRead(const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength);
40-
34+
ResourceMonitoring::Attributes::DegradationDirection::TypeInfo::Type aDegradationDirection,
35+
bool aResetConditionCommandSupported) :
36+
ResourceMonitoring::Instance(aDelegate, aEndpointId, aClusterId, aFeatureMap, aDegradationDirection,
37+
aResetConditionCommandSupported){};
38+
39+
chip::Protocols::InteractionModel::Status ExternalAttributeWrite(const EmberAfAttributeMetadata * attributeMetadata,
40+
uint8_t * buffer);
41+
chip::Protocols::InteractionModel::Status ExternalAttributeRead(const EmberAfAttributeMetadata * attributeMetadata,
42+
uint8_t * buffer, uint16_t maxReadLength);
4143
};
4244

43-
} // namespace ResourceMonitor
44-
45+
} // namespace ResourceMonitoring
4546

4647
namespace HepaFilterMonitoring {
4748
class HepaFilterMonitoringDelegate : public ResourceMonitoring::Delegate
@@ -86,6 +87,11 @@ void Shutdown();
8687
} // namespace app
8788
} // namespace chip
8889

89-
chip::Protocols::InteractionModel::Status chefResourceMonitoringExternalWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer);
90+
chip::Protocols::InteractionModel::Status
91+
chefResourceMonitoringExternalWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
92+
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer);
9093

91-
chip::Protocols::InteractionModel::Status chefResourceMonitoringExternalReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength);
94+
chip::Protocols::InteractionModel::Status
95+
chefResourceMonitoringExternalReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
96+
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
97+
uint16_t maxReadLength);

examples/chef/common/stubs.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
defined(MATTER_DM_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER)
1919
#include "chef-concentration-measurement.h"
2020
#endif
21-
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || \
22-
defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
21+
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
2322
#include "resource-monitoring/chef-resource-monitoring-delegates.h"
2423
#endif
2524

26-
2725
#if defined(MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER) || defined(MATTER_DM_PLUGIN_RVC_CLEAN_MODE_SERVER)
2826
#include "chef-rvc-mode-delegate.h"
2927
#endif
@@ -70,8 +68,7 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin
7068
case chip::app::Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id:
7169
return chefConcentrationMeasurementReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
7270
#endif
73-
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || \
74-
defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
71+
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
7572
case chip::app::Clusters::HepaFilterMonitoring::Id:
7673
case chip::app::Clusters::ActivatedCarbonFilterMonitoring::Id:
7774
return chefResourceMonitoringExternalReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
@@ -136,8 +133,7 @@ Protocols::InteractionModel::Status emberAfExternalAttributeWriteCallback(Endpoi
136133
case chip::app::Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id:
137134
return chefConcentrationMeasurementWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
138135
#endif
139-
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || \
140-
defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
136+
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
141137
case chip::app::Clusters::HepaFilterMonitoring::Id:
142138
case chip::app::Clusters::ActivatedCarbonFilterMonitoring::Id:
143139
return chefResourceMonitoringExternalWriteCallback(endpoint, clusterId, attributeMetadata, buffer);

0 commit comments

Comments
 (0)