Skip to content

Commit

Permalink
Add an accessing fabric index to AttributeAccessInterface writes. (#1…
Browse files Browse the repository at this point in the history
…2040)

We will need this for bindings.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Mar 8, 2022
1 parent fd542fb commit 1316258
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
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 @@ -594,7 +594,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

0 comments on commit 1316258

Please sign in to comment.