Skip to content

Commit a97c531

Browse files
authored
fan-control: guard SpeedMax::Get with MultiSpeed feature (project-chip#41780)
1 parent 5ce4e4d commit a97c531

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/app/clusters/fan-control-server/fan-control-server.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,6 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt
383383
DataModel::Nullable<Percent> percentSetting;
384384
Status status = PercentSetting::Get(attributePath.mEndpointId, percentSetting);
385385
VerifyOrReturn(Status::Success == status && !percentSetting.IsNull());
386-
uint8_t speedMax;
387-
status = SpeedMax::Get(attributePath.mEndpointId, &speedMax);
388-
VerifyOrReturn(Status::Success == status,
389-
ChipLogError(Zcl, "Failed to get SpeedMax with error: 0x%02x", to_underlying(status)));
390386

391387
// Avoid circular callback calls
392388
ScopedChange PercentWriteInProgress(gPercentWriteInProgress, true);
@@ -400,6 +396,11 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt
400396

401397
if (SupportsMultiSpeed(attributePath.mEndpointId))
402398
{
399+
uint8_t speedMax;
400+
status = SpeedMax::Get(attributePath.mEndpointId, &speedMax);
401+
VerifyOrReturn(Status::Success == status,
402+
ChipLogError(Zcl, "Failed to get SpeedMax with error: 0x%02x", to_underlying(status)));
403+
403404
// Adjust SpeedSetting from a percent value change for PercentSetting
404405
// speed = ceil( SpeedMax * (percent * 0.01) )
405406
uint16_t percent = percentSetting.Value();

0 commit comments

Comments
 (0)