From f7e07de4472dcd397ae8fa139cd094d920662c7a Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Fri, 15 Nov 2024 21:50:23 -0500 Subject: [PATCH] chef-fan-control: Remove unnecessary circular callback checks (#36517) * chef-fan-control: Remove unnecessary checks With the recent circular callback bugfixes done in the cluster code in pull/36515 and pull/36489, we can now safely remove unnecessary checks that prevented the circular callbacks in the app side. * remove unused includes/imports. --- .../chef/common/chef-fan-control-manager.cpp | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/examples/chef/common/chef-fan-control-manager.cpp b/examples/chef/common/chef-fan-control-manager.cpp index 7c2aec389e08a4..42555e8052bea0 100644 --- a/examples/chef/common/chef-fan-control-manager.cpp +++ b/examples/chef/common/chef-fan-control-manager.cpp @@ -207,11 +207,6 @@ FanControl::FanModeEnum ChefFanControlManager::SpeedToFanMode(uint8_t speed) void ChefFanControlManager::SetPercentCurrent(uint8_t aNewPercentCurrent) { - if (aNewPercentCurrent == mPercentCurrent) - { - return; - } - ChipLogDetail(NotSpecified, "ChefFanControlManager::SetPercentCurrent: %d", aNewPercentCurrent); mPercentCurrent = aNewPercentCurrent; Status status = FanControl::Attributes::PercentCurrent::Set(mEndpoint, mPercentCurrent); @@ -224,12 +219,6 @@ void ChefFanControlManager::SetPercentCurrent(uint8_t aNewPercentCurrent) void ChefFanControlManager::SetSpeedCurrent(uint8_t aNewSpeedCurrent) { - if (aNewSpeedCurrent == mSpeedCurrent) - { - return; - } - - ChipLogDetail(NotSpecified, "ChefFanControlManager::SetSpeedCurrent: %d", aNewSpeedCurrent); mSpeedCurrent = aNewSpeedCurrent; Status status = FanControl::Attributes::SpeedCurrent::Set(mEndpoint, aNewSpeedCurrent); if (status != Status::Success) @@ -245,11 +234,8 @@ void ChefFanControlManager::FanModeWriteCallback(FanControl::FanModeEnum aNewFan switch (aNewFanMode) { case FanControl::FanModeEnum::kOff: { - if (mSpeedCurrent != 0) - { - DataModel::Nullable speedSetting(0); - SetSpeedSetting(speedSetting); - } + DataModel::Nullable speedSetting(0); + SetSpeedSetting(speedSetting); break; } case FanControl::FanModeEnum::kLow: { @@ -291,20 +277,11 @@ void ChefFanControlManager::FanModeWriteCallback(FanControl::FanModeEnum aNewFan void ChefFanControlManager::SetSpeedSetting(DataModel::Nullable aNewSpeedSetting) { - if (aNewSpeedSetting.IsNull()) - { - ChipLogError(NotSpecified, "ChefFanControlManager::SetSpeedSetting: null value is invalid"); - return; - } - - if (aNewSpeedSetting.Value() != mSpeedCurrent) + Status status = FanControl::Attributes::SpeedSetting::Set(mEndpoint, aNewSpeedSetting); + if (status != Status::Success) { - Status status = FanControl::Attributes::SpeedSetting::Set(mEndpoint, aNewSpeedSetting); - if (status != Status::Success) - { - ChipLogError(NotSpecified, "ChefFanControlManager::SetSpeedSetting: failed to set SpeedSetting attribute: %d", - to_underlying(status)); - } + ChipLogError(NotSpecified, "ChefFanControlManager::SetSpeedSetting: failed to set SpeedSetting attribute: %d", + to_underlying(status)); } }