Skip to content

Commit

Permalink
Remove code duplication for CHIP_ERROR to ClusterCode conversion.
Browse files Browse the repository at this point in the history
We have a complete implementation of this in ClusterStatusCode.
Remove the logic in StatusIB and use the ClusterStatusCode one instead.

Generally StatusIB is just a ClusterStatusCode ontainer, however due to
direct TLV reads, it splits out its contents. I only updated the
constructor to use common code.
  • Loading branch information
andreilitvin committed Aug 2, 2024
1 parent 26c816a commit c563aba
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/app/MessageDef/StatusIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "StatusIB.h"

#include "MessageDefHelper.h"
#include "protocols/interaction_model/StatusCode.h"

#include <inttypes.h>
#include <stdarg.h>
Expand Down Expand Up @@ -151,27 +152,10 @@ CHIP_ERROR StatusIB::ToChipError() const

StatusIB::StatusIB(CHIP_ERROR aError)
{
if (aError.IsPart(ChipError::SdkPart::kIMClusterStatus))
{
mStatus = Status::Failure;
mClusterStatus = MakeOptional(aError.GetSdkCode());
return;
}

mClusterStatus = NullOptional;
if (aError == CHIP_NO_ERROR)
{
mStatus = Status::Success;
return;
}

if (aError.IsPart(ChipError::SdkPart::kIMGlobalStatus))
{
mStatus = static_cast<Status>(aError.GetSdkCode());
return;
}
ClusterStatusCode statusCode(aError);

mStatus = Status::Failure;
mStatus = statusCode.GetStatus();
mClusterStatus = statusCode.GetClusterSpecificCode();
}

namespace {
Expand Down

0 comments on commit c563aba

Please sign in to comment.