Skip to content

Commit

Permalink
[Examples] Remove EmberAfStatus from example files (#32056)
Browse files Browse the repository at this point in the history
* Replace EmberAfStatus in examples files

* Fix Tv-app

* fix ci

* remove using in headers
  • Loading branch information
jepenven-silabs authored Feb 13, 2024
1 parent d3e8903 commit 4597a3b
Show file tree
Hide file tree
Showing 100 changed files with 622 additions and 529 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <app-common/zap-generated/attributes/Accessors.h>
#include <protocols/interaction_model/StatusCode.h>

namespace chip {
namespace app {
Expand All @@ -31,19 +32,20 @@ class RelativeHumiditySensorManager

void Init()
{
EmberAfStatus status = RelativeHumidityMeasurement::Attributes::MinMeasuredValue::Set(mEndpointId, 0);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Protocols::InteractionModel::Status status = RelativeHumidityMeasurement::Attributes::MinMeasuredValue::Set(mEndpointId, 0);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set RelativeHumidityMeasurement MinMeasuredValue attribute"));

status = RelativeHumidityMeasurement::Attributes::MaxMeasuredValue::Set(mEndpointId, 10000);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set RelativeHumidityMeasurement MaxMeasuredValue attribute"));
};

void OnHumidityChangeHandler(uint16_t newValue)
{
EmberAfStatus status = RelativeHumidityMeasurement::Attributes::MeasuredValue::Set(mEndpointId, newValue);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Protocols::InteractionModel::Status status =
RelativeHumidityMeasurement::Attributes::MeasuredValue::Set(mEndpointId, newValue);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set RelativeHumidityMeasurement MeasuredValue attribute"));
ChipLogDetail(NotSpecified, "The new RelativeHumidityMeasurement value: %d", newValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <app-common/zap-generated/attributes/Accessors.h>
#include <protocols/interaction_model/StatusCode.h>

namespace chip {
namespace app {
Expand All @@ -31,19 +32,19 @@ class TemperatureSensorManager

void Init()
{
EmberAfStatus status = TemperatureMeasurement::Attributes::MinMeasuredValue::Set(mEndpointId, -500);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Protocols::InteractionModel::Status status = TemperatureMeasurement::Attributes::MinMeasuredValue::Set(mEndpointId, -500);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set TemperatureMeasurement MinMeasuredValue attribute"));

status = TemperatureMeasurement::Attributes::MaxMeasuredValue::Set(mEndpointId, 6000);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set TemperatureMeasurement MaxMeasuredValue attribute"));
}

void OnTemperatureChangeHandler(int16_t newValue)
{
EmberAfStatus status = TemperatureMeasurement::Attributes::MeasuredValue::Set(mEndpointId, newValue);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Protocols::InteractionModel::Status status = TemperatureMeasurement::Attributes::MeasuredValue::Set(mEndpointId, newValue);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set TemperatureMeasurement MeasuredValue attribute"));
ChipLogDetail(NotSpecified, "The new TemperatureMeasurement value: %d", newValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,13 @@ void AirPurifierManager::PercentSettingWriteCallback(uint8_t aNewPercentSetting)
if (aNewPercentSetting != percentCurrent)
{
ChipLogDetail(NotSpecified, "AirPurifierManager::PercentSettingWriteCallback: %d", aNewPercentSetting);
percentCurrent = aNewPercentSetting;
EmberAfStatus status = FanControl::Attributes::PercentCurrent::Set(mEndpointId, percentCurrent);
if (status != EMBER_ZCL_STATUS_SUCCESS)
percentCurrent = aNewPercentSetting;
Status status = FanControl::Attributes::PercentCurrent::Set(mEndpointId, percentCurrent);
if (status != Status::Success)
{
ChipLogError(NotSpecified,
"AirPurifierManager::PercentSettingWriteCallback: failed to set PercentCurrent attribute: %d", status);
"AirPurifierManager::PercentSettingWriteCallback: failed to set PercentCurrent attribute: %d",
to_underlying(status));
}
}
}
Expand All @@ -211,12 +212,12 @@ void AirPurifierManager::SpeedSettingWriteCallback(uint8_t aNewSpeedSetting)
if (aNewSpeedSetting != speedCurrent)
{
ChipLogDetail(NotSpecified, "AirPurifierManager::SpeedSettingWriteCallback: %d", aNewSpeedSetting);
speedCurrent = aNewSpeedSetting;
EmberAfStatus status = FanControl::Attributes::SpeedCurrent::Set(mEndpointId, speedCurrent);
if (status != EMBER_ZCL_STATUS_SUCCESS)
speedCurrent = aNewSpeedSetting;
Status status = FanControl::Attributes::SpeedCurrent::Set(mEndpointId, speedCurrent);
if (status != Status::Success)
{
ChipLogError(NotSpecified, "AirPurifierManager::SpeedSettingWriteCallback: failed to set SpeedCurrent attribute: %d",
status);
to_underlying(status));
}

// Determine if the speed change should also change the fan mode
Expand Down Expand Up @@ -299,22 +300,24 @@ void AirPurifierManager::SetSpeedSetting(DataModel::Nullable<uint8_t> aNewSpeedS

if (aNewSpeedSetting.Value() != speedCurrent)
{
EmberAfStatus status = FanControl::Attributes::SpeedSetting::Set(mEndpointId, aNewSpeedSetting);
if (status != EMBER_ZCL_STATUS_SUCCESS)
Status status = FanControl::Attributes::SpeedSetting::Set(mEndpointId, aNewSpeedSetting);
if (status != Status::Success)
{
ChipLogError(NotSpecified, "AirPurifierManager::SetSpeedSetting: failed to set SpeedSetting attribute: %d", status);
ChipLogError(NotSpecified, "AirPurifierManager::SetSpeedSetting: failed to set SpeedSetting attribute: %d",
to_underlying(status));
}
}
}

DataModel::Nullable<uint8_t> AirPurifierManager::GetSpeedSetting()
{
DataModel::Nullable<uint8_t> speedSetting;
EmberAfStatus status = FanControl::Attributes::SpeedSetting::Get(mEndpointId, speedSetting);
Status status = FanControl::Attributes::SpeedSetting::Get(mEndpointId, speedSetting);

if (status != EMBER_ZCL_STATUS_SUCCESS)
if (status != Status::Success)
{
ChipLogError(NotSpecified, "AirPurifierManager::GetSpeedSetting: failed to get SpeedSetting attribute: %d", status);
ChipLogError(NotSpecified, "AirPurifierManager::GetSpeedSetting: failed to get SpeedSetting attribute: %d",
to_underlying(status));
}

return speedSetting;
Expand All @@ -323,11 +326,12 @@ DataModel::Nullable<uint8_t> AirPurifierManager::GetSpeedSetting()
DataModel::Nullable<Percent> AirPurifierManager::GetPercentSetting()
{
DataModel::Nullable<Percent> percentSetting;
EmberAfStatus status = FanControl::Attributes::PercentSetting::Get(mEndpointId, percentSetting);
Status status = FanControl::Attributes::PercentSetting::Get(mEndpointId, percentSetting);

if (status != EMBER_ZCL_STATUS_SUCCESS)
if (status != Status::Success)
{
ChipLogError(NotSpecified, "AirPurifierManager::GetPercentSetting: failed to get PercentSetting attribute: %d", status);
ChipLogError(NotSpecified, "AirPurifierManager::GetPercentSetting: failed to get PercentSetting attribute: %d",
to_underlying(status));
}

return percentSetting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
*/

#include "thermostat-manager.h"
#include <protocols/interaction_model/StatusCode.h>

using chip::Protocols::InteractionModel::Status;

using namespace chip;
using namespace chip::app;
Expand All @@ -26,28 +29,28 @@ void ThermostatManager::Init()
{
BitMask<Thermostat::Feature> FeatureMap;
FeatureMap.Set(Thermostat::Feature::kHeating);
EmberAfStatus status = Thermostat::Attributes::FeatureMap::Set(mEndpointId, FeatureMap.Raw());
Status status = Thermostat::Attributes::FeatureMap::Set(mEndpointId, FeatureMap.Raw());

status = Thermostat::Attributes::ControlSequenceOfOperation::Set(mEndpointId,
Thermostat::ControlSequenceOfOperationEnum::kHeatingOnly);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
VerifyOrReturn(Status::Success == status,
ChipLogError(NotSpecified, "Failed to set Thermostat ControlSequenceOfOperation attribute"));

status = Thermostat::Attributes::AbsMinHeatSetpointLimit::Set(mEndpointId, 500);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
VerifyOrReturn(Status::Success == status,
ChipLogError(NotSpecified, "Failed to set Thermostat MinHeatSetpointLimit attribute"));

status = Thermostat::Attributes::AbsMaxHeatSetpointLimit::Set(mEndpointId, 3000);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
VerifyOrReturn(Status::Success == status,
ChipLogError(NotSpecified, "Failed to set Thermostat MaxHeatSetpointLimit attribute"));
}

void ThermostatManager::HeatingSetpointWriteCallback(int16_t newValue)
{
ChipLogDetail(NotSpecified, "ThermostatManager::HeatingSetpointWriteCallback: %d", newValue);
Thermostat::SystemModeEnum systemMode;
EmberAfStatus status = Thermostat::Attributes::SystemMode::Get(mEndpointId, &systemMode);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to get Thermostat SystemMode attribute"));
Status status = Thermostat::Attributes::SystemMode::Get(mEndpointId, &systemMode);
VerifyOrReturn(Status::Success == status, ChipLogError(NotSpecified, "Failed to get Thermostat SystemMode attribute"));

// A new setpoint has been set, so we shall infer that the we want to be in Heating mode
if (systemMode == Thermostat::SystemModeEnum::kOff)
Expand All @@ -58,7 +61,7 @@ void ThermostatManager::HeatingSetpointWriteCallback(int16_t newValue)
// Check the current temperature and turn on the heater if needed
DataModel::Nullable<int16_t> localTemperature;
status = Thermostat::Attributes::LocalTemperature::Get(mEndpointId, localTemperature);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
VerifyOrReturn(Status::Success == status,
ChipLogError(NotSpecified, "Failed to get TemperatureMeasurement MeasuredValue attribute"));

if (localTemperature.Value() < newValue)
Expand All @@ -81,14 +84,13 @@ void ThermostatManager::SystemModeWriteCallback(uint8_t newValue)
else if ((Thermostat::SystemModeEnum) newValue == Thermostat::SystemModeEnum::kHeat)
{
DataModel::Nullable<int16_t> localTemperature;
EmberAfStatus status = Thermostat::Attributes::LocalTemperature::Get(mEndpointId, localTemperature);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Status status = Thermostat::Attributes::LocalTemperature::Get(mEndpointId, localTemperature);
VerifyOrReturn(Status::Success == status,
ChipLogError(NotSpecified, "Failed to get TemperatureMeasurement MeasuredValue attribute"));

int16_t heatingSetpoint;
status = Thermostat::Attributes::OccupiedHeatingSetpoint::Get(mEndpointId, &heatingSetpoint);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
ChipLogError(NotSpecified, "Failed to get Thermostat HeatingSetpoint attribute"));
VerifyOrReturn(Status::Success == status, ChipLogError(NotSpecified, "Failed to get Thermostat HeatingSetpoint attribute"));

if (localTemperature.Value() < heatingSetpoint)
{
Expand All @@ -99,8 +101,8 @@ void ThermostatManager::SystemModeWriteCallback(uint8_t newValue)

void ThermostatManager::OnLocalTemperatureChangeCallback(int16_t temperature)
{
EmberAfStatus status = Thermostat::Attributes::LocalTemperature::Set(mEndpointId, temperature);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Status status = Thermostat::Attributes::LocalTemperature::Set(mEndpointId, temperature);
VerifyOrReturn(Status::Success == status,
ChipLogError(NotSpecified, "Failed to set TemperatureMeasurement MeasuredValue attribute"));
}

Expand All @@ -122,14 +124,13 @@ void ThermostatManager::SetHeating(bool isHeating)
runningState.Clear(Thermostat::RelayStateBitmap::kHeat);
}

EmberAfStatus status = Thermostat::Attributes::ThermostatRunningState::Set(mEndpointId, runningState);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
ChipLogError(NotSpecified, "Failed to set Thermostat RunningState attribute"));
Status status = Thermostat::Attributes::ThermostatRunningState::Set(mEndpointId, runningState);
VerifyOrReturn(Status::Success == status, ChipLogError(NotSpecified, "Failed to set Thermostat RunningState attribute"));
}

void ThermostatManager::SetHeatMode(bool heat)
{
EmberAfStatus status = Thermostat::Attributes::SystemMode::Set(
Status status = Thermostat::Attributes::SystemMode::Set(
mEndpointId, heat ? Thermostat::SystemModeEnum::kHeat : Thermostat::SystemModeEnum::kOff);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to set Thermostat SystemMode attribute"));
VerifyOrReturn(Status::Success == status, ChipLogError(NotSpecified, "Failed to set Thermostat SystemMode attribute"));
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <protocols/interaction_model/StatusCode.h>

#pragma once

Expand All @@ -11,19 +12,20 @@ class RelativeHumiditySensorManager
public:
RelativeHumiditySensorManager(EndpointId aEndpointId) : mEndpointId(aEndpointId)
{
EmberAfStatus status = RelativeHumidityMeasurement::Attributes::MinMeasuredValue::Set(mEndpointId, 0);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Protocols::InteractionModel::Status status = RelativeHumidityMeasurement::Attributes::MinMeasuredValue::Set(mEndpointId, 0);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set RelativeHumidityMeasurement MinMeasuredValue attribute"));

status = RelativeHumidityMeasurement::Attributes::MaxMeasuredValue::Set(mEndpointId, 100);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set RelativeHumidityMeasurement MaxMeasuredValue attribute"));
};

void OnHumidityChangeHandler(uint16_t newValue)
{
EmberAfStatus status = RelativeHumidityMeasurement::Attributes::MeasuredValue::Set(mEndpointId, newValue);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Protocols::InteractionModel::Status status =
RelativeHumidityMeasurement::Attributes::MeasuredValue::Set(mEndpointId, newValue);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set RelativeHumidityMeasurement MeasuredValue attribute"));
ChipLogDetail(NotSpecified, "The new RelativeHumidityMeasurement value: %d", newValue);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <app-common/zap-generated/attributes/Accessors.h>

#pragma once
#include <app-common/zap-generated/attributes/Accessors.h>

#include <protocols/interaction_model/StatusCode.h>

namespace chip {
namespace app {
Expand All @@ -11,19 +13,19 @@ class TemperatureSensorManager
public:
TemperatureSensorManager(EndpointId aEndpointId) : mEndpointId(aEndpointId)
{
EmberAfStatus status = TemperatureMeasurement::Attributes::MinMeasuredValue::Set(mEndpointId, -5);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Protocols::InteractionModel::Status status = TemperatureMeasurement::Attributes::MinMeasuredValue::Set(mEndpointId, -5);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set TemperatureMeasurement MinMeasuredValue attribute"));

status = TemperatureMeasurement::Attributes::MaxMeasuredValue::Set(mEndpointId, 60);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set TemperatureMeasurement MaxMeasuredValue attribute"));
};

void OnTemperatureChangeHandler(int16_t newValue)
{
EmberAfStatus status = TemperatureMeasurement::Attributes::MeasuredValue::Set(mEndpointId, newValue);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
Protocols::InteractionModel::Status status = TemperatureMeasurement::Attributes::MeasuredValue::Set(mEndpointId, newValue);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set TemperatureMeasurement MeasuredValue attribute"));
ChipLogDetail(NotSpecified, "The new TemperatureMeasurement value: %d", newValue);
}
Expand Down
Loading

0 comments on commit 4597a3b

Please sign in to comment.