Skip to content

Commit f6ccf2e

Browse files

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed
 

‎src/app/clusters/thermostat-server/thermostat-server-atomic.cpp

+29-9
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ void ThermostatAttrAccess::BeginAtomicWrite(CommandHandler * commandObj, const C
417417
// Add to the maximum timeout
418418
maximumTimeout += attributeTimeout.value();
419419
}
420-
421420
break;
422421
}
423422
}
@@ -509,14 +508,6 @@ void ThermostatAttrAccess::CommitAtomicWrite(CommandHandler * commandObj, const
509508
{
510509
case Presets::Id:
511510
statusCode = PrecommitPresets(endpoint);
512-
if (statusCode == Status::Success)
513-
{
514-
CHIP_ERROR err = delegate->CommitPendingPresets();
515-
if (err != CHIP_NO_ERROR)
516-
{
517-
statusCode = Status::InvalidInState;
518-
}
519-
}
520511
break;
521512
case Schedules::Id:
522513
statusCode = Status::Success;
@@ -532,6 +523,35 @@ void ThermostatAttrAccess::CommitAtomicWrite(CommandHandler * commandObj, const
532523
}
533524
}
534525

526+
if (status == Status::Success)
527+
{
528+
for (size_t i = 0; i < attributeStatuses.AllocatedSize(); ++i)
529+
{
530+
auto & attributeStatus = attributeStatuses[i];
531+
auto statusCode = Status::Success;
532+
switch (attributeStatus.attributeID)
533+
{
534+
case Presets::Id:
535+
CHIP_ERROR err = delegate->CommitPendingPresets();
536+
if (err != CHIP_NO_ERROR)
537+
{
538+
statusCode = Status::InvalidInState;
539+
}
540+
break;
541+
case Schedules::Id:
542+
break;
543+
default:
544+
commandObj->AddStatus(commandPath, Status::InvalidInState);
545+
return;
546+
}
547+
attributeStatus.statusCode = to_underlying(statusCode);
548+
if (statusCode != Status::Success)
549+
{
550+
status = Status::Failure;
551+
}
552+
}
553+
}
554+
535555
ResetAtomicWrite(endpoint);
536556
SendAtomicResponse(commandObj, commandPath, status, attributeStatuses);
537557
}

0 commit comments

Comments
 (0)
Please sign in to comment.