Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an accessing fabric index to AttributeAccessInterface writes. #12040

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/app/AttributeAccessInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class AttributeValueEncoder : protected TagBoundEncoder
class AttributeValueDecoder
{
public:
AttributeValueDecoder(TLV::TLVReader & aReader) : mReader(aReader) {}
AttributeValueDecoder(TLV::TLVReader & aReader, FabricIndex aAccessingFabricIndex) :
mReader(aReader), mAccessingFabricIndex(aAccessingFabricIndex)
{}

template <typename T>
CHIP_ERROR Decode(T & aArg)
Expand All @@ -116,9 +118,15 @@ class AttributeValueDecoder

bool TriedDecode() const { return mTriedDecode; }

/**
* The accessing fabric index for this write interaction.
*/
FabricIndex AccessingFabricIndex() const { return mAccessingFabricIndex; }

private:
TLV::TLVReader & mReader;
bool mTriedDecode = false;
const FabricIndex mAccessingFabricIndex;
};

class AttributeAccessInterface
Expand Down
5 changes: 5 additions & 0 deletions src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ CHIP_ERROR WriteHandler::AddStatus(const AttributePathParams & aAttributePathPar
return err;
}

FabricIndex WriteHandler::GetAccessingFabricIndex() const
{
return mpExchangeCtx->GetSessionHandle().GetFabricIndex();
}

const char * WriteHandler::GetStateStr() const
{
#if CHIP_DETAIL_LOGGING
Expand Down
2 changes: 2 additions & 0 deletions src/app/WriteHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class WriteHandler
return CHIP_ERROR_NOT_IMPLEMENTED;
}

FabricIndex GetAccessingFabricIndex() const;

private:
enum class State
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ CHIP_ERROR WriteSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVReader & a
AttributeAccessInterface * attrOverride = findAttributeAccessOverride(aClusterInfo.mEndpointId, aClusterInfo.mClusterId);
if (attrOverride != nullptr)
{
AttributeValueDecoder valueDecoder(aReader);
AttributeValueDecoder valueDecoder(aReader, apWriteHandler->GetAccessingFabricIndex());
ReturnErrorOnFailure(attrOverride->Write(aPath, valueDecoder));

if (valueDecoder.TriedDecode())
Expand Down