Skip to content

Commit

Permalink
Push the use of ConcreteReadAttributePath higher up the callstack. (#…
Browse files Browse the repository at this point in the history
…12067)

ReadSingleClusterData should definitely take a
ConcreteReadAttributePath.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Feb 17, 2022
1 parent 4503597 commit 88e2f6b
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath);
*
* @retval CHIP_NO_ERROR on success
*/
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteReadAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport);

/**
Expand Down
7 changes: 5 additions & 2 deletions src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ EventNumber Engine::CountEvents(ReadHandler * apReadHandler, EventNumber * apIni

CHIP_ERROR
Engine::RetrieveClusterData(FabricIndex aAccessingFabricIndex, AttributeReportIBs::Builder & aAttributeReportIBs,
const ConcreteAttributePath & aPath)
const ConcreteReadAttributePath & aPath)
{
CHIP_ERROR err = CHIP_NO_ERROR;

Expand Down Expand Up @@ -100,6 +100,8 @@ CHIP_ERROR Engine::BuildSingleReportDataAttributeReportIBs(ReportDataMessage::Bu
SuccessOrExit(err = aReportDataBuilder.GetError());

{
// TODO: Figure out how AttributePathExpandIterator should handle read
// vs write paths.
ConcreteAttributePath readPath;

// For each path included in the interested path of the read handler...
Expand Down Expand Up @@ -129,7 +131,8 @@ CHIP_ERROR Engine::BuildSingleReportDataAttributeReportIBs(ReportDataMessage::Bu

TLV::TLVWriter attributeBackup;
attributeReportIBs.Checkpoint(attributeBackup);
err = RetrieveClusterData(apReadHandler->GetAccessingFabricIndex(), attributeReportIBs, readPath);
ConcreteReadAttributePath pathForRetrieval(readPath);
err = RetrieveClusterData(apReadHandler->GetAccessingFabricIndex(), attributeReportIBs, pathForRetrieval);
if (err != CHIP_NO_ERROR)
{
// We met a error during writing reports, one common case is we are running out of buffer, rollback the
Expand Down
2 changes: 1 addition & 1 deletion src/app/reporting/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Engine
CHIP_ERROR BuildSingleReportDataEventReports(ReportDataMessage::Builder & reportDataBuilder, ReadHandler * apReadHandler,
bool * apHasMoreChunks);
CHIP_ERROR RetrieveClusterData(FabricIndex aAccessingFabricIndex, AttributeReportIBs::Builder & aAttributeReportIBs,
const ConcreteAttributePath & aClusterInfo);
const ConcreteReadAttributePath & aClusterInfo);
EventNumber CountEvents(ReadHandler * apReadHandler, EventNumber * apInitialEvents);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestReadInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class MockInteractionModelApp : public chip::app::ReadClient::Callback, public c

namespace chip {
namespace app {
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteReadAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport)
{
AttributeDataIB::Builder attributeData;
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/integration/chip_im_initiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa
gLastCommandResult = TestCommandResult::kSuccess;
}

CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteReadAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport)
{
AttributeStatusIB::Builder attributeStatus = aAttributeReport.CreateAttributeStatus();
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/integration/chip_im_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa
(void) apCommandObj;
}

CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteReadAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport)
{
AttributeDataIB::Builder attributeData = aAttributeReport.CreateAttributeData();
Expand Down
6 changes: 2 additions & 4 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath)
return emberAfContainsServer(aCommandPath.mEndpointId, aCommandPath.mClusterId);
}

CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteReadAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport)
{
ChipLogDetail(DataManagement,
Expand All @@ -234,14 +234,12 @@ CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const Concre
AttributeAccessInterface * attrOverride = findAttributeAccessOverride(aPath.mEndpointId, aPath.mClusterId);
if (attrOverride != nullptr)
{
ConcreteReadAttributePath readPath(aPath);

// TODO: We should probably clone the writer and convert failures here
// into status responses, unless our caller already does that.
writer = attributeDataIBBuilder.GetWriter();
VerifyOrReturnError(writer != nullptr, CHIP_NO_ERROR);
AttributeValueEncoder valueEncoder(writer, aAccessingFabricIndex);
ReturnErrorOnFailure(attrOverride->Read(readPath, valueEncoder));
ReturnErrorOnFailure(attrOverride->Read(aPath, valueEncoder));

if (valueEncoder.TriedEncode())
{
Expand Down
2 changes: 1 addition & 1 deletion src/controller/tests/data_model/TestCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath)
return (aCommandPath.mEndpointId == kTestEndpointId && aCommandPath.mClusterId == TestCluster::Id);
}

CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteReadAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/tests/data_model/TestRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath)
return (aCommandPath.mEndpointId == kTestEndpointId && aCommandPath.mClusterId == TestCluster::Id);
}

CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteReadAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport)
{

Expand Down
2 changes: 1 addition & 1 deletion src/controller/tests/data_model/TestWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath)
return (aCommandPath.mEndpointId == kTestEndpointId && aCommandPath.mClusterId == TestCluster::Id);
}

CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteReadAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
Expand Down

0 comments on commit 88e2f6b

Please sign in to comment.