Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and erwinpan1 committed Jun 11, 2024
1 parent 47e9eb7 commit cc89503
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* limitations under the License.
*/

#include <utility>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/clusters/resource-monitoring-server/resource-monitoring-cluster-objects.h>
#include <app/clusters/resource-monitoring-server/resource-monitoring-server.h>
#include <resource-monitoring/chef-resource-monitoring-delegates.h>
#include <lib/core/TLVReader.h>
#include <resource-monitoring/chef-resource-monitoring-delegates.h>
#include <utility>

using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -98,49 +98,47 @@ void HepaFilterMonitoring::Shutdown()
gHepaFilterDelegate.reset();
}

chip::Protocols::InteractionModel::Status ChefResourceMonitorInstance::ExternalAttributeWrite(const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
chip::Protocols::InteractionModel::Status
ChefResourceMonitorInstance::ExternalAttributeWrite(const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
{
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
AttributeId attributeId = attributeMetadata->attributeId;
AttributeId attributeId = attributeMetadata->attributeId;

switch (attributeId) {
case HepaFilterMonitoring::Attributes::Condition::Id:
switch (attributeId)
{
uint8_t newCondition = *(uint8_t *)buffer;
ret = UpdateCondition(newCondition);
case HepaFilterMonitoring::Attributes::Condition::Id: {
uint8_t newCondition = *(uint8_t *) buffer;
ret = UpdateCondition(newCondition);
}
break;
case HepaFilterMonitoring::Attributes::ChangeIndication::Id:
{
ResourceMonitoring::ChangeIndicationEnum newIndication = static_cast<ResourceMonitoring::ChangeIndicationEnum>(*(uint8_t *)buffer);
ret = UpdateChangeIndication(newIndication);
break;
case HepaFilterMonitoring::Attributes::ChangeIndication::Id: {
ResourceMonitoring::ChangeIndicationEnum newIndication =
static_cast<ResourceMonitoring::ChangeIndicationEnum>(*(uint8_t *) buffer);
ret = UpdateChangeIndication(newIndication);
}
break;
case HepaFilterMonitoring::Attributes::InPlaceIndicator::Id:
{
bool newInPlaceIndicator = *(bool *)buffer;
ret = UpdateInPlaceIndicator(newInPlaceIndicator);
break;
case HepaFilterMonitoring::Attributes::InPlaceIndicator::Id: {
bool newInPlaceIndicator = *(bool *) buffer;
ret = UpdateInPlaceIndicator(newInPlaceIndicator);
}
break;
case HepaFilterMonitoring::Attributes::LastChangedTime::Id:
{
uint32_t newValue = 0;
uint16_t tlvLen = *(uint16_t *) buffer;
break;
case HepaFilterMonitoring::Attributes::LastChangedTime::Id: {
uint32_t newValue = 0;
uint16_t tlvLen = *(uint16_t *) buffer;
chip::TLV::TLVReader reader;
reader.Init(buffer + sizeof(uint16_t), tlvLen);
reader.Next();
reader.Get(newValue);
DataModel::Nullable<uint32_t> newLastChangedTime = DataModel::MakeNullable(newValue);
ret = UpdateLastChangedTime(newLastChangedTime);
ret = UpdateLastChangedTime(newLastChangedTime);
}
break;
break;
case HepaFilterMonitoring::Attributes::DegradationDirection::Id:
default:
{
default: {
ChipLogError(Zcl, "Unsupported External Attribute Read: %d", static_cast<int>(attributeId));
ret = Protocols::InteractionModel::Status::UnsupportedWrite;
ret = Protocols::InteractionModel::Status::UnsupportedWrite;
}
break;
break;
}

return ret;
Expand All @@ -159,81 +157,89 @@ void emberAfActivatedCarbonFilterMonitoringClusterInitCallback(chip::EndpointId
gActivatedCarbonFilterInstance->Init();
}

chip::Protocols::InteractionModel::Status chefResourceMonitoringExternalWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
chip::Protocols::InteractionModel::Status
chefResourceMonitoringExternalWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer)
{
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
AttributeId attributeId = attributeMetadata->attributeId;
ChipLogProgress(Zcl, "chefResourceMonitoringExternalWriteCallback EP: %d, Cluster: %d, Att: %d", static_cast<int>(endpoint), static_cast<int>(clusterId), static_cast<int>(attributeId));
AttributeId attributeId = attributeMetadata->attributeId;
ChipLogProgress(Zcl, "chefResourceMonitoringExternalWriteCallback EP: %d, Cluster: %d, Att: %d", static_cast<int>(endpoint),
static_cast<int>(clusterId), static_cast<int>(attributeId));

switch (clusterId) {
switch (clusterId)
{
case HepaFilterMonitoring::Id:
ret = gHepaFilterInstance->ExternalAttributeWrite(attributeMetadata, buffer);
ret = gHepaFilterInstance->ExternalAttributeWrite(attributeMetadata, buffer);
break;
case ActivatedCarbonFilterMonitoring::Id:
ret = gActivatedCarbonFilterInstance->ExternalAttributeWrite(attributeMetadata, buffer);
ret = gActivatedCarbonFilterInstance->ExternalAttributeWrite(attributeMetadata, buffer);
break;
default:
ret = Protocols::InteractionModel::Status::UnsupportedWrite;
ret = Protocols::InteractionModel::Status::UnsupportedWrite;
break;
}

return ret;
}

chip::Protocols::InteractionModel::Status chefResourceMonitoringExternalReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength)
chip::Protocols::InteractionModel::Status
chefResourceMonitoringExternalReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
uint16_t maxReadLength)
{
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
AttributeId attributeId = attributeMetadata->attributeId;
ChipLogProgress(Zcl, "chefResourceMonitoringExternalReadCallback EP: %d, Cluster: %d, Att: %d", static_cast<int>(endpoint), static_cast<int>(clusterId), static_cast<int>(attributeId));
AttributeId attributeId = attributeMetadata->attributeId;
ChipLogProgress(Zcl, "chefResourceMonitoringExternalReadCallback EP: %d, Cluster: %d, Att: %d", static_cast<int>(endpoint),
static_cast<int>(clusterId), static_cast<int>(attributeId));

switch (clusterId) {
switch (clusterId)
{
case HepaFilterMonitoring::Id:
ret = gHepaFilterInstance->ExternalAttributeRead(attributeMetadata, buffer, maxReadLength);
ret = gHepaFilterInstance->ExternalAttributeRead(attributeMetadata, buffer, maxReadLength);
break;
case ActivatedCarbonFilterMonitoring::Id:
ret = gActivatedCarbonFilterInstance->ExternalAttributeRead(attributeMetadata, buffer, maxReadLength);
ret = gActivatedCarbonFilterInstance->ExternalAttributeRead(attributeMetadata, buffer, maxReadLength);
break;
default:
ret = Protocols::InteractionModel::Status::UnsupportedRead;
ret = Protocols::InteractionModel::Status::UnsupportedRead;
break;
}

return ret;
}

chip::Protocols::InteractionModel::Status ChefResourceMonitorInstance::ExternalAttributeRead(const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength)
chip::Protocols::InteractionModel::Status
ChefResourceMonitorInstance::ExternalAttributeRead(const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
uint16_t maxReadLength)
{
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Success;
AttributeId attributeId = attributeMetadata->attributeId;
AttributeId attributeId = attributeMetadata->attributeId;

switch (attributeId) {
case HepaFilterMonitoring::Attributes::Condition::Id:
switch (attributeId)
{
case HepaFilterMonitoring::Attributes::Condition::Id: {
*buffer = GetCondition();
}
break;
case HepaFilterMonitoring::Attributes::ChangeIndication::Id:
{
break;
case HepaFilterMonitoring::Attributes::ChangeIndication::Id: {
ResourceMonitoring::ChangeIndicationEnum changeIndication = GetChangeIndication();
// The underlying type of ResourceMonitoring::ChangeIndicationEnum is uint8_t
*buffer = to_underlying(changeIndication);
}
break;
case HepaFilterMonitoring::Attributes::InPlaceIndicator::Id:
{
*(bool *)buffer = GetInPlaceIndicator();
break;
case HepaFilterMonitoring::Attributes::InPlaceIndicator::Id: {
*(bool *) buffer = GetInPlaceIndicator();
}
break;
case HepaFilterMonitoring::Attributes::LastChangedTime::Id:
{
break;
case HepaFilterMonitoring::Attributes::LastChangedTime::Id: {
DataModel::Nullable<uint32_t> lastChangedTime = GetLastChangedTime();
*(uint32_t *)buffer = lastChangedTime.IsNull() ? 0 : lastChangedTime.Value();
*(uint32_t *) buffer = lastChangedTime.IsNull() ? 0 : lastChangedTime.Value();
}
break;
break;
case HepaFilterMonitoring::Attributes::DegradationDirection::Id:
default:
ChipLogError(Zcl, "Unsupported External Attribute Read: %d", static_cast<int>(attributeId));
ret = Protocols::InteractionModel::Status::UnsupportedRead;
ret = Protocols::InteractionModel::Status::UnsupportedRead;
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ class ChefResourceMonitorInstance : public ResourceMonitoring::Instance
{
public:
ChefResourceMonitorInstance(Delegate * aDelegate, EndpointId aEndpointId, ClusterId aClusterId, uint32_t aFeatureMap,
ResourceMonitoring::Attributes::DegradationDirection::TypeInfo::Type aDegradationDirection,
bool aResetConditionCommandSupported) : ResourceMonitoring::Instance(aDelegate, aEndpointId, aClusterId, aFeatureMap,
aDegradationDirection, aResetConditionCommandSupported) { };

chip::Protocols::InteractionModel::Status ExternalAttributeWrite(const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer);
chip::Protocols::InteractionModel::Status ExternalAttributeRead(const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength);

ResourceMonitoring::Attributes::DegradationDirection::TypeInfo::Type aDegradationDirection,
bool aResetConditionCommandSupported) :
ResourceMonitoring::Instance(aDelegate, aEndpointId, aClusterId, aFeatureMap, aDegradationDirection,
aResetConditionCommandSupported){};

chip::Protocols::InteractionModel::Status ExternalAttributeWrite(const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer);
chip::Protocols::InteractionModel::Status ExternalAttributeRead(const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength);
};

} // namespace ResourceMonitor

} // namespace ResourceMonitoring

namespace HepaFilterMonitoring {
class HepaFilterMonitoringDelegate : public ResourceMonitoring::Delegate
Expand Down Expand Up @@ -86,6 +87,11 @@ void Shutdown();
} // namespace app
} // namespace chip

chip::Protocols::InteractionModel::Status chefResourceMonitoringExternalWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer);
chip::Protocols::InteractionModel::Status
chefResourceMonitoringExternalWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer);

chip::Protocols::InteractionModel::Status chefResourceMonitoringExternalReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength);
chip::Protocols::InteractionModel::Status
chefResourceMonitoringExternalReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
uint16_t maxReadLength);
10 changes: 3 additions & 7 deletions examples/chef/common/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
defined(MATTER_DM_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER)
#include "chef-concentration-measurement.h"
#endif
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || \
defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
#include "resource-monitoring/chef-resource-monitoring-delegates.h"
#endif


#if defined(MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER) || defined(MATTER_DM_PLUGIN_RVC_CLEAN_MODE_SERVER)
#include "chef-rvc-mode-delegate.h"
#endif
Expand Down Expand Up @@ -70,8 +68,7 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin
case chip::app::Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id:
return chefConcentrationMeasurementReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
#endif
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || \
defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
case chip::app::Clusters::HepaFilterMonitoring::Id:
case chip::app::Clusters::ActivatedCarbonFilterMonitoring::Id:
return chefResourceMonitoringExternalReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength);
Expand Down Expand Up @@ -136,8 +133,7 @@ Protocols::InteractionModel::Status emberAfExternalAttributeWriteCallback(Endpoi
case chip::app::Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id:
return chefConcentrationMeasurementWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
#endif
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || \
defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
#if defined(MATTER_DM_PLUGIN_HEPA_FILTER_MONITORING_SERVER) || defined(MATTER_DM_PLUGIN_ACTIVATED_CARBON_FILTER_MONITORING_SERVER)
case chip::app::Clusters::HepaFilterMonitoring::Id:
case chip::app::Clusters::ActivatedCarbonFilterMonitoring::Id:
return chefResourceMonitoringExternalWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
Expand Down

0 comments on commit cc89503

Please sign in to comment.