Skip to content

Commit

Permalink
Add an accessing fabric index to AttributeAccessInterface writes.
Browse files Browse the repository at this point in the history
We will need this for bindings.
  • Loading branch information
bzbarsky-apple committed Nov 19, 2021
1 parent ebadd33 commit a74de4b
Show file tree
Hide file tree
Showing 4 changed files with 19 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
6 changes: 6 additions & 0 deletions src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <app/MessageDef/EventPathIB.h>
#include <app/WriteHandler.h>
#include <app/reporting/Engine.h>
#include <app/server/Server.h>
#include <app/util/MatterCallbacks.h>
#include <lib/support/TypeTraits.h>

Expand Down Expand Up @@ -252,6 +253,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
3 changes: 3 additions & 0 deletions src/app/WriteHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <app/AttributePathParams.h>
#include <app/InteractionModelDelegate.h>
#include <app/MessageDef/WriteResponseMessage.h>
#include <credentials/FabricTable.h>
#include <lib/core/CHIPCore.h>
#include <lib/core/CHIPTLVDebug.hpp>
#include <lib/support/CodeUtils.h>
Expand Down Expand Up @@ -84,6 +85,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

0 comments on commit a74de4b

Please sign in to comment.